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
110000 北京市 | |
110100 市辖区 | |
110101 东城区 | |
110102 西城区 | |
110105 朝阳区 | |
110106 丰台区 | |
110107 石景山区 | |
110108 海淀区 | |
110109 门头沟区 | |
110111 房山区 |
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 | |
module ClearActiveModelValidators | |
extend ActiveSupport::Concern | |
module ClassMethods | |
# 清除指定属性上的 validators | |
# 参数说明(请全部使用 symbol): | |
# :all 清除所有属性上的 validators | |
# 属性名列表 清除指定属性上的 validators | |
# |
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
{ | |
"template_default" : { | |
"template" : "*", | |
"mappings" : { | |
"_default_" : { | |
"_source" : { | |
"compress": true | |
} | |
} | |
} |
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
1.9.3p194 :005 > hash = { test_symbol_gc: "test" } | |
=> {:test_symbol_gc=>"test"} | |
1.9.3p194 :006 > Symbol.all_symbols.find { |s| s.to_s == "test_symbol_gc" } | |
=> :test_symbol_gc | |
1.9.3p194 :007 > hash = nil | |
=> nil | |
1.9.3p194 :008 > GC.start | |
=> nil | |
1.9.3p194 :009 > Symbol.all_symbols.find { |s| s.to_s == "test_symbol_gc" } | |
=> :test_symbol_gc |
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
class AlterUsersIdStartFrom10001 < ActiveRecord::Migration | |
def self.up | |
execute "ALTER TABLE users AUTO_INCREMENT = 10001;" | |
end | |
def self.down | |
execute "ALTER TABLE users AUTO_INCREMENT = 1;" | |
end | |
end |
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
# | |
# 这只是针对active_record_store情况下要做的修改,完整的cookie_store mode看这里 | |
# https://github.com/websymphony/Rails3-Paperclip-Uploadify | |
# | |
Uploader::Application.config.session_store :active_record_store, :key => '_uploader_session' | |
Rails.application.config.middleware.insert_before( | |
Rails.application.config.session_store, | |
FlashSessionCookieMiddleware, |
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
# from https://github.com/mpelos/nova_marine/blob/2dc882dac31532024d4edb196e4a632801738341/lib/paperclip_processors/watermark.rb | |
# Rails.root /lib/paperclip_processors/watermark.rb | |
module Paperclip | |
class Watermark < Thumbnail | |
def initialize(file, options = {}, attachment = nil) | |
super | |
@watermark_path = options[:watermark_path] | |
@position = options[:position].nil? ? "SouthEast" : options[:position] | |
end |