Skip to content

Instantly share code, notes, and snippets.

@sowawa
sowawa / memcached
Created April 2, 2012 04:28
memcached start/stop script for rackhub
#! /bin/sh
#
# chkconfig: - 55 45
# description: The memcached daemon is a network memory cache service.
# processname: memcached
# config: /etc/sysconfig/memcached
# Source function library.
# . /etc/rc.d/init.d/functions
@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:53
This is a test description
from api
@sowawa
sowawa / #{fileName}
Created April 28, 2012 16:54
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.