Skip to content

Instantly share code, notes, and snippets.

@baya
baya / README.markdown
Created January 21, 2012 09:15 — forked from AndorChen/README.markdown
Howto Depoly Rails App to VPS

#如何将 Rails 应用程序部署到 VPS 上

如果已经在 VPS 上假设好了 Rails 生产环境,接下来就可以将部署应用程序了。

###需要用到的工具


@baya
baya / lithp.rb
Created January 29, 2012 01:24 — forked from fogus/lithp.rb
class Lisp
def initialize
@env = {
:label => lambda { |(name,val), _| @env[name] = val },
:quote => lambda { |sexpr, _| sexpr[0] },
:car => lambda { |(list), _| list[0] },
:cdr => lambda { |(list), _| list.drop 1 },
:cons => lambda { |(e,cell), _| [e] + cell },
:eq => lambda { |(l,r), _| l == r },
:if => lambda { |(cond, thn, els), ctx| eval(cond, ctx) ? eval(thn, ctx) : eval(els, ctx) },
@baya
baya / server_install.md
Created February 27, 2012 14:28 — forked from bvajda/server_install.md
Postgresql 9.1 server on CentOS 6

install CentOS 6

yum update
yum upgrade

check the server time. sync the time to a time server if needed (service 'ntpd')

download and install Postgresql Server v9.1 rpm package:

rpm -Uvh http://yum.pgrpms.org/9.1/redhat/rhel-6-x86_64/pgdg-centos91-9.1-4.noarch.rpm

This should have installed the necessary server package: postgresql91-server.x86_64.

# simulate template rendering
class Template < Struct.new(:name)
def render
puts "#{name}_begin"
r = "#{name}_begin\n"
r << yield if block_given?
puts "#{name}_end\n"
r << "#{name}_end\n"
end
end
@baya
baya / fiber.rb
Created July 24, 2013 03:25 — forked from mfdela/fiber.rb
#!/usr/bin/ruby1.9
require 'fiber'
require 'benchmark'
class Ring
attr_reader :id
attr_accessor :attach
def initialize(id)
class Avatar < ActiveRecord::Base
attr_accessor :content_type, :original_filename, :image_data
before_save :decode_base64_image
has_attached_file :image,
PAPERCLIP_CONFIG.merge(
:styles => {
:thumb => '32x32#',
:medium => '64x64#',
@baya
baya / gist:6661074
Created September 22, 2013 15:30 — forked from luikore/gist:149493
# regexps to check if a string is pure chinese
class String
# 20k chars
CHINESE_UCS2 = /^(?:
[\x4e-\x9e][\x00-\xff]
|\x9f[\x00-\xa5]
)+$/xn
# 20k chars
CHINESE_UTF8 = /^(?: