Skip to content

Instantly share code, notes, and snippets.

@EricLondon
EricLondon / gist:2148743
Created March 21, 2012 15:45
ruby screen shot
#!/usr/bin/env ruby
require 'selenium-webdriver'
require 'uri'
website_url = ARGV[0]
if website_url.empty?
puts "Website Argument Required.\n"
exit()
end
@EricLondon
EricLondon / gist:2050793
Created March 16, 2012 16:15
Programmatically create paperclip attachment
1.9.2-p290 :002 > u = Upload.new
=> #<Upload id: nil, post_id: nil, created_at: nil, updated_at: nil, upload_file_name: nil, upload_content_type: nil, upload_file_size: nil, upload_updated_at: nil>
1.9.2-p290 :004 > u.upload = File.open('/Users/Eric/Desktop/estimation grid.png')
=> #<File:/Users/Eric/Desktop/estimation grid.png>
1.9.2-p290 :005 > u.save!
(0.1ms) begin transaction
SQL (17.4ms) INSERT INTO "uploads" ("created_at", "post_id", "updated_at", "upload_content_type", "upload_file_name", "upload_file_size", "upload_updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["created_at", Fri, 16 Mar 2012 16:13:46 UTC +00:00], ["post_id", nil], ["updated_at", Fri, 16 Mar 2012 16:13:46 UTC +00:00], ["upload_content_type", "image/png"], ["upload_file_name", "estimation_grid.png"], ["upload_file_size", 53079], ["upload_updated_at", Fri, 16 Mar 2012 16:13:43 UTC +00:00]]
(23.8ms) commit transaction