<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Logankoester's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 25 Jul 2008 20:52:44 GMT</pubDate>
    <description>DZone Snippets: Logankoester's Code Snippets</description>
    <item>
      <title>Create and lookup tinyurls with PHP</title>
      <link>http://snippets.dzone.com/posts/show/4720</link>
      <description>&lt;code&gt;&lt;br /&gt;        function reverse_tinyurl($url){&lt;br /&gt;            // Resolves a TinyURL.com encoded url to it's source.&lt;br /&gt;            $url = explode('.com/', $url);&lt;br /&gt;            $url = 'http://preview.tinyurl.com/'.$url[1];&lt;br /&gt;            $preview = file_get_contents($url);&lt;br /&gt;            preg_match('/redirecturl" href="(.*)"&gt;/', $preview, $matches);&lt;br /&gt;            return $matches[1];&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        function tinyurl($url){&lt;br /&gt;        // Shortens a url&lt;br /&gt;            $html = file_get_contents("http://tinyurl.com/create.php?url=".$url);&lt;br /&gt;            preg_match('/http:\/\/preview\.tinyurl\.com\/(.*)&lt;\/b&gt;/', $html, $matches);&lt;br /&gt;            return "http://tinyurl.com/".$matches[1];&lt;br /&gt;        } &lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 31 Oct 2007 05:42:45 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4720</guid>
      <author>logankoester (Logan Koester)</author>
    </item>
    <item>
      <title>Display the number of characters in the name of each month</title>
      <link>http://snippets.dzone.com/posts/show/4401</link>
      <description>&lt;code&gt;&lt;br /&gt;months = %w(January February March April May June July August September October November December)&lt;br /&gt;months.each { |m| print  m, " (", m.length, ")\n" }&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 08 Aug 2007 01:59:52 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4401</guid>
      <author>logankoester (Logan Koester)</author>
    </item>
    <item>
      <title>Rails route lets :id be a domain name</title>
      <link>http://snippets.dzone.com/posts/show/4376</link>
      <description>// Named route for an id that contains . characters, such as a domain name&lt;br /&gt;// eg: http://myapp/domains/foobar.com&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;map.domain 'domains/:id', :controller =&gt; 'domains', :action =&gt; 'show', :requirements =&gt; { :id =&gt; /[a-zA-Z0-9\-\.]+/ }&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 01 Aug 2007 02:51:20 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4376</guid>
      <author>logankoester (Logan Koester)</author>
    </item>
    <item>
      <title>Rename all *.gif files in a directory (prefix)</title>
      <link>http://snippets.dzone.com/posts/show/4315</link>
      <description>// My mind always seems to draw a blank when I want to do this sort of thing, so here's a concise little self-reminder&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;for file in $(echo *.gif); do mv ${file} prefix.${file}; done&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 18 Jul 2007 03:52:08 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4315</guid>
      <author>logankoester (Logan Koester)</author>
    </item>
    <item>
      <title>Reverse TinyURL</title>
      <link>http://snippets.dzone.com/posts/show/4237</link>
      <description>// Resolves a TinyURL.com encoded url to it's source.&lt;br /&gt;// Example: reverse_tinyurl('http://tinyurl.com/2ocfun') =&gt; "http://logankoester.com"&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function reverse_tinyurl($url){&lt;br /&gt;	$url = explode('.com/', $url);&lt;br /&gt;	$url = 'http://preview.tinyurl.com/'.$url[1];&lt;br /&gt;	$preview = file_get_contents($url);&lt;br /&gt;	preg_match('/redirecturl" href="(.*)"&gt;/', $preview, $matches);&lt;br /&gt;	return $matches[1];&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 02 Jul 2007 07:04:25 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4237</guid>
      <author>logankoester (Logan Koester)</author>
    </item>
    <item>
      <title>Tidy Remote HTML (using a web service)</title>
      <link>http://snippets.dzone.com/posts/show/4218</link>
      <description>// Clean up some code using a web service. If you need to do this more quickly I suggest using a local tidy installation&lt;br /&gt;// rather than my web service, but this is nice and easy. :)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function tidied($url) {&lt;br /&gt;  /* Cleans up a page via Tidy, returning the cleaned up html as a string&lt;br /&gt;   * By Logan Koester &lt;logan@logankoester.com&gt; 2007-06-28&lt;br /&gt;   * Props to http://infohound.net/tidy */&lt;br /&gt;  return file_get_contents("http://logankoester.com/tools/tidy.php?q=$url");&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 28 Jun 2007 10:16:46 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4218</guid>
      <author>logankoester (Logan Koester)</author>
    </item>
    <item>
      <title>Generate a random string of letters</title>
      <link>http://snippets.dzone.com/posts/show/4169</link>
      <description>// Generates a random string of lowercase letters. Great for email verification codes ;)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Array.new(6) { (rand(122-97) + 97).chr }.join&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 20 Jun 2007 05:58:44 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4169</guid>
      <author>logankoester (Logan Koester)</author>
    </item>
    <item>
      <title>Generate a random string of letters</title>
      <link>http://snippets.dzone.com/posts/show/4168</link>
      <description>// Generates a random string of lowercase letters. Great for email verification codes ;)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Array.new(6) { (rand(122-97) + 97).chr }.join&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 20 Jun 2007 05:56:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4168</guid>
      <author>logankoester (Logan Koester)</author>
    </item>
    <item>
      <title>Generate a random string of letters</title>
      <link>http://snippets.dzone.com/posts/show/4167</link>
      <description>// Generates a random string of lowercase letters. Great for email verification codes ;)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Array.new(6) { (rand(122-97) + 97).chr }.join&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 20 Jun 2007 05:56:38 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4167</guid>
      <author>logankoester (Logan Koester)</author>
    </item>
    <item>
      <title>Generate a random string of letters</title>
      <link>http://snippets.dzone.com/posts/show/4166</link>
      <description>Generates a random string of lowercase letters. Great for email verification codes ;)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Array.new(6) { (rand(122-97) + 97).chr }.join&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 20 Jun 2007 05:56:27 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4166</guid>
      <author>logankoester (Logan Koester)</author>
    </item>
  </channel>
</rss>
