Assign Hyper_L to Caps_Lock

This works in Xubuntu 15.04. I don't know about others

  1. Create a file named .Xmodmap in your home with the following contents:

    keysym Caps_Lock = Hyper_L
    				
  2. That's it

Caveats

Don't invoke the xmodmap command from your session startup: keyboard shortcuts will stop working if you do

npm_lazy

  1. Install npm_lazy via npm install -g npm_lazy

  2. Create script nl: #!/bin/bash # You must set the port in your npm_lazy config # See https://github.com/mixu/npm_lazy#installation PORT=9090 function ctrl_c() { npm config delete registry } trap ctrl_c INT npm_lazy --config ~/npm_lazy.config.js & npm config set registry http://localhost:$PORT # Wait sleep infinity

  3. Create npm_lazy.config.js: var path = require('path'), homePath = path.normalize(process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']); module.exports = { // Logging config loggingOpts: { // Print to stdout with colors logToConsole: true, // Write to file logToFile: false, // This should be a file path. filename: homePath + '/npm_lazy.log' }, // Cache config // `cacheDirectory`: Directory to store cached packages. // // Note: Since any relative path is resolved relative to the current working // directory when the server is started, you should use a full path. cacheDirectory: homePath + '/.npm_lazy', // `cacheAge`: maximum age before an index is refreshed from remoteUrl // - negative value means no refresh (e.g. once cached, never update the package.json metadata) // - zero means always refresh (e.g. always ask the registry for metadata) // - positive value means refresh every n milliseconds // (e.g. 60 * 60 * 1000 = expire metadata every 60 minutes) // // Note: if you want to use `npm star` and other methods which update // npm metadata, you will need to set cacheAge to 0. npm generally wants the latest // package metadata version so caching package metadata will interfere with it. // Recommended setting: 0 cacheAge: 0, // Request config // max milliseconds to wait for each HTTP response httpTimeout: 10000, // maximum number of retries per HTTP resource to get maxRetries: 5, // whether or not HTTPS requests are checked against Node's list of CAs // set false if you are using your own npm mirror with a self-signed SSL cert rejectUnauthorized: true, // Remote and local URL // external url to npm_lazy, no trailing / externalUrl: 'http://localhost:9090', // registry url with trailing / remoteUrl: 'https://registry.npmjs.org/', //remoteUrl: 'http://registry.npmjs.eu/', // bind port and host port: 9090, host: '0.0.0.0', // Proxy config // You can also configure this using the http_proxy and https_proxy environment variables // cf. https://wiki.archlinux.org/index.php/proxy_settings proxy: { // http: 'http://1.2.3.4:80/', // https: 'http://4.3.2.1:80/' } };

Handy bash functions

md() {
    mkdir -p $1 && cd $_
}

fn() {
    find . -name "*$1*"
}

fnv() {
    result=`fn $1`
    $VISUAL $result
}

			

Git

Aliases

In ~/.gitconfig

[alias]
	ci = commit
	co = checkout
	br = branch
	st = status
	pu = push
	pl = pull
	me = merge
	#conflicts = !git ls-files -u | cut -f 2 | sort -u
	# the following does not need external tools
	conflicts = diff --name-only --diff-filter=U

				

Check history of a fragment in a file

$ git log -L <start line number>,<end line number>:<file>
				

Check history of a line in a file

$ git log -L <line number>,+1:<file>
				

Debian package building

For

debchange -R
to work properly remember to set the environment variables DEBNAME and DEBEMAIL (or EMAIL) to appropriate values.

Sample gulp project

Patch elf binaries rpath

You can use the binary patchelf, which must be installed for your architecture, like this:

patchelf --set-rpath '$$ORIGIN/../lib' <binary>

The double dollar sign is needed for escaping purposes

The patchelf may not be installed in your host, or may not be available for your architecture (esp in cross-compiling targets).

You can use the binary elfedit, which must be installed for your architecture, like this:

elfedit -e 'dyn:runpath $$ORIGIN/../lib' <binary>

The double dollar sign is needed for escaping purposes

When cross-compiling for armhf on amd64 in a debian-based distro you may want to install the package crossbuild-essential-armhf, which includes arm-linux-gnueabihf-elfedit

Manjaro

Electron apps crashing

Manjaro does not use the Debian/Ubuntu spec that uses the path /usr/lib/x86_64-linux-gnu instead leaving all subdirectories of that path on the path /usr/lib itself.

A simple patch for apps that expect this path to exist is to create a symlink from that path to the actual path in Manjaro, like this:

# ln -s /usr/lib/x86_64-linux-gnu /usr/lib

Android

Color adb log output

adb logcat --pid= -v color

Remote

Run firefox remotely

ssh -YC4 <hostname> firefox -no-remote -no-xshm