Version: 1.0.0 Protocol Version: 2024-11-05 Last Updated: 2026-01-10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 = /^(?: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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#', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/ruby1.9 | |
| require 'fiber' | |
| require 'benchmark' | |
| class Ring | |
| attr_reader :id | |
| attr_accessor :attach | |
| def initialize(id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) }, |
#如何将 Rails 应用程序部署到 VPS 上
如果已经在 VPS 上假设好了 Rails 生产环境,接下来就可以将部署应用程序了。
###需要用到的工具