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)
ProxyCommand for your ssh_config for home servers and lame home routers
Goal: Easily edit Java classes (if you have to) by name.
vi ~/.zshrc and add before compinit:
fpath=(~/.zsh/completion $fpath)mkdir -p ~/.zsh/completionvi ~/.zsh/completion/_vj (code see below)vi ~/.zshrc (code see below)#compdef vj
compadd $(find -type f -name '*.java' -exec basename '{}' .java \;)
vj() { # mnemonic: vi java
$EDITOR **/$1.java
}
% 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
python -c "import datetime;print(datetime.timedelta(0,int(open('/proc/uptime').read().split('.')[0])))"
Choose beetween the LPM-optimized color version, the LPM-optimized black-and-white version and the original version.
>>>> 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
ssh s -R 5900:localhost:5900 "ncat -l 9999 -c 'ncat localhost 5900'"
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:
deploy_n950() {
filename=$(basename $1)
scp $1 udali: && ssh udali devel-su -c "'dpkg -i /home/user/$filename'"
}
#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
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>:
#compdef github compadd $(curl -s https://api.github.com/users/thp/repos | grep -o 'git@github.com:[^"]*')
Protip: Replace thp with your username ;)
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 $* }
ffmpeg -i sample.mp4 -vn -acodec copy sample.m4a
while ((ent = readdir(d)) != NULL) { /* ... */}
vs.
while ((ent = readdir(d) != NULL)) { /* ... */}
.gitconfig:
[alias]
todo = grep -E '(TODO|FIXME|XXX)'
Usage: git todo