<?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>OneFluidMotion</title>
	<atom:link href="http://onefluidmotion.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://onefluidmotion.com</link>
	<description></description>
	<lastBuildDate>Sun, 13 Feb 2011 00:55:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>List Entropy</title>
		<link>http://onefluidmotion.com/?p=39</link>
		<comments>http://onefluidmotion.com/?p=39#comments</comments>
		<pubDate>Sun, 13 Feb 2011 00:55:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[entropy]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://onefluidmotion.com/?p=39</guid>
		<description><![CDATA[def entropy&#40;l&#41;: &#160; &#160; &#160; &#160; from math import log &#160; &#160; &#160; &#160; log2=lambda x:log&#40;x&#41;/log&#40;2&#41; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; total=len&#40;l&#41; &#160; &#160; &#160; &#160; counts=&#123;&#125; &#160; &#160; &#160; &#160; for item in l: &#160; &#160; &#8230; <a href="http://onefluidmotion.com/?p=39">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class='sniplrcode'><span style="color: #ff7700;font-weight:bold;">def</span> entropy<span style="color: black;">&#40;</span>l<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">math</span> <span style="color: #ff7700;font-weight:bold;">import</span> log<br />
&nbsp; &nbsp; &nbsp; &nbsp; log2=<span style="color: #ff7700;font-weight:bold;">lambda</span> x:log<span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>/log<span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; total=<span style="color: #008000;">len</span><span style="color: black;">&#40;</span>l<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; counts=<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> l:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counts.<span style="color: black;">setdefault</span><span style="color: black;">&#40;</span>item,<span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counts<span style="color: black;">&#91;</span>item<span style="color: black;">&#93;</span>+=<span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; ent=<span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> counts:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p=<span style="color: #008000;">float</span><span style="color: black;">&#40;</span>counts<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>/total<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ent-=p<span style="color: #66cc66;">*</span>log2<span style="color: black;">&#40;</span>p<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> ent</div>
<ul class='snippet-meta'>
<li><strong><a href='http://snipplr.com/view/48791/entropy'>Entropy</a></strong></li>
</ul>
<p>Take a list and return it&#8217;s entropy.</p>
]]></content:encoded>
			<wfw:commentRss>http://onefluidmotion.com/?feed=rss2&amp;p=39</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>efficient array element matching</title>
		<link>http://onefluidmotion.com/?p=36</link>
		<comments>http://onefluidmotion.com/?p=36#comments</comments>
		<pubDate>Sun, 13 Feb 2011 00:52:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[binomial coefficient]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://onefluidmotion.com/?p=36</guid>
		<description><![CDATA[public static void main&#40;String&#91;&#93; args&#41; &#123; &#160; &#160; &#160; &#160; String&#91;&#93; arr = &#123;&#34;0&#34;,&#34;1&#34;,&#34;2&#34;,&#34;3&#34;&#125;; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; int len = arr.length; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; for&#40;int p= 0;p&#60;len;p++&#41;&#123; &#160; &#160; &#160; &#8230; <a href="http://onefluidmotion.com/?p=36">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class='sniplrcode'><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> arr <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;0&quot;</span>,<span style="color: #0000ff;">&quot;1&quot;</span>,<span style="color: #0000ff;">&quot;2&quot;</span>,<span style="color: #0000ff;">&quot;3&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> len <span style="color: #339933;">=</span> arr.<span style="color: #006633;">length</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> p<span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>p<span style="color: #339933;">&lt;</span>len<span style="color: #339933;">;</span>p<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span>len<span style="color: #339933;">;</span>i<span style="color: #339933;">&#8211;&gt;</span>p<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>arr<span style="color: #009900;">&#91;</span>p<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span>arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div>
<ul class='snippet-meta'>
<li><strong><a href='http://snipplr.com/view/43264/matching-elements-in-an-array'>Matching elements in an array</a></strong></li>
</ul>
<p>I couldn&#8217;t find something like this at the time, so fashioned this nifty function to print all combinations without repetition in a list.  for example:<br />
if the input is an array that looks like :   {&#8220;0&#8243;,&#8221;1&#8243;,&#8221;2&#8243;,&#8221;3&#8243;}<br />
It will print out the following:<br />
01<br />
02<br />
03<br />
12<br />
13<br />
23<br />
The typical way a noob programmer would do with would be the cross product of the duplicate of this array, or a full loop within a loop.  While this is still of complexity O(n^2) in the long run it still save some cpu cycles in the short run.  Imagine trying to compare the elements of a 1000 member array.  for each element compare with each element,  that&#8217;s 1000*1000 iterations.  The naive approach is doing 1,000,000 iterations while the above approach does (1000/2)*999 iterations or 499,000 iterations. ie. 1000 choose 2.</p>
]]></content:encoded>
			<wfw:commentRss>http://onefluidmotion.com/?feed=rss2&amp;p=36</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New York Times Article API function</title>
		<link>http://onefluidmotion.com/?p=34</link>
		<comments>http://onefluidmotion.com/?p=34#comments</comments>
		<pubDate>Sun, 13 Feb 2011 00:41:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[NY Times]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://onefluidmotion.com/?p=34</guid>
		<description><![CDATA[&#60;?php //ini_set(&#8216;display_errors&#8217;,3); //error_reporting(E_ALL &#160;&#38; ~E_NOTICE &#38; ~E_WARNING); include_once&#40;&#34;simple_html_dom.php&#34;&#41;; //NYT_query(&#34;json&#34;,&#34;javascript&#34;,&#34;[article search key]&#34;,false); // with the 4th parameter set to false , it will only print out the total numbser of articles matching your query. NYT_query&#40;&#34;json&#34;,&#34;jay-z&#34;,&#34;[article search key]&#34;,true,80&#41;; NYT_query&#40;&#34;json&#34;,&#34;eminem&#34;,&#34;[article search key]&#34;,true,80&#41;; //NYT_query(&#34;json&#34;,&#34;javascript&#34;,&#34;[article &#8230; <a href="http://onefluidmotion.com/?p=34">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class='sniplrcode'><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #666666; font-style: italic;">//ini_set(&#8216;display_errors&#8217;,3);</span><br />
<span style="color: #666666; font-style: italic;">//error_reporting(E_ALL &nbsp;&amp; ~E_NOTICE &amp; ~E_WARNING);</span><br />
<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;simple_html_dom.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></p>
<p><span style="color: #666666; font-style: italic;">//NYT_query(&quot;json&quot;,&quot;javascript&quot;,&quot;[article search key]&quot;,false);</span><br />
<span style="color: #666666; font-style: italic;">// with the 4th parameter set to false , it will only print out the total numbser of articles matching your query.</span></p>
<p>NYT_query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;json&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;jay-z&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;[article search key]&quot;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">80</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
NYT_query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;json&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;eminem&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;[article search key]&quot;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">80</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></p>
<p><span style="color: #666666; font-style: italic;">//NYT_query(&quot;json&quot;,&quot;javascript&quot;,&quot;[article search key]&quot;,true,10);</span><br />
<span style="color: #666666; font-style: italic;">//with the 4th parameter set to true, it will print out the total number and also, write each article to file.</span><br />
<span style="color: #666666; font-style: italic;">//the txt files will be in the current working directory under a directory named {your query} &nbsp;in this case it&#8217;s javascript</span><br />
<span style="color: #666666; font-style: italic;">//some will return zero kb. &nbsp;im not sure what the hell is going on with that(nyt server error status 500), but you can get most articles this way.</span><br />
<span style="color: #666666; font-style: italic;">//the 5th paramter is to specify the maximum number of articles to write to file. &nbsp;This is pretty helpful when queries like &quot;computer&quot; have over 120000 results</span></p>
<p><span style="color: #666666; font-style: italic;">//in the future i&#8217;ll probably refine the search paramters a bit to get more accurate results such as the ability to search for all articles containing &quot;computer&quot; in the &quot;technology&quot; section of the NYTimes</span></p>
<p><span style="color: #000000; font-weight: bold;">function</span> NYT_query<span style="color: #009900;">&#40;</span><span style="color: #000088;">$format</span><span style="color: #339933;">,</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span><span style="color: #000088;">$apikey</span><span style="color: #339933;">,</span><span style="color: #000088;">$writetoFile</span><span style="color: #339933;">,</span><span style="color: #000088;">$max</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$URL</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://api.nytimes.com/svc/search/v1/article?format=<span style="color: #006699; font-weight: bold;">$format</span>&amp;query=<span style="color: #006699; font-weight: bold;">$query</span>&amp;api-key=<span style="color: #006699; font-weight: bold;">$apikey</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> file_get_html<span style="color: #009900;">&#40;</span><span style="color: #000088;">$URL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$result</span><span style="color: #339933;">=</span> <a href="http://www.php.net/json_decode"><span style="color: #990000;">json_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$arr</span> <span style="color: #339933;">=</span> &nbsp;<span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$total</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">total</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$total</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$writetoFile</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$max</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$max</span><span style="color: #339933;">&gt;</span><span style="color: #000088;">$total</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$max</span><span style="color: #339933;">=</span><span style="color: #000088;">$total</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$maximum</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$max</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$maximum</span><span style="color: #339933;">=</span> <a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$total</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$maximum</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$url</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://api.nytimes.com/svc/search/v1/article?format=<span style="color: #006699; font-weight: bold;">$format</span>&amp;query=<span style="color: #006699; font-weight: bold;">$query</span>&amp;offset=<span style="color: #006699; font-weight: bold;">$i</span>&amp;api-key=<span style="color: #006699; font-weight: bold;">$apikey</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> file_get_html<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$result</span><span style="color: #339933;">=</span> <a href="http://www.php.net/json_decode"><span style="color: #990000;">json_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> &nbsp;<span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$t</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/urldecode"><span style="color: #990000;">urldecode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$t</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$t</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$artBody</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/html_entity_decode"><span style="color: #990000;">html_entity_decode</span></a><span style="color: #009900;">&#40;</span>extractArticle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_dir"><span style="color: #990000;">is_dir</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;archive/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writeToFile<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;archive/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$query</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.txt&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$artBody</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/mkdir"><span style="color: #990000;">mkdir</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;archive/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writeToFile<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;archive/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$query</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.txt&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$artBody</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></p>
<p><span style="color: #000000; font-weight: bold;">function</span> extractArticle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> file_get_html<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$body</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&#8216;.articleBody&#8217;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$element</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$body</span><span style="color: #339933;">.=</span> <span style="color: #000088;">$element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">plaintext</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$body</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">function</span> writeToFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span><span style="color: #000088;">$body</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$myFile</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$filename</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$fh</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/fopen"><span style="color: #990000;">fopen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myFile</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&#8216;w&#8217;</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;can&#8217;t open file&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$stringData</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$body</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/fwrite"><span style="color: #990000;">fwrite</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #339933;">,</span> <span style="color: #000088;">$stringData</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/fclose"><span style="color: #990000;">fclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span></div>
<ul class='snippet-meta'>
<li><strong><a href='http://snipplr.com/view/42380/new-york-times-article-api-function'>new york times article api function</a></strong></li>
</ul>
<p>very nice little script I made September of 2010.  This makes it easy to query the nytimes api to find relative news articles in bulk.</p>
]]></content:encoded>
			<wfw:commentRss>http://onefluidmotion.com/?feed=rss2&amp;p=34</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Itunes Currently Playing Song&#8217;s Lyrics Finder</title>
		<link>http://onefluidmotion.com/?p=30</link>
		<comments>http://onefluidmotion.com/?p=30#comments</comments>
		<pubDate>Sun, 13 Feb 2011 00:36:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[applescript]]></category>
		<category><![CDATA[itunes]]></category>
		<category><![CDATA[lyrics]]></category>

		<guid isPermaLink="false">http://onefluidmotion.com/?p=30</guid>
		<description><![CDATA[tell application &#34;iTunes&#34; &#160; &#160; &#160; &#160; if player state is playing then &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; set artist_name to artist of current track &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; set track_name to name &#8230; <a href="http://onefluidmotion.com/?p=30">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class='sniplrcode'><span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> player state <span style="color: #ff0033; font-weight: bold;">is</span> playing <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> artist_name <span style="color: #ff0033; font-weight: bold;">to</span> artist <span style="color: #ff0033; font-weight: bold;">of</span> current track<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> track_name <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> current track<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> artist_name <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> artist <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">selection</span> <span style="color: #ff0033; font-weight: bold;">of</span> browser <span style="color: #0066ff;">window</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> track_name <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">selection</span> <span style="color: #ff0033; font-weight: bold;">of</span> browser <span style="color: #0066ff;">window</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span></p>
<p><span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> artist_name <span style="color: #ff0033; font-weight: bold;">to</span> replace_chars<span style="color: #000000;">&#40;</span>artist_name, <span style="color: #009900;">&quot; &quot;</span>, <span style="color: #009900;">&quot;+&quot;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> track_name <span style="color: #ff0033; font-weight: bold;">to</span> replace_chars<span style="color: #000000;">&#40;</span>track_name, <span style="color: #009900;">&quot; &quot;</span>, <span style="color: #009900;">&quot;+&quot;</span><span style="color: #000000;">&#41;</span></p>
<p><span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Safari&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066ff;">activate</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> URL <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #ff0033;">the</span> <span style="color: #ff0033;">front</span> <span style="color: #0066ff;">document</span> <span style="color: #ff0033; font-weight: bold;">to</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;http://search.lyrics.astraweb.com/?word=&quot;</span> <span style="color: #000000;">&amp;</span> artist_name <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;+&quot;</span> <span style="color: #000000;">&amp;</span> track_name <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;&quot;</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span></p>
<p>
<span style="color: #ff0033; font-weight: bold;">on</span> replace_chars<span style="color: #000000;">&#40;</span>this_text, search_string, replacement_string<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> AppleScript<span style="">&#8216;</span>s <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">item</span> <span style="color: #0066ff;">delimiters</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> search_string<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> item_list <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">every</span> <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">item</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_text<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> AppleScript<span style="">&#8216;</span>s <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">item</span> <span style="color: #0066ff;">delimiters</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> replacement_string<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_text <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> item_list <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> AppleScript<span style="">&#8216;</span>s <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">item</span> <span style="color: #0066ff;">delimiters</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> this_text<br />
<span style="color: #ff0033; font-weight: bold;">end</span> replace_chars</div>
<ul class='snippet-meta'>
<li><strong><a href='http://snipplr.com/view/28698/itunes-lyrics-finder'>Itunes lyrics finder</a></strong></li>
</ul>
<p>Another applescript I fashioned a while back along with the guitar tabs finder.  It&#8217;s been relatively time-saving.  no more clicking or typing more than a hotkey when I want to find lyrics or guitar tabs yesssss.</p>
]]></content:encoded>
			<wfw:commentRss>http://onefluidmotion.com/?feed=rss2&amp;p=30</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Itunes Currently Playing Song&#8217;s Guitar Tabs Finder</title>
		<link>http://onefluidmotion.com/?p=24</link>
		<comments>http://onefluidmotion.com/?p=24#comments</comments>
		<pubDate>Sun, 13 Feb 2011 00:33:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[applescript]]></category>
		<category><![CDATA[guitar]]></category>
		<category><![CDATA[guitar tabs]]></category>
		<category><![CDATA[itunes]]></category>

		<guid isPermaLink="false">http://onefluidmotion.com/?p=24</guid>
		<description><![CDATA[tell application &#34;iTunes&#34; &#160; &#160; &#160; &#160; if player state is playing then &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; set artist_name to artist of current track &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; set track_name to name &#8230; <a href="http://onefluidmotion.com/?p=24">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class='sniplrcode'><span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> player state <span style="color: #ff0033; font-weight: bold;">is</span> playing <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> artist_name <span style="color: #ff0033; font-weight: bold;">to</span> artist <span style="color: #ff0033; font-weight: bold;">of</span> current track<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> track_name <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> current track<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> artist_name <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> artist <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">selection</span> <span style="color: #ff0033; font-weight: bold;">of</span> browser <span style="color: #0066ff;">window</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> track_name <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">selection</span> <span style="color: #ff0033; font-weight: bold;">of</span> browser <span style="color: #0066ff;">window</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span></p>
<p><span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> artist_name <span style="color: #ff0033; font-weight: bold;">to</span> replace_chars<span style="color: #000000;">&#40;</span>artist_name, <span style="color: #009900;">&quot; &quot;</span>, <span style="color: #009900;">&quot;+&quot;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> track_name <span style="color: #ff0033; font-weight: bold;">to</span> replace_chars<span style="color: #000000;">&#40;</span>track_name, <span style="color: #009900;">&quot; &quot;</span>, <span style="color: #009900;">&quot;+&quot;</span><span style="color: #000000;">&#41;</span></p>
<p><span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Safari&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066ff;">activate</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> URL <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #ff0033;">the</span> <span style="color: #ff0033;">front</span> <span style="color: #0066ff;">document</span> <span style="color: #ff0033; font-weight: bold;">to</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;http://www.ultimate-guitar.com/search.php?bn=&quot;</span> <span style="color: #000000;">&amp;</span> artist_name <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;&amp;sn=&quot;</span> <span style="color: #000000;">&amp;</span> track_name <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;&amp;type%5B%5D=1&amp;type%5B%5D=3&quot;</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span></p>
<p>
<span style="color: #ff0033; font-weight: bold;">on</span> replace_chars<span style="color: #000000;">&#40;</span>this_text, search_string, replacement_string<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> AppleScript<span style="">&#8216;</span>s <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">item</span> <span style="color: #0066ff;">delimiters</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> search_string<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> item_list <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">every</span> <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">item</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_text<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> AppleScript<span style="">&#8216;</span>s <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">item</span> <span style="color: #0066ff;">delimiters</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> replacement_string<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_text <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> item_list <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> AppleScript<span style="">&#8216;</span>s <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">item</span> <span style="color: #0066ff;">delimiters</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> this_text<br />
<span style="color: #ff0033; font-weight: bold;">end</span> replace_chars</div>
<ul class='snippet-meta'>
<li><strong><a href='http://snipplr.com/view/28697/itunes-guitar-tab-finder'>Itunes guitar tab finder</a></strong></li>
</ul>
<p>Cool applescript I made a while back that takes the currently playing song in itunes and searches <a href="http://ultimate-guitar.com">utimate-guitar.com</a> for guitar tabs.  I set it up with Quicksilver to easily put the script on a hot-key combination for quick guitar tabs hunting.</p>
]]></content:encoded>
			<wfw:commentRss>http://onefluidmotion.com/?feed=rss2&amp;p=24</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>download first 50,000,000 prime numbers</title>
		<link>http://onefluidmotion.com/?p=15</link>
		<comments>http://onefluidmotion.com/?p=15#comments</comments>
		<pubDate>Sun, 13 Feb 2011 00:27:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Prime Numbers]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[one-liners]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://onefluidmotion.com/?p=15</guid>
		<description><![CDATA[for i in &#123;1..50&#125;; do wget &#34;http://primes.utm.edu/lists/small/millions/primes$i.zip&#34;; done download the first 50,000,000 prime numbers I don&#8217;t remember when i figured this out, I just remember that I was doing a programming challenge of some sorts and didn&#8217;t want to generate &#8230; <a href="http://onefluidmotion.com/?p=15">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class='sniplrcode'><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span>..<span style="color: #000000;">50</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">&quot;http://primes.utm.edu/lists/small/millions/primes<span style="color: #007800;">$i</span>.zip&quot;</span>; <span style="color: #000000; font-weight: bold;">done</span></div>
<ul class='snippet-meta'>
<li><strong><a href='http://snipplr.com/view/29996/download-the-first-50000000-prime-numbers'>download the first 50,000,000 prime numbers</a></strong></li>
</ul>
<p>I don&#8217;t remember when i figured this out, I just remember that I was doing a programming challenge of some sorts and didn&#8217;t want to generate prime numbers.<br />
this is a bash one-liner for those of you that didn&#8217;t get that right that right off the bat.  wget is included on most unix/linux systems by default.</p>
]]></content:encoded>
			<wfw:commentRss>http://onefluidmotion.com/?feed=rss2&amp;p=15</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

