Skip to content

Instantly share code, notes, and snippets.

@sowawa
sowawa / gist:5610150
Last active December 17, 2015 12:29
luhn check sum(ISO 7812)
"4242424242424242".reverse.chars.each_with_index.map{|ch, index| index.even? ? ch.to_i : (ch.to_i * 2) % 10 + (ch.to_i * 2) / 10 }.inject(:+) % 10 == 0
@sowawa
sowawa / README.md
Created February 3, 2013 07:23
Gist urls
git clone git://gist.github.com/{gist_id}.git
@sowawa
sowawa / sinachiku.rb
Created June 18, 2012 07:00 — forked from mattn/sinachiku.rb
sinatra on mruby
require 'HTTP'
require 'UV'
module Sinachiku
@routes = { 'GET' => [], 'POST' => [] }
def self.route(method, path, opts, &block)
@routes[method] << [path, opts, block]
end
def self.do(r)
@routes[r.method].each {|path|
@sowawa
sowawa / consistent_hashr.rb
Created May 7, 2012 07:23 — forked from prisoner/consistent_hashr.rb
A Consistent Hashing implementation for Ruby
require 'zlib'
module ConsistentHashr
@circle = {}
@number_of_replicas = 20
##
# Computes a key
def self.hash_key(key)
Zlib.crc32("#{key}")
@sowawa
sowawa / #{fileName}
Created April 28, 2012 16:54
This is a test description
from api
@sowawa
sowawa / #{fileName}
Created April 28, 2012 16:53
This is a test description
from api
@sowawa
sowawa / .gitignore
Created April 28, 2012 07:34
Rails 4.0 beta new repository named hoge
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
# Ignore bundler config
/.bundle
# Ignore the default SQLite database.
@sowawa
sowawa / .recipe
Created April 28, 2012 03:45
Installing rails 4.0.0 beta
thumbnail: http://pds.exblog.jp/pds/1/201101/16/02/d0055302_13383029.jpg
video: http://www.youtube.com/watch?v=UE27t_LJpx0