<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Odie5533</title>
	
	<link>http://odie5533.com</link>
	<description />
	<lastBuildDate>Mon, 06 Sep 2010 01:31:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Odie5533" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="odie5533" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>VarisCite: Zotero-based Citation Generation for Google Chrome</title>
		<link>http://odie5533.com/406-variscite-zotero-based-citation-generation-for-google-chrome</link>
		<comments>http://odie5533.com/406-variscite-zotero-based-citation-generation-for-google-chrome#comments</comments>
		<pubDate>Thu, 19 Aug 2010 05:02:47 +0000</pubDate>
		<dc:creator>odie5533</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Zotero]]></category>

		<guid isPermaLink="false">http://odie5533.com/?p=406</guid>
		<description><![CDATA[VarisCite is a native citation generator for Google Chrome and is based on Zotero&#8217;s JavaScript translator structure. VarisCite creates a Chrome page action which, when clicked, will use a Zotero-style translator to generate a citation from the current webpage. Currently, VarisCite only supports IGN.com for citation generation and it does not support multiple Zotero translators [...]]]></description>
			<content:encoded><![CDATA[<p><strong>VarisCite</strong> is a native citation generator for Google Chrome and is based on <a href="http://www.zotero.org/">Zotero&#8217;s</a> JavaScript translator structure. VarisCite creates a <a href="http://code.google.com/chrome/extensions/pageAction.html">Chrome page action</a> which, when clicked, will use a Zotero-style translator to generate a citation from the current webpage. Currently, VarisCite only supports IGN.com for citation generation and it does not support multiple Zotero translators at the same time (yet). I offer this program as a proof of concept, both as the first external application to use Zotero&#8217;s translators that I know of, and to hopefully push for the expansion of Zotero or a Zotero-like application outside of Firefox. I want to release it in its working state because I often get side-tracked and end up writing some widget and never releasing it (I have a few sitting on the nearly-ready-for-release pile). I have more I would like to say regarding Zotero-like applications but I will leave that for another time and another post.</p>

<p><img src="http://i35.tinypic.com/292r40k.png"/></p>

<p><a href="/programs/VarisCite/VarisCite.crx">Install VarisCite PoC</a>. Now go to an article on <a href="http://pc.ign.com/articles/111/1114139p1.html">IGN</a> to test it.</p>

<p>If you want the source, right-click save as. Crx files are zip files with the extension change from zip to crx.</p>
]]></content:encoded>
			<wfw:commentRss>http://odie5533.com/406-variscite-zotero-based-citation-generation-for-google-chrome/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Chrome Sniffer 0.2.1 Breakout Exploit From Poor Design Choices</title>
		<link>http://odie5533.com/400-chrome-sniffer-0-2-1-breakout-exploit-from-poor-design-choices</link>
		<comments>http://odie5533.com/400-chrome-sniffer-0-2-1-breakout-exploit-from-poor-design-choices#comments</comments>
		<pubDate>Thu, 19 Aug 2010 02:13:29 +0000</pubDate>
		<dc:creator>odie5533</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://odie5533.com/?p=400</guid>
		<description><![CDATA[Chrome Sniffer is an extension for Google Chrome which lets you know what scripts and cms the website you&#8217;re browsing is using. A neat tool to have, it suffers from some poor design choices. The developers of Google Chrome took pains to use ensure extensions could not be compromised by a website&#8217;s own JavaScript. Rather [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://chrome.google.com/extensions/detail/homgcnaoacgigpkkljjjekpignblkeae">Chrome Sniffer</a> is an extension for Google Chrome which lets you know what scripts and cms the website you&#8217;re browsing is using. A neat tool to have, it suffers from some poor design choices. The developers of Google Chrome took pains to use ensure extensions could not be compromised by a website&#8217;s own JavaScript. Rather than using the Google Chrome isolated worlds messaging paradigm, the developer(s) of Chrome Sniffer seem to have taken it as a personal challenge to allow a website&#8217;s own javascript to directly affect the extension. <a href="youtube.com/watch?v=laLudeUmXHM#t=1m19s">Google Chrome Extensions: Content Scripts and Isolated Worlds</a>, a video by Google on why isolated worlds exist.</p>

<p>Beware of all content scripts. Even ones you wouldn&#8217;t expect to be modifying your DOM may be doing it anyways for the hell of it. When an extension asks if you want to allow it access to &#8220;Your data on all websites&#8221;, ask yourself if this is really necessary, and do you trust the extension&#8217;s author?</p>

<p>To be more technical, the extension works by injecting JavaScript into the actual website. The JavaScript then stores its results into a meta variable, &#8220;chromesniffer_meta&#8221;, inside the web page&#8217;s DOM. The exploit works by modifying this element before the extension has time to read it. This coupled with little to no data cleansing means we can inject both HTML and JavaScript into the extension.</p>

<p>I&#8217;ve created a simple DoS exploit located at <a href="/chrome_sniffer_exploit.html">chrome<em>sniffer</em>exploit.html</a>. The page has a warning on it on what to do engage the exploit. Simply clicking the link will <strong>not</strong> engage the exploit, blow up your computer, or do anything.</p>
]]></content:encoded>
			<wfw:commentRss>http://odie5533.com/400-chrome-sniffer-0-2-1-breakout-exploit-from-poor-design-choices/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Chrome Extension: Wikipedia Watchlist</title>
		<link>http://odie5533.com/385-google-chrome-extension-wikipedia-watchlist</link>
		<comments>http://odie5533.com/385-google-chrome-extension-wikipedia-watchlist#comments</comments>
		<pubDate>Sun, 15 Aug 2010 06:45:38 +0000</pubDate>
		<dc:creator>odie5533</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Wikipedia]]></category>

		<guid isPermaLink="false">http://odie5533.com/?p=385</guid>
		<description><![CDATA[This is a Google Chrome Extension for the English Wikipedia. Wikipedia Watchlist checks your watchlist and updates the badge on the browser action icon to reflect new changes. Clicking on the badge opens up a popup where you can highlight different changes to view both the edit summary and the time the change was made. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://chrome.google.com/extensions/detail/kmfbnpoggnebafhbanelibhdpbkkncfe"><img alt="" src="http://i35.tinypic.com/2iw9grk.png" title="Wikipedia Watchlist" class="alignright" width="638" height="231" /></a></p>

<p>This is a <a href="https://chrome.google.com/extensions/">Google Chrome Extension</a> for the <a href="http://en.wikipedia.org/wiki/Main_Page">English Wikipedia</a>. Wikipedia Watchlist checks <a href="http://en.wikipedia.org/wiki/Special:Watchlist">your watchlist</a> and updates the badge on the browser action icon to reflect new changes. Clicking on the badge opens up a popup where you can highlight different changes to view both the edit summary and the time the change was made. Clicking the little &#8216;d&#8217; will take you to the last difference for the page and clicking the page name will take you to the page itself.</p>

<p><a href="https://chrome.google.com/extensions/detail/kmfbnpoggnebafhbanelibhdpbkkncfe">Click Here. Wikipedia Watchlist</a> at the Google chrome extensions site.</p>
]]></content:encoded>
			<wfw:commentRss>http://odie5533.com/385-google-chrome-extension-wikipedia-watchlist/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery RSS Parser in 7 Lines</title>
		<link>http://odie5533.com/373-jquery-rss-parser-in-7-lines</link>
		<comments>http://odie5533.com/373-jquery-rss-parser-in-7-lines#comments</comments>
		<pubDate>Sun, 15 Aug 2010 06:33:25 +0000</pubDate>
		<dc:creator>odie5533</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Snippet]]></category>

		<guid isPermaLink="false">http://odie5533.com/?p=373</guid>
		<description><![CDATA[&#8220;He&#8217;d fly through the feed with the greatest of ease, That daring young parser on the flying trapeze.&#8221; /* Trapeze RSS parser in 7 lines */ function parseRSS&#40;d&#41; &#123; return $&#40;d&#41;.find&#40;'item'&#41;.map&#40;function&#40;&#41; &#123; var i = new Object&#40;&#41;; $&#40;this&#41;.children&#40;&#41;.each&#40;function&#40;&#41;&#123;i&#91;this.tagName&#93;= this.textContent;&#125;&#41;; return i; &#125;&#41;; &#125; Called with a return document from an ajax request, this function returns [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;He&#8217;d fly through the <em>feed</em> with the greatest of ease,
That daring young <em>parser</em> on the flying trapeze.&#8221;</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/* Trapeze RSS parser in 7 lines */</span>
<span style="color: #003366; font-weight: bold;">function</span> parseRSS<span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> $<span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'item'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">map</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Object<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>i<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">tagName</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">textContent</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> i<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<p>Called with a return document from an ajax request, this function returns an array of items which are associative arrays from the feed&#8217;s items.</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Here's an example</span>
$.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span>your<span style="color: #339933;">-</span>rss<span style="color: #339933;">-</span>feed<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    parseRSS<span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;a&gt;&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">title</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">link</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;br/&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://odie5533.com/373-jquery-rss-parser-in-7-lines/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Razer Diamondback 3G: Just another bad mouse</title>
		<link>http://odie5533.com/361-razer-diamondback-3g-just-another-bad-mouse</link>
		<comments>http://odie5533.com/361-razer-diamondback-3g-just-another-bad-mouse#comments</comments>
		<pubDate>Thu, 12 Aug 2010 19:00:35 +0000</pubDate>
		<dc:creator>odie5533</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://odie5533.com/?p=361</guid>
		<description><![CDATA[I&#8217;ve owned Razer Diamondback 3G mice for over a year now. I say mice because I had to RMA it after about six months. Not all mice are created equal and some are more fit than others. Diamondback 3Gs are rubbish. When you get the mouse the first warning sign will be that the buttons [...]]]></description>
			<content:encoded><![CDATA[<p><div style="float: right; margin: 5px;"><img src="http://i36.tinypic.com/fvwm5u.jpg" alt="Garbage compressed into mouse-form" /></div>I&#8217;ve owned Razer Diamondback 3G mice for over a year now. I say mice because I had to RMA it after about six months. Not all mice are created equal and some are more fit than others. Diamondback 3Gs are rubbish. When you get the mouse the first warning sign will be that the buttons on the right side are more useless than your appendix. The fault for this rests on the shoulders of the driver developers. And if this were their only mistake we might be in good stead. To be plainspoken, the drivers should never be installed and must be uninstalled if they were. The immediate reason for this is that they render the mouse useless in both Opera and Google Chrome. In Google Chrome, you will be unable to use the middle mouse button for scrolling (although the scroll wheel still works, wait for my next point). In Opera, when you middle click to open a tab instead of one new tab you will get two new ones, always and in all cases. On top of that, using the middle mouse button to scroll is not supported correctly, although the scroll wheel still works*. Once uninstalled, however, the thumb buttons no longer work correctly, and to go &#8220;back&#8221; you press the top thumb button, but to go forward you must use the top little finger button.</p>

<p>The biggest problem with the mouse is that the scroll wheel will only work for about six months. As I said in the beginning I had to RMA my first mouse because the scroll wheel died after six months. Six months more, and the casualty count increases. It just doesn&#8217;t scroll at all now. I only used it for scrolling in the browser and I&#8217;d imagine if I liked using it for video games it would have gone even faster. So now I am left with a useless scroll wheel, having to use the pinkie button to go forward, and no ability to remap buttons. Currently on the lookout for a new mouse.</p>
]]></content:encoded>
			<wfw:commentRss>http://odie5533.com/361-razer-diamondback-3g-just-another-bad-mouse/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twisted Python RDT/RTSP Library and Stream Downloader</title>
		<link>http://odie5533.com/346-twisted-python-rdt-rtsp-library-and-stream-downloader</link>
		<comments>http://odie5533.com/346-twisted-python-rdt-rtsp-library-and-stream-downloader#comments</comments>
		<pubDate>Tue, 01 Jun 2010 03:09:51 +0000</pubDate>
		<dc:creator>odie5533</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://odie5533.com/?p=346</guid>
		<description><![CDATA[Twisted is a great framework for Python, but they don&#8217;t support RDT or RTSP protocol used for streaming Real video. The RDT/RTSP handler in MPlayer is a bit buggy and suffers from disconnect problems when receiving RTSP packets after switching to raw mode for RDT (though perhaps such occurrences are out of specification, they do [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twistedmatrix.com/trac/">Twisted</a> is a great framework for Python, but they don&#8217;t support <a href="http://en.wikipedia.org/wiki/Real_Data_Transport">RDT</a> or <a href="http://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol">RTSP</a> protocol used for streaming Real video. The RDT/RTSP handler in <a href="http://en.wikipedia.org/wiki/MPlayer">MPlayer</a> is a bit buggy and suffers from disconnect problems when receiving RTSP packets after switching to raw mode for RDT (though perhaps such occurrences are out of specification, they do still occur). Thus, I set off to create my own.</p>

<p>The library includes support for RTSP, RDT, <a href="http://en.wikipedia.org/wiki/Session_Description_Protocol">SDPP</a>, ASMRP, and <a href="https://common.helixcommunity.org/2003/HCS_SDK_r5/htmfiles/rmff.htm">RMFF</a>, and it is all in pure Python and Pythonically coded where possible (see sdpp.py). It requires Python 2.6 and the Twisted Python library. The library has only one known bug, and I can&#8217;t for the life of me find it. Perhaps another set of eyes will effect a solution.</p>

<p>To use the library to simply download an RTSP stream:
<code>python rdt.py -u &lt;URL&gt; -f &lt;FILENAME&gt;</code></p>

<p>If you like this post, <b>please comment</b>. Commenting is fast, anonymous, and greatly appreciated.
<a href="/programs/RDT-RTSP/Twisted RDT-RTSP Library 2010-07-05.zip">Download the Twisted Python RDT-RTSP Library here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://odie5533.com/346-twisted-python-rdt-rtsp-library-and-stream-downloader/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automatically Download Songs from Grooveshark</title>
		<link>http://odie5533.com/334-automatically-download-songs-from-grooveshark</link>
		<comments>http://odie5533.com/334-automatically-download-songs-from-grooveshark#comments</comments>
		<pubDate>Mon, 31 May 2010 01:11:42 +0000</pubDate>
		<dc:creator>odie5533</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://odie5533.com/?p=334</guid>
		<description><![CDATA[Because manually downloading songs from Grooveshark is too tedious, here&#8217;s a nice process to automatically save all the songs you listen to on Grooveshark. Unlike other methods, this does not use any extra bandwidth so you don&#8217;t need to listen to the song and download it, once is enough. Update After doing some searching, I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>Because <a href="http://odie5533.com/downloading-mp3-songs-from-grooveshark-322">manually downloading songs from Grooveshark</a> is too tedious, here&#8217;s a nice process to automatically save all the songs you listen to on Grooveshark. Unlike other methods, this does not use any extra bandwidth so you don&#8217;t need to listen to the song and download it, once is enough.<span id="more-334"></span></p>

<p><font color="red">Update</font> After doing some searching, I&#8217;ve found a FireFox plugin caled <a href="https://addons.mozilla.org/en-US/firefox/addon/3006/">Video DownloadHelper</a> which performs much the same function as the program I&#8217;ve written, but is more stable and integrated directly into FireFox. Its only downside is that it doesn&#8217;t automatically download the songs as you listen, you need to start downloading the ones you want. But it is more stable than my program and much more user friendly. Be sure to use Mp3tag (listed below) to quickly rename all the files you&#8217;ve downloaded.</p>

<p>Download and install the following pre-requisites:
<ol><li>Python 2.6.5 &#8211; <a href="http://www.python.org/ftp/python/2.6.5/python-2.6.5.msi">http://www.python.org/ftp/python/2.6.5/python-2.6.5.msi</a></li>
<li>dpkt 1.7 &#8211; <a href="http://dpkt.googlecode.com/files/dpkt-1.7.win32.exe">http://dpkt.googlecode.com/files/dpkt-1.7.win32.exe</a></li>
<li>pypcap 1.1 &#8211; <a href="/programs/Grooveshark/pcap-1.1.win32-py2.6.exe">pcap-1.1.win32-py2.6.exe</a></li>
</ol></p>

<p>Save this Python program into a folder of its own: <a href="/programs/Grooveshark/groovegrab.py">groovegrab.py</a></p>

<p>Run the program using <code>python groovegrab.py</code></p>

<p>As you listen to songs on Grooveshark, the folder will populate with mp3 files. Each are named Track_X.mp3. But there&#8217;s a really neat, easy way to rename them. Download <a href="http://www.mp3tag.de/en/download.html">Mp3tag</a> and in the program go to File > Change Directory and choose the directory where the mp3 files are. Select all the mp3 files in the main pane and go to Convert > Tag to Filename.</p>

<p>Enjoy your perfectly named mp3 files from a Grooveshark listening session.</p>

<p>Thanks to dugsong for <a href="http://code.google.com/p/dpkt/">dpkt</a> and <a href="http://code.google.com/p/pypcap/">pypcap</a>, and thanks to Andrew Brampton for his <a href="http://bramp.net/blog/follow-http-stream-with-decompression">tutorial on dpkt/pypcap</a>!</p>

<p>If you liked this post, please comment. Commeting is fast, anonymous, and greatly appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://odie5533.com/334-automatically-download-songs-from-grooveshark/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Downloading MP3 Songs From Grooveshark</title>
		<link>http://odie5533.com/322-downloading-mp3-songs-from-grooveshark</link>
		<comments>http://odie5533.com/322-downloading-mp3-songs-from-grooveshark#comments</comments>
		<pubDate>Sun, 30 May 2010 14:28:07 +0000</pubDate>
		<dc:creator>odie5533</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://odie5533.com/?p=322</guid>
		<description><![CDATA[A friend of mine recently introduced me to Grooveshark, a website offering streaming radio similar to Pandora but which allows you to specify what song you would like to listen to rather than listening in a guided method as Pandora offers. I wondered if it was possible to save songs which are streamed from Grooveshark. [...]]]></description>
			<content:encoded><![CDATA[<p>A friend of mine recently introduced me to <a href="http://grooveshark.com">Grooveshark</a>, a website offering streaming radio similar to <a href="http://www.pandora.com/">Pandora</a> but which allows you to specify what song you would like to listen to rather than listening in a guided method as Pandora offers. I wondered if it was possible to save songs which are streamed from Grooveshark.</p>

<p><img src="http://i45.tinypic.com/xdhv9d.png"/>
<span id="more-322"></span></p>

<p>The simplest method is to just record whatever the computer plays. This can be done using <a href="http://audacity.sourceforge.net/">Audacity</a>, or anything which will record the audio the computer is currently playing. I found an application which uses this method to record audio from streaming websites. <a href="http://www.recordstreamingaudio.net/download-grooveshark-music.html">Streaming Audio Recorder</a> records streaming audio by all audio coming from the computer. This is a very naive approach and suffers from quality degradation if the file was not originally going to be re-encoded, but it has the advantage of working in all cases.</p>

<p>Another approach is to capture the stream urls as they are played. Examples of this are WmRecorder, Jaksta, and Orbit Grab++. The stream is then requested a second time and the program records the response. This method downloads each stream twice, once from the original site, then again using the capture program. This works for many sites, but Grooveshark has a handshake challenge which breaks this method.</p>

<p>A final approach, and perhaps the best, is to capture the stream the first time. Unlike the previous approach, it downloads the stream only once. To accomplish this method on Grooveshark, I used <a href="http://www.wireshark.org/">WireShark</a>.</p>

<p><b><u>Downloading the mp3 from Grooveshark:</u></b>
<ol><li>In <a href="http://www.wireshark.org/">WireShark</a>, go to Capture > Options. Under Capture Filter, enter in <code>port 80</code> and start the capture.</li>
<li>Begin listening to the song on Grooveshark and many new lines should begin scrolling in WireShark. At the top of WireShark is a Filter: box. Enter in <code>http.content_type == "audio/mpeg"</code>, press enter, and only one line should appear (more lines if more than one song was played).</li>
<li>Click the line once and if it comes up processing, hit Stop. Then in the middle pane click the Media Type line (again, Stop if necessary). Right-click the Media Type line and choose Export Selected Packet Bytes&#8230; Then save the file somewhere as an mp3 file, choosing All Files as the filetype.</li></ol>
The nice thing about this method is that no extra packets are sent to Grooveshark, so the method is undetectable.</p>

<p>If you liked this post, please comment. Commenting is fast, anonymous, and greatly appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://odie5533.com/322-downloading-mp3-songs-from-grooveshark/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>GIMP Resize and Match DPI in Scheme</title>
		<link>http://odie5533.com/304-gimp-resize-and-match-dpi-in-scheme</link>
		<comments>http://odie5533.com/304-gimp-resize-and-match-dpi-in-scheme#comments</comments>
		<pubDate>Mon, 17 May 2010 03:33:29 +0000</pubDate>
		<dc:creator>odie5533</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[GIMP]]></category>
		<category><![CDATA[Scheme]]></category>

		<guid isPermaLink="false">http://odie5533.com/?p=304</guid>
		<description><![CDATA[Resize-match-dpi is a GIMP Script-Fu script written in Scheme to resize or scale an image along with scaling the DPI. Let&#8217;s consider an image being scanned which is 4.75&#8243; x 4.70&#8243;. We scan the image at 300 DPI with a pixel resolution of 1425 x 1409 and we want to scale it down to 1280&#215;1266. [...]]]></description>
			<content:encoded><![CDATA[<p>Resize-match-dpi is a GIMP Script-Fu script written in Scheme to resize or scale an image along with scaling the DPI. Let&#8217;s consider an image being scanned which is 4.75&#8243; x 4.70&#8243;. We scan the image at 300 DPI with a pixel resolution of 1425 x 1409 and we want to scale it down to 1280&#215;1266. Using IrfanView, XNView, GIMP, and other programs will rescale the image, but the DPI will still be 300. This means when the image is viewed on a monitor or printed out it will appear too small (4.27&#8243; x 4.22&#8243;). This script scales the DPI to match the new pixel resolution so it will still appear as 4.75&#8243; x 4.70&#8243;.</p>

<p>If you like this post, please comment. Commenting is fast, anonymous, and greatly appreciated.<span id="more-304"></span></p>

<p>To install the script, save it as resize-match-dpi.scm into C:\Users\Odie&#46;gimp-2.6\scripts&#46; Open up GIMP and the script will appear under the Script-Fu menu at the top of an image window. If you are really adventurous, I&#8217;ve included a small wrapper allowing the script to be called from the console as follows:
<pre>"C:\Program Files\GIMP-2.0\bin\gimp-console-2.6" -i -b "(resize<em>match</em>dpi \"input.bmp\" \"output.bmp\" 1280 0)" -b "(gimp-quit 0)"</pre></p>

<p>resize-match-dpi.scm:</p>


<div class="wp_syntax"><div class="code"><pre class="scheme" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">; Released under the GNU GPL 3.0 or later</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> <span style="color: #66cc66;">&#40;</span>resize<span style="color: #66cc66;">-</span>match<span style="color: #66cc66;">-</span>dpi image drawable newwidth newheight<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let*</span> <span style="color: #66cc66;">&#40;</span>
	 <span style="color: #66cc66;">&#40;</span>oldwidth <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>image<span style="color: #66cc66;">-</span>width image<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
	 <span style="color: #66cc66;">&#40;</span>oldheight <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>image<span style="color: #66cc66;">-</span>height image<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
	 <span style="color: #66cc66;">&#40;</span>newdpi <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">=</span> newheight <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">set!</span> newheight <span style="color: #66cc66;">&#40;</span>round <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">/</span> oldheight oldwidth<span style="color: #66cc66;">&#41;</span> newwidth<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">=</span> newwidth <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">set!</span> newwidth <span style="color: #66cc66;">&#40;</span>round <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">/</span> oldwidth oldheight<span style="color: #66cc66;">&#41;</span> newheight<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">set!</span> newdpi <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">/</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span> newwidth <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>image<span style="color: #66cc66;">-</span>get<span style="color: #66cc66;">-</span>resolution image<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> oldwidth<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>image<span style="color: #66cc66;">-</span>undo<span style="color: #66cc66;">-</span>group<span style="color: #66cc66;">-</span>start image<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>image<span style="color: #66cc66;">-</span>scale image newwidth newheight<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>image<span style="color: #66cc66;">-</span>set<span style="color: #66cc66;">-</span>resolution image newdpi newdpi<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>image<span style="color: #66cc66;">-</span>undo<span style="color: #66cc66;">-</span>group<span style="color: #66cc66;">-</span>end image<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> <span style="color: #66cc66;">&#40;</span>resize_match_dpi filename output newwidth newheight<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let*</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>image    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>file<span style="color: #66cc66;">-</span><span style="color: #b1b100;">load</span> RUN<span style="color: #66cc66;">-</span>NONINTERACTIVE filename filename<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
         <span style="color: #66cc66;">&#40;</span>drawable <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>image<span style="color: #66cc66;">-</span>get<span style="color: #66cc66;">-</span>active<span style="color: #66cc66;">-</span>layer image<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>resize<span style="color: #66cc66;">-</span>match<span style="color: #66cc66;">-</span>dpi image drawable newwidth newheight<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>file<span style="color: #66cc66;">-</span>save RUN<span style="color: #66cc66;">-</span>NONINTERACTIVE image drawable output output<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>image<span style="color: #66cc66;">-</span>delete image<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> <span style="color: #66cc66;">&#40;</span>resize_match_dpi_multi pattern outdir newwidth newheight<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let*</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>filelist <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cadr</span> <span style="color: #66cc66;">&#40;</span>file<span style="color: #66cc66;">-</span>glob pattern <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>while <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">null?</span> filelist<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
	   <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let*</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>filename <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> filelist<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
		  <span style="color: #66cc66;">&#40;</span>image    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>file<span style="color: #66cc66;">-</span><span style="color: #b1b100;">load</span> RUN<span style="color: #66cc66;">-</span>NONINTERACTIVE
						 filename filename<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
		  <span style="color: #66cc66;">&#40;</span>drawable <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>image<span style="color: #66cc66;">-</span>get<span style="color: #66cc66;">-</span>active<span style="color: #66cc66;">-</span>layer image<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
		  <span style="color: #66cc66;">&#40;</span>outf <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">string-append</span> outdir <span style="color: #ff0000;">&quot;/&quot;</span> filename<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
	     <span style="color: #66cc66;">&#40;</span>resize<span style="color: #66cc66;">-</span>match<span style="color: #66cc66;">-</span>dpi image drawable newwidth newheight<span style="color: #66cc66;">&#41;</span>
	     <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>file<span style="color: #66cc66;">-</span>save RUN<span style="color: #66cc66;">-</span>NONINTERACTIVE image drawable outf outf<span style="color: #66cc66;">&#41;</span>
	     <span style="color: #66cc66;">&#40;</span>gimp<span style="color: #66cc66;">-</span>image<span style="color: #66cc66;">-</span>delete image<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
	   <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">set!</span> filelist <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cdr</span> filelist<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>script<span style="color: #66cc66;">-</span>fu<span style="color: #66cc66;">-</span>register <span style="color: #ff0000;">&quot;resize-match-dpi&quot;</span>
  <span style="color: #ff0000;">&quot;&lt;Image&gt;/Script-Fu/Resize Match DPI&quot;</span>
  <span style="color: #ff0000;">&quot;Resize and match DPI&quot;</span>
  <span style="color: #ff0000;">&quot;odie5533&quot;</span>
  <span style="color: #ff0000;">&quot;odie5533&quot;</span>
  <span style="color: #ff0000;">&quot;2010-05-16&quot;</span>
  <span style="color: #ff0000;">&quot;RGB*&quot;</span>
  SF<span style="color: #66cc66;">-</span>IMAGE <span style="color: #ff0000;">&quot;Image&quot;</span>  <span style="color: #cc66cc;">0</span>
  SF<span style="color: #66cc66;">-</span>DRAWABLE <span style="color: #ff0000;">&quot;Drawable&quot;</span> <span style="color: #cc66cc;">0</span>
&nbsp;
  SF<span style="color: #66cc66;">-</span>VALUE  <span style="color: #ff0000;">&quot;New width&quot;</span> <span style="color: #ff0000;">&quot;1280&quot;</span>
  SF<span style="color: #66cc66;">-</span>VALUE  <span style="color: #ff0000;">&quot;New height&quot;</span> <span style="color: #ff0000;">&quot;0&quot;</span>
<span style="color: #66cc66;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://odie5533.com/304-gimp-resize-and-match-dpi-in-scheme/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TinyPic Command Line Uploader in AWK</title>
		<link>http://odie5533.com/286-tinypic-command-line-uploader-in-awk</link>
		<comments>http://odie5533.com/286-tinypic-command-line-uploader-in-awk#comments</comments>
		<pubDate>Wed, 05 May 2010 15:05:37 +0000</pubDate>
		<dc:creator>odie5533</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Awk]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[TinyPic]]></category>

		<guid isPermaLink="false">http://odie5533.com/?p=286</guid>
		<description><![CDATA[This AWK script uploads an image to TinyPic.com and returns the direct url to the uploaded image. Example script usage: $ awk -f tinypic.awk The_Grass_Snake_-_Natrix_natrix.jpg http://i39.tinypic.com/dlnb6r.jpg Let me start by saying I have no idea why I wrote this in AWK. I&#8217;ve only used AWK once before for a very short one-liner. I find AWK [...]]]></description>
			<content:encoded><![CDATA[<p>This AWK script uploads an image to <a href="http://tinypic.com">TinyPic.com</a> and returns the direct url to the uploaded image.</p>

<p>Example script usage:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-f</span> tinypic.awk The_Grass_Snake_-_Natrix_natrix.jpg
http:<span style="color: #000000; font-weight: bold;">//</span>i39.tinypic.com<span style="color: #000000; font-weight: bold;">/</span>dlnb6r.jpg</pre></div></div>


<p>Let me start by saying I have no idea why I wrote this in AWK. I&#8217;ve only used AWK once before for a very short one-liner. I find AWK to be better than Perl, but worse than Python. It does make for a light and portable language: the Windows AWK executable (<a href="http://gnuwin32.sourceforge.net/packages/gawk.htm">available here</a>) is only 345 KB, combine with Windows cURL (<a href="http://curl.haxx.se/download.html#Win32">available here</a>) which is 405 KB and you&#8217;re still under a meg for both. My bloated Python install is over 100 MB and I just installed <a href="http://strawberryperl.com/">Strawberry Perl</a> which is 174 MB.</p>

<p>If you like this post, please comment. Commenting is fast, anonymous, and much appreciated.<span id="more-286"></span></p>

<p>Here&#8217;s the script. Save as tinypic.awk</p>


<div class="wp_syntax"><div class="code"><pre class="awk" style="font-family:monospace;"><span style="color: #C20CB9; font-weight: bold;">BEGIN</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    file = <span style="color: #4107D5; font-weight: bold;">ARGV</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
    <span style="color:#808080;"># parse file extension</span>
    <span style="color: #07D589; font-weight: bold;">split</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>file, arr, <span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
    file_ext = arr<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #07D589; font-weight: bold;">length</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>arr<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
&nbsp;
    url = <span style="color: #ff0000;">&quot;http://plugin.tinypic.com/plugin/index.php?popts=c,url<span style="color: #000099; font-weight: bold;">\\</span>|s,false&quot;</span>;
    <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;curl -s &quot;</span> url | <span style="color: #0BD507; font-weight: bold;">getline</span> <span style="color:#000088;">$0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color:black;">&gt;</span> <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color:#808080;"># parse necessary post variables from the HTML page</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #07D589; font-weight: bold;">match</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color:#000088;">$0</span>, <span style="color: #ff0000;">&quot;form action=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://s(.)&quot;</span>, arr<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            server = arr<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
        <span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #07D589; font-weight: bold;">match</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color:#000088;">$0</span>, <span style="color:black;">/</span>id=<span style="color: #ff0000;">&quot;uid&quot;</span> value=<span style="color: #ff0000;">&quot;([^&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color:black;">+</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color:black;">/</span>, arr<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            uid = arr<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
        <span style="color: #000000; font-weight: bold;">if</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color:black;">!</span>uid <span style="color:black;">&amp;&amp;</span> <span style="color: #07D589; font-weight: bold;">match</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color:#000088;">$0</span>, <span style="color:black;">/</span>name=<span style="color: #ff0000;">&quot;UPLOAD_IDENTIFIER&quot;</span> value=<span style="color: #ff0000;">&quot;([^&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color:black;">+</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color:black;">/</span>, arr<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            uid = arr<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #07D589; font-weight: bold;">match</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color:#000088;">$0</span>, <span style="color:black;">/</span>name=<span style="color: #ff0000;">&quot;upk&quot;</span> value=<span style="color: #ff0000;">&quot;([^&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color:black;">+</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color:black;">/</span>, arr<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            upk = arr<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
    <span style="color:#808080;"># compile curl command to upload the file</span>
    curl_cmd = <span style="color: #07D589; font-weight: bold;">sprintf</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;curl -s -L -F UPLOAD_IDENTIFIER=<span style="color: #000099; font-weight: bold;">\&quot;</span>%s<span style="color: #000099; font-weight: bold;">\&quot;</span> -F upk=<span style="color: #000099; font-weight: bold;">\&quot;</span>%s<span style="color: #000099; font-weight: bold;">\&quot;</span> -F domain_lang=<span style="color: #000099; font-weight: bold;">\&quot;</span>en<span style="color: #000099; font-weight: bold;">\&quot;</span> -F action=<span style="color: #000099; font-weight: bold;">\&quot;</span>upload<span style="color: #000099; font-weight: bold;">\&quot;</span> -F MAX_FILE_SIZE=<span style="color: #000099; font-weight: bold;">\&quot;</span>500000000<span style="color: #000099; font-weight: bold;">\&quot;</span> -F shareopt=<span style="color: #000099; font-weight: bold;">\&quot;</span>true<span style="color: #000099; font-weight: bold;">\&quot;</span> -F the_file=<span style="color: #000099; font-weight: bold;">\&quot;</span>@%s<span style="color: #000099; font-weight: bold;">\&quot;</span> -F file_type=<span style="color: #000099; font-weight: bold;">\&quot;</span>image<span style="color: #000099; font-weight: bold;">\&quot;</span> -F dimension=<span style="color: #000099; font-weight: bold;">\&quot;</span>1600<span style="color: #000099; font-weight: bold;">\&quot;</span> <span style="color: #000099; font-weight: bold;">\&quot;</span>http://s%s.tinypic.com/plugin/upload.php<span style="color: #000099; font-weight: bold;">\&quot;</span> -H <span style="color: #000099; font-weight: bold;">\&quot;</span>Expect:<span style="color: #000099; font-weight: bold;">\&quot;</span> -e <span style="color: #000099; font-weight: bold;">\&quot;</span>http://plugin.tinypic.com/plugin/index.php<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>, uid, upk, file, server<span style="color: #7a0874; font-weight: bold;">&#41;</span>;
&nbsp;
    <span style="color:#808080;"># upload the picture and parse the picture URL</span>
    <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>curl_cmd | <span style="color: #0BD507; font-weight: bold;">getline</span> <span style="color:#000088;">$0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color:black;">&gt;</span> <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #07D589; font-weight: bold;">match</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color:#000088;">$0</span>, <span style="color:black;">/</span>name=<span style="color: #ff0000;">&quot;pic&quot;</span> value=<span style="color: #ff0000;">&quot;([^&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color:black;">+</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color:black;">/</span>, arr<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            img = arr<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #07D589; font-weight: bold;">match</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color:#000088;">$0</span>, <span style="color:black;">/</span>name=<span style="color: #ff0000;">&quot;ival&quot;</span> value=<span style="color: #ff0000;">&quot;([^&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color:black;">+</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color:black;">/</span>, arr<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            ival = arr<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>img <span style="color:black;">&amp;&amp;</span> ival<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #0BD507; font-weight: bold;">printf</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;http://i%s.tinypic.com/%s%s&quot;</span>, ival, img, <span style="color: #ff0000;">&quot;.&quot;</span> file_ext<span style="color: #7a0874; font-weight: bold;">&#41;</span>;
    <span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #0BD507; font-weight: bold;">print</span> <span style="color: #ff0000;">&quot;Unable to parse the return page.&quot;</span>;
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://odie5533.com/286-tinypic-command-line-uploader-in-awk/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
