2012 Archie V. A. Tor

Pausenrap. When you know there are better tools around, but you have to do the Java thingie :/


Naive PDF page counter bash function (if you don't have pdfinfo available):

pdfpages() { grep -aHwo /Page $* | uniq -c | sed -e 'sx:/Page$xx'; }

Fix UTF-8 encoding on Mac OS X Lion Terminal.app when using ssh: comment SendEnv LANG LC_* in /etc/ssh_config (source)


My .Xmodmap (MBP5,5 / 2012-02-04):

! Caps lock as Escape key
clear Lock
keycode 0x42 = Escape

! Make sure the key next to left shift on MacBook Pro gives ` and ~ (like OS X)
keycode 94 = grave asciitilde
keycode 49 = grave asciitilde

! OS X-like "natural scrolling"
pointer = 1 2 3 5 4 7 6 8 9 10 11 12

Some indie games worth looking at (cf ngj12): stdbits, shitgame, lost in static, ponycorn adventure. Nice "offline" game: who took the apple.


try:
    ...
except:
    ...
        
-- pokemon exception handling (gotta' catch them all) (via, more)
Win7 bootable USB in Linux
Root/unlock the Nexus S (+ Fastboot for OS X): Nexus S rooting Guide
ssh-local-chooser: ProxyCommand for your ssh_config for home servers and lame home routers

Zsh "vi java" hack (2012-03-29)

Goal: Easily edit Java classes (if you have to) by name.

~/.zsh/completion/_vj

#compdef vj
compadd $(find -type f -name '*.java' -exec basename '{}' .java \;)

"vj" function in ~/.zshrc

vj() { # mnemonic: vi java
    $EDITOR **/$1.java
}

Usage

% vj <Tab> # Will find all .java files
SomeClass SomeOtherClass Util
% vj Util<Return> # Will open all Util.java files from subdirectories

References: Writing own completion functions


rotating cube start page
Python one liners 101: uptime!
python -c "import datetime;print(datetime.timedelta(0,int(open('/proc/uptime').read().split('.')[0])))"

N9 Low Power Mode Operator Logo - Drei.at

Choose beetween the LPM-optimized color version, the LPM-optimized black-and-white version and the original version.


Python's .func_defaults
>>>> def x(a=[], b=1, c=2): pass
...
>>> x.func_defaults
([], 1, 2)
>>> def y(a, b, c): print a, b, c
...
>>> y.func_defaults = 'a', 'b', 'c'
>>> y()
a b c
>>> y(1, 2, 3)
1 2 3
>>> y.func_defaults = 'x', 'y'
>>> y()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: y() takes at least 1 argument (0 given)
>>> y('z')
z x y

http://www.tinypy.org/
http://ccodearchive.net/
public vnc ssh s -R 5900:localhost:5900 "ncat -l 9999 -c 'ncat localhost 5900'"
PS Move Nose Tests Runner Provide instant visual feedback if your unit tests run through or not. Requires PS Move API, nosetests and a Move controller. nose_tests_runner.py
QDir::entryList performance A test application to compare the performance of Qt's QDir::entryList in a directory with 10000 files when using sorting vs. a hand-written method that gives the same result but uses opendir() and friends: qdir_entrylist_performance.cpp (submitted changeset by Robin Burchell upstream)
gkrellm-2.3.5_osx10.8_fixes.patch - Patch for GKrellM with recent libs on OS X 10.8 (submitted upstream 2012-08-13)
Render HTML as HTML

Useful when HTML pages are sent as text/plain (e.g. when showing the raw source of an HTML file on Github) and you want to show it in your browser:

Render HTML as HTML (Usage: Paste the HTML into the text area, then hit Tab or click anywhere so that it loses focus.)
Deploy a .deb to developer device, zsh function
deploy_n950() {
        filename=$(basename $1)
            scp $1 udali: && ssh udali devel-su -c "'dpkg -i /home/user/$filename'"
}

the weekend has landed
gpodder.net logo proposals
psmove_mixxx_2012-09-08.patch - PS Move API gyro control for Mixxx
Minimalistic toggle Bluetooth for OS X
#import <Foundation/Foundation.h>
int main()
{
    int state = IOBluetoothPreferenceGetControllerPowerState();
    IOBluetoothPreferenceSetControllerPowerState(1-state);
    return 0;
}
Compile with: gcc -o bt_toggle bt_toggle.m -framework IOBluetooth
Measure shutdown time of Mac OS X's blued: wait_for_blued.m
Check pairing of HID devices in Mac OS X: check_pairing.c

zsh Github "git clone" completion function (2012-10-02)

After an idea by Brandon. See instructions for Zsh vi java hack above for details, or just plant this into your $HOME and use github <Tab>:

~/.zsh/completion/_github

#compdef github
compadd $(curl -s https://api.github.com/users/thp/repos | grep -o 'git@github.com:[^"]*')

Protip: Replace thp with your username ;)

~/.zshrc

fpath=(~/.zsh/completion $fpath)
autoload -U compinit && compinit
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*' group-name ''

github() { git clone $* }

Mac OS X iSight Exposure Lock exposure_lock.m (locks the exposure of the iSight camera; useful for e.g. PS Move use cases)
Extract audio from MP4
ffmpeg -i sample.mp4 -vn -acodec copy sample.m4a

glsl sandbox
while ((ent = readdir(d)) != NULL) { /* ... */} vs. while ((ent = readdir(d) != NULL)) { /* ... */}
the unofficial phoronix digest (build script)
New addition to my .gitconfig:
[alias]
        todo = grep -E '(TODO|FIXME|XXX)'

Usage: git todo


vim_cheat_sheet_2012-12-06.txt
socketproxy_fixed_ports.py
aopatad mirror
C# (csharp) cheat sheet (cf)
up-dir | sup-up-dir | contact info