Skip to content

Instantly share code, notes, and snippets.

// http://okajima.air-nifty.com/b/2010/01/post-abc6.html
#include <iostream>
#include <vector>
#include <deque>
#include <string>
#include <utility>
#include <climits>
using namespace std;
#!/usr/bin/env ruby
# twit_anime_icon.rb
# convert an animated gif file to an uploadable format for Twitter.
infile = ARGV[0] || ""
outfile = ARGV[1] || "output.gif"
if infile.empty?
puts "usage: #{$0} input.gif [output.gif]"
@mickey24
mickey24 / parser.rb
Created August 19, 2010 10:15 — forked from yagays/parser.rb
#/usr/bin/env ruby
def open_t_delimited_file(filename)
h = {}
open(filename) {|f|
f.each_line do |line|
a = line.split("\t")
h[a[0]] = a
end
}
@mickey24
mickey24 / nearest_gene.cc
Created August 21, 2010 09:53
二つの遺伝子発現データを比較し,発現領域が近い遺伝子のペアを出力する.#DBCLS
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <vector>
using namespace std;
// 遺伝子発現領域データ用構造体
@mickey24
mickey24 / mpl_brainfuck.cc
Created September 9, 2010 12:29
A Brainf*ck interpreter using Boost.MPL
#include <iostream>
// change this parameter according to the length of your program
#define BOOST_MPL_LIMIT_STRING_SIZE 128
#include <boost/mpl/at.hpp>
#include <boost/mpl/comparison.hpp>
#include <boost/mpl/erase.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/insert.hpp>
@mickey24
mickey24 / udonge_quine.rb
Created September 15, 2010 11:02
udone_quine.rb
eval$s =%w'
b= " BAhsKwG
vfg A AAAAA PAAA
AIw AA AAA gD8AAAA4
AQA AA Ph 4AAAAcAMAA
ICDf wA A AOAGAADA8D8
AAAD wB g AAQPwfAAAA
eAY AA E D/AwAAA
DgGA AB A fwAAAAA
8DAAA QH 8 AAA AAf
@mickey24
mickey24 / quine.rb
Created January 30, 2011 14:43
Quine in Ruby
str = "str = %c%s%c; printf str, 34, str, 34"; printf str, 34, str, 34
# -*- coding: utf-8 -*-
i = 0
ARGF.each_char do |c|
printf "\x1b[3#{(i += 1) % 6 + 1}m#{c}"
end
print "\x1b[39m"
@mickey24
mickey24 / bitly.rb
Created February 24, 2011 15:03
shorten a URL by bit.ly API ( http://bit.ly/hKSXnN )
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require "net/http"
require "cgi"
require "nkf"
require "json"
class Bitly
def initialize(account, api_key)
@mickey24
mickey24 / convert_fukushima.rb
Created March 14, 2011 16:18
奥村先生による福島原発のデータ fukushima*.csv ( http://oku.edu.mie-u.ac.jp/~okumura/stat/data/ ) をRなどで処理しやすい形に加工するスクリプトです.使い方についてはコメント欄を参照してください.
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require "time"
puts %w[datetime mon day hour min place gamma neutron wind_dir wind_speed].join("\t")
lines = ARGF.each_line.to_a[2..-1]
date = ""
lines.each do |line|