<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: quote code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 10:08:18 GMT</pubDate>
    <description>DZone Snippets: quote code</description>
    <item>
      <title>Bash title random Quote routine</title>
      <link>http://snippets.dzone.com/posts/show/5428</link>
      <description>#&lt;br /&gt;#this is a script in my .bash_profile that gets a random&lt;br /&gt;#quote .txt file and assigns it to the terminal title.&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;quote_path="/Users/glynch/Documents/quotes/*"&lt;br /&gt;files=($quote_path)&lt;br /&gt;N=${#files[@]}&lt;br /&gt;((N=RANDOM%N))&lt;br /&gt;randomfile=${files[$N]}&lt;br /&gt;quote=""&lt;br /&gt;while read line; do quote="$quote $line"; done &lt; $randomfile&lt;br /&gt;echo -n -e "\033]0;$quote\007"</description>
      <pubDate>Thu, 24 Apr 2008 19:43:08 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5428</guid>
      <author>robotsu (Gavin)</author>
    </item>
    <item>
      <title>itcrowdquote.rb</title>
      <link>http://snippets.dzone.com/posts/show/4621</link>
      <description>// Prints a quote from Channel 4's "The IT Crowd"&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/env ruby&lt;br /&gt;&lt;br /&gt;require "rubygems"&lt;br /&gt;require "open-uri"&lt;br /&gt;require "hpricot"&lt;br /&gt;require "htmlentities"&lt;br /&gt;&lt;br /&gt;coder=HTMLEntities.new()&lt;br /&gt;&lt;br /&gt;doc=open("http://www.channel4.com/entertainment/tv/microsites/I/itcrowd/quote_generator/") { |f| Hpricot(f) }&lt;br /&gt;&lt;br /&gt;section=doc/"blockquote"/"p"&lt;br /&gt;(section/"cite").remove()&lt;br /&gt;quote=section.inner_html&lt;br /&gt;&lt;br /&gt;# remove leading whitespace&lt;br /&gt;quote=quote.gsub(/^\s+/, "")&lt;br /&gt;&lt;br /&gt;# remove trailing whitespace&lt;br /&gt;quote=quote.gsub(/\s+$/, $/)&lt;br /&gt;&lt;br /&gt;# remove dash&lt;br /&gt;quote=quote.gsub(/\s\-\s+$/, $/).chomp&lt;br /&gt;&lt;br /&gt;# decode HTML entities&lt;br /&gt;quote=coder.decode(quote)&lt;br /&gt;&lt;br /&gt;puts quote&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 08 Oct 2007 05:28:14 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4621</guid>
      <author>mcandre (Andrew Pennebaker)</author>
    </item>
    <item>
      <title>SQL quotation for Symbian DBMS</title>
      <link>http://snippets.dzone.com/posts/show/1616</link>
      <description>&lt;code&gt;&lt;br /&gt;import e32db, time&lt;br /&gt;&lt;br /&gt;timestamp = time.time()&lt;br /&gt;distance = 10.5&lt;br /&gt;comment = "I'm fine, thanks!"&lt;br /&gt;&lt;br /&gt;# for date/time, int/float, and string respectively&lt;br /&gt;&lt;br /&gt;sql = "INSERT INTO events VALUES (#%s#, %d, '%s')" %\&lt;br /&gt;  (e32db.format_time(timestamp),&lt;br /&gt;   distance,&lt;br /&gt;   comment.replace("'", "''") )&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;- date/time need to be quoted with # and formatted with e32db.format_time&lt;br /&gt;- int/float need no quotation&lt;br /&gt;- string need to be quoted with single quote and repeat the quote if it happen to be inside.&lt;br /&gt;- binary can't be used. You may need to encode it (eg. base64)&lt;br /&gt;&lt;br /&gt;One day, I wish to see an easy-to-use SQL abstraction layer for pys60.&lt;br /&gt;An ORM(SQLObject or SQLAlchemy) is even better.</description>
      <pubDate>Thu, 02 Mar 2006 18:56:25 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1616</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
