Never been to DZone Snippets 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

About this user

James Robertson http://www.r0bertson.co.uk

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

Searching through your Twitter archive

This Ruby code downloads previous twitter entries as html files to a local file directory.
(1..5).each {|i| `wget --user=jrobertson --password=secret http://twitter.com/account/archive?page=#{i}`}

then using grep -i <keyword> * you can search for anything you've twittered in the past.

Note: Use Wget sparingly.

Wget's switch to preserve the filename

Download a file and preserve the filename. Without the switch -O the next time the file is downloaded the new filename would be projxmlbase.rb.1

wget -O projxmlbase.rb http://xml.mysqueak.info/p/projxmlbase.rb

Ruby equivalent of a simple Wget

Reads the file contents from a URL. I used this code to work around the problem with the Ruby RSS reader which couldn't read the RSS file from digg.com. The reason being that the website would not allow files to be downloaded without supplying the User-Agent string.

require 'open-uri'
puts open('http://digg.com/rss/index.xml',
     'User-Agent' => 'Ruby-Wget').read
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS