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 / morse.sh
Created November 17, 2011 16:18
Morse on numlock LED. To run, echo "モールス信号" | ./morse.sh
#!/bin/zsh
int_short=0.1
int_long=$(($int_short * 3))
int_between_char=$(($int_short * 3))
int_between_word=$(($int_short * 7))
ledon() {
setleds +num +caps +scroll < /dev/tty7
}
@eiiches
eiiches / gist:1771948
Created February 8, 2012 18:27
tcpdump result
03:26:12.795292 IP6 2002:8533:5452:b:68d0:41eb:532e:7b52.52698 > 2404:6800:4004:b::6.www: Flags [S], seq 4145269032, win 65535, options [mss 1440,nop,wscale 2,nop,nop,TS val 723215303 ecr 0,sackOK,eol], length 0
03:26:12.795490 IP6 2002:8533:5452:b:68d0:41eb:532e:7b52.52698 > 2404:6800:4004:b::6.www: Flags [S], seq 4145269032, win 65535, options [mss 1440,nop,wscale 2,nop,nop,TS val 723215303 ecr 0,sackOK,eol], length 0
03:26:12.795494 IP6 2002:8533:5452:b:68d0:41eb:532e:7b52.52698 > 2404:6800:4004:b::6.www: Flags [S], seq 4145269032, win 65535, options [mss 1440,nop,wscale 2,nop,nop,TS val 723215303 ecr 0,sackOK,eol], length 0
03:26:12.795673 IP6 2002:8533:5452:b:68d0:41eb:532e:7b52.52698 > 2404:6800:4004:b::6.www: Flags [S], seq 4145269032, win 65535, options [mss 1440,nop,wscale 2,nop,nop,TS val 723215303 ecr 0,sackOK,eol], length 0
03:26:12.795677 IP6 2002:8533:5452:b:68d0:41eb:532e:7b52.52698 > 2404:6800:4004:b::6.www: Flags [S], seq 4145269032, win 65535, options [mss 1440,nop,wscale 2,nop,nop,TS val 72
@eiiches
eiiches / bk-tree.hpp
Created March 11, 2012 12:17
BK-tree implementation in C++
/*
* BK-tree implementation in C++
* Copyright (C) 2012 Eiichi Sato
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@eiiches
eiiches / integer_sum.cpp
Created March 26, 2012 02:30
1から100までの整数の和を表示するプログラムを作れ
#include <iostream>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/fold.hpp>
using namespace boost;
int
main(int argc, char **argv)
@eiiches
eiiches / fib.cpp
Created March 26, 2012 10:13
Fibonatti
#include <iostream>
template <int i>
struct fib {
static const int value = fib<i-1>::value + fib<i-2>::value;
};
template <>
struct fib<0> {
static const int value = 1;
@eiiches
eiiches / i_prefer_c.py
Created May 16, 2012 12:53
C++ to C converter
import sys
print '''
#include <stdlib.h>
#include <stdio.h>
const char *prg = "{0}";
int main(int argc, char **argv) {{
char *tmp = tempnam("/tmp", "hoge-");
FILE *fp = fopen(tmp, "w");
fprintf(fp, "%s", prg);
fclose(fp);
@eiiches
eiiches / c.snip
Created August 9, 2012 16:38
Neocomplcache snippet for extending gobject.
snippet gobject
/* class: ${1:CAPITAL_CASE}, ${2:CamelCase}, ${3:lower_case}, ${4:simple_name} */
/* base: ${5:G_TYPE_OBJECT}, ${6:GObject} */
/* prefix: ${7:EGG} */
/* ===== Header ===== */
#ifndef _$1_H_
#define _$1_H_
import java.lang.reflect.Field;
import sun.misc.Unsafe;
public class Test {
private static final int N = 128 * 1024 * 1024;
public static void main(String[] args) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
{
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");