Friday, June 19, 2015

IRC cheat sheet


Register IRC nick

/msg NickServ REGISTER password youremail@example.com

Identify to primary IRC account:

/msg NickServ IDENTIFY account password

Get nick info

/msg NickServ INFO account

Reset password

/msg NickServ SET PASSWORD mynewpassword


Wednesday, June 17, 2015

Reset command hash


To flush the hash table used by the shell to remember the full path names of executable files:

hash -r
 

 

Friday, June 05, 2015

git recipes


Git: prune local branches without remotes

git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D 

Cache git credentials (Linux)


While it is possible to store git credentials locally via .netrc, that requires storing them in plain text. Even with 400 permissions, it is an unnecessary risk. I have read references about using GPG for encryption within this file, which increases security, but introduces a new dependency. When changing hosts frequently, local dependencies become highly impractical. Instead, to cache the credentials in memory with an expiration timeout, one hour, for example:

git config --global credential.helper 'cache --timeout=3600'

Sunday, January 25, 2015

Fix brightness controls in Ubuntu 14


In some instances of Ubuntu 14, brightness control keys do not work. To correct this, first determine the type  of video card adapter controlling the display backlight; use:

$ ls /sys/class/backlight
intel_backlight

sudo vim /usr/share/X11/xorg.conf.d/20-intel.conf
Add the following lines to this file:
Section "Device"
        Identifier  "card0"
        Driver      "intel"
        Option      "Backlight"  "intel_backlight"
        BusID       "PCI:0:2:0"
EndSection
Save it. Log out and log in back. The brightness control should be working through function keys now:


Thursday, January 15, 2015

Setting up Scalding


Twitter does not publish Scalding binaries. To set up Scalding locally, the following is needed:

1. Clone: git clone https://github.com/twitter/scalding.git
2. sbt assembly
3. If necessary, adjust sbt-assembly version accoridng to Scala/sbt versions (use sbt about). Under project/plugins.sbt, e.g.:

-addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.10.2")
+addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
 

4. sbt publishLocal

Wednesday, December 17, 2014

Using netcat


Send a string (e.g. to a Graphite server)

echo "metrics.test.random $RANDOM $(date +%s)" | nc 10.60.35.50 2003

Test status of a TCP daemon

nc -vz someserver port

-v: verbose
-z: scan for listening daemons but send no data

Disable IPv6 on CentOS


echo 'install ipv6 /bin/true' > /etc/modprobe.d/ipv6.conf
init 6

This process disables the IPv6 kernel module entirely. It can be considered good form, but by no means necessity, to do the following:

chkconfig ip6tables off

Also in /etc/sysconfig/network-scripts/ifcfg-*:

IPV6INIT=no
IPV6_AUTOCONF=no

To verify, the following should produce empty output:

lsmod | grep v6

Wednesday, December 03, 2014

Tuesday, December 02, 2014

VirtualBox video resolution: guest only allows small video resolutions


Symptom: Guest OS (Kubuntu) only allows 640x480 video resolution

Solution: Increase video memory allocation on virtual machine - on VirtualBox: Settings > Display > Video > Video Memory (set to >64MB)

Wednesday, November 26, 2014

VMWare Player scare: Boot time error: The file specified is not a virtual disk

Documented here, the issue occurs due to mismatched settings between the virtual hard drive descriptor and data files. This was caused by a VMDK file deleted by VirtualBox (presumed) and mirculously retrieved using TOKIWA data recovery. The restored file was uncorrupted, but unrecognized by VMWare Player. The solution was to unregister the VM and register it anew. Blessed be the goddess.

Ugly hack - Elasticsearch plugin (Knapsack) install on Windows



  • Under Cygwin, with a mix of POSIX and Windows paths
  • Firewalled ES node -- downloaded to RDP client and pulled binary via tsclient
  • ES server is embedded in a proprietary stack


$ 'C:\Program Files\ObscureDistro\java/bin/java' -Xmx64m -Xms16m -Delasticsearch '-Des.path.home=/cygdrive/c/Program Files/ObscureDistro/server/bin' -cp  'C:\Program Files\ObscureDistro\server\lib.obscure\*' org.elasticsearch.plugins.PluginManager -install knapsack -url 'file:///\\tsclient\C\Users\someone\Downloads\elasticsearch-knapsack-1.3.2.0-plugin.zip'

-> Installing knapsack...
Trying file://///tsclient/C/Users/someone/Downloads/elasticsearch-knapsack-1.3.2.0-plugin.zip...
Downloading .....DONE
Installed knapsack into C:\cygdrive\c\Program Files\ObscureDistro\server\bin\plugins\knapsack



  • ES node must be restarted

Tuesday, November 25, 2014

Using strace


Trace system calls from a process and all its children and threads:

sudo strace -f -p 3914 2>&1 | grep -vE 'clock_gettime|SIGSTOP|gettime|epoll|futex|restart' | head -10000 | less

-f: track forked
-p: parent PID
grep: remove fast, unimportant calls