Skip to content

Instantly share code, notes, and snippets.

View bingxie's full-sized avatar

Bing Xie bingxie

View GitHub Profile
@bingxie
bingxie / capybara cheat sheet
Created May 25, 2016 00:38 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=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')
@bingxie
bingxie / player.rb
Created February 29, 2016 04:32
Ruby Warrior on bloc.io solution
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)
@bingxie
bingxie / gist:7523930
Created November 18, 2013 07:22
A better use of database_cleaner with RSpec. In spec_helper.rb
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
@bingxie
bingxie / applications.eye.rb
Last active August 29, 2015 14:11
Eye配置
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
@bingxie
bingxie / gist:a0039781a52ad908b0a2
Last active August 29, 2015 14:11
Nginx的配置
# nginx.conf
http {
client_max_body_size 20M; #上传文件的大小
}
------------------------------------------------------------------------------------
#Nginx应用配置
upstream app-name {
# 配置unicorn服务器器
server unix:/opt/app-name/tmp/sockets/unicorn.sock
@bingxie
bingxie / unicorn.rb
Last active August 29, 2015 14:11
Unicorn的配置
# 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' # 开发环境用于测试和验证一些配置