Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Takuya Akiba iwiwi

🏠
Working from home
View GitHub Profile
View xorshift.h
/*
* An xorshift random generator implementation, which is compatible to std::random.
*
* References:
* - http://cpplover.blogspot.jp/2013/03/blog-post_22.html
* - http://xorshift.di.unimi.it/xorshift64star.c
* - http://xorshift.di.unimi.it/xorshift1024star.c
*/
#include <random>
@iwiwi
iwiwi / dblp.rb
Created Apr 8, 2013
DBLP dump parser for generating multiple networks
View dblp.rb
#!/usr/bin/env ruby
#
# dblp.rb --- Parse dblp.xml to generate graphs
#
# Usage:
# dblp.rb author <dblp.xml --> co-author network
# dblp.rb key cite <dblp.xml --> citation network
# dblp.rb key author <dblp.xml --> paper-author network
# dblp.rb key venue <dblp.xml --> paper-venue network
View sockets.rb
#!/usr/bin/env ruby
#
# sockets.rb --- by Takuya Akiba (@iwiwi)
#
# Usage:
# sockets.rb PID
#
`ls -l /proc/#{ARGV[0]}/fd | grep [s]ocket`.scan(/\[([0-9]+)\]/).each_with_index do |m, i|
@iwiwi
iwiwi / shrink_ids.cc
Created Jun 10, 2013
Convert edge lists described by names to those described by 0-indexed vertex IDs
View shrink_ids.cc
/*
* Basic usage:
* $ CXXFLAGS=-O3 make shrink_ids
* $ ./shrink_ids < EDGES > SHRINKED_EDGES
*
* Example:
* $ echo "hoge piyo\nfuga hoge" | ./shrink_ids
* 0 1
* 2 0
*
@iwiwi
iwiwi / qsub.rb
Last active Apr 27, 2016
Torque job machine-gun
View qsub.rb
#!/usr/bin/env ruby
#
# qsub.rb --- Torque job machine-gun
#
# Usage:
# 1. Rewrite the shell script template & parameters
# 2. Execute
# $ qsub.rb (cat) --> Output generated shell scripts
# $ qsub.rb sh --> Execute locally
View log.py
# 普通の場合
>>> class A:
... def hello(self):
... print('hellooooo')
... def __len__(self):
... print('lennnnnn')
... return 10
... def __call__(self):
... print('calllllled')
...
View mnist-random-labels.py
import numpy as np
import sklearn.datasets
import sklearn.ensemble
import xgboost
N_TRAIN = 60000
NS_ITERATIONS = [2 ** k for k in range(8)]
MODELS = [
('RandomForestClassifier', sklearn.ensemble.RandomForestClassifier, {'n_jobs': -1}),
View numba_example.py
"""
(anaconda3-4.2.0) ~/tmp% python numba_example.py [18:00:09]
Python: 3.641503095626831
Numba: 0.09061694145202637
"""
import time
from numba import jit, int32
View selu.py
import chainer.functions as F
def selu(x, alpha=1.6732632423543772848170429916717, scale=1.0507009873554804934193349852946):
return scale * F.elu(x, alpha=alpha)
View rnn_forward.py
from typing import *
class Variable(object):
def __init__(self, data):
# type: (float) -> None
self.data = data
self.creator = None # type: Function