This file contains 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 | |
print 'Enter file size (MB): ' | |
the_size = gets.chomp | |
unless the_size =~ /^\d+$/ | |
puts "Error: bad file size" | |
exit | |
end |
This file contains 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
desc 'Generate Sitemap' | |
task :sitemap => :environment do | |
require 'big_sitemap' | |
sitemap = BigSitemap.new(:url_options => {:host => 'example.com'}) | |
sitemap.add Ticket | |
sitemap.generate | |
# sitemap.ping_search_engines | |
end |
This file contains 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 'rubygems' | |
require 'twitter' | |
auth = Twitter::HTTPAuth.new('username', 'password') | |
base = Twitter::Base.new(auth) | |
guilty = base.friend_ids - base.follower_ids | |
puts "There are #{guilty.size} People you follow who do not follow you" | |
guilty.each do |user_id| |
This file contains 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 'rubygems' | |
require 'twitter' | |
base = Twitter::Base.new(Twitter::HTTPAuth.new('username', 'password')) | |
my_friends = base.friend_ids | |
candidates = my_friends.inject(Array.new) { |array,id| array += Twitter.friend_ids(id); array } | |
candidates -= my_friends | |
tallied = candidates.inject(Hash.new(0)) { |hash, can| hash[can] += 1; hash } | |
ordered = tallied.sort { |x,y| y[1] <=> x[1] } |
This file contains 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
print 'Enter file size (MB): ' | |
the_size = gets.chomp | |
fail "bad file size" unless the_size =~ /^\d+$/ | |
file_size = 0 | |
string = "abcdefghijklmnopqrstuvwxyz123456" | |
File.open(the_size + 'MB', 'w') do |f| | |
while file_size < the_size.to_i * 1048576 # bytes in 1MB |
This file contains 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
APTGET = "apt-get install -qqy" | |
RUBY19 = "ruby-1.9.1-p129" | |
SRC = "/usr/local/src" | |
WGET = "wget -q" | |
namespace :ruby do | |
desc 'download and compile Ruby 1.9' | |
task :install_19 do | |
deps = %w'zlib1g-dev libopenssl-ruby1.9' |
This file contains 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
=dead-center(!height,!width) | |
:height= !height | |
:margin-top= -(!height / 2) | |
:top 50% | |
:width= !width | |
:margin-left= -(!width / 2) | |
:left 50% | |
:position absolute | |
:text-align center |
This file contains 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
- (void)applicationDidFinishLaunching:(UIApplication *)application { | |
[window addSubview:[navigationController view]]; | |
[window makeKeyAndVisible]; | |
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]; | |
} | |
// Delegation methods | |
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken { | |
Device *device = [[Device alloc] init]; | |
device.token = [devToken description]; |
This file contains 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 'test_helper' | |
class DownloadsTest < ActionController::IntegrationTest | |
context "An existing donor" do | |
setup do | |
@donor = Factory(:donor) | |
end | |
should " be able to download a tax receipt" do |
This file contains 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 'date' | |
class Santo | |
def is_awesome? | |
true | |
end | |
def birthday_today? | |
today = Date.today | |
today.month == bday.month && today.day == bday.day |