Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Infrant Widget Patch to add support for BitTorrent Add-on

// This requires the BitTorrent add-on from RAIDiator 4.00c1-p2.
// This adds the following functionality to the widget:
// Adds a button on the back of widget to connect to bittorrent admin interface on port 8080.
// Adds drag-and-drop support to allow multiple torrents to be added from local filesystem.

curl http://www.infrant.com/beta/raidar/RAIDar.wdgt -o RAIDar.wdgt.zip
curl -O http://speedbinge.com/code/RAIDar_bt.patch
unzip RAIDar.wdgt.zip
patch -p0 < RAIDar_bt.patch
open RAIDar.wdgt

Scrape torrents on btjunkie

// download all .torrent links on the btjunkie frontpage
//
// more fun with mechanize @
// http://tramchase.com/scrape-myspace-youtube-torrents-for-fun-and-profit

agent = WWW::Mechanize.new
agent.get("http://btjunkie.org/")
links = agent.page.search('.tor_details tr a')
hrefs = links.map { |m| m['href'] }.select { |u| u =~ /\.torrent$/ } # just links ending in .torrent
FileUtils.mkdir_p('btjunkie-torrents') # keep it neat
hrefs.each { |torrent|
  filename = "btjunkie-torrents/#{torrent[0].split('/')[-2]}"
  puts "Saving #{torrent} as #{filename}"
  agent.get(torrent).save_as(filename)
}