<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>soledad penadés &#187; ruby</title>
	<atom:link href="http://soledadpenades.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://soledadpenades.com</link>
	<description>repeat 4[fd 100 rt 90]</description>
	<lastBuildDate>Wed, 25 Apr 2012 21:10:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>A first impression on Ruby&#8217;s Mechanize</title>
		<link>http://soledadpenades.com/2012/03/17/a-first-impression-on-rubys-mechanize/</link>
		<comments>http://soledadpenades.com/2012/03/17/a-first-impression-on-rubys-mechanize/#comments</comments>
		<pubDate>Sat, 17 Mar 2012 11:47:29 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[hpricot]]></category>
		<category><![CDATA[irb]]></category>
		<category><![CDATA[mechanize]]></category>
		<category><![CDATA[nokogiri]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[screen scrapping]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=3927</guid>
		<description><![CDATA[TL;DR: If you need to do screen scrapping, use ruby's Mechanize.]]></description>
			<content:encoded><![CDATA[<p>I had to do some screen scrapping yesterday and, while I previously have used <a href="https://github.com/hpricot/hpricot">hpricot</a> for these kinds of things (or maybe even just plain <a href="http://curl.haxx.se/">cURL</a> or similar), this time the page required me to be logged in, and not using any HTTP &#8220;standard&#8221; way of Auth that cURL could deal with, but a custom CMS html-based login form. So I understood that I needed something more powerful; something that could pass as a &#8220;proper&#8221; browser and not just a simple crawler.</p>
<p>I had heard quite nice successful experiences with Mechanize before, so I decided I would give it a try, and it turned out to vastly exceed what I expected from it! :-)</p>
<p><a href="http://mechanize.rubyforge.org/">Mechanize</a> is a port of the original <a href="http://search.cpan.org/dist/WWW-Mechanize/">Perl  Mechanize</a> library; there is a <a href="http://wwwsearch.sourceforge.net/mechanize/">Python port</a> too, and there might be ports for other languages too but I wasn&#8217;t interested in that.</p>
<p>For some reason my mind was in the ruby-mood yesterday, so I decided to go for the ruby port. Everything was flowing nicely between ruby and me. I even dared prototyping what I wanted to do in a terminal, using <a href="http://en.wikipedia.org/wiki/Interactive_Ruby_Shell">irb</a>, before writing the final script I needed to write. My ruby muscle was getting toned again, so to speak.</p>
<p>I got some false starts, though. I first invoked just &#8216;ruby&#8217; in the terminal, only to be greeted with a waiting pipe, i.e. nothing happened as &#8211;I guess&#8211; ruby was expecting me to provide him with something to run. I remembered that the interactive ruby executable was called irb. A Control+C and four other keystrokes later, I was in immediate-mode ruby.</p>
<p>Another gotcha: not having to
<div class="syhi_block"><code><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span></code></div>
<p> when running in irb, but having to when writing a script. Thankfully that I remembered and was able to fix quickly.</p>
<p>But I&#8217;m digressing. Back to Mechanize: it simulates a real browser interacting with a website. You can even fake the user agent. But unlike the most basic screen-scrappers, which simply download a page and then do something with it and then download another one and do something else, without keeping any sort of continuity between downloads and connections, Mechanize is stateful. Which means that it keeps the state between &#8216;visited&#8217; pages. To all effects, and for the visited websites, there&#8217;s a normal browser at the other end of the line. Unless you go crazy and begin hammering a server with tons of requests, crawling websites this way might be almost invisible to servers.</p>
<p>Which is exactly what I wanted!</p>
<p>The syntax is quite nice and intuitive. Borrowing shamelessly from the manual:</p>
<div class="syhi_block"><code><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'mechanize'</span><br />
<br />
agent = Mechanize.<span style="color:#9900CC;">new</span><br />
page = agent.<span style="color:#9900CC;">get</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'http://google.com/'</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
<span style="color:#008000; font-style:italic;"># List links on the page</span><br />
page.<span style="color:#9900CC;">links</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>link<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> link.<span style="color:#9900CC;">text</span>, link.<span style="color:#9900CC;">href</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Click on the first link with text 'News'</span><br />
page = agent.<span style="color:#9900CC;">page</span>.<span style="color:#9900CC;">link_with</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:text</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'News'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">click</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Do a Google search, using the search form</span><br />
google_form = page.<span style="color:#9900CC;">form</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'f'</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
google_form.<span style="color:#9900CC;">q</span> = <span style="color:#996600;">'ruby mechanize'</span><br />
page = agent.<span style="color:#9900CC;">submit</span><span style="color:#006600; font-weight:bold;">&#40;</span>google_form, google_form.<span style="color:#9900CC;">buttons</span>.<span style="color:#9900CC;">first</span><span style="color:#006600; font-weight:bold;">&#41;</span></code></div>
<p>Something that made me even more happier is that Mechanize also uses <a href="http://nokogiri.org/">Nokogiri</a> internally for parsing HTML&#8211;which means we can do the same style of nice DOM tree traversing that I used to do with Hpricot, only even better! (Nokogiri is the successor to Hpricot).</p>
<p>I didn&#8217;t need that last feature for this particular case, but it left me wondering what I could use Mechanize for&#8211;in order to use this! I will have a look at my TODO list and see where can I use my newly acquired Mechanize skills!</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=3927&amp;md5=052672dc02fda8f87b6b023a6e61ab68" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2012/03/17/a-first-impression-on-rubys-mechanize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=8399&amp;amp;url=http%3A%2F%2Fsoledadpenades.com%2F2012%2F03%2F17%2Fa-first-impression-on-rubys-mechanize%2F&amp;amp;language=en_GB&amp;amp;category=text&amp;amp;title=A+first+impression+on+Ruby%26%238217%3Bs+Mechanize&amp;amp;description=I+had+to+do+some+screen+scrapping+yesterday+and%2C+while+I+previously+have+used+hpricot+for+these+kinds+of+things+%28or+maybe+even+just+plain+cURL+or+similar%29%2C+this+time+the+page+required+me+to+be+logged+in%2C+and+not+using+any+HTTP+%22standard%22+way+of+Auth+that+cURL+could+deal+with%2C+but+a+custom+CMS+html-based+login+form.+So+I+understood+that+I+needed+something+more+powerful%3B+something+that+could+pass+as+a+%22proper%22+browser+and+not+just+a+simple+crawler.%0D%0A%0D%0AI+had+heard+quite+nice+successful+experiences+with+Mechanize+before%2C+so+I+decided+I+would+give+it+a+try%2C+and+it+turned+out+to+vastly+exceed+what+I+expected+from+it%21+%3A-%29%0D%0A%0D%0AMechanize+is+a+port+of+the+original+Perl++Mechanize+library%3B+there+is+a+Python+port+too%2C+and+there+might+be+ports+for+other+languages+too+but+I+wasn%27t+interested+in+that.%0D%0A%0D%0AFor+some+reason+my+mind+was+in+the+ruby-mood+yesterday%2C+so+I+decided+to+go+for+the+ruby+port.+Everything+was+flowing+nicely+between+ruby+and+me.+I+even+dared+prototyping+what+I+wanted+to+do+in+a+terminal%2C+using+irb%2C+before+writing+the+final+script+I+needed+to+write.+My+ruby+muscle+was+getting+toned+again%2C+so+to+speak.%0D%0A%0D%0AI+got+some+false+starts%2C+though.+I+first+invoked+just+%27ruby%27+in+the+terminal%2C+only+to+be+greeted+with+a+waiting+pipe%2C+i.e.+nothing+happened+as+--I+guess--+ruby+was+expecting+me+to+provide+him+with+something+to+run.+I+remembered+that+the+interactive+ruby+executable+was+called+irb.+A+Control%2BC+and+four+other+keystrokes+later%2C+I+was+in+immediate-mode+ruby.%0D%0A%0D%0AAnother+gotcha%3A+not+having+to+require+%27rubygems%27+when+running+in+irb%2C+but+having+to+when+writing+a+script.+Thankfully+that+I+remembered+and+was+able+to+fix+quickly.%0D%0A%0D%0ABut+I%27m+digressing.+Back+to+Mechanize%3A+it+simulates+a+real+browser+interacting+with+a+website.+You+can+even+fake+the+user+agent.+But+unlike+the+most+basic+screen-scrappers%2C+which+simply+download+a+page+and+then+do+something+with+it+and+then+download+another+one+and+do+something+else%2C+without+keeping+any+sort+of+continuity+between+downloads+and+connections%2C+Mechanize+is+stateful.+Which+means+that+it+keeps+the+state+between+%27visited%27+pages.+To+all+effects%2C+and+for+the+visited+websites%2C+there%27s+a+normal+browser+at+the+other+end+of+the+line.+Unless+you+go+crazy+and+begin+hammering+a+server+with+tons+of+requests%2C+crawling+websites+this+way+might+be+almost+invisible+to+servers.%0D%0A%0D%0AWhich+is+exactly+what+I+wanted%21%0D%0A%0D%0AThe+syntax+is+quite+nice+and+intuitive.+Borrowing+shamelessly+from+the+manual%3A%0D%0A%0D%0A%0D%0Arequire+%27rubygems%27%0D%0Arequire+%27mechanize%27%0D%0A%0D%0Aagent+%3D+Mechanize.new%0D%0Apage+%3D+agent.get%28%27http%3A%2F%2Fgoogle.com%2F%27%29%0D%0A%0D%0A%23+List+links+on+the+page%0D%0Apage.links.each+do+%7Clink%7C%0D%0A++puts+link.text%2C+link.href%0D%0Aend%0D%0A%0D%0A%23+Click+on+the+first+link+with+text+%27News%27%0D%0Apage+%3D+agent.page.link_with%28%3Atext+%3D%3E+%27News%27%29.click%0D%0A%0D%0A%23%C2%A0Do+a+Google+search%2C+using+the+search+form%0D%0Agoogle_form+%3D+page.form%28%27f%27%29%0D%0Agoogle_form.q+%3D+%27ruby+mechanize%27%0D%0Apage+%3D+agent.submit%28google_form%2C+google_form.buttons.first%29%0D%0A%0D%0A%0D%0ASomething+that+made+me+even+more+happier+is+that+Mechanize+also+uses+Nokogiri+internally+for+parsing+HTML--which+means+we+can+do+the+same+style+of+nice+DOM+tree+traversing+that+I+used+to+do+with+Hpricot%2C+only+even+better%21+%28Nokogiri+is+the+successor+to+Hpricot%29.%0D%0A%0D%0AI+didn%27t+need+that+last+feature+for+this+particular+case%2C+but+it+left+me+wondering+what+I+could+use+Mechanize+for--in+order+to+use+this%21+I+will+have+a+look+at+my+TODO+list+and+see+where+can+I+use+my+newly+acquired+Mechanize+skills%21&amp;amp;tags=hpricot%2Cirb%2Cmechanize%2Cnokogiri%2Cruby%2Cscreen+scrapping%2Cblog" type="text/html" />
	</item>
		<item>
		<title>My favourite GIMP plug-ins</title>
		<link>http://soledadpenades.com/2012/02/12/my-favourite-gimp-plug-ins/</link>
		<comments>http://soledadpenades.com/2012/02/12/my-favourite-gimp-plug-ins/#comments</comments>
		<pubDate>Sun, 12 Feb 2012 22:11:04 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[gimp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=3896</guid>
		<description><![CDATA[When I used Ubuntu I normally installed a fancy package called gimp-plugin-registry that came with most of the plug-ins I liked, and then some more stuff that I never used. I had learnt to ignore that, but there was still the pain of not knowing where things were. Some filters went to &#8220;Colors&#8221;, others to [...]]]></description>
			<content:encoded><![CDATA[<p>When I used Ubuntu I normally installed a fancy package called gimp-plugin-registry that came with most of the plug-ins I liked, and then some more stuff that I never used. I had learnt to ignore that, but there was still the pain of not knowing where things were. Some filters went to &#8220;Colors&#8221;, others to &#8220;Light and shadow&#8221;, etc. It was extremely hard to remember where each filter was meant to be.</p>
<p>Now that I&#8217;m using Arch I couldn&#8217;t find any equivalent package but I thought that it was OK&#8211;that way I would only install what I really needed to install. In the process I&#8217;ve found a couple more plug-ins that I didn&#8217;t know about, so it&#8217;s been quite productive.</p>
<p>What I&#8217;ve done is I&#8217;ve written a script that takes care of downloading the scripts from the specified URLs, placing them in the appropriate gimp folder (~/.gimp2-6/scripts in my case), and the best of all is that it also patches them so that all are under the <em>Filters/Photo</em> menu entry. Yay! No more wandering around menus and submenus! My brain is now happy, I can just focus on playing with the pictures!</p>
<p>If you want to use this script just <a href="https://raw.github.com/sole/snippets/master/gimp/favourite_plugins/install.rb">download it</a> (it&#8217;s on my <a href="https://github.com/sole/snippets/blob/master/gimp/favourite_plugins/install.rb">snippets</a> repository). You might want to modify it as you wish. There are a couple of TO DO&#8217;s but the file is fully functional (as long as you&#8217;ve got Ruby installed).</p>
<p>Oh, and pardon my rudimentary Ruby. It&#8217;s been ages since I last wrote anything with Ruby. I still don&#8217;t know what I want to use. Ideally I&#8217;d like something as easy as php but with a syntax that is a mix of Python and Ruby, and lots of easy functional and metaprogramming.</p>
<p>I guess my problem is that I know too much, but still so little, not enough. Maybe if I just knew one language, I would be happy with that one. In any case, I&#8217;ll keep on experimenting and try to decide what I like best. Maybe my Japanese side will win over the European one? Who knows!</p>
<p>Meanwhile, be sure to enjoy the filters! Wooo!</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=3896&amp;md5=93933ba93dad096b62848ff634652238" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2012/02/12/my-favourite-gimp-plug-ins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=8399&amp;amp;url=http%3A%2F%2Fsoledadpenades.com%2F2012%2F02%2F12%2Fmy-favourite-gimp-plug-ins%2F&amp;amp;language=en_GB&amp;amp;category=text&amp;amp;title=My+favourite+GIMP+plug-ins&amp;amp;description=When+I+used+Ubuntu+I+normally+installed+a+fancy+package+called+gimp-plugin-registry+that+came+with+most+of+the+plug-ins+I+liked%2C+and+then+some+more+stuff+that+I+never+used.+I+had+learnt+to+ignore+that%2C+but+there+was+still+the+pain+of+not+knowing+where+things+were.+Some+filters+went+to+%22Colors%22%2C+others+to+%22Light+and+shadow%22%2C+etc.+It+was+extremely+hard+to+remember+where+each+filter+was+meant+to+be.%0D%0A%0D%0ANow+that+I%27m+using+Arch+I+couldn%27t+find+any+equivalent+package+but+I+thought+that+it+was+OK--that+way+I+would+only+install+what+I+really+needed+to+install.+In+the+process+I%27ve+found+a+couple+more+plug-ins+that+I+didn%27t+know+about%2C+so+it%27s+been+quite+productive.%0D%0A%0D%0AWhat+I%27ve+done+is+I%27ve+written+a+script+that+takes+care+of+downloading+the+scripts+from+the+specified+URLs%2C+placing+them+in+the+appropriate+gimp+folder+%28%7E%2F.gimp2-6%2Fscripts+in+my+case%29%2C+and+the+best+of+all+is+that+it+also+patches+them+so+that+all+are+under+the+Filters%2FPhoto+menu+entry.+Yay%21+No+more+wandering+around+menus+and+submenus%21+My+brain+is+now+happy%2C+I+can+just+focus+on+playing+with+the+pictures%21%0D%0A%0D%0AIf+you+want+to+use+this+script+just+download+it+%28it%27s+on+my+snippets+repository%29.+You+might+want+to+modify+it+as+you+wish.+There+are+a+couple+of+TO+DO%27s+but+the+file+is+fully+functional+%28as+long+as+you%27ve+got+Ruby+installed%29.%0D%0A%0D%0AOh%2C+and+pardon+my+rudimentary+Ruby.+It%27s+been+ages+since+I+last+wrote+anything+with+Ruby.+I+still+don%27t+know+what+I+want+to+use.+Ideally+I%27d+like+something+as+easy+as+php+but+with+a+syntax+that+is+a+mix+of+Python+and+Ruby%2C+and+lots+of+easy+functional+and+metaprogramming.%0D%0A%0D%0AI+guess+my+problem+is+that+I+know+too+much%2C+but+still+so+little%2C+not+enough.+Maybe+if+I+just+knew+one+language%2C+I+would+be+happy+with+that+one.+In+any+case%2C+I%27ll+keep+on+experimenting+and+try+to+decide+what+I+like+best.+Maybe+my+Japanese+side+will+win+over+the+European+one%3F+Who+knows%21%0D%0A%0D%0AMeanwhile%2C+be+sure+to+enjoy+the+filters%21+Wooo%21&amp;amp;tags=gimp%2Cphp%2Cplugins%2Cpython%2Cruby%2Cblog" type="text/html" />
	</item>
		<item>
		<title>ruby in the pub #4 :after</title>
		<link>http://soledadpenades.com/2010/06/23/ruby-in-the-pub-4-after/</link>
		<comments>http://soledadpenades.com/2010/06/23/ruby-in-the-pub-4-after/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 08:36:22 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[london]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby in the pub]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=2689</guid>
		<description><![CDATA[Julian Burgess (who I had virtually met via Twitter) suggested me I should attend the next ruby in the pub. It sounded decidedly odd: mixing journalists with an interest for code with ruby developers; even more strange considering I&#8217;m not a ruby expert as much as I try, so I thought it could be interesting [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twitter.com/aubergene">Julian Burgess</a> (who I had virtually met via Twitter) suggested me I should attend the next ruby in the pub. It sounded decidedly odd: mixing journalists with an interest for code with ruby developers; even more strange considering I&#8217;m not a ruby expert as much as I try, so I thought it could be interesting to go and see what an event like that could turn out to be.</p>
<p>So there I went after mentally memorising the map from Liverpool Street Station to <a href="http://www.lbi.co.uk/">LBi</a>&#8216;s offices in Brick Lane. Funny because I have done the Brick Lane-Liverpool St. route several times already, but since it was dark and I got an <a href="http://mrdoob.com">excellent guide</a>, I never paid much attention. Anyway, I arrived, gave my name to the security guy which was kind of confused with my Spanish name and then went downstairs where the people with laptops on the couches were.</p>
<p>I took a look and didn&#8217;t know anyone &#8212; so I decided the direct approach would be better: waved and said &#8220;hi&#8221; to whoever was looking at me at that point, and got a friendly response. Yay!</p>
<p>In a minute I was happily talking with <a href="http://twitter.com/just_francesca">Francesca</a>, a nice front end web developer, then with someone else whose name I didn&#8217;t find out, then I got to associate Julian&#8217;s name with his face. A little while after, <a href="http://www.paulcarvill.com/">Paul Carvill</a> came downstairs with lots of pizza boxes &#8211;all vegetarian, and yummy!&#8211; and as we were discussing about Rails 3.0, <a href="http://joannageary.com">Joanna Geary</a> made a little speech, more or less on the lines of this:</p>
<blockquote><p>&#8216;Journalists, raise your hands!&#8217;</p>
<p>They do.</p>
<p>&#8216;Journalists, find a developer and explain them what do you have in mind that could be done with code, and let&#8217;s see if it&#8217;s doable or not!&#8217;</p></blockquote>
<p>And then a girl approached Francesca and me. She looked strangely familiar but I couldn&#8217;t really tell why. We sat in a table, took the laptops out of their sleeves and set out to try and find if the data we needed was available. But the wireless didn&#8217;t quite work. So we chatted about something fascinating and kind of related to the topic: Volcanoes! It really helped that she had a degree in Geology so she could really offer interesting insight about how volcanoes work. Also, amazing as it sounds, she could pronounce Eyjafjallajökull in one go without hesitation!</p>
<p>We ate some more pizza, and then the wireless started working. So we checked and saw that the data wasn&#8217;t available &#8212; but we agreed she would contact the organisation and ask them for it. Maybe they already have it but it&#8217;s not publicly advertised.</p>
<p>Then it&#8217;s when the real coding part began; she said she would love to learn programming, but didn&#8217;t know where to start, or the guides she had tried were boring. I immediately proposed Processing; I know there&#8217;s <a href="http://hacketyhack.heroku.com">Hackety Hack</a> by _why, which is ruby based, but I don&#8217;t have any experience with it, so I went for the safer option. </p>
<p>I actually hadn&#8217;t done much Processing recently and as such I always forget the names of the basic functions (was it <em>setup</em>, or was it <em>load</em>? was it <em>loop</em> or was it <em>play</em>?) but it was even better, so that way they could follow along. She downloaded Processing and was typing in stuff in the sketchbook immediately&#8230; which was amazing! No setup, no preparation, no rebooting the computer after the installation; just download and experiment!</p>
<p>We&#8217;ve done just extremely simple things such as opening a window, setting its background colour, changing its size and&#8230; drawing a line! Still, I find it really enlightening to observe how &#8216;normal people&#8217; (i.e. not <em>hardcore</em> developers) react to all these concepts when exposed to them.</p>
<p>Interesting things I&#8217;ve noticed (teachers, take note!):</p>
<ul>
<li>people love to see results immediately &#8211; no theory to start with!</li>
<li>people love to have some starting snippets, which they can modify and experiment with, learning how they work meanwhile</li>
</ul>
<p>So that makes Processing an excellent programming environment for beginners, because it&#8217;s got that beatiful <a href="http://processing.org/reference/">reference</a> written in pretty much plain language and with example snippets that can be copied and pasted for each function/class.</p>
<p>In a few minutes the word had spread: there were people doing stuff with Processing in the room! And so a little audience gathered, another guy (a journalist) came with his laptop, downloaded Processing and was doing little simple things as the aforementioned ones, copying code from her wife&#8217;s screen &#8211;isn&#8217;t it sweet?</p>
<p>On the other side of the table I was showing Paul and Francesca my word processing and statistical experiments with <a href="http://5013.es/p/1">Tolkien</a> works and we also spoke about Processing versus other environments such as Javascript or Flash.</p>
<p>In between, the girl had told us her name, and if the face looked familiar, the name was insanely familiar! She humbly told me she was in lots of events and etc, but didn&#8217;t make a big thing of it. I asked her about events I had been in (that I could recall at that point) to no avail &#8211;we didn&#8217;t seem to have been in the same events. But then I came home and looked for &#8220;<a href="http://suw.charman-anderson.com/">Suw Charman</a>&#8221; and found that not only had I seen her speak at resfest&#8217;05 but she had also posted a few messages to a mailing list I follow. I think that&#8217;s why the name sounded sooo familiar!</p>
<p>Of course, there couldn&#8217;t be a nice event without Rob McKinnon in it! I just love how I always find him everywhere I go, whether it&#8217;s a full fledged event or just a coffee shop anywhere in London, it&#8217;s just so funny. Couldn&#8217;t exchange more than a few &#8220;hey hey hi!&#8221; waves because we both were busy with our new friends, so I don&#8217;t know which sorts of interesting stuff did he show this time (the last time <a href="http://soledadpenades.com/2007/03/13/london-ruby-users-group-brings-you-back-to-uni/">he spoke about Hpricot</a>).</p>
<p>The event ended at around 22h, but mainly because people had to leave and take trains and all those things, but I&#8217;m pretty sure otherwise we could have stayed and playing with Processing for a long while :-)</p>
<p>And that&#8217;s how <em>ruby in the pub</em>, &#8220;with hardly any ruby and certainly no pub&#8221;, was. See you in the next one?</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=2689&amp;md5=3c650f8fa0662dd57054c1ccc6fb9b43" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2010/06/23/ruby-in-the-pub-4-after/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=8399&amp;amp;url=http%3A%2F%2Fsoledadpenades.com%2F2010%2F06%2F23%2Fruby-in-the-pub-4-after%2F&amp;amp;language=en_GB&amp;amp;category=text&amp;amp;title=ruby+in+the+pub+%234+%3Aafter&amp;amp;description=Julian+Burgess+%28who+I+had+virtually+met+via+Twitter%29+suggested+me+I+should+attend+the+next+ruby+in+the+pub.+It+sounded+decidedly+odd%3A+mixing+journalists+with+an+interest+for+code+with+ruby+developers%3B+even+more+strange+considering+I%27m+not+a+ruby+expert+as+much+as+I+try%2C+so+I+thought+it+could+be+interesting+to+go+and+see+what+an+event+like+that+could+turn+out+to+be.%0D%0A%0D%0ASo+there+I+went+after+mentally+memorising+the+map+from+Liverpool+Street+Station+to+LBi%27s+offices+in+Brick+Lane.+Funny+because+I+have+done+the+Brick+Lane-Liverpool+St.+route+several+times+already%2C+but+since+it+was+dark+and+I+got+an+excellent+guide%2C+I+never+paid+much+attention.+Anyway%2C+I+arrived%2C+gave+my+name+to+the+security+guy+which+was+kind+of+confused+with+my+Spanish+name+and+then+went+downstairs+where+the+people+with+laptops+on+the+couches+were.%0D%0A%0D%0AI+took+a+look+and+didn%27t+know+anyone+--+so+I+decided+the+direct+approach+would+be+better%3A+waved+and+said+%22hi%22+to+whoever+was+looking+at+me+at+that+point%2C+and+got+a+friendly+response.+Yay%21%0D%0A%0D%0AIn+a+minute+I+was+happily+talking+with+Francesca%2C+a+nice+front+end+web+developer%2C+then+with+someone+else+whose+name+I+didn%27t+find+out%2C+then+I+got+to+associate+Julian%27s+name+with+his+face.+A+little+while+after%2C+Paul+Carvill+came+downstairs+with+lots+of+pizza+boxes+--all+vegetarian%2C+and+yummy%21--+and+as+we+were+discussing+about+Rails+3.0%2C+Joanna+Geary+made+a+little+speech%2C+more+or+less+on+the+lines+of+this%3A%0D%0A%0D%0A%27Journalists%2C+raise+your+hands%21%27%0D%0A%0D%0AThey+do.%0D%0A%0D%0A%27Journalists%2C+find+a+developer+and+explain+them+what+do+you+have+in+mind+that+could+be+done+with+code%2C+and+let%27s+see+if+it%27s+doable+or+not%21%27%0D%0A%0D%0AAnd+then+a+girl+approached+Francesca+and+me.+She+looked+strangely+familiar+but+I+couldn%27t+really+tell+why.+We+sat+in+a+table%2C+took+the+laptops+out+of+their+sleeves+and+set+out+to+try+and+find+if+the+data+we+needed+was+available.+But+the+wireless+didn%27t+quite+work.+So+we+chatted+about+something+fascinating+and+kind+of+related+to+the+topic%3A+Volcanoes%21+It+really+helped+that+she+had+a+degree+in+Geology+so+she+could+really+offer+interesting+insight+about+how+volcanoes+work.+Also%2C+amazing+as+it+sounds%2C+she+could+pronounce+Eyjafjallaj%C3%B6kull+in+one+go+without+hesitation%21%0D%0A%0D%0AWe+ate+some+more+pizza%2C+and+then+the+wireless+started+working.+So+we+checked+and+saw+that+the+data+wasn%27t+available+--+but+we+agreed+she+would+contact+the+organisation+and+ask+them+for+it.+Maybe+they+already+have+it+but+it%27s+not+publicly+advertised.%0D%0A%0D%0AThen+it%27s+when+the+real+coding+part+began%3B+she+said+she+would+love+to+learn+programming%2C+but+didn%27t+know+where+to+start%2C+or+the+guides+she+had+tried+were+boring.+I+immediately+proposed+Processing%3B+I+know+there%27s+Hackety+Hack+by+_why%2C+which+is+ruby+based%2C+but+I+don%27t+have+any+experience+with+it%2C+so+I+went+for+the+safer+option.+%0D%0A%0D%0AI+actually+hadn%27t+done+much+Processing+recently+and+as+such+I+always+forget+the+names+of+the+basic+functions+%28was+it+setup%2C+or+was+it+load%3F+was+it+loop+or+was+it+play%3F%29+but+it+was+even+better%2C+so+that+way+they+could+follow+along.+She+downloaded+Processing+and+was+typing+in+stuff+in+the+sketchbook+immediately...+which+was+amazing%21+No+setup%2C+no+preparation%2C+no+rebooting+the+computer+after+the+installation%3B+just+download+and+experiment%21%0D%0A%0D%0AWe%27ve+done+just+extremely+simple+things+such+as+opening+a+window%2C+setting+its+background+colour%2C+changing+its+size+and...+drawing+a+line%21+Still%2C+I+find+it+really+enlightening+to+observe+how+%27normal+people%27+%28i.e.+not+hardcore+developers%29+react+to+all+these+concepts+when+exposed+to+them.%0D%0A%0D%0AInteresting+things+I%27ve+noticed+%28teachers%2C+take+note%21%29%3A%0D%0A%0D%0A%09people+love+to+see+results+immediately+-+no+theory+to+start+with%21%0D%0A%09people+love+to+have+some+starting+snippets%2C+which+they+can+modify+and+experiment+with%2C+learning+how+they+work+meanwhile%0D%0A%0D%0A%0D%0ASo+that+makes+Processing+an+excellent+programming+environment+for+beginners%2C+because+it%27s+got+that+beatiful+reference+written+in+pretty+much+plain+language+and+with+example+snippets+that+can+be+copied+and+pasted+for+each+function%2Fclass.%0D%0A%0D%0AIn+a+few+minutes+the+word+had+spread%3A+there+were+people+doing+stuff+with+Processing+in+the+room%21+And+so+a+little+audience+gathered%2C+another+guy+%28a+journalist%29+came+with+his+laptop%2C+downloaded+Processing+and+was+doing+little+simple+things+as+the+aforementioned+ones%2C+copying+code+from+her+wife%27s+screen+--isn%27t+it+sweet%3F%0D%0A%0D%0AOn+the+other+side+of+the+table+I+was+showing+Paul+and+Francesca+my+word+processing+and+statistical+experiments+with+Tolkien+works+and+we+also+spoke+about+Processing+versus+other+environments+such+as+Javascript+or+Flash.%0D%0A%0D%0AIn+between%2C+the+girl+had+told+us+her+name%2C+and+if+the+face+looked+familiar%2C+the+name+was+insanely+familiar%21+She+humbly+told+me+she+was+in+lots+of+events+and+etc%2C+but+didn%27t+make+a+big+thing+of+it.+I+asked+her+about+events+I+had+been+in+%28that+I+could+recall+at+that+point%29+to+no+avail+--we+didn%27t+seem+to+have+been+in+the+same+events.+But+then+I+came+home+and+looked+for+%22Suw+Charman%22+and+found+that+not+only+had+I+seen+her+speak+at+resfest%2705+but+she+had+also+posted+a+few+messages+to+a+mailing+list+I+follow.+I+think+that%27s+why+the+name+sounded+sooo+familiar%21%0D%0A%0D%0AOf+course%2C+there+couldn%27t+be+a+nice+event+without+Rob+McKinnon+in+it%21+I+just+love+how+I+always+find+him+everywhere+I+go%2C+whether+it%27s+a+full+fledged+event+or+just+a+coffee+shop+anywhere+in+London%2C+it%27s+just+so+funny.+Couldn%27t+exchange+more+than+a+few+%22hey+hey+hi%21%22+waves+because+we+both+were+busy+with+our+new+friends%2C+so+I+don%27t+know+which+sorts+of+interesting+stuff+did+he+show+this+time+%28the+last+time+he+spoke+about+Hpricot%29.%0D%0A%0D%0AThe+event+ended+at+around+22h%2C+but+mainly+because+people+had+to+leave+and+take+trains+and+all+those+things%2C+but+I%27m+pretty+sure+otherwise+we+could+have+stayed+and+playing+with+Processing+for+a+long+while+%3A-%29%0D%0A%0D%0AAnd+that%27s+how+ruby+in+the+pub%2C+%22with+hardly+any+ruby+and+certainly+no+pub%22%2C+was.+See+you+in+the+next+one%3F&amp;amp;tags=flash%2Cjavascript%2Clondon%2Cprocessing%2Cruby%2Cruby+in+the+pub%2Cblog" type="text/html" />
	</item>
		<item>
		<title>How to install hpricot in Ubuntu 8.4</title>
		<link>http://soledadpenades.com/2008/10/24/how-to-install-hpricot-in-ubuntu-84/</link>
		<comments>http://soledadpenades.com/2008/10/24/how-to-install-hpricot-in-ubuntu-84/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 09:56:59 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[hpricot]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=778</guid>
		<description><![CDATA[This could be considered a fresh installation, speaking in ruby terms. I just had ruby installed, no ruby gems, nor ruby dev nor anything else ruby. So this should be enough for installing hpricot as well as ruby gems (which are required for installing hpricot). As you can see, I didn&#8217;t download any source file, [...]]]></description>
			<content:encoded><![CDATA[<p>This could be considered a fresh installation, speaking in ruby terms. I just had ruby installed, no ruby gems, nor ruby dev nor anything else ruby. So this should be enough for installing hpricot as well as ruby gems (which are required for installing hpricot). </p>
<p>As you can see, I didn&#8217;t download any source file, instead I was happy with using apt-get and the hpricot version from ubuntu repositories, although they are relatively old (for example rubygems is more than a year old). If I find any problem and need to update to newer versions I&#8217;ll report that here ;-)</p>
<div class="syhi_block"><code><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> rubygems<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>source_cache<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gem update<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> ruby1.8-dev<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> hpricot</code></div>
<p>It&#8217;s a pity they don&#8217;t have a metapackage for ruby&#8217;s development files (the ruby1.8-dev package), the same way there&#8217;s a <strong>ruby</strong> metapackage which depends on the <strong>ruby1.8</strong> package, so whenever ruby is updated it will update the ruby version as well, without the user having to worry about the version number.</p>
<p>Even more, I instinctively tried a <em>naive</em><strong> sudo apt-get install rubydev</strong> and was greeted with a sad<em> &#8220;Couldn&#8217;t find package rubydev&#8221;</em>. It somehow proves that a metapackage called rubydev would be quite useful&#8230; at least for instinctive users.</p>
<p>Enjoy your screen scrapping!</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=778&amp;md5=9d485ac144e0ac71ee31f1dc093ea7a5" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2008/10/24/how-to-install-hpricot-in-ubuntu-84/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=8399&amp;amp;url=http%3A%2F%2Fsoledadpenades.com%2F2008%2F10%2F24%2Fhow-to-install-hpricot-in-ubuntu-84%2F&amp;amp;language=en_GB&amp;amp;category=text&amp;amp;title=How+to+install+hpricot+in+Ubuntu+8.4&amp;amp;description=This+could+be+considered+a+fresh+installation%2C+speaking+in+ruby+terms.+I+just+had+ruby+installed%2C+no+ruby+gems%2C+nor+ruby+dev+nor+anything+else+ruby.+So+this+should+be+enough+for+installing+hpricot+as+well+as+ruby+gems+%28which+are+required+for+installing+hpricot%29.+%0D%0A%0D%0AAs+you+can+see%2C+I+didn%27t+download+any+source+file%2C+instead+I+was+happy+with+using+apt-get+and+the+hpricot+version+from+ubuntu+repositories%2C+although+they+are+relatively+old+%28for+example+rubygems+is+more+than+a+year+old%29.+If+I+find+any+problem+and+need+to+update+to+newer+versions+I%27ll+report+that+here+%3B-%29%0D%0A%0D%0A%0D%0Asudo+apt-get+install+rubygems%0D%0Asudo+rm+%2Fvar%2Flib%2Fgems%2F1.8%2Fsource_cache%0D%0Asudo+gem+update%0D%0Asudo+apt-get+install+ruby1.8-dev%0D%0Asudo+gem+install+hpricot%0D%0A%0D%0A%0D%0AIt%27s+a+pity+they+don%27t+have+a+metapackage+for+ruby%27s+development+files+%28the+ruby1.8-dev+package%29%2C+the+same+way+there%27s+a+ruby+metapackage+which+depends+on+the+ruby1.8+package%2C+so+whenever+ruby+is+updated+it+will+update+the+ruby+version+as+well%2C+without+the+user+having+to+worry+about+the+version+number.%0D%0A%0D%0AEven+more%2C+I+instinctively+tried+a+naive+sudo+apt-get+install+rubydev+and+was+greeted+with+a+sad+%22Couldn%27t+find+package+rubydev%22.+It+somehow+proves+that+a+metapackage+called+rubydev+would+be+quite+useful...+at+least+for+instinctive+users.%0D%0A%0D%0AEnjoy+your+screen+scrapping%21&amp;amp;tags=hpricot%2Cruby%2Cubuntu%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Parsing a del.icio.us export with Hpricot</title>
		<link>http://soledadpenades.com/2008/03/25/parsing-a-delicious-export-with-hpricot/</link>
		<comments>http://soledadpenades.com/2008/03/25/parsing-a-delicious-export-with-hpricot/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 08:54:11 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[bookmarks]]></category>
		<category><![CDATA[data scrapping]]></category>
		<category><![CDATA[delicious]]></category>
		<category><![CDATA[hpricot]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/2008/03/25/parsing-a-delicious-export-with-hpricot/</guid>
		<description><![CDATA[The trickiest part is to detect if a bookmark has a corresponding description. The export is in the same format that Netscape used for its bookmarks export, which means it is a simple html file with a definition list (dl) and a series of definition terms (dt). A term (=bookmarks) may have a description (dd). [...]]]></description>
			<content:encoded><![CDATA[<p>The trickiest part is to detect if a bookmark has a corresponding description. The export is in the same format that Netscape used for its bookmarks export, which means it is a simple html file with a definition list (<strong>dl</strong>) and a series of definition terms (<strong>dt</strong>). A term (=bookmarks) may have a description (<strong>dd</strong>).</p>
<p>But how do you detect if there&#8217;s a description? It seems the answer was rather simple: use <strong>term.next</strong> and if the <em>next</em> element&#8217;s name is <em>dd</em>, we&#8217;re lucky and have a description. The only problem was that I didn&#8217;t know how to access the name of an element, until I just thought: what if I simply use <em>name</em>? and guess what&#8230; it worked! So term.next.name was exactly what I looked for :-)</p>
<div class="syhi_block"><code><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'hpricot'</span><br />
<br />
doc = <span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;bookmarks.html&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> Hpricot<span style="color:#006600; font-weight:bold;">&#40;</span>f<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
<br />
bookmarks = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
<br />
<span style="color:#006600; font-weight:bold;">&#40;</span>doc<span style="color:#006600; font-weight:bold;">/</span><span style="color:#996600;">&quot;dl/dt&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>term<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; link = <span style="color:#006600; font-weight:bold;">&#40;</span>term<span style="color:#006600; font-weight:bold;">/</span><span style="color:#996600;">&quot;a&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> term.<span style="color:#9966CC; font-weight:bold;">next</span> <span style="color:#9966CC; font-weight:bold;">and</span> term.<span style="color:#9966CC; font-weight:bold;">next</span>.<span style="color:#9900CC;">name</span> == <span style="color:#996600;">'dd'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; desc = term.<span style="color:#9966CC; font-weight:bold;">next</span>.<span style="color:#9900CC;">inner_text</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; desc = <span style="color:#0000FF; font-weight:bold;">nil</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> link.<span style="color:#9900CC;">attr</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'tags'</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tags = link.<span style="color:#9900CC;">attr</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'tags'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;,&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tags = <span style="color:#0000FF; font-weight:bold;">nil</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; bookmarks <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:address</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">=&gt;</span>&nbsp; &nbsp; &nbsp; link.<span style="color:#9900CC;">attr</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'href'</span><span style="color:#006600; font-weight:bold;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:created_at</span> &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">=&gt;</span>&nbsp; &nbsp; &nbsp; link.<span style="color:#9900CC;">attr</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'last_visit'</span><span style="color:#006600; font-weight:bold;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:tags</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">=&gt;</span>&nbsp; &nbsp; &nbsp; tags,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:description</span>&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">=&gt;</span>&nbsp; &nbsp; &nbsp; desc,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:title</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">=&gt;</span>&nbsp; &nbsp; &nbsp; link.<span style="color:#9900CC;">inner_text</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color:#9966CC; font-weight:bold;">end</span></code></div>
<p><a href="http://github.com/sole/snippets/blob/master/web/scrapping/delicious_dump_parse/extract.rb">Source</a> at supersnippets.</p>
<p>I also extended this a bit to save the results into a database, using ActiveRecord, but since <em>each db schema is a different world</em>, I didn&#8217;t post that version here. If anybody thinks it might be useful just let me know.</p>
<p>Also, this code is not very <em>rubyesque</em> yet, suggestions in order to improve it will be really appreciated. I&#8217;m specially thinking about the <em>if &#8230; else</em> parts, I&#8217;m pretty sure there&#8217;s a way to shorten those lines :-)</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=690&amp;md5=b18abb1777f8d959fefc87e1c4b5e248" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2008/03/25/parsing-a-delicious-export-with-hpricot/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=8399&amp;amp;url=http%3A%2F%2Fsoledadpenades.com%2F2008%2F03%2F25%2Fparsing-a-delicious-export-with-hpricot%2F&amp;amp;language=en_GB&amp;amp;category=text&amp;amp;title=Parsing+a+del.icio.us+export+with+Hpricot&amp;amp;description=The+trickiest+part+is+to+detect+if+a+bookmark+has+a+corresponding+description.+The+export+is+in+the+same+format+that+Netscape+used+for+its+bookmarks+export%2C+which+means+it+is+a+simple+html+file+with+a+definition+list+%28dl%29+and+a+series+of+definition+terms+%28dt%29.+A+term+%28%3Dbookmarks%29+may+have+a+description+%28dd%29.%0D%0A%0D%0ABut+how+do+you+detect+if+there%27s+a+description%3F+It+seems+the+answer+was+rather+simple%3A+use+term.next+and+if+the+next+element%27s+name+is+dd%2C+we%27re+lucky+and+have+a+description.+The+only+problem+was+that+I+didn%27t+know+how+to+access+the+name+of+an+element%2C+until+I+just+thought%3A+what+if+I+simply+use+name%3F+and+guess+what...+it+worked%21+So+term.next.name+was+exactly+what+I+looked+for+%3A-%29%0D%0A%0D%0A%0D%0Arequire+%27rubygems%27%0D%0Arequire+%27hpricot%27%0D%0A%0D%0Adoc+%3D+open%28%22bookmarks.html%22%29+%7B%7Cf%7C+Hpricot%28f%29+%7D%0D%0A%0D%0Abookmarks+%3D+%5B%5D%0D%0A%0D%0A%28doc%2F%22dl%2Fdt%22%29.each+do+%7Cterm%7C%0D%0A%09link+%3D+%28term%2F%22a%22%29%0D%0A%09%0D%0A%09if+term.next+and+term.next.name+%3D%3D+%27dd%27%0D%0A%09%09desc+%3D+term.next.inner_text%0D%0A%09else%0D%0A%09%09desc+%3D+nil%0D%0A%09end%0D%0A%09%0D%0A%09if+link.attr%28%27tags%27%29%0D%0A%09%09tags+%3D+link.attr%28%27tags%27%29.split%28%22%2C%22%29%0D%0A%09else%0D%0A%09%09tags+%3D+nil%0D%0A%09end%0D%0A%09%0D%0A%09bookmarks+%09link.attr%28%27href%27%29%2C%0D%0A%09%09%3Acreated_at%09%3D%3E%09link.attr%28%27last_visit%27%29%2C%0D%0A%09%09%3Atags%09%09%09%3D%3E%09tags%2C%0D%0A%09%09%3Adescription%09%3D%3E%09desc%2C%0D%0A%09%09%3Atitle%09%09%09%3D%3E%09link.inner_text%0D%0A%09%7D%0D%0A%09%0D%0Aend%0D%0A%0D%0A%0D%0ASource+at+supersnippets.%0D%0A%0D%0AI+also+extended+this+a+bit+to+save+the+results+into+a+database%2C+using+ActiveRecord%2C+but+since+each+db+schema+is+a+different+world%2C+I+didn%27t+post+that+version+here.+If+anybody+thinks+it+might+be+useful+just+let+me+know.%0D%0A%0D%0AAlso%2C+this+code+is+not+very+rubyesque+yet%2C+suggestions+in+order+to+improve+it+will+be+really+appreciated.+I%27m+specially+thinking+about+the+if+...+else+parts%2C+I%27m+pretty+sure+there%27s+a+way+to+shorten+those+lines+%3A-%29&amp;amp;tags=bookmarks%2Cdata+scrapping%2Cdelicious%2Chpricot%2Cruby%2Cblog" type="text/html" />
	</item>
	</channel>
</rss>

