Skip to content

Instantly share code, notes, and snippets.

View yandy's full-sized avatar

Michael Ding yandy

View GitHub Profile
@yandy
yandy / tmux-cheatsheet.markdown
Created May 4, 2016 01:12 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
GEM
remote: http://ruby.taobao.org/
specs:
activemodel (3.2.14)
activesupport (= 3.2.14)
builder (~> 3.0.0)
activesupport (3.2.14)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
backports (3.3.3)
@yandy
yandy / Jobfile.rb
Last active December 22, 2015 08:48
Jobs for hackers
source 'http://dotide.com'
ruby '2.0.0'
group :backend do
gem 'rails', '4.0.0'
gem 'grape'
gem 'mongoid'
gem 'redis'
end
@yandy
yandy / cors-invoke.js
Last active December 19, 2015 02:28
cors related
$('.feature-slides li').removeClass('hide');
// Make the actual CORS request.
function makeCorsRequest() {
// All HTML5 Rocks properties support CORS.
var url = 'http://api.dotide.com:9292/v1/products';
var xhr = createCORSRequest('GET', url);
if (!xhr) {
alert('CORS not supported');
return;
@yandy
yandy / express.r
Created June 3, 2013 15:46
趣味代码片段
n=50000;
r=0.7;r_e=(1-r*r)^.5;
X=rnorm(n);
Y=X*r+r_e*rnorm(n);
Y=ifelse(X>0,Y,-Y);
plot(X,Y,col="pink",main="This picture represents my heart")
n=50000;
r=0.7;r_e=(1-r*r)^.5;
X=rnorm(n);
@yandy
yandy / gist:3947716
Created October 24, 2012 17:59
替换文本
find :path -type f -exec sed -e 's/ugly/beautiful/g' -i '' {} \;
@yandy
yandy / gist:2918742
Created June 12, 2012 17:09 — forked from defunkt/gist:208588
unicorn worker monitor besides "god"
# This will ride alongside god and kill any rogue memory-greedy
# processes. Their sacrifice is for the greater good.
unicorn_worker_memory_limit = 300_000
Thread.new do
loop do
begin
# unicorn workers
#
@yandy
yandy / gist:2906789
Created June 10, 2012 18:10 — forked from defunkt/gist:208581
god monitor unicorn
# http://unicorn.bogomips.org/SIGNALS.html
rails_env = ENV['RAILS_ENV'] || 'production'
rails_root = ENV['RAILS_ROOT'] || "/data/github/current"
God.watch do |w|
w.name = "unicorn"
w.interval = 30.seconds # default
# unicorn needs to be run from the rails root
@yandy
yandy / gist:2906788
Created June 10, 2012 18:10 — forked from defunkt/gist:206253
unicorn config
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@yandy
yandy / god.rb
Created June 10, 2012 18:10 — forked from defunkt/god.rb
god monitor delayed_job
rails_root = "/data/github/current"
20.times do |num|
God.watch do |w|
w.name = "dj-#{num}"
w.group = 'dj'
w.interval = 30.seconds
w.start = "rake -f #{rails_root}/Rakefile production jobs:work"
w.uid = 'git'