Skip to content

Instantly share code, notes, and snippets.

class Poker
NO_PAIR = 0
ONE_PAIR = 1
TWO_PAIR = 2
THREE_OF_KIND = 3
STRAIGHT = 4
FLUSH = 5
FULL_HOUSE = 6
FOUR_CARD = 7
STRAIGHT_FLUSH = 8
@mostlyfine
mostlyfine / gist:701479
Created November 16, 2010 05:25
Produce the japanese names of 200 million people.
def generate
sei = %w(山 川 谷 柳 大 小 地 高 吉 沢 田 中 畑 木 森 林 松 浜 滝 宮 橋 鈴 藤 石 池 島 岡 村 町 上 下 崎 野 坂 塚 本 竹 岡 西 東 杉 原 内 尾 吉 倉 堀 井).sort_by{rand}
mei1 = %w(安 高 彩 遙 秀 優 愛 涼 桃 由 雪 健 賢 憲 順 純 貴 真 清 晴 聖 舞 夕 朝 理 利 祐 裕 洋 陽 広 友 雅 正 京 和 久 知 智 紀 康 幸 明 響 恭 春 夏 秋 冬).sort_by{rand}
mei2 = %w(美 子 里 奈 香 佳 恵 乃 代 依 之 文 夫 志 治 士 郎 史 司 彦 平 也 一 二 三).sort_by{rand}
names = []
sei.each do |s1|
sei.each do |s2|
mei1.each do |m1|
mei2.each do |m2|
@mostlyfine
mostlyfine / gist:703290
Created November 17, 2010 11:31
libro news page parser
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'jcode'
$KCODE='u'
page_content = Struct.new('PageContent', :category, :title, :body, :updated_at)
content = Nokogiri::HTML.parse(open('http://www.libro.jp/news/').read)
contents = content.xpath("//div[@class='entry']").map do |entry|
page = page_content.new(
@mostlyfine
mostlyfine / gist:709780
Created November 22, 2010 10:21
Converts an hash object into a string suitable for use as a URL query string, using the given key as the param name.
def queryize(hash)
require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
hash.map{|i| i.map {|j| CGI.escape j.to_s}.join('=') }.join('&')
end
@mostlyfine
mostlyfine / gist:710507
Created November 22, 2010 19:36
over 300 bookmark by anonymous diary
http://mrss.dokoda.jp/a/http/b.hatena.ne.jp/entrylist?sort=hot&threshold=300&url=http%3A%2F%2Fanond.hatelabo.jp&mode=rss
@mostlyfine
mostlyfine / gist:735678
Created December 10, 2010 02:39
slim on sinatra
require 'rubygems'
require 'sinatra'
require 'slim'
module Sinatra
module Templates
def slim(template, options={}, locals={})
render :slim, template, options, locals
end
end
require 'rubygems'
require 'open-uri'
require 'nokogiri'
KCODE = 'euc-jp'
index_url = 'http://www.dmm.co.jp/digital/videoa/-/actress/=/keyword=%s/'
%w(a ka sa ta na ha ma ya ra wa).each do |w|
content = Nokogiri::HTML.parse(open(index_url % w).read)
#!/usr/bin/env ruby
# -*- coding: utf-8; -*-
#
# scraping nikkei.com for Kindle
#
require 'nokogiri'
require 'open-uri'
TOP = 'http://www.nikkei.com'
@mostlyfine
mostlyfine / gist:800053
Created January 28, 2011 09:48
含んでんの?広げてんの?どうなの?実際
module Hoge
def hello
puts "hello"
end
end
class Test
end
@mostlyfine
mostlyfine / jQuery Plugin Sample1
Created December 6, 2011 08:17
プラグインの単体呼び出し、オプションの指定
//
// プラグイン呼び出し
//
$(function() {
$.sample({debug:true});
});
//
// プラグイン本体