Skip to content

Instantly share code, notes, and snippets.

View lidaobing's full-sized avatar
🦍
Mammal - verified by Github

LI Daobing lidaobing

🦍
Mammal - verified by Github
View GitHub Profile
require 'rack'
module Rack
class Obama
CONTENT_TYPE = "nobel-prize/peace".freeze
def initialize(app)
@app = app
@kdwinter
kdwinter / authenticable.rb
Created June 14, 2010 21:52
Authlogic with Mongoid (in spirit of http://pastie.org/503478)
module Authenticable
def self.included(model)
model.class_eval do
extend ClassMethods
include InstanceMethods
field :username
field :email
field :crypted_password
field :password_salt
@lidaobing
lidaobing / .vimrc
Created September 9, 2010 07:21
.vimrc
set ai
"set guioptions-=m
set guioptions-=T
"set textwidth=72
"set background=light
set wrap
set nocp
syntax on
filetype on
filetype indent on
#!/usr/bin/env python
# Usage:
# This script will generate two files(vpnup and vpndown) after executing.
# Do chmod a+x on the two newly created files, and then move them to the
# openvpn config folder. then add the following two lines to the vpn config file:
# up vpnup
# down vpndown
# you might also need 'redirect-gateway' in the config file, if you don't use vpn
# as the default gateway.
@lidaobing
lidaobing / auto_route.py
Created September 26, 2010 03:07 — forked from KidFeng/gist:584331
automatic route config
#!/usr/bin/env python
# Usage:
# This script will generate two files(vpnup and vpndown) after executing.
# Do chmod a+x on the two newly created files, and then move them to the
# openvpn config folder. then add the following two lines to the vpn config file:
# up vpnup
# down vpndown
# you might also need 'redirect-gateway' in the config file, if you don't use vpn
# as the default gateway.
@ryanb
ryanb / rails_3_1_rc4_changes.md
Created May 6, 2011 01:10
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 RC4

  • The new rake task assets:clean removes precompiled assets. [fxn]

  • Application and plugin generation run bundle install unless --skip-gemfile or --skip-bundle. [fxn]

  • Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]

  • Template generation for jdbcpostgresql #jruby [Vishnu Atrai]

:+1:
:-1:
:airplane:
:art:
:bear:
:beer:
:bike:
:bomb:
:book:
:bulb:
@otobrglez
otobrglez / as3.rake
Created June 29, 2011 13:40
Rake task for uploading Rails 3.1 compiled assets to Amazon S3 storage
# 1) Put 's3' gem in Gemfile.
# 2) Create as3.yml configuration for S3
# 3) Create initializer for as3.yml
# 4) Make "assets" folder inside your bucket
# 5) After running task run "RAILS_ENV=production rake assets:precompile"
# 6) Invoke task by running "rake as3:upload"
namespace :as3 do
desc "Uploads compiled assets (public/assets) to Amazone AS3"
task :upload do
@huacnlee
huacnlee / nginx.conf
Created September 14, 2011 13:50
Nginx http proxy cache to mirror of Rubygems.org
# 在本地服务器建立 rubygems.org 的镜像缓存,以提高 gem 的安装速度
# 此配置设置缓存过期为1天,也就是说,新上的 gem 无法马上安装
# 做这个起什么作用?
# rubygems 的很多资源文件是存放到 Amazon S3 上面的,由于 GFW 对某些 S3 服务器又连接重置或丢包,导致 gem 安装异常缓慢或有时候根本无法连接安装。
# 而通过这种跳板的方式可以很好的解决这个问题,当然前提是 Nginx反向代理 服务器需要在国外
proxy_cache_path /var/cache/rubygems levels=1:2 keys_zone=RUBYGEMS:10m
inactive=24h max_size=1g;
server {
listen 80;
@funny-falcon
funny-falcon / changes.md
Last active March 23, 2024 05:53
Performace patch for ruby-1.9.3-p327

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.