Skip to content

Instantly share code, notes, and snippets.

Avatar
🏈
Go 49ers!

Ryosuke Iwanaga riywo

🏈
Go 49ers!
View GitHub Profile
View test.tsv
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
aaaa bbb
ccc ddd
View gist:6790103
class String
def to_bin
bytes = self.size/2
self.unpack('a2'*bytes).map{|x| x.hex}.pack('C'*bytes)
end
end
"20814804c1767293b99f1d9cab3bc3e7".to_bin #=> " \x81H\x04\xC1vr\x93\xB9\x9F\x1D\x9C\xAB;\xC3\xE7"
View p.py
from subprocess import Popen, PIPE
p = Popen(["cat"], stdin=PIPE, stdout=PIPE)
print "stdin.write"
p.stdin.write("aaa")
p.stdin.flush()
print "stdout.read"
print p.stdout.readlines()
p.stdin.close()
p.wait()
@riywo
riywo / config.ru
Last active Dec 20, 2015
nginx with pow
View config.ru
require "anypow"
extend Anypow
run_pow "erb ./conf/nginx.conf.erb > ./conf/nginx.conf && ./sbin/nginx"
@riywo
riywo / gist:5937400
Created Jul 5, 2013
cross multiple arraies
View gist:5937400
class Array
def cross(array)
product(array).map { |e| e.flatten }
end
end
p [1,2].cross([3,4])
#=> [[1, 3], [1, 4], [2, 3], [2, 4]]
p [1,2].cross([3,4]).cross([5,6])
#=> [[1, 3, 5], [1, 3, 6], [1, 4, 5], [1, 4, 6], [2, 3, 5], [2, 3, 6], [2, 4, 5], [2, 4, 6]]
View game1.tsv
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
2013-07-03 10000
2013-07-02 9000
2013-07-01 4000
2013-06-30 300
2013-06-29 100
View test.json
$ ./bin/packer -v
Packer v0.1.0
$ ./bin/packer build test.json
virtualbox output will be in this color.
==> virtualbox: Downloading VirtualBox guest additions. Progress will be shown periodically.
==> virtualbox: Copying or downloading ISO. Progress will be reported periodically.
panic: EOF
goroutine 41 [running]:
View gist:5889271
{
"builders": [{
"type": "virtualbox",
"guest_os_type": "Ubuntu_64",
"iso_url": "http://releases.ubuntu.com/12.04/ubuntu-12.04.2-server-amd64.iso",
"iso_md5": "af5f788aee1b32c4b2634734309cc9e9",
"ssh_username": "packer",
"ssh_wait_timeout": "60s",
"boot_wait": "30s",
"boot_command": [
@riywo
riywo / gist:5883286
Last active Dec 19, 2015
rbenv install
View gist:5883286
MAKE_OPTS="-j 4" RUBY_CONFIGURE_OPTS="--enable-load-relative --with-readline-dir=`brew --prefix readline`" rbenv install -k -v 2.0.0-p247
View gist:5809166
sub check_sudo {
my @commands = (
'/bin/netstat',
);
my @unexecutable = grep {
system("sudo -l -U user $_ > /dev/null 2>&1") != 0;
} @commands;
message_for_sudo(@unexecutable);