Skip to content

Instantly share code, notes, and snippets.

@johnantoni
johnantoni / unicorn.rb
Created August 2, 2012 15:48
unicorn + nginx setup + ssl
unicorn.rb
-----------------------------------
application = "jarvis"
remote_user = "vagrant"
env = ENV["RAILS_ENV"] || "development"
RAILS_ROOT = File.join("/home", remote_user, application)
worker_processes 8
timeout 30
@trcarden
trcarden / gist:3295935
Created August 8, 2012 15:28
Rails 3.2.7 SSL Localhost (no red warnings, no apache config)
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@djburdick
djburdick / rails_db_migrate_multiple_databases.rb
Created May 22, 2013 17:16
make schema_migrations work over multiple databases. #rails
module ActiveRecord
class Migrator
class << self
def get_all_versions
table = Arel::Table.new(schema_migrations_table_name)
# must not be Base.establish_connection b/c that'll drop the mysql2
# adapter connection and blow up rake db:schema:dump
SchemaMigration.establish_connection(ActiveRecord::Base.configurations['cluster'][Rails.env])
cluster_migrations = SchemaMigration.connection.select_values(table.project(table['version'])).map{ |v| v.to_i }
@dergachev
dergachev / prepend-timestamp.md
Last active September 28, 2016 14:56
shell snippet to prepend timestamp to command output

prepend-timestamp

Shell snippet that prepends a nice to a command's output.

For example, here's the (snipped) output of vagrant provision:

Successfully installed bundler-1.3.5  
1 gem installed  
Using rmagick (2.13.2)  
@ozuma
ozuma / nochunk.cgi
Created July 24, 2013 05:30
Suppress "Transfer-Encoding: chunked" header and chunked body in CGI. (Apache, Perl)
#!/usr/bin/perl
use strict;
use warnings;
my $body = <<"EOM";
<html>
<head>
<title>title</title>
</head>
ACTION
AD_HOC_CODE_SIGNING_ALLOWED
ALTERNATE_GROUP
ALTERNATE_MODE
ALTERNATE_OWNER
ALWAYS_SEARCH_USER_PATHS
ALWAYS_USE_SEPARATE_HEADERMAPS
APPLE_INTERNAL_DEVELOPER_DIR
APPLE_INTERNAL_DIR
APPLE_INTERNAL_DOCUMENTATION_DIR
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Custom tasks
require 'capistrano/composer'
require 'capistrano/npm'
@ohryan
ohryan / responsive-align.less
Last active April 30, 2019 17:27
Bootstrap 3 Responsive Text Align
.text-xs-left { text-align: left; }
.text-xs-right { text-align: right; }
.text-xs-center { text-align: center; }
.text-xs-justify { text-align: justify; }
@media (min-width: @screen-sm-min) {
.text-sm-left { text-align: left; }
.text-sm-right { text-align: right; }
.text-sm-center { text-align: center; }
.text-sm-justify { text-align: justify; }
@zedar
zedar / GroovyHTTPBuilderChunkedResponse.md
Last active August 29, 2015 14:08
HTTPBuilder and chunked response

There is a bug in Groovy version up to 2.3.7. HTTPBuilder is not able to automatically parse chunked response to JSON format. If external server returns response with header:

Transfer-Encoding : chunked

Usually applied code:

def http = new HTTPBuilder(url)

def result = http.request(POST, JSON) { req ->

@stevegraham
stevegraham / active_jerbz.rake
Created December 4, 2014 15:47
Run ActiveJobs with Sneakers
require 'sneakers/runner'
task :environment
namespace :sneakers do
desc "Start processing jobs with all workers"
task :work => :environment do
silence_warnings do
Rails.application.eager_load! unless Rails.application.config.eager_load
end