Skip to content

Instantly share code, notes, and snippets.

View aaronbbrown's full-sized avatar

Aaron Brown aaronbbrown

View GitHub Profile
@aaronbbrown
aaronbbrown / gist:2245780
Created March 30, 2012 02:06
exclusion query notes (sakila)
SELECT title FROM film f JOIN inventory i USING (film_id) LEFT JOIN rental r USING (inventory_id) WHERE r.inventory_id IS NULL;
mysql> EXPLAIN SELECT title FROM film f JOIN inventory i USING (film_id) LEFT JOIN rental r USING (inventory_id) WHERE r.inventory_id IS NULL\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: f
type: index
possible_keys: PRIMARY
key: idx_title
@aaronbbrown
aaronbbrown / hack.sh
Created March 31, 2012 12:39 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@aaronbbrown
aaronbbrown / gist:2368044
Created April 12, 2012 15:15
How to test an erb
1 [11:13:09] aaron@gaeta-wifi:~$ cat /tmp/foo.erb
my name is <%= name %>
0 [11:13:14] aaron@gaeta-wifi:~$ erb -x -T '-' /tmp/foo.erb > /tmp/foo.rb
0 [11:13:37] aaron@gaeta-wifi:~$ vim !$
#!/usr/bin/env ruby
name = "Aaron" # ADD THIS
_erbout = ''; _erbout.concat "my name is "; _erbout.concat(( name ).to_s); _erbout.concat "\
n"
; _erbout.concat "\n"
@aaronbbrown
aaronbbrown / gist:2428910
Created April 20, 2012 14:01
skypegerian
Hello  Aarron,  
I have been in search of someone with this last name" Aarron,so when I saw your name I was pushed to contact you and see how best we can assist each other. I am Mr Frank Wilus, a Banker here in Ghana. I believe it is the wish of God for me to come across you on skype now. I am having an important business discussion I wish to share with you which I believe will interest you because, it is in connection with your last name and you are going to benefit from it.
One Late Mr Ahmad R. Aarron,a citizen of your country had a fixed deposit with my bank in 2004 for 36 calendar months, valued a US$8,400,000.00 (Eight Million, Four Hundred Thousand US Dollars) the due date for this deposit contract was the 16th of January 2007.Sadly Ahmad  was among the death victims in the May 26 2006 Earthquake disaster in Jawa,Indonesia that killed over 5,000 people. He was in Indonesia on a business trip and that was how he met his end.  My bank management is yet to know about his death, I knew about it because h
@aaronbbrown
aaronbbrown / gist:2966320
Created June 21, 2012 15:12
get ec2 volumes from md device
def get_volumes (mount = nil)
return [] unless @ec2_instance_id
mount ||= @datadir
vols = []
devs = get_devs(mount)
instance = @ec2.instances[@ec2_instance_id]
vols = instance.block_device_mappings.map { |dev,attach| attach.volume.id if devs.include?(dev) }.compact
return vols
end
@aaronbbrown
aaronbbrown / count_queries.rb
Created August 17, 2012 16:58
count queries
#!/usr/bin/env ruby
require 'pp'
h = { :select => 0, :insert => 0, :delete => 0, :update => 0}
ARGF.each do |line|
case line
when /SELECT.*FROM/i then
h[:select] += 1
when /INSERT.*INTO/i then
@aaronbbrown
aaronbbrown / hashsub.rb
Created August 29, 2012 15:58
Subtract Hashes
#!/usr/bin/env ruby
require 'pp'
class Hash
def subtract (h)
result = {}
self.each do |k,v|
result[k] = (self[k] - h[k]) if h[k]
end
result
@aaronbbrown
aaronbbrown / gist:3707263
Created September 12, 2012 15:10
nginx gzip HTTP/1.0 vs HTTP/1.1

HTTP/1.0 request

$ curl  -sv0IH 'Accept-Encoding: gzip' -H 'Host: www.ideeli.com' http://www.ideeli.com/welcome?MuttAndJeff=1
* About to connect() to www.ideeli.com port 80 (#0)
*   Trying 208.39.105.3...
* connected
* Connected to www.ideeli.com (208.39.105.3) port 80 (#0)
> HEAD /welcome?MuttAndJeff=1 HTTP/1.0
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Accept: */*
@aaronbbrown
aaronbbrown / fix_shitty_csv.rb
Created November 19, 2012 21:13
Fixing broken CSV data
#!/usr/bin/env ruby
require 'pp'
require 'csv'
require 'logger'
def join_and_quote ( a )
a.to_csv(:row_sep => "\r\n", :quote_char => '"')
end
@aaronbbrown
aaronbbrown / iam.md
Last active December 11, 2015 11:48
Using IAM

Installation and Setup

Install the AWS IAM tools:

Homebrew:

brew install aws-iam-tools