Skip to content

Instantly share code, notes, and snippets.

View yyuu's full-sized avatar
👽
Working from home

Yamashita, Yuu yyuu

👽
Working from home
View GitHub Profile
@yyuu
yyuu / Main.scala
Created March 18, 2014 14:28
quick sort with using scala.concurrent.forkjoin
import scala.concurrent.forkjoin.ForkJoinPool
import scala.concurrent.forkjoin.RecursiveTask
object Main {
def main(args: Array[String]) {
val pool = new ForkJoinPool()
println(s"${Thread.currentThread.getId}: unsorted=" + args.mkString(", "))
val sorted = pool.invoke(new QuickSortingTask(args))
println(s"${Thread.currentThread.getId}: sorted=" + sorted.mkString(", "))
}
@yyuu
yyuu / match.go
Last active August 29, 2015 14:04
A utility to test Go's filepath.Match to write .dockerignore
package main
import (
"fmt"
"os"
"path/filepath"
)
func main() {
if len(os.Args) < 2 {
This file has been truncated, but you can view the full file.
/var/folders/rc/_9kglbjs651431bbh2736s300000gn/T/python-build.20141227152802.9648 ~
Downloading Python-3.4.1.tgz...
HTTP/1.1 200 OK
Date: Sat, 27 Dec 2014 06:28:03 GMT
Server: GitHub.com
Content-Type: application/octet-stream
Last-Modified: Tue, 04 Nov 2014 09:32:24 GMT
Expires: Sat, 27 Dec 2014 04:57:53 GMT
Cache-Control: max-age=600
Content-Length: 19113124
@yyuu
yyuu / json2msgpackgz.rb
Created June 25, 2015 05:00
json2msgpackgz.rb
#!/usr/bin/env ruby
require "json"
require "msgpack"
require "tempfile"
require "zlib"
io = Tempfile.new(File.basename($0))
gzip = Zlib::GzipWriter.new(io)
packer = MessagePack::Packer.new(gzip)
ARGF.each do |s|
record = JSON.parse(s)
hello, gist
@yyuu
yyuu / gist:931016
Created April 20, 2011 11:18
unit conversion in awk
function atoix(a) {
if(a~/Pi?B/) return int(a)*1024^5;
if(a~/Ti?B/) return int(a)*1024^4;
if(a~/Gi?B/) return int(a)*1024^3;
if(a~/Mi?B/) return int(a)*1024^2;
if(a~/Ki?B/) return int(a)*1024^1;
return int(a);
}
function itoax(i) {
@yyuu
yyuu / gist:931210
Created April 20, 2011 12:33
Makefile to dump all Cassandra's SSTables to JSON (with LZO compression)
SRCDIR = /var/lib/cassandra/data
DSTDIR = .
SOURCES = $(wildcard $(SRCDIR)/*/*-Data.db)
ALL = $(foreach S,$(SOURCES),$(basename $(subst $(SRCDIR)/,,$(S))).json.lzo)
.SUFFIXES: .json.lzo
all: $(ALL)
@yyuu
yyuu / resolvconf.conf
Created May 24, 2011 17:12
upstart configuration for resolvconf (LP:448095)
# upstart script for resolvconf
start on ( virtual-filesystems and starting udev )
stop on runlevel [06]
pre-start script
invoke-rc.d resolvconf start
end script
@yyuu
yyuu / irc.alert
Created July 14, 2011 10:19
irc alert script for mon
#!/usr/bin/env ruby
require 'logger'
require 'net/irc'
require 'optparse'
require 'thread'
class IRCNotifier < Net::IRC::Client
def initialize(host, port, opts={})
super
@yyuu
yyuu / gist:1084613
Created July 15, 2011 12:46
fucking cardinal conversion in awk
function int2(str, card, rec) {
if(!card) card=10;
i = index("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", toupper(substr(str, 1, 1)))-1;
if(length(str) < 2) {
return rec*card+i;
} else {
return int2(substr(str, 2), card, rec*card+i);
}
}