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
=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 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
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 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
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 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 '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 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 '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 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
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 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 | |
print 'Enter file size (MB): ' | |
the_size = gets.chomp | |
unless the_size =~ /^\d+$/ | |
puts "Error: bad file size" | |
exit | |
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
class Pickup < ActiveRecord::Base | |
validate_on_create :date_three_days_in_future | |
private | |
def date_three_days_in_future | |
errors.add_to_base "must be at least 3 days from now" unless date >= 3.days.from_now.to_date | |
end | |
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 'ping' | |
unless ARGV.first =~ /\d+\.\d+\.\d+\.\d+/ | |
puts "Bad Network address: #{ARGV.first}" | |
exit 1 | |
end | |
$stdout = File.open(ARGV.last,"w") if ARGV.size == 2 | |
class_c = ARGV.first.gsub(/\d+$/,"") |
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/local/bin/ruby | |
require 'resolv' | |
require 'rubygems' | |
require 'rb-skypemac' | |
include SkypeMac | |
def set_location(loc) | |
Skype.send_ :command => "SET PROFILE MOOD_TEXT #{loc}" | |
end |