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 'hpricot' | |
require 'open-uri' | |
dict = `cat /usr/share/dict/words`.split(/\n/) | |
count = dict.size | |
image_count = 0 | |
words = [] | |
500.times 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
sys = require('sys'); // if you remove this semicolon, the script bombs... | |
["foo", "bar"].forEach(function(n) { sys.puts(n) }) |
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
class ExampleWorker | |
extend ResqueHelper | |
@queue = :example | |
def self.perform(user_id) | |
logger.info("Checking to see if there are any other jobs queued for user #{user_id}") | |
return if already_queued? { |args| args.first == user_id } | |
# do something expensive... |
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
module ResqueHelper | |
def already_queued?(queue = @queue, &block) | |
queue_data = Resque.peek(queue, 0, -1) | |
return false unless queue_data | |
case queue_data | |
when Array | |
queue_data.any? do |job| | |
block.call(job["args"]) | |
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
b = Watir::Safari.new | |
def b.js_eval(javascript_code) | |
@scripter.send(:eval_js, javascript_code) | |
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
// This uses Node.js to push audience members into Mad Mimi | |
var sys = require("sys"), | |
http = require("http") | |
var mimi = http.createClient(80, "www.madmimi.com") | |
var request = mimi.request("POST", "/[email protected]&api_key=75aFAKEe48API51ffKEYcbcc300", {"host": "www.madmimi.com"}) | |
request.sendBody("csv_file=email,dog\[email protected],cheddar bob") |
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 'httparty' | |
require 'json' | |
class Campfire | |
include HTTParty | |
base_uri 'https://YOUR_DOMAIN.campfirenow.com' | |
basic_auth 'YOUR_API_KEY', 'X' # yes, that is a literal X string. it's needed to satisfy basic_auth(), but campfire ignores it. | |
headers 'Content-Type' => 'application/json' | |
def self.speak(message) |
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 "hpricot" # need hpricot and open-uri | |
require "open-uri" | |
require "date" | |
current_date = Date.civil(2007, 6, 16) | |
while (current_date != Date.today) | |
puts [current_date, fetch_number_of_assaults(current_date)].join(":") | |
current_date = current_date.next | |
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 "hpricot" # need hpricot and open-uri | |
require "open-uri" | |
require "date" | |
current_date = Date.civil(2007, 6, 16) | |
while (current_date != Date.today) | |
puts "#{ current_date }:#{ fetch_number_of_assaults(current_date) }" | |
current_date = current_date.next | |
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
foo |