Skip to content

Instantly share code, notes, and snippets.

Cody Caughlan ruckus

Block or report user

Report or block ruckus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ruckus / statistics.sql
Created Jun 5, 2013
Postgres statistics queries
View statistics.sql
** Find commmonly accessed tables and their use of indexes:
SELECT relname,seq_tup_read,idx_tup_fetch,cast(idx_tup_fetch AS numeric) / (idx_tup_fetch + seq_tup_read) AS idx_tup_pct FROM pg_stat_user_tables WHERE (idx_tup_fetch + seq_tup_read)>0 ORDER BY idx_tup_pct;
Returns output like:
relname | seq_tup_read | idx_tup_fetch | idx_tup_pct
schema_migrations | 817 | 0 | 0.00000000000000000000
user_device_photos | 349 | 0 | 0.00000000000000000000
ruckus / gist:2293434
Created Apr 3, 2012
Basic setup of WAL-E for continuous archiving and recovery
View gist:2293434

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60
ruckus / gist:3124445
Created Jul 16, 2012
Rails Single Table Inheritance example
View gist:3124445
create_table :media_items do |t|
t.string :type, :null => false, :limit => 32
t.string :name
class MediaItem < ActiveRecord::Base
validates_presence_of :kind
MONTH=`date +"%Y-%m"`
DAY=`date +"%d"`
THISHOUR=`date +"%H"`
TIMESTAMP=`date +"%Y-%m-%d"`
echo "Start: postgresql.log.${TIMESTAMP}"
ruckus / rds_download_logfiles.rb
Created Jan 9, 2015
Ruby script to download log files from RDS and archive to S3.
View rds_download_logfiles.rb
This script uses the AWS v2 API
source ""
gem "aws-sdk", "2.0.17.pre"
ruckus / AppController.php
Created Oct 25, 2012
CakePHP Request logging ala Rails
View AppController.php
class AppController extends Controller {
function beforeFilter() {
Log some basic basic details of the HTTP Request:
Started GET "/users/lost" for at 2012-10-24 19:18:25 -0700
ruckus / gist:3989311
Created Oct 31, 2012
tumblr theme with fixed footer
View gist:3989311
<!DOCTYPE html>
High Res Theme 1.1.9 -- 26 September 2012
(c) 2011-2012 Justin Ouellette, all rights reserved
<title>{Title}{block:PostSummary} - {PostSummary}{/block:PostSummary}</title>
<meta name="tumblr-theme" content="30257" />
ruckus / Gemfile
Last active Dec 22, 2016
Example controller for a SOAP Endpoint for Quickbooks Web Connector (QWC)
View Gemfile
# QBD Integration
gem "wash_out", "0.9.0"
gem 'qbxml', '~> 0.1.5'
ruckus / mailer_recipient_override.rb
Created Sep 9, 2016
Place in `config/initializers/mailer_recipient_override.rb` and be sure to define an environment variable for `EMAIL_RECIPIENT_OVERRIDE`
View mailer_recipient_override.rb
class OverrideMailReciptient
def self.delivering_email(mail)
if Rails.env.development?
mail.subject = "[DEVELOPMENT] #{mail.subject} - Recipient: #{original_to}"
if &&
new_body = "#{mail.body}\n\nRemoved CC: recipients: #{", ")}"
mail.body = new_body = []

Summary: if you're posting a form via Content-Type: application/x-www-form-urlencoded then the data attribute itself must be a valid URL-encoded string - it CANNOT be a hash. Angular $http will not convert it to a URL-encoded format (like jQuery does).

When you run this code your cake log will have a line like:

2013-11-12 20:08:50 Error: POST: Array
    [name] => scott
    [flavor] => vanilla
You can’t perform that action at this time.