Put pre-commit and han.yml under /path/to/project/.git/hooks.
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
if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".ruby-version" ]; then | |
source "$rvm_path/scripts/rvm" | |
if [ -f ".ruby-gemset" ]; then | |
rvm use `cat .ruby-version`@`cat .ruby-gemset` | |
else | |
rvm use `cat .ruby-version` | |
fi | |
fi |
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
# app/constraints/role_constraint.rb | |
class RoleConstraint | |
def initialize(*roles) | |
@roles = roles.map { |r| r.to_s } | |
end | |
def matches?(request) | |
@roles.include? request.env['warden'].user(:user).try(:role) | |
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
source 'https://rubygems.org' | |
gem 'rails', '4.0.0' | |
gem 'mysql2' | |
gem 'sass-rails', '~> 4.0.0' | |
gem 'uglifier', '>= 1.3.0' | |
gem 'coffee-rails', '~> 4.0.0' | |
gem 'jquery-rails' | |
#gem 'turbolinks' | |
gem 'jbuilder', '~> 1.2' |
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
*** buffer overflow detected ***: gvim terminated | |
======= Backtrace: ========= | |
/usr/lib/libc.so.6(__fortify_fail+0x37)[0x7f681dd17e67] | |
/usr/lib/libc.so.6(+0xf9070)[0x7f681dd16070] | |
/usr/lib/libc.so.6(+0xfadd7)[0x7f681dd17dd7] | |
gvim[0x5206a5] | |
gvim(mch_call_shell+0x577)[0x522297] | |
gvim(call_shell+0x6d)[0x4ec86d] | |
gvim(do_shell+0xe3)[0x47bc33] | |
gvim(ex_make+0x298)[0x529b88] |
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
# 更换身份 | |
> telnet localhost 9051 | |
AUTHENTICATE | |
SETCONF ExitNodes={us} | |
SETCONF StrictNodes=1 | |
SIGNAL NEWNYM | |
QUIT | |
Or |
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
# 假设新建一个叫 core1 的 core | |
mkdir -p /path/to/core1/data | |
cd /path/to/project | |
cp -r `bundle show sunspot_solr`/solr/solr/conf /path/to/core1 | |
bundle exec rake sunspot:solr:start |
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
2,7c2,7 | |
< * actionmailer (3.2.13) | |
< * actionpack (3.2.13) | |
< * activemodel (3.2.13) | |
< * activerecord (3.2.13) | |
< * activeresource (3.2.13) | |
< * activesupport (3.2.13) | |
--- | |
> * actionmailer (3.2.12) | |
> * actionpack (3.2.12) |
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 'open-uri' | |
require 'nokogiri' | |
code = 2904 | |
doc = Nokogiri::HTML(open("http://just2.entrust.com.tw/z/zc/zca/zca_#{code}.djhtm")) | |
# 當前股價,既網頁中的收盤價 | |
doc.css('table')[2].css('tr')[1].css('td').last.inner_text.to_f |
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
#!/usr/bin/env bash | |
apt-get -y update | |
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev ruby1.9.3 | |
gem install chef ruby-shadow bundler --no-ri --no-rdoc |