Skip to content

Instantly share code, notes, and snippets.

View rubyonrailsworks's full-sized avatar

RubyonRailsWorks rubyonrailsworks

  • Shanghai,China
View GitHub Profile
@rubyonrailsworks
rubyonrailsworks / load.rb
Created January 18, 2013 07:12
导入作品数据
def self.load_old_data
OldDesign.all.each do |old|
user = User.find_by_old_id(old.user_id)
next unless user
design = Design.create(user_id: user.id, title: old.title, content: old.title, view_count: old.view_count,
style: old.style, recommended: old.recommended, tag_list: old.tags.gsub(',', ','))
p design
OldDesignFile.where(:old_design_id => old.id).all.each do |file|
image = DesignImage.new
image.user_id = user.id
/path/to/unicorn/log/unicorn.stderr.log
/path/to/production/log/production.log
{
daily
missingok
rotate 180
compress
dateext
# this is important if using "compress" since we need to call
@rubyonrailsworks
rubyonrailsworks / aliicolor.apache.conf
Last active December 11, 2015 05:48
Passenger Vs UNICORN
<VirtualHost *:80>
ServerName xxx
ServerAlias xxx
RewriteEngine On
PassengerEnabled off
DocumentRoot /home/www/rails/icolor/current/public
RewriteCond /home/www/rails/icolor/current/public/%{REQUEST_URI} !-f
# -*- encoding : utf-8 -*-
set :assets_dependencies, %w(app/assets lib/assets vendor/assets Gemfile.lock config/routes.rb)
namespace :deploy do
namespace :assets do
desc <<-DESC
Run the asset precompilation rake task. You can specify the full path \
to the rake executable by setting the rake variable. You can also \
@rubyonrailsworks
rubyonrailsworks / rbconfig.json
Created January 12, 2013 06:35
Rconfig sample
{
"CHDIR" =>"cd -P",
"RMALL" =>"rm -fr",
"RMDIRS" =>"rmdir --ignore-fail-on-non-empty -p",
"RMDIR" =>"rmdir --ignore-fail-on-non-empty",
"CP" =>"cp",
"RM" =>"rm -f",
"PKG_CONFIG" =>"pkg-config",
"DOXYGEN" =>"",
"DOT" =>"",
@rubyonrailsworks
rubyonrailsworks / 数据库创建和ftp环境搭建
Created January 5, 2013 09:01
为爱上色@好耶服务器 操作
1.创建 tonghuashijie数据库,授权给tonghuashijie
mysql> create database tonghuashijie;
Query OK, 1 row affected (0.01 sec)
mysql> GRANT ALL ON tonghuashijie.* TO tonghuashijie@localhost IDENTIFIED BY 'PASSWORD';
Query OK, 0 rows affected (0.09 sec)
mysql> GRANT ALL ON tonghuashijie.* TO tonghuashijie@"%" IDENTIFIED BY 'PASSWORD';
Query OK, 0 rows affected (0.00 sec)
@rubyonrailsworks
rubyonrailsworks / 20130104.json
Created January 5, 2013 02:43
Trade Sample for dulux
{
"_type": "TaobaoTrade",
"adjust_fee": 0,
"alipay_id": "2088702392722633",
"alipay_no": "2012112400001000630016952482",
"buyer_nick": "不远有多远",
"buyer_obtain_point_fee": 0,
"cod_fee": 0,
"cod_status": "NEW_CREATED",
"created": ISODate("2012-11-23T11:06:46.0Z"),
@rubyonrailsworks
rubyonrailsworks / convert.rake
Created December 8, 2012 04:28 — forked from mperham/convert.rake
Ruby script to update MySQL from Latin1 to UTF8 without data conversion
desc "convert a latin1 database with utf8 data into proper utf8"
task :convert_to_utf8 => :environment do
puts Time.now
dryrun = ENV['DOIT'] != '1'
conn = ActiveRecord::Base.connection
if dryrun
def conn.run_sql(sql)
puts(sql)
end
else
SELECT `tid`, DATE_ADD(`send_goods_at`, INTERVAL 8 HOUR) FROM `taobao_orders` WHERE `tid` IN ('166766380536047', '166789906978402')
@rubyonrailsworks
rubyonrailsworks / changes.md
Created November 27, 2012 07:58 — forked from funny-falcon/changes.md
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.