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
def get_cookie | |
buffer = StringIO.new | |
@agent.cookie_jar.dump_cookiestxt(buffer) | |
buffer.string | |
end | |
def set_cookie cookie | |
@agent.cookie_jar.load_cookiestxt(cookie) unless cookie.blank? | |
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
namespace :deploy do | |
desc "重启服务器" | |
task :restart, :roles => :app do | |
run "touch #{current_path}/tmp/restart.txt" | |
end | |
desc "在本地生成配置文件" | |
task :setup_local_configs do |
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
#方法一: Pdf To Images | |
# 将pdf 转化为image,主要用的Magick,找到两个方法,基本都相同 | |
#function1 | |
pdf =Magick::ImageList.new("test.pdf") | |
pdf.write("demo.jpg") | |
#function2 | |
pdf= Magick::Image.read("test.pdf") |
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
def parse_to_png(pdf_file) | |
pdf = Magick::ImageList.new(pdf_file) | |
pdf.each_with_index do |image,index| | |
thumb = image.scale(1024, 768) | |
thumb.write("pngs/#{index.to_s}.png") | |
end | |
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
# in order to DRY,we can use common config | |
# common config | |
common: &common | |
adapter: mysql2 | |
encoding: utf8 | |
pool: 10 | |
username: root | |
password: | |
host: localhost | |
port: 3306 |
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
coffee: | |
$wrapper = $('.js-infinitescroll-wrap') | |
$wrapper.find('.feed-paging nav.pagination').hide() | |
$wrapper.infinitescroll | |
navSelector: "nav.pagination" | |
nextSelector: "nav.pagination .next a" | |
itemSelector: ".js-infinitescroll-item" | |
bufferPx: 150 | |
loading: | |
img: "/assets/spinner.gif" |
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
before_save :set_material_should_change_field | |
after_save :change_material_attributes | |
def set_material_should_change_field | |
option_changed_attributes = self.changed_attributes | |
@change_field = {} | |
if self.new_record? | |
@change_field.merge!( { :price => true, :lead_time => true } ) | |
elsif option_changed_attributes.include?('price_min') || option_changed_attributes.include?('price_max') |
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
# 更换源 | |
comment_lines "Gemfile", /source .http.*/ | |
add_source "http://ruby.taobao.org" | |
# HTML模板 | |
gem 'slim' | |
# 单点登录 | |
gem 'rubycas-client' | |
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
//= require jquery | |
//= require gigabase | |
$ -> | |
$('.infinitescroll_wrapper').each -> | |
$wrapper = $(this) | |
$wrapper.find('.feed-paging nav.pagination').hide() | |
$wrapper.infinitescroll | |
navSelector: "nav.pagination" | |
nextSelector: "nav.pagination .next a" |
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 MessageSidebar | |
constructor: (element) -> | |
$element = $(element) | |
compose_regex = "messages\/new" | |
inbox_regex = 'messages' | |
outbox_regex = "messages\/outbox" | |
archived_regex = "messages\/archived" | |
trash_regex = "messages\/trash" | |
if window.location.pathname.match(compose_regex) |
OlderNewer