Skip to content

Instantly share code, notes, and snippets.

View zires's full-sized avatar
🎎
anxiety

zshuaibin zires

🎎
anxiety
View GitHub Profile
@zires
zires / nginx.conf
Created June 1, 2011 18:47
nginx configuration file
# you generally only need one nginx worker unless you're serving
# large amounts of static files which require blocking disk reads
worker_processes 1;
# # drop privileges, root is needed on most systems for binding to port 80
# # (or anything < 1024). Capability-based security may be available for
# # your system and worth checking out so you won't need to be root to
# # start nginx to bind on 80
user nobody nogroup; # for systems with a "nogroup"
@zires
zires / unicorn.conf
Created June 1, 2011 18:51
Unicorn nginx configuration
upstream app_server {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
# for UNIX domain socket setups:
server unix:/tmp/.sock fail_timeout=0;
# for TCP setups, point these to your backend servers
# server 192.168.0.7:8080 fail_timeout=0;
@zires
zires / unicorn.rb
Created June 1, 2011 19:03
unicorn configuration
# Sample verbose configuration file for Unicorn (not Rack)
#
# This configuration file documents many features of Unicorn
# that may not be needed for some applications. See
# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
# for a much simpler configuration file.
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
@zires
zires / deploy.rb
Created June 1, 2011 19:30
deploy use unicorn and nginx
set :application, "hermes"
set :repository, "git@your_repository:hermes.git"
set :user, 'root'
set :use_sudo, false
set :deploy_via, :remote_cache
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
role :web, "xxx.com" # Your HTTP server, Apache/etc
@zires
zires / boot.rb
Created July 20, 2011 17:00
rails2.3.5 boot.rb
class Rails::Boot
def run
load_initializer
Rails::Initializer.class_eval do
def load_gems
@bundler_loaded ||= Bundler.require :default, Rails.env
end
end
@zires
zires / preinitializer.rb
Created July 20, 2011 17:02
rails2.3.5 preinitializer file
begin
require "rubygems"
require "bundler"
rescue LoadError
raise "Could not load the bundler gem. Install it with `gem install bundler`."
end
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
raise RuntimeError, "Your bundler version is too old for Rails 2.3." +
"Run `gem install bundler` to upgrade."
@zires
zires / mongo_backup.rb
Created August 11, 2011 01:39 — forked from huobazi/mongo_backup.rb
Backup solution for mongodb which dumps gridfs items on filesystem
#!/usr/bin/env ruby
# This script is a backup tool for mongodb.
#
# The main purpose is to dump files from gridfs to filesystem,
# to take advantage of backup solutions based on tools like
# rsync.
# Developed against mongo 1.6.0
@zires
zires / GridfsController.rb
Created August 16, 2011 02:25
read grid files
require 'mongo'
class GridfsController < ActionController::Metal
def serve
env["PATH_INFO"].match(/\/attach\/([\da-zA-Z]+)\//)
begin
grid = Mongo::Grid.new(Mongoid.database).get(BSON::ObjectId($1))
self.headers["Content-Length"] = grid.file_length.to_s
self.content_type = grid.content_type
self.response_body = grid.read
@zires
zires / css.css
Created October 22, 2011 10:51
css3 compatible
.box-shadow{
filter: progid:DXImageTransform.Microsoft.Shadow(color='#969696', Direction=135, Strength=5);/*for ie6,7,8*/
background-color: #eee;
-webkit-box-shadow:2px 2px 5px #969696;/*webkit*/
box-shadow:2px 2px 5px #969696;/*opera或ie9*/
@zires
zires / gist:1499989
Created December 20, 2011 02:43 — forked from seyhunak/gist:1499751
Rails 3.2.0 Changelogs

Railties 3.2.0 (unreleased)

  • Speed up development by only reloading classes if dependencies files changed. This can be turned off by setting config.reload_classes_only_on_change to false. José Valim

  • New applications get a flag config.active_record.auto_explain_threshold_in_seconds in the environments configuration files. With a value of 0.5 in development.rb, and commented out in production.rb. No mention in test.rb. fxn

  • Add DebugExceptions middleware which contains features extracted from ShowExceptions middleware José Valim

  • Display mounted engine's routes in rake routes Piotr Sarnacki