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
# could we track github forks as "sources"? | |
$ brew track [github user] | |
$ brew track lukeredpath | |
# refresh sources if we're caching? | |
$ brew refresh [github user] (default: --all) | |
# listing formulae |
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
def file_upload_from_string(string, content_type = 'text/plain') | |
test_upload_file = nil | |
Tempfile.open('file_upload_from_string') do |tempfile| | |
tempfile.write(string) | |
tempfile.rewind | |
test_upload_file = ActionController::TestUploadedFile.new(tempfile.path, content_type) | |
end | |
return test_upload_file | |
end |
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
#define kApproxRadiusOfEarthInMiles 3963.1676 | |
#define kApproxSizeOfOneDegreeLatitudeInMiles 68.71 | |
#define kApproxSizeOfOneDegreeLongitudeAtLatitude(lat) ((M_PI/180.0)* kApproxRadiusOfEarthInMiles *cos(lat)) | |
static function MKCoordinateSpan MKCoordinateSpanMakeWithDistanceInMiles(float miles, CLLocationDegrees latitude) { | |
MKCoordinateSpan viewSpan; | |
viewSpan.latitudeDelta = miles / kApproxSizeOfOneDegreeLatitudeInMiles; | |
viewSpan.longitudeDelta = miles / kApproxSizeOfOneDegreeLongitudeAtLatitude(latitude); | |
return viewSpan; | |
} |
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
## remove unnecessary files and folders | |
%w{README doc public/favicon.ico}.each { |file| run("rm -rf #{file}") } | |
## configure git repository | |
git :init | |
file ".gitignore", %Q{ | |
log/* |
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
# prints to STDOUT by default, optional -o switch to specify output file | |
$ ruby tweetstream.rb -t 'myhashtag' -f 'lukeredpath' -e 'path/to/template.erb' | |
Options: | |
--tag, -t <s>: Hashtag to use as a filter | |
--from, -f <s>: Restrict to tweets from a specific user | |
--template, -e <s>: ERB template used to render the stream | |
--output, -o <s>: Output to this file | |
--help, -h: Show this message |
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
#import "EGOCache.h" | |
@interface EGOCache (Plist) | |
- (NSData*)plistForKey:(NSString*)key; | |
- (void)setPlist:(id)plistObject forKey:(NSString*)key; | |
- (void)setPlist:(id)plistObject forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval; | |
@end |
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
require 'money' | |
require 'xe_exchange' | |
Money.default_bank = XE::Exchange.instance | |
ten_dollars = Money.new(1000, 'USD') | |
ten_dollars_in_pounds = ten_dollars.exchange_to('GBP') |
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
# this goes in ~/.freeagent | |
ENV['FA_COMPANY'] = 'mycompany' | |
ENV['FA_USERNAME'] = 'myloginemail' | |
ENV['FA_PASSWORD'] = 'mypassword' |
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
#!/usr/bin/env ruby | |
# if you have lib/scripts/do_something.rb | |
# you might run: | |
# script/runner lib/scripts/do_something.rb | |
# but now you can do: | |
# script/daemon lib/scripts/do_something.rb (run|start|stop|restart) | |
require File.join(File.dirname(__FILE__), *%w[.. config environment]) | |
require 'daemons' |
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
require 'active_support' | |
require 'curb' | |
require 'yajl' | |
class TweetStreamer | |
def initialize(username, password, host = 'stream.twitter.com') | |
@username, @password = username, password | |
@host = host | |
@api_version = 1 | |
end |