This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
imap <C-j> <esc> | |
set backspace=indent,eol,start | |
noremap | |
noremap! | |
noremap <BS> | |
noremap! <BS> | |
set number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LTSV { | |
static Map parse(String str) { | |
var pairs = str.trim().split("\t"); | |
var ret = {}; | |
for (var pair in pairs) { | |
var chunks = pair.split(":"); | |
var name = chunks.removeAt(0); | |
ret[name] = chunks.join(":"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class ThreadLocalTest implements Runnable { | |
public static final Random RAND = new Random(); | |
public static int counter = 1; | |
public static class MyObject { | |
private final int n; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import tornado.web | |
import tornado.httpserver | |
import tornado.gen | |
import tornado.ioloop | |
import functools | |
import collections | |
import pprint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# only works on 1.9+ | |
# base idea is from: | |
# - http://stackoverflow.com/questions/2583472/regex-to-validate-json | |
# - http://www.slideshare.net/takesako/shibuyapm16-regexpjsonvalidator | |
module JsonMatcher | |
NUMBER = /-? (?= [1-9]|0(?!\d) ) \d+ (\.\d+)? ([eE] [+-]? \d+)?/x | |
BOOLEAN = /true | false | null/x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#define MAX 10000000 | |
void bit_true(char* vec, int pos) { | |
int char_idx = pos / 8; | |
int bit_idx = pos % 8; | |
int mask = 1 << bit_idx; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define DATA_FILE "./rand.txt" | |
#define N 1000000 | |
void my_msort(int* ary, int stack_level, int sidx, int eidx) { | |
int i, j, tmp; | |
int len = eidx - sidx + 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# perform async MessagePack RPC request | |
# base idea is from: https://github.com/msgpack/msgpack-rpc-python/pull/5 | |
import tornado.web | |
import tornado.gen | |
import tornado.httpserver | |
import tornado.ioloop | |
import msgpackrpc | |
import msgpackrpc.loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# using https://github.com/tomotaka/msgpack-rpc-python/commit/9a116f7255a5d6c2f773ee48225cd05173b7916b | |
import tornado.web | |
import tornado.gen | |
import tornado.httpserver | |
import tornado.ioloop | |
import msgpackrpc | |
import msgpackrpc.loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
def hoge(n): | |
n2 = n * 2 | |
print "this is hoge, n*2=%d" % n2 | |
s_hoge = pickle.dumps(hoge) | |
loaded_hoge = pickle.loads(s_hoge) |