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
How to get accepted in Fileice (200% Working) 22/2012
Premium Account
FILE HOSTS PREMIUM ACCOUNT
ALL FILE HOST PREMIUM ACCOUNTS
Zynga Slingo Trainer v5.12
iTunes Gift Card Generator V3.1 2012
Diablo 3 GOLD Coins FREE
Working PS3 Jailbreak 3.65 And 3.66
ExtaBit Premium Accounts and Cookies
Steam Wallet Hack - Money Adder & Hack v3
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
Better way to get content via jQuery $.get()
Free Microsoft Points
Simple Days Purger
Sharecash Downloader Bypass Surveys New 05/2012
Pastable version of
ATP Tournament iCalendar
<pre class='prettyprint' language='ruby'>#!/usr/bin/env ruby require 'rubygems' require 'hpricot' require 'icalendar' require 'date' class ATPCalendar def initialize(source) @source = source if @source =~ /^http/ # if source = website @hp = Hpricot(open(@source)) else # if source = file @hp = open(@source) { |f| Hpricot(f) } end prettify_output(parse_resource(@hp)) # some debugging #(1..3).each do |t| # puts @tourneys[t].inspect #end end def parse_resource(doc) @rows = [] # rows array will contain the raw data of evey event (doc/"div.maincolwide//table[4]//tr").each do |row| cells = [] (row/"td").each do |cell| next if cell.inner_text == "" # skip empty cells next if cell.inner_text =~ /\302\240/ raw = cell.inner_text # we just want the text raw.gsub!(/\t/,'') # remove funny formatting #raw.gsub!(/\\/,'') # remove funny formatting raw.strip! cells << raw end @rows << cells unless cells.size == 0 end @rows end def build_ical(filename) cal = Icalendar::Calendar.new @tourneys.each do |t| event = cal.event event.start = t[:date] event.summary = t[:tourney] event.description = "Surface: #{t[:surface]}; Winners: #{t[:winners]}" event.location = t[:location] cal.add_event(event) end cal_file = File.new(File.join(Dir.getwd, filename), "w+") cal_file.puts cal.to_ical end private # create nicely formatted hashes out # of each row of tournament info def prettify_output(rows) @items = rows @tourneys = [] rows.each_with_index do |row, index| loc = rows[index][1].split("\n") # location and tourney tourney = { :date => Date.parse(@items[index][0]), :location => loc[0], :tourney => loc[1].sub(/(\w)ATP/,"\\1\nATP"), :surface => @items[index][2], :price => @items[index][3], :tickets => @items[index][4], :winners => @items[index][5] || "no info available" } @tourneys << tourney end end end calendar = ATPCalendar.new("atp_cal2009.html") calendar.build_ical("atp_tourneys_2009.ics")</pre> <a href="http://www.refactormycode.com/codes/832-atp-tournament-icalendar" 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>