Skip to content

Instantly share code, notes, and snippets.

@giacomomacri
giacomomacri / deploy.rb
Created March 28, 2014 13:10
A workaround for skipping Rails asset pipeline compilation in Capistrano 2 and avoid to compile asset on servers.
# Comment load 'deploy/assets' in Capfile
# Usage
# cap deploy -> deploy with asset pipeline compilation
# cap deploy -s skip_asset=true -> deploy without asset pipeline compilation, just keep the old asset
namespace :deploy do
task :default do
update
# migrate # uncomment this when you need to run migrations
assets.precompile
@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)
#
@thbounzer
thbounzer / get_rf.rb
Created June 1, 2012 13:20
Get rf a2c modem state
require "net/https"
require "uri"
def check_rf(sitid)
magic_number = 1040187392+sitid.to_i
uri = URI.parse("https://sap2.astra2connect.com/tms/term/4-#{magic_number}/cgi-bin/modem_status")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
begin
@cdarne
cdarne / apache_setup.sh
Created May 24, 2012 11:17
Upstart/init.d config example for rails/passenger
sudo a2enmod proxy_http
sudo service apache2 restart
@bvajda
bvajda / solutions.markdown
Created August 13, 2011 12:25
ruby/rails tips, tricks, solutions

Ruby and Rails Tips, Tricks and Solutions

  • 'normalize_yaml_input' error might be caused by wrong locale settings.

    # CLI
    locale
    # => "LC_ALL ="
    export LC_ALL="en_US" # (or your locale of choice)
    
@mgreenly
mgreenly / gist:1109325
Created July 27, 2011 13:11
database cleaner multiple connections single orm outside of rails
RSpec.configure do |config|
config.before(:suite) do
ActiveRecord::Base.establish_connection database['one']
DatabaseCleaner.strategy = :deletion
ActiveRecord::Base.establish_connection config.database['two']
DatabaseCleaner.strategy = :deletion
end
config.before(:each) do
@wbailey
wbailey / databases.rake
Created February 11, 2011 08:58
ActiveRecord migrations outside of Rails
require 'yaml'
require 'logger'
require 'active_record'
namespace :db do
def create_database config
options = {:charset => 'utf8', :collation => 'utf8_unicode_ci'}
create_db = lambda do |config|
ActiveRecord::Base.establish_connection config.merge('database' => nil)
@ryanflorence
ryanflorence / static_server.js
Last active February 27, 2025 06:28
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);