Skip to content

Instantly share code, notes, and snippets.

Eiichi Sato eiiches

  • Akihabara, Tokyo
Block or report user

Report or block eiiches

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View unsafe_vs_array.java
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");
@eiiches
eiiches / c.snip
Created Aug 9, 2012
Neocomplcache snippet for extending gobject.
View c.snip
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_
@eiiches
eiiches / i_prefer_c.py
Created May 16, 2012
C++ to C converter
View i_prefer_c.py
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);
View fib.cpp
#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 / integer_sum.cpp
Created Mar 26, 2012
1から100までの整数の和を表示するプログラムを作れ
View integer_sum.cpp
#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 / bk-tree.hpp
Created Mar 11, 2012
BK-tree implementation in C++
View bk-tree.hpp
/*
* 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,
View gist:1771948
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 / morse.sh
Created Nov 17, 2011
Morse on numlock LED. To run, echo "モールス信号" | ./morse.sh
View 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
}
View git-push-sigalrm-loop.strace
[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 ...>
View 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 "$@"
You can’t perform that action at this time.