Skip to content

Instantly share code, notes, and snippets.

View graysky's full-sized avatar

Mike Champion graysky

View GitHub Profile
### Keybase proof
I hereby claim:
* I am graysky on github.
* I am graysky (https://keybase.io/graysky) on keybase.
* I have a public key whose fingerprint is 79CC D292 20EB D561 69BA 98F4 AA26 21B4 180F 32BF
To claim this, I am signing this object:
@graysky
graysky / sociallinks.html
Created November 15, 2012 03:30
Make Hubspot social links open in new window
@graysky
graysky / fm_open.js
Created November 15, 2012 01:28
Javascript to open Follow Me links in new window
jQuery("div a").filter('a[href*="twitter"]').parent().find("a").attr("target", "_blank");
@graysky
graysky / kabir.txt
Created January 15, 2011 18:54
For Kabir's tumblr
Kabir asks: "Wish there were a way to grab all my tweets minus @ replies, and post them as a roundup on tumblr."
https://twitter.com/#!/KabirH/status/26329299560701952
Here's how I would do it:
1) Create a public Twitter list with just you to filter out your @replies. I created one to use on my own blog:
http://twitter.com/#!/graysky/my-public-tweets
include Marshal
o = MyObject.new
# Print number of bytes
puts dump(o).size
# vs.
puts 1.megabyte
# Probably a better way, but couldn't find one to make a mysql database dump
# that includes the schema of all tables, but excludes the contents of certain tables (like sessions, delayed_jobs)
# that just bloat the size of the backup.
#
def mysql_db_backup
raw_dump = Tempfile.new("raw_db_dump")
dump_file = Tempfile.new("dump")
# First dump just the full schema
cmd = "mysqldump --quick --single-transaction --no-data --create-options #{mysql_options} > #{raw_dump.path}"
10.251.214.84 - - [21/Feb/2010:18:35:52 -0800] "GET / HTTP/1.1" 200 6338 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; Data Center; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)" "75.101.179.129"
10.251.214.84 - - [21/Feb/2010:18:35:52 -0800] "GET /stylesheets/ie.css?1266704708 HTTP/1.1" 200 659 "http://oneforty.com/" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; Data Center; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)" "75.101.179.129"
10.251.214.84 - - [21/Feb/2010:18:35:53 -0800] "GET /images/icons/sign-in-with-twitter.png?1266704708 HTTP/1.1" 200 2490 "http://oneforty.com/" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; Data Center; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)" "75.101.179.129"
10.251.214
# Put in environment.rb to force Vanity to make a new connection to Redis
# to play nice with Passenger's smart forking.
# monkey patch vanity to force new redis connection when Passenger forks
if defined?(PhusionPassenger)
class Vanity::Playground
def reconnect_redis
@redis = nil
# Need to remove method or unable to force a reconnect because it
# Open an email in Mail.app to preview an HTML email.
#
# Usage: preview_email( MyMailer.create_welcome_msg )
#
def preview_email(tmail)
f = File.open("#{Dir::tmpdir}/email_preview_#{rand(10000)}.eml", 'w')
f.write(tmail.to_s)
f.flush
f.close
`open #{f.path}`
@graysky
graysky / stats.rb
Created September 15, 2009 20:24 — forked from mojombo/stats.rb
# Run the given block +num+ times and then print out the mean, median, min,
# max, and stddev of the run. For example:
#
# irb> stats(10) { sleep(rand / 100) }
# mean: 5.99ms
# median: 6.76ms
# min: 1.49ms
# max: 9.28ms
# stddev: 2.54ms
def stats(num)