Skip to content

Instantly share code, notes, and snippets.

@mururu
mururu / kawadu_fuck.js
Created October 20, 2011 06:07
KawaduFuck
window.onload = function(){
var ptr = 0;
var mem = [];
var count = 1;
var input_set = function(input) {
var splited = input.split(' ');
var ary = [];
for(var i = 0, len = splited.length; i < len; ){
ary.push(splited[i++] + splited[i++]);
}
@mururu
mururu / web-game.js
Created October 26, 2011 07:59
web-game .devquiz2011
var card_num = 0;
var card_array = new Array();
var card_twin = new Array();
//カードの要素を取得
for (var ai = 0; true; ai++){
if(document.getElementById('card' + ai) == null){
card_num = ai;
break;
}
@mururu
mururu / hitori-game.rb
Created October 26, 2011 08:22
hitori-game .devquiz2011
=begin
入力形式
T ケースの数(1<=T<=100)
N ケース1の数の個数(1<=N<=10)
a1 a2 ... aN 与えられる数(0<=an<=1,000,000)
M ケース2の数の個数
b1 b2 ... bM 与えられる数
... ...
=end
@mururu
mururu / billboards.rb
Created January 25, 2012 06:21
Billboards - Facebook Hacker Cup 2012 Qualification Round
# coding: utf-8
class Billboards
def initialize(input)
lines = []
open(input) do |f|
lines = f.readlines.map{|l|l.chomp!}
end
@num = lines.shift.to_i
@case = []
@mururu
mururu / soup.rb
Created January 25, 2012 06:22
Alphabet Soup - Facebook Hacker Cup 2012 Qualification Round
# coding: utf-8
class Soup
def initialize(input)
lines = []
open(input) do |f|
lines = f.readlines.map{|l|l.chomp!}
end
@num = lines.shift.to_i
@case = lines
@mururu
mururu / fav_to_hatebu.rb
Created February 13, 2012 07:26
twitter favorite -> hatena bookmark
# coding: utf-8
require 'rubygems'
require 'twitter'
require 'net/http'
require 'uri'
require 'digest/sha1'
# WSSE認証
def wsse(id, pass)
# coding: utf-8
require "twitter"
def search(target)
result = []
(1..100).each do |i|
result << Twitter.search(target, :page => i, :rpp => 100) rescue break
end
iemon(result.flatten.uniq.sort_by(&:created_at).map(&:attrs))
@mururu
mururu / roman.rb
Created April 25, 2012 14:45
Shinjuku.rb #4
class Integer
def to_roman
raise if self <= 0 || self >= 4000
a = ("%04d" % self).split(//).map(&:to_i).reverse
m = { 1 => 'I', 5 => 'V', 10 => 'X', 50 => 'L', 100 => 'C', 500 => 'D', 1000 => 'M' }
(0..3).inject("") do |s,i|
i = 3 - i
s += case a[i]
@mururu
mururu / add_up.rb
Created May 5, 2012 08:29
配列の各要素数をカウントするやつ
class Array
def add_up
Hash.new(0).tap{|h| self.each{|v| h[v]+=1 } }
end
end
@mururu
mururu / exenv.rb
Created November 13, 2012 00:19
exenv homebrew formula
require 'formula'
class Exenv < Formula
homepage 'https://github.com/mururu/exenv'
url 'https://github.com/mururu/exenv/tarball/v0.1.0'
sha1 '8254e6351c9c5614aaa79923b152671d3585a188'
def install
prefix.install Dir['*']