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
By default ssh-copy-id is missing on Mac OS X, but since it’s just a simple bash script you can install it quickly from the official Portable OpenSSH CVS repository: | |
$ sudo bash -c "cvs -d [email protected]:/cvs \ | |
get -p openssh/contrib/ssh-copy-id > /usr/local/bin/ssh-copy-id" | |
$ sudo chmod +x /usr/local/bin/ssh-copy-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
- Install "Command Line Tools for XCode" (Get it from Apple Developer Program) or Install XCode via Appstore | |
where option one is the faster one, 170MB vs 1.xGB | |
- Install https://github.com/sstephenson/rbenv | |
git clone into your home folder; | |
set environment variables, see install docs of rbenv; | |
- Get libyaml | |
wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz | |
configure |
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
include Rails.application.routes.url_helpers |
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
perl -MEncode -pi -e '$_=encode_utf8(decode(gb2312=>$_))' FILE_NAME |
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 PostsController < ActionController::Base | |
def create | |
Post.create(post_params) | |
end | |
def update | |
Post.find(params[:id]).update_attributes!(post_params) | |
end | |
private |
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
validates :name, :format => { :with => /^[A-Za-z0-9]+$/, :message => '只支持英文及数字' }, :length => { :in => 3..20 }, :presence => true, :uniqueness => { :case_sensitive => false } |
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
# config/initializers/quiet_assets.rb | |
Rails.application.assets.logger = Logger.new('/dev/null') | |
Rails::Rack::Logger.class_eval do | |
def call_with_quiet_assets(env) | |
previous_level = Rails.logger.level | |
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0 | |
call_without_quiet_assets(env).tap do | |
Rails.logger.level = previous_level | |
end |
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 Post | |
include Mongoid::Document | |
include Mongoid::MultiParameterAttributes | |
field :published_at, type: DateTime | |
end |
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
# Chinese (China) translations for Devise 2.0 | |
# by HungYuhei (https://github.com/HungYuHei) | |
# forked from https://gist.github.com/1319590 | |
zh-CN: | |
errors: | |
messages: | |
expired: "您已过期,请重新申请" | |
not_found: "没有找到" | |
already_confirmed: "已经激活,请重新登录." |
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
# | |
# lib/mongoid/counter_cache.rb | |
# ruby | |
# | |
# Created by Zhang Alex on 2011-06-17. | |
# Copyright 2011 __ZhangHanDong__. All rights reserved. | |
# | |
# =================================== | |
# class Forum | |
# references_many :topics |