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.use_transactional_fixtures = false | |
config.before(:suite) do | |
DatabaseCleaner.clean_with :truncation #start the process by truncating all the tables | |
end | |
config.before(:each) do | |
if example.metadata[:js] | |
DatabaseCleaner.strategy = :truncation # for javascript tests using :truncation | |
else | |
DatabaseCleaner.strategy = :transaction #use the faster transaction strategy |
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
# unicorn通过master进程管理worker进程,这里初始化工作进程的数量,默认为3个 | |
# 举例: AWS EC2 m3.2xlarge 设置30个worker | |
worker_processes Integer(ENV["UNICORN_CONCURRENCY"] || 3) | |
preload_app true | |
# 工作进程的响应超时时间(秒) | |
timeout 120 | |
listen "/tmp/sockets/unicorn.sock" | |
pid "/tmp/pids/unicorn.pid" | |
if ENV['RAILS_ENV'] == 'development' # 开发环境用于测试和验证一些配置 |
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
# nginx.conf | |
http { | |
client_max_body_size 20M; #上传文件的大小 | |
} | |
------------------------------------------------------------------------------------ | |
#Nginx应用配置 | |
upstream app-name { | |
# 配置unicorn服务器器 | |
server unix:/opt/app-name/tmp/sockets/unicorn.sock |
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
DEPLOY_PATH = { | |
:staging => 'app-name', | |
:production => 'app-name', | |
:uat => 'app-name-uat' | |
} | |
SERVICES = %w(app-name) | |
ENVIRONMENTS = [:staging, :uat] #这是测试环境的配置,对于产品环境可以改成[:production] | |
TIMEOUT = 30.seconds | |
LONG_TIMEOUT = 60.seconds |
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 Player | |
REST_HEALTH = 15 | |
FLEE_HEALTH = 7 | |
def play_turn(warrior) | |
@last_known_health ||= warrior.health | |
@direction ||= :forward | |
feel_space = warrior.feel @direction | |
if clear_shot?(warrior) |
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
#!/usr/bin/perl -w | |
# | |
(my $prog = $0) =~ s/^.*\///; | |
sub Usage { | |
die @_, &herefile( qq{ | |
| Usage: $prog > ~/.magick/type.xml | |
| $prog [-d] font1.ttf font2.ttf ... > type.xml | |
| $prog -f ttf_font_file_list > type.xml | |
| | |
| Generate an ImageMagick font list "type.xml" file for ALL fonts |
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
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
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
git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
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
mkdir ~/vim | |
cd ~/vim | |
# Staically linked vim version compiled from https://github.com/ericpruitt/static-vim | |
# Compiled on Jul 20 2017 | |
curl 'https://s3.amazonaws.com/bengoa/vim-static.tar.gz' | tar -xz | |
export VIMRUNTIME="$HOME/vim/runtime" | |
export PATH="$HOME/vim:$PATH" | |
cd - |
OlderNewer