This file contains 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
APPPATH/log/production.log { | |
compress | |
daily | |
rotate 30 | |
create | |
missingok | |
compresscmd /usr/bin/zip | |
uncompresscmd /usr/bin/unzip | |
compressoptions -9 | |
compressext .zip |
This file contains 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
def get_promotion | |
result = TaobaoFu.get(:method => 'taobao.trade.fullinfo.get', | |
:fields => 'promotion_details', | |
:tid => '170933582981157' | |
) | |
if result["trade_fullinfo_get_response"] && result["trade_fullinfo_get_response"]['trade'] && | |
result["trade_fullinfo_get_response"]["trade"]["promotion_details"] | |
promotion_info = result["trade_fullinfo_get_response"]["trade"]["promotion_details"]["promotion_detail"] | |
if !promotion_info.to_a.nil? and self.taobao_promotions.blank? | |
p promotion_info.to_a |
This file contains 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
# -*- encoding : utf-8 -*- | |
require "csv" | |
task :check_missing_tids => :environment do | |
missing_tids=[] | |
open("lib/data/ExportOrderList201211121238.csv").readlines.each do |line| | |
row = line.split(",") | |
tid = row[0].strip | |
order = TaobaoOrder.find_by_tid(tid) | |
unless order.present? | |
unless TaobaoOrder.find_by_tid tid |
This file contains 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
Request URL:http://localhost:4000/admin/taobao_orders?utf8=%E2%9C%93&created_date_from=&order%5Bfrom%281i%29%5D=2012&order%5Bfrom%282i%29%5D=11&order%5Bfrom%283i%29%5D=9&order%5Bfrom%284i%29%5D=17&order%5Bfrom%285i%29%5D=58&created_date_to=&order%5Bto%281i%29%5D=2012&order%5Bto%282i%29%5D=11&order%5Bto%283i%29%5D=9&order%5Bto%284i%29%5D=17&order%5Bto%285i%29%5D=58&pay_condition=1&pay_date_from=11%2F1%2F2012&order%5Bpay_from%281i%29%5D=2012&order%5Bpay_from%282i%29%5D=11&order%5Bpay_from%283i%29%5D=9&order%5Bpay_from%284i%29%5D=17&order%5Bpay_from%285i%29%5D=58&pay_date_to=11%2F9%2F2012&order%5Bpay_to%281i%29%5D=2012&order%5Bpay_to%282i%29%5D=11&order%5Bpay_to%283i%29%5D=9&order%5Bpay_to%284i%29%5D=17&order%5Bpay_to%285i%29%5D=58&rate_date_from=&order%5Brate_from%281i%29%5D=2012&order%5Brate_from%282i%29%5D=11&order%5Brate_from%283i%29%5D=9&order%5Brate_from%284i%29%5D=17&order%5Brate_from%285i%29%5D=58&rate_date_to=&order%5Brate_to%281i%29%5D=2012&order%5Brate_to%282i%29%5D=11&order%5Brate_to%283i%29%5D=9&ord |
This file contains 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
# rails new NAME -OJ -m https://gist.github.com/raw/903515/rails-template.rb | |
remove_file 'README' | |
remove_file 'public/index.html' | |
remove_file 'public/images/rails.png' | |
prepend_file 'config/boot.rb' do <<-RB | |
begin | |
require 'yaml' | |
YAML::ENGINE.yamler = 'syck' |
This file contains 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
request.env['HTTP_REFERER'] | |
request.referer | |
<%= link_to_function "返回上一页", "history.go(-1)" %> | |
<%= link_to "Back", :back %> | |
redirect_to :back |
This file contains 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
# coding: UTF-8 | |
# | |
# 以下为 Rake 任务,功能是将普通文件系统里面的东西转移到 MongoDB GridFS 里面 | |
# 此代码片段来自于 Homeland 项目: https://github.com/huacnlee/homeland/tree/mysql | |
# 场景: | |
# 老架构 Linux File Store, Paperclip, hash 目录:"https://github.com/huacnlee/homeland/blob/ca0bdd8ab26da7b780e2dae7eba12b79f41e6d65/config/initializers/paperclip_hashpath.rb" | |
# 新架构 Mongodb GridFS, Garrierwave, 继续沿用 Paperclip 目录兼容: https://github.com/huacnlee/homeland/tree/7100ce4c506cc2c4387f25e50c533e5bbcac6cc2/app/uploaders | |
# 整个过程不会修改任何原始数据库和上传文件 | |
# | |
require 'mongo' |
This file contains 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
# -*- encoding: utf-8 -*- | |
require 'digest/md5' | |
require 'nestful' | |
class Smsbao | |
attr_accessor :login, :passwd | |
def initialize(login, passwd) | |
@login = login | |
@passwd = Digest::MD5.hexdigest(passwd) |
This file contains 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
# Gemfile | |
gem 'redis', '~> 3.0.1' |
This file contains 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/clear_logs.rb | |
if Rails.env.development? | |
MAX_LOG_SIZE = 10.megabytes | |
logs = [ File.join(Rails.root, 'log', 'development.log'), File.join(Rails.root, 'log', 'test.log') ] | |
logs.each do |log| | |
if File.size?(log).to_i > MAX_LOG_SIZE | |
$stdout.puts "Removing Log: #{log}" | |
`rm #{log}` |