Skip to content

Instantly share code, notes, and snippets.

@kirs
kirs / deploy.rb
Created July 5, 2012 12:38 — forked from mikhailov/0. nginx_setup.sh
Nginx+Unicorn (production-ready setup)
# Capistrano configuration
#
# require 'new_relic/recipes' - Newrelic notification about deployment
# require 'capistrano/ext/multistage' - We use 2 deployment environment: staging and production.
# set :deploy_via, :remote_cache - fetch only latest changes during deployment
# set :normalize_asset_timestamps - no need to touch (date modification) every assets
# "deploy:web:disable" - traditional maintenance page (during DB migrations deployment)
# task :restart - Unicorn with preload_app should be reloaded by USR2+QUIT signals, not HUP
@andrewbroman
andrewbroman / checksum.rb
Created July 12, 2012 16:16
Ruby: create checksum on hash
# Thanks to tenderlove on Peepcode play by play
require 'digest/md5'
def fetch username
records = JSON.parse get username
records.each do |hash|
checksum = Digest::MD5.hexdigest Marshal.dump(hash)
hash['checksum'] = checksum
end
@jhjguxin
jhjguxin / application.rb
Created September 14, 2012 03:08
rails IE, IFRAME, P3P, COOKIES
#userful gem [rack-p3p](https://github.com/hoopla/rack-p3p)
# [ie_iframe_cookies](https://github.com/grosser/ie_iframe_cookies)
# encoding: utf-8
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_p3p
def set_p3p
headers['P3P'] = "policyref=\"/w3c/p3p.xml\", CP=\"ALL DSP COR CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT\""
end
@chuanxshi
chuanxshi / devise.zh-CN.yml
Created September 23, 2012 03:47
Simplified Chinese Translation for Devise 2.1
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
zh-CN:
errors:
messages:
expired: "您已过期,请重新申请"
not_found: "没有找到"
already_confirmed: "已经激活,请重新登录."
not_locked: "未锁定"
not_saved:
@jugyo
jugyo / gist:3882497
Created October 13, 2012 00:16
nginx + ngx_lua on Mac
@mouse-lin
mouse-lin / yml
Created March 5, 2013 12:01
load yml
module Settings
def self.get key
val = data.fetch(Rails.env, nil).try(:[], ENV["PLATFORM"]).try(:[], key)
raise "value nil in #{ Rails.en }" if val.nil? && Rails.env != "test"
val
end
def self.data
@data ||= YAML.load_file File.join(Rails.root, "config/settings.yml")
end
@mzupan
mzupan / etc-default-uwsgi-graphite
Created March 20, 2013 19:26
graphite with nginx and uwsgi
PYTHONPATH=/opt/graphite/webapp/graphite
MODULE=graphite_uwsgi
@ryansobol
ryansobol / gist:5252653
Last active February 23, 2025 06:28
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@yorkxin
yorkxin / rfc6749.md
Last active March 17, 2025 03:03
RFC 6749 in Markdown - Edited from http://tools.ietf.org/rfc/rfc6749.txt
Internet Engineering Task Force (IETF)                     D. Hardt, Ed.
Request for Comments: 6749                                     Microsoft
Obsoletes: 5849                                             October 2012
Category: Standards Track
ISSN: 2070-1721

The OAuth 2.0 Authorization Framework

Abstract

@huacnlee
huacnlee / .tm_properties
Created November 1, 2013 02:20
~/.tm_properties TextMate 2 for Ruby, Ruby on Rails, RSpec 配置文件
[ "{*.yml,*.yml.default}" ]
fileType = source.yaml
[ "{Capfile,Gemfile,Gemfile.lock,Guardfile}" ]
fileType = source.ruby
[ *_spec.rb ]
fileType = source.ruby.rspec
[ "{app/{models,controllers,mailers,helpers,cells,uploaders}/**/*.rb,*_controller.rb,*_helper.rb,*_mailer.rb}" ]