This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
<html> | |
<head> | |
<script type="text/javascript"> | |
window.addEventListener("load", postSize, false); | |
function postSize(e){ | |
var target = parent.postMessage ? parent : (parent.document.postMessage ? parent.document : undefined); | |
if (typeof target != "undefined" && document.body.scrollHeight) | |
target.postMessage(document.getElementById("foo").scrollHeight, "*"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
def get_suffix_array(str) | |
hash = {} | |
str.size.times do | i | | |
hash[i + 1] = str.slice(i, str.size) | |
end | |
a = [] | |
hash.each do | x, y | | |
a << y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
def bin_search(array, search) | |
lowerbound = 0 | |
upperbound = array.size - 1 | |
while (lowerbound <= upperbound) | |
middle = (lowerbound + upperbound) / 2 | |
return middle if (search == array[middle]) | |
if (search < array[middle]) | |
upperbound = middle - 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
class Cards | |
def deal(num_players, deck) | |
if num_players > deck.scan(/./).size | |
ary = [] | |
num_players.times do | |
ary << "" | |
end | |
return ary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
class ReportAccess | |
def who_can_see(user_names, allowed_data, report_data) | |
h = {} | |
allowed_data.each_with_index do | data, i | | |
data.split(/ /).each do | v | | |
h[i] = user_names[i] unless report_data.index(v).nil? | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Tumblr Dashboard Expand Embed | |
// @namespace http://d.hatena.ne.jp/bannyan/ | |
// @description From the beginning to show Embed | |
// @include http://www.tumblr.com/dashboard/* | |
// ==/UserScript== | |
(function(unsafeWindow){ | |
var expandEmbed = function(node) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "fileutils" | |
files = %w( | |
file1.txt | |
file2.txt | |
) | |
src_root = '/path/to/src/' | |
dest_root = '/path/to/dest/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MM2 | |
def setup | |
puts "Setup" | |
end | |
def teardown | |
puts "Tear down" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Collatz | |
def init(i) | |
buf = [i] | |
while i != 1 | |
if (i % 2) == 0 | |
i = i / 2 | |
else | |
i = i * 3 + 1 | |
end | |
buf << i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Collatz | |
def init(i) | |
buf = [i] | |
while i != 1 | |
if (i % 2) == 0 | |
i = i / 2 | |
else | |
i = i * 3 + 1 | |
end | |
buf << i |
OlderNewer