Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Working PS3 Jailbreak 3.65 And 3.66
ExtaBit Premium Accounts and Cookies
Steam Wallet Hack - Money Adder & Hack v3
Empires & Allies Hack Cheat Trainer v5.4.1
Eve Onnline 60 Days Time Card Generator v2
Xbox Lve Generator v3
Better way to get content via jQuery $.get()
Free CarTown Blue Points Generator and CarTown Templates
Steam Wallet Hack 2012
Diablo 3 error 37 & error 3006 fix
Popular
XBOX POINTS GENERATOR - MICROSOFT POINTS GENERATOR v1.2012
11 may 2012 premium uploading accounts 100% working
Free Microsoft Points
Free Microsoft Points - Microsoft Points Generator - Xbox Live Codes 2012
Car Town Free Blue Points Hack
Free CarTown Blue Points Generator and CarTown Templates
Free Microsoft Points
Simple Days Purger
Sharecash Downloader Bypass Surveys New 05/2012
PAYPAL REMOVE ACCESS LIMITED ACCOUNT 100% Working
Pastable version of
Help tighten up this code
<pre class='prettyprint' language='ruby'>#!/usr/bin/env ruby require 'rubygems' require 'nokogiri' require 'open-uri' require 'uri' # User configurable user = "yourtwitterusernamehere" # get the XML for the user geturl = "http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=#{user}" doc = Nokogiri::XML(open(geturl)) #doc = Nokogiri::XML(File.new('twitter.xml')) # TODO - error checking # grabbed from http://stackoverflow.com/questions/2034580/i-am-creating-a-twitter-clone-in-ruby-on-rails-how-do-i-code-it-so-that-the def linkup_mentions_and_hashtags(text) text.gsub!(/@([\w]+)(\W)?/, '<a href="http://twitter.com/\1">@\1</a>\2') text.gsub!(/#([\w]+)(\W)?/, '<a href="http://twitter.com/search?q=%23\1">#\1</a>\2') text end # deal with various tweet parsing code to link usernames, links, etc def parsetweet(t) urls = URI.extract(t,%w[ http https ftp ]) urls.each { |url| t.gsub!(url,"<a href=\"#{url}\">#{url}</a>") } # auto-link @usernames t = linkup_mentions_and_hashtags(t) t end doc.xpath('//status').each do |status| tweetid = status.xpath('.//id').first.content datetext = status.xpath('.//created_at').first.content tweet = status.xpath('.//text').first.content url = "http://twitter.com/thinkinginrails/statuses/#{tweetid}" date = Date.parse(datetext) #datepretty = "#{date.year}/#{date.month}/#{date.day}" tweettext = parsetweet(tweet) puts "<li>#{tweettext} <em><a href=\"#{url}\">#</a></em></li>\n" end</pre> <a href="http://www.refactormycode.com/codes/1275-help-tighten-up-this-code" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>