This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery("div a").filter('a[href*="twitter"]').parent().find("a").attr("target", "_blank"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include Marshal | |
o = MyObject.new | |
# Print number of bytes | |
puts dump(o).size | |
# vs. | |
puts 1.megabyte |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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}` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
NewerOlder