Skip to content

Instantly share code, notes, and snippets.

View rubyonrailsworks's full-sized avatar

RubyonRailsWorks rubyonrailsworks

  • Shanghai,China
View GitHub Profile
@rubyonrailsworks
rubyonrailsworks / gist:1442461
Created December 7, 2011 11:22
ruby编译安装
* How to compile and install
This is what you need to do to compile and install Ruby:
1. If ./configure does not exist or is older than configure.in,
run autoconf to (re)generate configure.
2. Run ./configure, which will generate config.h and Makefile.
Some C compiler flags may be added by default depending on your
@rubyonrailsworks
rubyonrailsworks / apache2
Created December 8, 2011 01:06
ETC/CONF
#
# Based upon the NCSA server configuration files originally by Rob McCool.
#
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.2/ for detailed information about
# the directives.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
#yum install curl-devel as root
#yum remove as root
#yum install httpd
#yum install httpd-devel
#yum install apr-devel
#yum install apr-util-devel
#passenger-install-apache2-module
So, have you started to work with rails 3? Did you realize that your UTF-8 databases doesn’t work nice with mysql? This is because the mysql gem works with ASCII-8BIT encoding, but ruby 1.9 and rails 3 works with UTF-8 encoding, so when you create a model into the database, everything works fine, but when you work with those models, it doesn’t works so nice and you don’t get what you stored.
What’s the solution? Well, there are actually three solutions, the most recommended, use mysql2,
blackmac001:ten bill$ cap deploy:setup
triggering start callbacks for `deploy:setup'
* executing `multistage:ensure'
*** Defaulting to `staging'
* executing `staging'
* executing `deploy:setup'
* executing "mkdir -p /home/staging/www/ten /home/staging/www/ten/releases /home/staging/www/ten/shared /home/staging/www/ten/shared/system /home/staging/www/ten/shared/log /home/staging/www/ten/shared/pids"
servers: ["myserver.com"]
[myserver.com] executing command
@rubyonrailsworks
rubyonrailsworks / devise.rb
Created February 8, 2012 11:05 — forked from kulbirsaini/devise.rb
Devise configuration to allow username or email address for sign_in, confirmation, unlock, forgot password instructions.
################################################################
# For views/migrations etc. check http://tinyurl.com/3xfx3zm #
################################################################
# File : RAILS_APP/config/initializers/devise.rb
# Change the following only. Rest can stay same
# NOTE : You must use devise master or any version released after Mar 13, 2011 to get everything mentioned here working.
config.authentication_keys = [ :login ]
config.confirmation_keys = [ :login ]
config.unlock_keys = [ :login ]
@rubyonrailsworks
rubyonrailsworks / resultCheck.js
Created February 11, 2012 07:18
输入验证
var regexEnum =
{
cn_username:"(?!_)(?![0-9])^[-_a-zA-Z0-9\u4e00-\u9fa5]", //用来用户注册。匹配由数字、26个英文字母、中文字符或者下划线组成的字符串
password:"^[-_a-zA-Z0-9]{6,16}$",
email:"^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", //邮件
mobile:"^(13|15|18)[0-9]{9}$", //手机
msn:"^([a-z][a-z0-9\_\.]*[a-z0-9])(@)(([a-z0-9][a-z0-9\-]*[a-z0-9][\.])+(com|cn|net|hk|tw|au|uk|de|tv|info|biz))$",//msn
telephone:"(^(\d{2,4}[-_-—]?)?\d{3,8}([-_-—]?\d{3,8})?([-_-—]?\d{1,7})?$)|(^0?1[35]\d{9}$)",//固定电话
tel:"^(([0\\+]\\d{2,3}-)?(0\\d{2,3})-)?(\\d{7,8})(-(\\d{3,}))?$", //电话号码的函数(包括验证国内区号,国际区号,分机号)
zipcode:"^\\d{6}$", //邮编
@rubyonrailsworks
rubyonrailsworks / deploy.rb
Created February 25, 2012 02:05
capistrano-with-passenger-stand-alone
# -*- encoding : utf-8 -*-
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_ruby_string, '1.9.2' # Or whatever env you want it to run in.
require 'bundler/capistrano'
set :application, "yourapp"
set :use_sudo, false
@rubyonrailsworks
rubyonrailsworks / deploy.rb
Created March 4, 2012 04:22
Capistrano-unicorn-apache2
# -*- encoding : utf-8 -*-
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_ruby_string, '1.9.2' # Or whatever env you want it to run in.
require 'bundler/capistrano'
set :application, "YourApp"
@rubyonrailsworks
rubyonrailsworks / devise_migration.rb
Created April 14, 2012 07:12 — forked from iwarshak/devise_migration.rb
Migrating to a new password encryption in devise, coming from authlogic
class MigrateUserToDevise < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.string :encrypted_password, :null => false, :limit => 128
# ...
end
end
def self.down
end