Skip to content

Instantly share code, notes, and snippets.

View seanmarcia's full-sized avatar
🐼
Happily living the dream.

Sean Marcia seanmarcia

🐼
Happily living the dream.
View GitHub Profile
@seanmarcia
seanmarcia / migrate_s3.rake
Created August 17, 2012 19:23
rake task to migrate paperclip attachments to Amazon S3
namespace :attachments do
task :migrate_to_s3 => :environment do
require 'aws/s3'
# Load credentials
s3_options = YAML.load_file(File.join(Rails.root, 'config/s3.yml')).symbolize_keys
bucket = s3_options[:bucket_name]
# Establish S3 connection
@seanmarcia
seanmarcia / sgu.rb
Created August 29, 2011 10:27
Skeptics Guide to the Universe downloader
require 'nokogiri'
require 'open-uri'
url = 'http://www.theskepticsguide.org/archive/podcast.aspx?mid=1'
doc = Nokogiri::HTML(open(url))
sgu_mp3s = doc.xpath("//a").select {|link| link['href'] =~ /\.mp3$/ }
sgu_mp3s.each do |link|
xpathhref = link['href']