<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: one-liner code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 12 Oct 2008 12:00:15 GMT</pubDate>
    <description>DZone Snippets: one-liner code</description>
    <item>
      <title>ruby: random alphanumeric string</title>
      <link>http://snippets.dzone.com/posts/show/5017</link>
      <description>generate random alphanumeric string 'size' characters long&lt;br /&gt;&lt;br /&gt;&lt;code&gt;size = 8; (1..size).map{([*('a'..'z')]+[*('A'..'Z')]+[*(1..9)].map{|n|n.to_s}).instance_eval{self[rand(self.size)]}}.join&lt;/code&gt;</description>
      <pubDate>Mon, 21 Jan 2008 09:03:01 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5017</guid>
      <author>elliottcable (elliott cable)</author>
    </item>
    <item>
      <title>Twitter bot weatherlisbon</title>
      <link>http://snippets.dzone.com/posts/show/4159</link>
      <description>This little bash script shows how to use curl, grep, tail, sed and perl one-liners in order to compose a bleeding-edge twitter bot.&lt;br /&gt;This one returns daily weather forecasts for Lisbon city based on the BBC weather forecast rss feed.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#! /bin/sh&lt;br /&gt;&lt;br /&gt;#Goto here&lt;br /&gt;here=/home/guillaume/Personal&lt;br /&gt;cd $here&lt;br /&gt;&lt;br /&gt;#BBC Lisbon weather id&lt;br /&gt;id=0048&lt;br /&gt;&lt;br /&gt;#BBC weather RSS feed address&lt;br /&gt;feed="http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/${id}.xml"&lt;br /&gt;&lt;br /&gt;#City&lt;br /&gt;city=lisbon&lt;br /&gt;&lt;br /&gt;#temporary file&lt;br /&gt;file="weather${city}"&lt;br /&gt;&lt;br /&gt;#Weather twitter bot&lt;br /&gt;twitbot=weatherlisbon:*******&lt;br /&gt;&lt;br /&gt;#Timestamp the log file&lt;br /&gt;echo .&gt;&gt; $file.log&lt;br /&gt;date &gt;&gt; $file.log&lt;br /&gt;&lt;br /&gt;#Read the RSS feed and filter it&lt;br /&gt;curl $feed | grep 'title' | tail -n 1 | perl -wlne'm/title&gt;(.*)&lt;\/title/i &amp;&amp; print $1' | sed -e "s/&amp;#xB0;//g" &gt; $file.txt&lt;br /&gt;&lt;br /&gt;#Read the forecast into a weather variable&lt;br /&gt;read weather &lt; $file.txt&lt;br /&gt;&lt;br /&gt;#Twit the weather variable away&lt;br /&gt;curl --basic --user $twitbot --data status="$weather" http://twitter.com/statuses/update.xml &gt;&gt; $file.log&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 18 Jun 2007 21:37:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4159</guid>
      <author>griflet (guillaume riflet)</author>
    </item>
    <item>
      <title>wazup?!!!?!??1:!!??</title>
      <link>http://snippets.dzone.com/posts/show/2600</link>
      <description>Only in Ruby can something this awesome be possible!&lt;br /&gt;&lt;br /&gt;Try to guess its output before you run it.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def wazup?(a) puts "#{a} dat!" end&lt;br /&gt;wazup?!!!?!??1:!!??&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 16 Sep 2006 01:19:27 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2600</guid>
      <author>jicksta (Jay Phillips)</author>
    </item>
    <item>
      <title>Sierpinski Triangle - ruby one-liner</title>
      <link>http://snippets.dzone.com/posts/show/1784</link>
      <description>&lt;code&gt;&lt;br /&gt;ruby -le'32.times{|y|print" "*(31-y),(0..y).map{|x|~y&amp;x&gt;0?" .":" A"}}'&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Source: &lt;a href="http://ruby-talk.org/cgi-bin/vframe.rb/ruby/ruby-talk/122644?122482-123428"&gt;Signatures and one liners&lt;/a&gt;</description>
      <pubDate>Tue, 28 Mar 2006 15:49:57 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1784</guid>
      <author>413x ()</author>
    </item>
  </channel>
</rss>
