Skip to content

Instantly share code, notes, and snippets.

@mikhailov
mikhailov / 0. nginx_setup.sh
Last active January 21, 2025 08:21
NGINX+SPDY with Unicorn. True Zero-Downtime unless migrations. Best practices.
# Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@mperham
mperham / gist:1831203
Created February 14, 2012 22:39
Campfire deploy announcements
# Put this at the bottom of your config/deploy.rb
# Requires config file ~/.campfire.yml with your API token from
# your Campfire "My Info" page:
#
# token: lkjsadfsaduoi1u31oui3eh1kj2h
# roomid: 123456
# subdomain: acmeco
class Room
attr_accessor :config
- unless Rails.env.development?
/ Require jQuery
= javascript_include_tag 'http://yandex.st/jquery/1.7.1/jquery.min.js'
/ Require Google's jQuery if Yandex is down
:javascript
window.jQuery || document.write('<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">\x3C/script>')
/ Require local jQuery if Google is down / is development env
:javascript
window.jQuery || document.write('<script src="#{asset_path('jquery.js')}">\x3C/script>')
@shtirlic
shtirlic / git-backup
Created November 30, 2011 12:36
Script for git repo backup in dropbox via git bundle
#!/usr/bin/env ruby
if __FILE__ == $0
bundle_name = ARGV[0] if (ARGV[0])
bundle_name = `pwd`.split('/').last.chomp if bundle_name.nil?
bundle_name += ".git.bundle"
puts "Backing up to bundle #{bundle_name}"
`git bundle create ~/Dropbox/backup/git-repos/#{bundle_name} --all`
end
@brainopia
brainopia / gist:1255687
Created October 1, 2011 06:28
The easiest way to escape nested bash commands
def bash_escape(argument)
"$'" + argument.gsub("\\'", '\\\\\&').gsub("'", "\\\\'") + "'"
end
ruby_code = "puts 'something'"
command = "ruby -e #{bash_escape ruby_code}"
puts "ssh server #{bash_escape command}" # => ssh server $'ruby -e $\'puts \\\'something\\\'\''
@jraines
jraines / rails31init.md
Created May 24, 2011 17:03
Rails 3.1 with Rspec, Cucumber, Factory Girl, Haml, and Simple Form

Install Rails 3.1 RC

gem install rails --pre

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile