Skip to content

Instantly share code, notes, and snippets.

View eiiches's full-sized avatar

Eiichi Sato eiiches

View GitHub Profile
@eiiches
eiiches / git-push-sigalrm-loop.strace
Created October 27, 2011 06:40
strace log of git push
[pid 11671] <... select resumed> ) = 1 (in [4])
[pid 11731] <... write resumed> ) = 8192
[pid 11671] read(4, "L\273q\f*\306\3353\17\337sCd\206/\321[\276M\320Gy\374\372\373\236\304\207,\323Y\271"..., 16384) = 16384
[pid 11731] write(1, "\317g\335\351\334\357\242c\264\r\303\204\367\377]\20\371\263:\327\22%}\343\355,n<\276\314\322\305"..., 8192 <unfinished ...>
[pid 11671] select(7, [3 4], [3], NULL, NULL <unfinished ...>
[pid 11731] <... write resumed> ) = 8192
[pid 11671] <... select resumed> ) = 1 (in [4])
[pid 11671] read(4, "i#\264Sg\244$\276\2&+\362\360\n@\354\276\240\310\363\237\304y\301\0g\321\266\2\244\272N"..., 16384) = 16384
[pid 11731] write(1, "\255fM\324\t[\256w\254\247\306\261\221*\267\32*\355Z\305^_D\213\260\341^\375!\232\rF"..., 8192 <unfinished ...>
[pid 11671] mremap(0x7f74db754000, 2068480, 2101248, MREMAP_MAYMOVE <unfinished ...>
@eiiches
eiiches / glib-valgrind.sh
Created September 28, 2011 10:13
glib-valgrind.sh
#!/bin/bash
export G_SLICE=always-malloc
export G_DEBUG=gc-friendly
valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=20 "$@"
@eiiches
eiiches / imagediff
Created August 12, 2011 07:23
A git-difftool script for images.
#!/bin/bash
tmp=`tempfile`
composite -compose difference "$1" "$2" "$tmp";
evince "$tmp"
@eiiches
eiiches / comprehension.py
Created August 8, 2011 16:39
List Comprehension / Generator in Python2.7 and 3.
# I found this already described in:
# Comprehensions in a class definition mostly cannot access class variable
# [ http://bugs.python.org/issue11796 ]
# ...and my understanding is that this is not going to be fixed.
class Foo1:
def foo(i): return i
bar = (foo(i) for i in range(10))
print(Foo1.bar)
@eiiches
eiiches / lambda.py
Created July 21, 2011 20:01
Concealing 'lambda' as λ in vim.
# -*- coding: utf-8 -*-
from functools import partial
(lambda x: x*2)((lambda y: y+3)(2))
(lambda x: 5)(10)
(lambda x:(lambda y:x+3*y))(12)(4)
def church2num(church):
try: return church(lambda x: x+1, 0)
@eiiches
eiiches / resizewindow.vim
Created July 17, 2011 17:12
Continous window resize in vim.
function! PrintMode(mode)
if &showmode
echoh ModeMsg | echo a:mode | echohl None
redraw
endif
endfunction
function! ResizeMode()
while 1
call PrintMode('-- RESIZE --')
@eiiches
eiiches / latex.mk
Created June 24, 2011 16:34
Makefile for LaTeX
# vim: ft=make
TEX = platex
.SUFFIXES: .tex .dvi
.tex.dvi:
nkf -e $< | $(TEX) -no-parse-first-line -interaction=nonstopmode -shell-escape -jobname=$(basename $< .tex) /dev/stdin
nkf -e $< | $(TEX) -no-parse-first-line -interaction=nonstopmode -shell-escape -jobname=$(basename $< .tex) /dev/stdin
# .SUFFIXES: .dvi .pdf
@eiiches
eiiches / search_available_host.sh
Created February 27, 2011 07:53
Search hosts available for SSH.
#!/bin/bash
grep 'ant\|bee\|cat\|dog\|emu' /etc/hosts | while read ip host; do
nc -w 1 -z "$ip" 22 > /dev/null && echo "$host" &
done
@eiiches
eiiches / gnome-terminal-transparency.sh
Created November 15, 2010 03:32
a script for changing gnome-terminal's background transparency from the command line.
#!/bin/sh
if [ $# -lt 1 ]; then
echo "Usage: $0 (darkness in 0.0 - 1.0)" 1>&2
fi
tmpfile=`mktemp`
gnome-terminal --save-config="$tmpfile"
profile=`grep "^ProfileID=" "$tmpfile" | cut -c 11-`
rm -f "$tmpfile"