Skip to content

Instantly share code, notes, and snippets.

View kenn's full-sized avatar

Kenn Ejima kenn

View GitHub Profile
class Redis
class Classy
class << self
attr_accessor :db
def inherited(subclass)
subclass.db = Redis::Namespace.new(subclass.name, :redis => self.db)
end
def method_missing(method_name, *args, &block)
def some_action
buffer = Zip::Archive.open_buffer(Zip::CREATE) do |file|
data = CSV.generate do |csv|
csv << ['Title', 'Body']
things.each do |thing|
csv << [thing.title, thing.body]
end
end
file.add_buffer("things.csv", data)
end
/* keyframes for animation; simple 0 to 360 */
@-webkit-keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
@-moz-keyframes spin {
from { -moz-transform: rotate(0deg); }
to { -moz-transform: rotate(360deg); }
}
%li
= link_to some_url do
%strong= blog.title
%i= unread_count
@kenn
kenn / gist:2306749
Created April 5, 2012 00:15
unixbench - Sakura VPS 1G
========================================================================
BYTE UNIX Benchmarks (Version 5.1.2)
System: uptimer-staging: GNU/Linux
OS: GNU/Linux -- 2.6.32-5-686 -- #1 SMP Mon Mar 26 05:20:33 UTC 2012
Machine: i686 (unknown)
Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
CPU 0: Intel(R) Xeon(R) CPU E5645 (4800.2 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSCALL/SYSRET
CPU 1: Intel(R) Xeon(R) CPU E5645 (4800.2 bogomips)
controller :users do
[ :login, :signup, :thankyou, :forgot, :goodbye ].each do |name|
match name, action: name, as: name
end
[ :confirm, :reset_password ].each do |name|
match "#{name}/:id", action: name, as: name
end
post 'logout', action: :logout, as: :logout
end
resources :users
@kenn
kenn / gist:3139790
Created July 18, 2012 23:56
What's gist.io?

Trying out gist.io

Turning gist into a blogging platform? Cool idea.

If you're interested, go to gist.io.

http {
set $limitreq_zone 1;
limit_req_zone $limitreq_zone zone=one:10m rate=100r/s;
...
server {
...
location /foo/ {
limit_req zone=one;
> GeoIP::DB.country '64.15.156.242'
=> #<struct GeoIP::City
request="64.15.156.242",
ip="64.15.156.242",
country_code2="CA",
country_code3="CAN",
country_name="Canada",
continent_code="NA",
region_name="QC",
city_name="Montreal",
class Person < ActiveRecord::Base
def self.recent
where('added_at > ? AND deleted = ?', ...).where('address IS NULL').order('last_name, first_name')
end
end