<?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>cat brain.log &#124; less &#187; Scripts, Tricks and Hacks</title>
	<atom:link href="http://log.largevoid.com/cat/scripts-tricks-hacks/feed/" rel="self" type="application/rss+xml" />
	<link>http://log.largevoid.com</link>
	<description>Getting it down on `paper`</description>
	<lastBuildDate>Mon, 06 Feb 2012 06:23:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Disable Annoying Camera and Video Sounds on Rooted Android</title>
		<link>http://log.largevoid.com/2011/08/disable-annoying-camera-and-video-sounds-on-rooted-android/</link>
		<comments>http://log.largevoid.com/2011/08/disable-annoying-camera-and-video-sounds-on-rooted-android/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 23:27:10 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Gotchas]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[adb]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[CyanogenMod]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=582</guid>
		<description><![CDATA[Pre-req: Fastboot drivers installed. ROM: CyanogenMod 7.1 RC1 (YMMV). Phone: HTC Desire &#8211; BravoC DVT2 Enable USB debugging. Connect your phone to your computer. Bring up a command prompt. Change to android-sdk-windows directory. adb remount adb shell cd system/media/audio/ui mv camera_click.ogg camera_click.og_ mv VideoRecord.ogg VideoRecord.og_ Source: http://android.modaco.com/topic/319541-camera-shutter-sound/ Reference: http://theunlockr.com/2009/10/06/how-to-set-up-adb-usb-drivers-for-android-devices/]]></description>
			<content:encoded><![CDATA[<p>Pre-req: Fastboot drivers <a href="http://theunlockr.com/2011/08/02/how-to-gain-s-off-flash-a-custom-recovery-and-root-your-android-phone-using-the-revolutionary-method/">installed</a>.<br />
ROM: CyanogenMod 7.1 RC1 (YMMV).<br />
Phone: HTC Desire &#8211; BravoC DVT2</p>
<p>Enable USB debugging.<br />
Connect your phone to your computer.<br />
Bring up a command prompt.<br />
Change to android-sdk-windows directory.</p>

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">adb remount
adb shell
<span style="color: #b1b100; font-weight: bold;">cd</span> system/media/audio/ui
mv camera_click.ogg camera_click.og_
mv VideoRecord.ogg VideoRecord.og_</pre></div></div>

<p>Source: <a href="http://android.modaco.com/topic/319541-camera-shutter-sound/">http://android.modaco.com/topic/319541-camera-shutter-sound/</a><br />
Reference: <a href="http://android.modaco.com/topic/319541-camera-shutter-sound/">http://theunlockr.com/2009/10/06/how-to-set-up-adb-usb-drivers-for-android-devices/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2011/08/disable-annoying-camera-and-video-sounds-on-rooted-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Root an HTC Desire to Get More Space for Apps</title>
		<link>http://log.largevoid.com/2011/08/root-an-htc-desire-to-get-more-space-for-apps/</link>
		<comments>http://log.largevoid.com/2011/08/root-an-htc-desire-to-get-more-space-for-apps/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 10:42:12 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Reference]]></category>
		<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[CDMA]]></category>
		<category><![CDATA[ClockworkMod]]></category>
		<category><![CDATA[CyanogenMod]]></category>
		<category><![CDATA[Gingerbread]]></category>
		<category><![CDATA[HTC Desire]]></category>
		<category><![CDATA[revolutionary]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=577</guid>
		<description><![CDATA[Rooted my android &#8212; HTC Desire (CDMA)! At time of rooting, the specs were: BravoC DVT2 Ship S-on HBOOT-1.06.0000 Microp-051e Touch Panel-Synt0101 Radio-2.15.00.2.17 Dec 22, 2010, 16:16:39 Abridged Instructions: Download/Install HTCDriver3.0.0.007 (AKA Fastboot drivers) Download/Apply revolutionary-0.3pre7 (Boot/Recovery loader) Download/Apply su-2.3.6.3-efgh-signed (root) &#8230; ClockworkMod backup!! (protect your original OEM install) ClockworkMod to wipe data/cache (now wipe [...]]]></description>
			<content:encoded><![CDATA[<p>Rooted my android &#8212; HTC Desire (CDMA)!</p>
<p>At time of rooting, the specs were:</p>
<pre>BravoC DVT2 Ship S-on
HBOOT-1.06.0000
Microp-051e
Touch Panel-Synt0101
Radio-2.15.00.2.17
Dec 22, 2010, 16:16:39</pre>
<p>Abridged Instructions:</p>
<ol>
<li>Download/Install HTCDriver3.0.0.007 (AKA Fastboot drivers)</li>
<li>Download/Apply revolutionary-0.3pre7 (Boot/Recovery loader)</li>
<li>Download/Apply su-2.3.6.3-efgh-signed (root)</li>
<li>&#8230; ClockworkMod backup!! (protect your original OEM install)</li>
<li>ClockworkMod to wipe data/cache (now wipe it clean)</li>
<li>ClockworkMod to create/format 512MB sd-ext partition (add partition for apps)</li>
<li>Download/Apply CyanogenMod 7 &#8211; update-cm-7.0.3-BravoC-signed (the ROM for your device)</li>
<li>Android Market &gt; S2E &gt; configure (check all) &gt; reboot (Use sd-ext thoroughly: more apps, long reboot)</li>
<li>Android Market madness! (download away!)</li>
<li>Software configuration madness&#8230; (configure before backup snapshot)</li>
<li>&#8230; ClockworkMod backup!!! (make backup of customized OS)</li>
<li>AWESOME (do dangerous things, knowing you have a backup!)</li>
</ol>
<p>Learning curve: 7 hours of pain + 2 hours of tinkering + 2 hours of diligent due process, 30 minutes of documentation.</p>
<p>Unlock device, install boot loader, root:<br />
<a href="http://theunlockr.com/2011/08/02/how-to-gain-s-off-flash-a-custom-recovery-and-root-your-android-phone-using-the-revolutionary-method/">http://theunlockr.com/2011/08/02/how-to-gain-<wbr>s-off-flash-a-custom-recovery-and-root-your-androi<wbr>d-phone-using-the-revolutionary-method/</wbr></wbr></a></p>
<p>Choose your mod (not very many for CDMA):<br />
<a href="http://forum.cyanogenmod.com/forum/118-htc-desire-cdma/">http://forum.cyanogenmod.com/forum/118-htc-d<wbr>esire-cdma/</wbr></a></p>
<p>Force use of newly created sd card ext partition (get lots of app space):<br />
<a href="https://market.android.com/details?id=ru.krikun.s2e">https://market.android.com/details?id=ru.kr<wbr>ikun.s2e</wbr></a></p>
<p>*Background info re. the apps data partition/A2SD conundrum:<br />
<a href="http://android.modaco.com/topic/331205-guide-how-to-get-more-free-space-for-your-apps/"> http://android.modaco.com/topic/331205-guide-how-to-get-more-free-space-for-your-apps/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2011/08/root-an-htc-desire-to-get-more-space-for-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ranking Colleges by Reading Level</title>
		<link>http://log.largevoid.com/2010/12/ranking-colleges-by-reading-level/</link>
		<comments>http://log.largevoid.com/2010/12/ranking-colleges-by-reading-level/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 12:15:07 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Reference]]></category>
		<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[intelligence]]></category>
		<category><![CDATA[publications]]></category>
		<category><![CDATA[ranking]]></category>
		<category><![CDATA[reading level]]></category>
		<category><![CDATA[university]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=496</guid>
		<description><![CDATA[Google recently released a new feature that allows you to see the reading level for a given domain. I was curious what this meant for universities, and wondered which universities&#8217; websites had the most advanced reading level documents. Top 10 (excerpt): School Rank1 Advanced Intermediate Basic Num Results Cornell University 1 98 1 1 34300000 [...]]]></description>
			<content:encoded><![CDATA[<p>Google recently released a new feature that allows you to see the reading level for a given domain.  I was curious what this meant for universities, and wondered which universities&#8217; websites had the most advanced reading level documents.</p>
<p>Top 10 (excerpt):</p>
<table>
<thead>
<tr>
<td>School</td>
<td>Rank<sup>1</sup></td>
<td>Advanced</td>
<td>Intermediate</td>
<td>Basic</td>
<td>Num Results</td>
</tr>
</thead>
<tbody>
<tr>
<td><a href="http://www.cornell.edu/">Cornell University</a></td>
<td>1</td>
<td>98</td>
<td>1</td>
<td>1</td>
<td>34300000</td>
</tr>
<tr>
<td><a href="http://www.jhu.edu/">Johns Hopkins University</a></td>
<td>2</td>
<td>75</td>
<td>21</td>
<td>2</td>
<td>36600000</td>
</tr>
<tr>
<td><a href="http://www.stanford.edu/">Stanford University</a></td>
<td>3</td>
<td>66</td>
<td>28</td>
<td>4</td>
<td>28800000</td>
</tr>
<tr>
<td><a href="http://web.mit.edu/">Massachusetts Institute of Technology</a></td>
<td>4</td>
<td>60</td>
<td>29</td>
<td>10</td>
<td>21200000</td>
</tr>
<tr>
<td><a href="http://www.berkeley.edu/">University of California-Berkeley</a></td>
<td>5</td>
<td>52</td>
<td>38</td>
<td>8</td>
<td>14900000</td>
</tr>
<tr>
<td><a href="http://www.harvard.edu/">Harvard University</a></td>
<td>6</td>
<td>91</td>
<td>6</td>
<td>2</td>
<td>12400000</td>
</tr>
<tr>
<td><a href="http://www.psu.edu/">Pennsylvania State University</a>*</td>
<td>7</td>
<td>97</td>
<td>2</td>
<td>1</td>
<td>11300000</td>
</tr>
<tr>
<td><a href="http://www.umich.edu/">University of Michigan</a>*</td>
<td>8</td>
<td>65</td>
<td>29</td>
<td>5</td>
<td>12400000</td>
</tr>
<tr>
<td><a href="http://www.wsc.mass.edu/">Westfield State College</a></td>
<td>9</td>
<td>41</td>
<td>49</td>
<td>8</td>
<td>12100000</td>
</tr>
<tr>
<td><a href="http://oregonstate.edu/">Oregon State University</a></td>
<td>10</td>
<td>58</td>
<td>34</td>
<td>7</td>
<td>8780000</td>
</tr>
</tbody>
</table>
<p>The results can be found here: <a href="http://largevoid.com/out/university-ranking/">University Ranking</a>, <a href="http://largevoid.com/out/university-ranking/university-ranking.tar.gz">Source Code</a>.</p>
<p>My assumption is that the higher the reading level, the more intelligent the professors are at their respective universities.  With this premise, one can use the search results to rank the universities accordingly.</p>
<p>This assumption comes with several caveats.  One such example includes the situation where publications are not hosted under the university&#8217;s primary domain.  While I haven&#8217;t found this to be the case, I cannot prove otherwise.  The results are clearly biased in favor of universities with more publications online.  This is justified in that the prodigious universities will publish more papers than their less substantial counterparts. </p>
<p><strong>The ranking algorithm:</strong> <code>(3*advanced + 2*intermediate + 1*basic) * num_documents</code></p>
<p>The primary caveat is that Google returns the percentage of documents for one of 3 reading levels, as well as the number of search results.  By multiplying the result count by the percent, we calculate the number of documents at the advanced, intermediate and basic reading levels.  However, we can&#8217;t simply sort our results by raw numbers alone.  For example, a school that has 100 advanced level, 800 intermediate level, and 100 basic level documents should not be ranked lower than a school that has 101 advanced level, 100 intermediate level, and 800 basic level documents.  In fact, the basic level documents negatively weights on the second school.  For this to be the case, one must apply scaling factors to each of the reading levels.  Unfortunately, these scaling factors may be selected arbitrarily, and may also be subjective.</p>
<p>Final caveat: The comparison is done on reading level and documents available online.  For a school that emphasizes publishing papers, the results will be weighted in its favor.  For a school that emphasizes the arts, the advanced reading level metric becomes less important.</p>
<p>References:<br />
<a href="http://www.utexas.edu/world/univ/alpha/">List of American Universities</a><br />
<a href="http://www.google.com/search?q=site%3Alog.largevoid.com&#038;num=10&#038;lr=&#038;ft=i&#038;cr=&#038;safe=off&#038;tbs=rl%3A1">Google Search [site:log.largevoid.com]</a></p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2010/12/ranking-colleges-by-reading-level/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Securing Your Internet Traffic on a Public Network</title>
		<link>http://log.largevoid.com/2010/12/securing-your-internet-traffic-on-a-public-network/</link>
		<comments>http://log.largevoid.com/2010/12/securing-your-internet-traffic-on-a-public-network/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 00:06:53 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[firesheep]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[putty]]></category>
		<category><![CDATA[socks5]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tunnel]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=491</guid>
		<description><![CDATA[I was on a public WiFi hotspot and was worried about someone sniffing my passwords with firesheep. I went in search of a howto that would teach allow me to tunnel browser traffic to my secure home network over SSH. What I found was How To Tunnel Traffic With SSH. It is the easiest and [...]]]></description>
			<content:encoded><![CDATA[<p>I was on a public WiFi hotspot and was worried about someone sniffing my passwords with firesheep.  I went in search of a howto that would teach allow me to tunnel browser traffic to my secure home network over SSH.  What I found was <a href="http://www.makeuseof.com/tag/how-to-tunnel-traffic-with-ssh/">How To Tunnel Traffic With SSH</a>.  It is the easiest and one of the more straight-forward tunneling approaches.  It requires Firefox, a secure remote server running ssh, and the putty client.</p>
<p>The long and short of it is to set up a local SOCKS5 proxy with putty.  Simply open up putty, go to Connection>SSH>Tunnels.  Add a new forwarded port (say 1080), make it dynamic, then hit add.  Now log in to your remote machine and you have a local SOCKS5 proxy running on port 1080.  You can then point your browser to use this proxy for all your web traffic.</p>
<p>The link also mentions how to make Firefox tunnel DNS requests for added security, but I won&#8217;t go into that.</p>
<p>Happy safe browsing!</p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2010/12/securing-your-internet-traffic-on-a-public-network/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Collapsible Monthly Archives</title>
		<link>http://log.largevoid.com/2010/11/wordpress-collapsible-monthly-archives/</link>
		<comments>http://log.largevoid.com/2010/11/wordpress-collapsible-monthly-archives/#comments</comments>
		<pubDate>Sat, 20 Nov 2010 01:07:31 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[archives]]></category>
		<category><![CDATA[monthly]]></category>
		<category><![CDATA[preg_replace]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp_get_archives]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=488</guid>
		<description><![CDATA[The default monthly archives are pretty ugly (IMO), so I set out to make the archives collapsible by year, with the current year expanded. The code took about 5 minutes to write, and 5 more to look up the workings of wp_get_archives. The code is comprised of 3 parts. PHP/HTML generation: echo&#40;'&#60;h2&#62;'._e&#40;'Monthly:'&#41;.'&#60;/h2&#62;'&#41;; $args = array&#40; [...]]]></description>
			<content:encoded><![CDATA[<p>The default monthly archives are pretty ugly (IMO), so I set out to make the archives collapsible by year, with the current year expanded.  The code took about 5 minutes to write, and 5 more to look up the workings of wp_get_archives.  The code is comprised of 3 parts.</p>
<p>PHP/HTML generation:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;h2&gt;'</span><span style="color: #339933;">.</span>_e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Monthly:'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/h2&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
  <span style="color: #0000ff;">'type'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'monthly'</span><span style="color: #339933;">,</span>
  <span style="color: #0000ff;">'format'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'html'</span><span style="color: #339933;">,</span>
  <span style="color: #0000ff;">'echo'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$curYear</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>wp_get_archives<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$year</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,-</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$curYear</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$year</span> <span style="color: #339933;">!==</span> <span style="color: #000088;">$curYear</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$css</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$curYear</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;/ul&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$css</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' style=&quot;display:none&quot;'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'&lt;span onclick=&quot;toggle_year('</span><span style="color: #339933;">.</span><span style="color: #000088;">$year</span><span style="color: #339933;">.</span><span style="color: #0000ff;">');&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$year</span><span style="color: #339933;">.</span>
      <span style="color: #0000ff;">&quot;&lt;/span&gt;&lt;br/&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;ul id=&quot;year_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$year</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$css</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&gt;(\S+)\s+\d+&lt;/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&gt;$1&lt;'</span><span style="color: #339933;">,</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</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: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$curYear</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$year</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$curYear</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>JavaScript event handling:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">function</span> toggle_year<span style="color: #009900;">&#40;</span>year<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> el <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'year_'</span><span style="color: #339933;">+</span>year<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> el.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>el.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span> </pre></div></div>

<p>CSS styling (to make the collapsed YEAR headers look good):</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">&lt;style type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span><span style="color: #00AA00;">&gt;</span>
span<span style="color: #6666ff;">.yearly</span> <span style="color: #00AA00;">&#123;</span>  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">110%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
&lt;/style<span style="color: #00AA00;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2010/11/wordpress-collapsible-monthly-archives/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When a Domain is Blocked by Filtering Software</title>
		<link>http://log.largevoid.com/2010/08/when-a-domain-is-blocked-by-filter-software/</link>
		<comments>http://log.largevoid.com/2010/08/when-a-domain-is-blocked-by-filter-software/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 01:17:04 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Reference]]></category>
		<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[blocked]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[cmd.exe]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[google dns]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=425</guid>
		<description><![CDATA[Can&#8217;t access your favorite websites because some stupid ISP or access point is using DNS-level filtering? Set your DNS to use Google&#8217;s DNS: 8.8.8.8 and 8.8.4.4 Then flush the existing DNS cache and register the new DNS. In Windows 7, you&#8217;ll need elevated privileges to changes to the DNS. Make sure you start cmd.exe as [...]]]></description>
			<content:encoded><![CDATA[<p>Can&#8217;t access your favorite websites because some stupid ISP or access point is using DNS-level filtering?</p>
<p>Set your DNS to use Google&#8217;s DNS:<br />
<code>8.8.8.8</code> and <code>8.8.4.4</code></p>
<p>Then flush the existing DNS cache and register the new DNS.</p>
<p>In Windows 7, you&#8217;ll need elevated privileges to changes to the DNS. Make sure you start cmd.exe as Administrator.</p>
<ol>
<li>Press the window Key</li>
<li>Type &#8220;cmd&#8221;</li>
<li>Right click the cmd.exe that&#8217;s found.</li>
<li>Select &#8220;Run as administrator&#8221;</li>
<li>Type <code>ipconfig /flushdns</code></li>
<li>Then type <code>ipconfig /registerdns</code></li>
</ol>
<p>Now you&#8217;re free to roam the internet.</p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2010/08/when-a-domain-is-blocked-by-filter-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get the Directory Path of a Bash Script</title>
		<link>http://log.largevoid.com/2010/06/directory-path-of-bash-scrip/</link>
		<comments>http://log.largevoid.com/2010/06/directory-path-of-bash-scrip/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 23:42:27 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[$0]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cwd]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[dirname]]></category>
		<category><![CDATA[path]]></category>
		<category><![CDATA[pwd]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=375</guid>
		<description><![CDATA[So you have a bash script and you want to run it from crontab or some other context where the current working directory isn&#8217;t known. Your script wants to use relative path information (from the script itself), perhaps to create a directory structure in the script&#8217;s base directory. The question is: How do you get [...]]]></description>
			<content:encoded><![CDATA[<p>So you have a bash script and you want to run it from crontab or some other context where the current working directory isn&#8217;t known.  Your script wants to use relative path information (from the script itself), perhaps to create a directory structure in the script&#8217;s base directory.</p>
<p>The question is: How do you get the directory path of the script?  dirname?  Not reliably.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">ABSPATH</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(cd &quot;${0%/*}&quot; 2&gt;/dev/null; echo &quot;$PWD&quot;/&quot;${0##*/}&quot;)</span>&quot;</span>
<span style="color: #007800;">CWD</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dirname</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ABSPATH</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span></pre></div></div>

<p>Nice!</p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2010/06/directory-path-of-bash-scrip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Periodic Tarballs: Find and Awk</title>
		<link>http://log.largevoid.com/2010/06/periodic-tarballs-find-and-awk/</link>
		<comments>http://log.largevoid.com/2010/06/periodic-tarballs-find-and-awk/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 08:43:04 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[cut]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pipe]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=355</guid>
		<description><![CDATA[I have a gang of directories. There&#8217;s a new directory each day! Each directory stores about 20k files. Over time, the performance of the directory hierarchy degrades, and it&#8217;s best for me to tar up old stuff. In linux-land, there&#8217;s always more than one way of doing things&#8230; even if it&#8217;s not the right way. [...]]]></description>
			<content:encoded><![CDATA[<p>I have a gang of directories.  There&#8217;s a new directory each day!  Each directory stores about 20k files.  Over time, the performance of the directory hierarchy degrades, and it&#8217;s best for me to tar up old stuff.</p>
<p>In linux-land, there&#8217;s always more than one way of doing things&#8230; even if it&#8217;s not the right way.  Today, we&#8217;ll explore find piped to awk piped to the shell.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">touch</span> . ; <span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-type</span> d <span style="color: #660033;">-maxdepth</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-mtime</span> +<span style="color: #000000;">60</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;/&quot;</span> <span style="color: #ff0000;">'{print &quot;tar czf &quot; $2 &quot;.tar.gz --remove-files ./&quot; $2 &quot;; rmdir &quot; $2 }'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sh</span></pre></div></div>

<p>Basically, make sure the current direction has been recently modified, so it&#8217;s not returned by the find command.  Then, find all sub-directories in the current directory &#8212; don&#8217;t go recursive.  Sort for a predictable sequence of operations.  Extract the file name portion (lots of ways to do this).  Generate a shell command <code>tar czf {{dirname}}.tar.gz --remove-files ./{{dirname}}; rmdir {{dirname}}</code> to build the tarball and remove the empty directory when done.  Finally, we just tell <code>sh</code> to execute it all&#8230; one directory at a time. Bam!</p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2010/06/periodic-tarballs-find-and-awk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Less-Common Tools for Linux</title>
		<link>http://log.largevoid.com/2010/04/less-common-tools-for-linux/</link>
		<comments>http://log.largevoid.com/2010/04/less-common-tools-for-linux/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 00:41:07 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Reference]]></category>
		<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[dialog]]></category>
		<category><![CDATA[kdialog]]></category>
		<category><![CDATA[logger]]></category>
		<category><![CDATA[notify-send]]></category>
		<category><![CDATA[setleds]]></category>
		<category><![CDATA[setterm]]></category>
		<category><![CDATA[smbclient]]></category>
		<category><![CDATA[sockets]]></category>
		<category><![CDATA[tput]]></category>
		<category><![CDATA[zenity]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=331</guid>
		<description><![CDATA[As found here: 10 Tools to Add Some Spice to Your UNIX Shell Scripts. This is no substitute for the great write-up and screenshots that the author put together. It&#8217;s a summary for myself. The highlights (and how I really feel about them): notify-send (I never knew &#8212; better than tweat deck) tput (eh, maybe) [...]]]></description>
			<content:encoded><![CDATA[<p>As found here: <a href="http://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html">10 Tools to Add Some Spice to Your UNIX Shell Scripts</a>.  This is no substitute for the great write-up and screenshots that the author put together.  It&#8217;s a summary for myself.</p>
<p>The highlights (and how I really feel about them):</p>
<ul>
<li>notify-send (I never knew &#8212; better than tweat deck)</li>
<li>tput (eh, maybe)</li>
<li>setleds (i don&#8217;t have lock-key LEDs on my keyboard)</li>
<li>zenity (has potential)</li>
<li>kdialog (better than zenity?  looks like VB functionality &#8212; good?)</li>
<li>dialog (like kdialog, but uses (n)curses, not kde)</li>
<li>logger (good to know!)</li>
<li>setterm (practical jokes&#8230; and maybe useful for modal/portal stuff)</li>
<li>smbclient (does that still work?  Couldn&#8217;t get past authentication prompt)</li>
<li>bash sockets (interesting&#8230; ICP?  wasteful)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2010/04/less-common-tools-for-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDF to PostScript</title>
		<link>http://log.largevoid.com/2010/03/pdf-to-postscript/</link>
		<comments>http://log.largevoid.com/2010/03/pdf-to-postscript/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 22:36:53 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[identify]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[pdf2ps]]></category>
		<category><![CDATA[pdfimages]]></category>
		<category><![CDATA[pdfinfo]]></category>
		<category><![CDATA[pdftops]]></category>
		<category><![CDATA[poppler]]></category>
		<category><![CDATA[poppler-utils]]></category>
		<category><![CDATA[ps]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/2010/03/pdf-to-postscript/</guid>
		<description><![CDATA[Tired of the ghostscript errors? Try poppler (and poppler-utils). Here&#8217;s my problem. I have these PDFs and they are huge! 500MB. The pdf contents is exactly one page, and it&#8217;s a scanned image. I want to convert each pdf to a png. When I use ImageMagick&#8217;s `convert`, I get this error (followed by a bunch [...]]]></description>
			<content:encoded><![CDATA[<p>Tired of the ghostscript errors?  Try poppler (and poppler-utils).</p>
<p>Here&#8217;s my problem.  I have these PDFs and they are huge! 500MB.  The pdf contents is exactly one page, and it&#8217;s a scanned image. I want to convert each pdf to a png.  When I use ImageMagick&#8217;s `convert`, I get this error (followed by a bunch of rubbish):</p>
<pre>$ convert 01.pdf 01.ps
   **** Warning:  An error occurred while reading an XREF table.
   **** The file has been damaged.  This may have been caused
   **** by a problem while converting or transfering the file.
   **** Ghostscript will attempt to recover the data.</pre>
<p> &#8211; Enter poppler -</p>
<p>Install poppler-utils (for pdftops)<br />
<code>$ sudo yum install poppler-utils</code></p>
<p>What do I get when I install poppler-utils?  <q>This package contains pdftops (PDF to PostScript converter), pdfinfo (PDF document information extractor), pdfimages (PDF image extractor), pdftohtml (PDF to HTML converter), pdftotext (PDF to text converter), and pdffonts (PDF font analyzer).</q> <cite><a href="http://packages.debian.org/sid/poppler-utils">packages.debian.org</a></cite></p>
<p>Let&#8217;s look at basic metadata</p>
<pre>$ pdfinfo 01.pdf
Producer:       Adobe Photoshop for Macintosh
CreationDate:   Fri Mar 12 17:03:08 2010
ModDate:        Fri Mar 12 23:12:35 2010
Tagged:         no
Pages:          1
Encrypted:      no
Page size:      4114.32 x 3270.72 pts
File size:      450186770 bytes
Optimized:      yes
PDF version:    1.7
</pre>
<p>Now at document-level metadata, including true pixel resolution.<br />
Redundant? Yes, I noticed this too &#8212; but look, there&#8217;s more!</p>
<pre>$ pdfinfo -meta 01.pdf | more
Producer:       Adobe Photoshop for Macintosh
CreationDate:   Fri Mar 12 17:03:08 2010
ModDate:        Fri Mar 12 23:12:35 2010
Tagged:         no
Pages:          1
Encrypted:      no
Page size:      <strong>4114</strong>.32 x <strong>3270</strong>.72 <strong>pts</strong>
File size:      450186770 bytes
Optimized:      yes
PDF version:    1.7
Metadata:
&lt;?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?&gt;
&lt;x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2.1-c041 52.342996
, 2008/05/07-21:37:19        "&gt;
 &lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&gt;
 &lt;rdf:Description rdf:about=""
 xmlns:tiff="http://ns.adobe.com/tiff/1.0/"&gt;
 &lt;tiff:<strong>ImageWidth</strong>&gt;17143&lt;/tiff:ImageWidth&gt;
 &lt;tiff:<strong>ImageLength</strong>&gt;13628&lt;/tiff:ImageLength&gt;
 &lt;tiff:Compression&gt;5&lt;/tiff:Compression&gt;
 &lt;tiff:PhotometricInterpretation&gt;2&lt;/tiff:PhotometricInterpretation&gt;
 &lt;tiff:Orientation&gt;1&lt;/tiff:Orientation&gt;
 &lt;tiff:SamplesPerPixel&gt;3&lt;/tiff:SamplesPerPixel&gt;
 &lt;tiff:PlanarConfiguration&gt;1&lt;/tiff:PlanarConfiguration&gt;
 &lt;tiff:<strong>XResolution</strong>&gt;3000000/10000&lt;/tiff:XResolution&gt;
 &lt;tiff:<strong>YResolution</strong>&gt;3000000/10000&lt;/tiff:YResolution&gt;
 &lt;tiff:ResolutionUnit&gt;2&lt;/tiff:ResolutionUnit&gt;
 &lt;tiff:NativeDigest&gt;256,257,258,259,262,274,277,284,530,531,282,283,296,
301,318,319,529,532,306,270,271,272,305,315,33432;B4FF87F3DB26D93C7CFD5C3C5C66BE
9E&lt;/tiff:NativeDigest&gt;
 &lt;tiff:BitsPerSample&gt;
 &lt;rdf:Seq&gt;
 &lt;rdf:li&gt;8&lt;/rdf:li&gt;
 &lt;rdf:li&gt;8&lt;/rdf:li&gt;
 &lt;rdf:li&gt;8&lt;/rdf:li&gt;
 &lt;/rdf:Seq&gt;
 &lt;/tiff:BitsPerSample&gt;
 &lt;/rdf:Description&gt;
 ... edited for brevity ...
</pre>
<p>Look! We found the image dimensions: 17143px by 13628px.  </p>
<p>Ok, so why is it that when I run `pdftops` to convert from pdf to ps, followed by ImageMagick&#8217;s `convert` from ps to png, I get an image that&#8217;s 4114&#215;3270 pixels?  I want the full resolution!<br />
<strong>Warning, this snippet is incorrect</strong></p>
<pre>$ pdftops 01.pdf 01.ps
$ convert 01.ps 01.png
$ identify 01.png
01.png PNG 4115x3271 4115x3271+0+0 DirectClass 24mb
</pre>
<p>I must be missing something. &#8230; so it is.  I overlooked `<em>pdfimages</em>`.</p>
<p><strong>Proper conversion found here</strong></p>
<pre>$ pdfimages -j 01.pdf img
$ ls
01.pdf img-000.ppm
$ identify img-000.ppm
img-000.ppm PNM 17143x13628 17143x13628+0+0 DirectClass 6.7e+02mb 4.110u 0:05
</pre>
<p>Lookie there: full resolution&#8230; in a .PPM file?  Who cares if ImageMagick can handle it! </p>
<p><strong>From PPM to PNG (like I wanted)</strong></p>
<pre>$ convert img-000.ppm img-000.png
$ identify img-000.png
img-000.png PNG 17143x13628 17143x13628+0+0 DirectClass 3.5e+02mb 12.540u 0:14
</pre>
<p>And there you have it &#8211; Stupid PDF converted to awesome full resolution PNG.</p>
<p>Thank you, come again.</p>
<p>Reference: <a href="http://stefaanlippens.net/pdf2ps_vs_pdftops">http://stefaanlippens.net/pdf2ps_vs_pdftops</a></p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2010/03/pdf-to-postscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recursive directory merge</title>
		<link>http://log.largevoid.com/2010/03/recursive-directory-merge/</link>
		<comments>http://log.largevoid.com/2010/03/recursive-directory-merge/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 01:08:00 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Reference]]></category>
		<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[cp]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[filies]]></category>
		<category><![CDATA[move]]></category>
		<category><![CDATA[mv]]></category>
		<category><![CDATA[path]]></category>
		<category><![CDATA[recursive]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=309</guid>
		<description><![CDATA[Problem: I have two directories that are similar in structure but different in content. Say one is an older snapshot of the other. I want to copy the stuff from the new directory into the old directory (recursively). Copy: rsync -a SOURCE/ DEST/ --ignore-existing --whole-file Move (no clobber): rsync -a SOURCE/ DEST/ --remove-sent-files --ignore-existing --whole-file [...]]]></description>
			<content:encoded><![CDATA[<p>Problem: I have two directories that are similar in structure but different in content.  Say one is an older snapshot of the other.  I want to copy the stuff from the new directory into the old directory (recursively).</p>
<p>Copy:<br />
<code>rsync -a SOURCE/ DEST/ --ignore-existing --whole-file</code></p>
<p>Move (no clobber):<br />
<code>rsync -a SOURCE/ DEST/ --remove-sent-files --ignore-existing --whole-file</code></p>
<p>Move (and clobber):<br />
<code>rsync -a SOURCE/ DEST/ --remove-sent-files --whole-file</code></p>
<p>Move, but only update with newer:<br />
<code>rsync -a SOURCE/ DEST/ --remove-sent-files --update --whole-file</code></p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2010/03/recursive-directory-merge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git: Recovering a file that you deleted</title>
		<link>http://log.largevoid.com/2010/03/git-recovering-a-file-that-you-deleted/</link>
		<comments>http://log.largevoid.com/2010/03/git-recovering-a-file-that-you-deleted/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 21:02:36 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[branch]]></category>
		<category><![CDATA[checkout]]></category>
		<category><![CDATA[commit]]></category>
		<category><![CDATA[deleted]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[recover]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[restore]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=304</guid>
		<description><![CDATA[You might be doing some spring cleaning to your source code, or you might move files around that you think are unnecessary. Later on, you realize that one of the files you removed was a dependency. Now what? For this, we use git checkout. If this is you: ...edit files... git add edited-file git commit [...]]]></description>
			<content:encoded><![CDATA[<p>You might be doing some spring cleaning to your source code, or you might move files around that you think are unnecessary.  Later on, you realize that one of the files you removed was a dependency.  Now what?  For this, we use <code>git checkout</code>.</p>
<p>If this is you:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">...edit files...
<span style="color: #c20cb9; font-weight: bold;">git</span> add edited-file
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;made changed&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> seemingly-useless-file
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;removed unreferenced dependency&quot;</span>
... edit <span style="color: #c20cb9; font-weight: bold;">file</span> ... realize you dynamically included that <span style="color: #c20cb9; font-weight: bold;">file</span> elsewhere..</pre></div></div>

<p>Then you can simply follow up with:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> checkout 0a323 <span style="color: #000000; font-weight: bold;">//</span> the previous revision <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">hash</span> from <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">git</span> log<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #c20cb9; font-weight: bold;">cp</span> seemingly-useless-file seemingly-useless-file.1
<span style="color: #c20cb9; font-weight: bold;">git</span> checkout master
<span style="color: #c20cb9; font-weight: bold;">mv</span> seemingly-useless-file.1 seemingly-useless-file
<span style="color: #c20cb9; font-weight: bold;">git</span> add seemingly-useless-file
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Restored seemingly-useless-file&quot;</span></pre></div></div>

<p>You may want to <code>git blame</code> yourself while you&#8217;re at it.</p>
<p>If you know of a better way, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2010/03/git-recovering-a-file-that-you-deleted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Untrack Files with Git</title>
		<link>http://log.largevoid.com/2009/12/untrack-files-with-git/</link>
		<comments>http://log.largevoid.com/2009/12/untrack-files-with-git/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 04:22:21 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Reference]]></category>
		<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[cached]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[untrack]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=258</guid>
		<description><![CDATA[When I found this little gem, I couldn&#8217;t not (double negative for emphasis) store it for reference. git rm --cached filename Don&#8217;t worry, it won&#8217;t remove your local copy. It just stages it for removal from the history of tracked files. Reference: untrack files in git]]></description>
			<content:encoded><![CDATA[<p>When I found this little gem, I couldn&#8217;t not (double negative for emphasis) store it for reference.</p>
<p><code>git rm --cached filename</code></p>
<p>Don&#8217;t worry, it won&#8217;t remove your local copy.  It just stages it for removal from the history of tracked files.</p>
<p>Reference:<br />
  <a href="http://source.kohlerville.com/?p=149">untrack files in git</a></p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2009/12/untrack-files-with-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP/GD Bug: imageFilledEllipse Centered on Y=0</title>
		<link>http://log.largevoid.com/2009/11/phpgd-bug-imagefilledellipse-centered-on-y0/</link>
		<comments>http://log.largevoid.com/2009/11/phpgd-bug-imagefilledellipse-centered-on-y0/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 23:04:43 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[imageFilledEllipse]]></category>
		<category><![CDATA[imageFilledRectangle]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=145</guid>
		<description><![CDATA[I was drawing circles using PHP&#8217;s GD function imageFilledEllipse. I noticed that when I went to draw a circle having its center at $y=0,there would be a line missing at $y=1. Here&#8217;s the work-around: if&#40; -1 &#60;= $py &#38;&#38; $py &#60;= 1 &#41; &#123; // Undocumented PHP bug when Y coordinate is zero. imageFilledEllipse&#40;$img,$px,$py,$X,$X,$color&#41;; imageFilledRectangle&#40;$img,$px-$halfX,$py-1,$px+$halfX,$py+1,$color&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>I was drawing circles using PHP&#8217;s GD function <a href="http://us3.php.net/manual/en/function.imagefilledellipse.php"><em>imageFilledEllipse</em></a>.  I noticed that when I went to draw a circle having its center at $y=0,there would be a line missing at $y=1.</p>
<p>Here&#8217;s the work-around:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">&lt;=</span> <span style="color: #000088;">$py</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$py</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// Undocumented PHP bug when Y coordinate is zero.</span>
  <span style="color: #990000;">imageFilledEllipse</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #339933;">,</span><span style="color: #000088;">$px</span><span style="color: #339933;">,</span><span style="color: #000088;">$py</span><span style="color: #339933;">,</span><span style="color: #000088;">$X</span><span style="color: #339933;">,</span><span style="color: #000088;">$X</span><span style="color: #339933;">,</span><span style="color: #000088;">$color</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">imageFilledRectangle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #339933;">,</span><span style="color: #000088;">$px</span><span style="color: #339933;">-</span><span style="color: #000088;">$halfX</span><span style="color: #339933;">,</span><span style="color: #000088;">$py</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #000088;">$px</span><span style="color: #339933;">+</span><span style="color: #000088;">$halfX</span><span style="color: #339933;">,</span><span style="color: #000088;">$py</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #000088;">$color</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #990000;">imageFilledEllipse</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #339933;">,</span><span style="color: #000088;">$px</span><span style="color: #339933;">,</span><span style="color: #000088;">$py</span><span style="color: #339933;">,</span><span style="color: #000088;">$X</span><span style="color: #339933;">,</span><span style="color: #000088;">$X</span><span style="color: #339933;">,</span><span style="color: #000088;">$color</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>PHP Version:</p>
<pre>PHP 4.3.9 (cgi) (built: Apr  1 2009 10:41:42)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies</pre>
<p><code>$ yum search php-gd</code></p>
<pre>
php-gd.i386                              4.3.9-3.26             installed
Matched from:
php-gd
The php-gd package contains a dynamic shared object that will add
support for using the gd graphics library to PHP.
</pre>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2009/11/phpgd-bug-imagefilledellipse-centered-on-y0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Plugins &#8211; Playground</title>
		<link>http://log.largevoid.com/2009/11/wordpress-plugins-playground/</link>
		<comments>http://log.largevoid.com/2009/11/wordpress-plugins-playground/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 03:51:24 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp-syntax]]></category>
		<category><![CDATA[wp-terminal]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=43</guid>
		<description><![CDATA[I just installed wp-syntax and wp-terminal and want to see a demo. wp-syntax 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 [...]]]></description>
			<content:encoded><![CDATA[<p>I just installed wp-syntax and wp-terminal and want to see a demo.<span id="more-43"></span></p>
<h2>wp-syntax</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #009933; font-style: italic;">/**
  * Since every project has an acquire and insert, and most of those
  * projects have the same mechanisms of acquisition and insertion,
  * we create this class to handle these mundane operations.
  *
  * @file BaseProject.php
  * @date 2009-07-28 15:00 HST
  * @author &lt;nobody&gt;
  * @version 1.0.0
  *
  * @modifications
  * 1.0.0 - 2009-07-28 - Created
  */</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> BaseProject <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$DB_NAME</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$TABLE_NAME</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$MAX_RECORDS</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">32767</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$DEBUG</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> BaseProject<span style="color: #009900;">&#40;</span><span style="color: #000088;">$db</span><span style="color: #339933;">=</span>DB_NAME<span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #339933;">=</span>TABLE_NAME<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DB_NAME</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$db</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">TABLE_NAME</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$table</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> getAcquireUrl<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ts</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enotice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;getAcquireUrl: Abstract function.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> getRecords<span style="color: #009900;">&#40;</span><span style="color: #000088;">$fpath</span><span style="color: #339933;">,&amp;</span><span style="color: #000088;">$records</span><span style="color: #339933;">,</span><span style="color: #000088;">$start</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$limit</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$records</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$records</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enotice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;getRecords: Abstract function.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> getHeader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">header</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
      <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">header</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;header&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;header&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enotice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;getHeader: Abstract function.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> getOutputFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ts</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$ts</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$ts</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%s</span>/<span style="color: #009933; font-weight: bold;">%s</span>/<span style="color: #009933; font-weight: bold;">%s</span>/<span style="color: #009933; font-weight: bold;">%s</span>_<span style="color: #009933; font-weight: bold;">%s</span>.dat&quot;</span><span style="color: #339933;">,</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDataDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      <span style="color: #990000;">gmdate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">gmdate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Ymd&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">TABLE_NAME</span><span style="color: #339933;">,</span> <span style="color: #990000;">gmdate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;YmdHis&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> getDataDirectory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> DATASTORE_DATA_PRIMARY<span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DB_NAME</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">TABLE_NAME</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> getStateFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$op</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%s</span>.<span style="color: #009933; font-weight: bold;">%s</span>.state&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">TABLE_NAME</span><span style="color: #339933;">,</span><span style="color: #000088;">$op</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> getInsertStateFile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStateFile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'insert'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> getAcquireStateFile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStateFile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'acquire'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> acquire<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$ts</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$ts</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$ts</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">is_null</span><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: #009900;">&#123;</span>
      <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAcquireUrl</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$url</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enotice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Url not valid: <span style="color: #006699; font-weight: bold;">$url</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$opath</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOutputFile</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DEBUG</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DEBUG: Filesystem::mkdir(&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$opath</span><span style="color: #009900;">&#41;</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: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
      Filesystem<span style="color: #339933;">::</span><span style="color: #990000;">mkdir</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$opath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$cmd</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">&quot;wget -qq <span style="color: #009933; font-weight: bold;">%s</span> -O <span style="color: #009933; font-weight: bold;">%s</span>&quot;</span><span style="color: #339933;">,</span>
      <span style="color: #990000;">escapeshellarg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      <span style="color: #990000;">escapeshellarg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$opath</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notice</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cmd</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DEBUG</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DEBUG: system(<span style="color: #006699; font-weight: bold;">$cmd</span>,retVal);<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DEBUG: setLastAcquireTime(<span style="color: #006699; font-weight: bold;">$ts</span>);<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$retVal</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #990000;">system</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cmd</span><span style="color: #339933;">,</span><span style="color: #000088;">$retVal</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLastAcquireTime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$retVal</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// END: function acquire($url=null)</span>
&nbsp;
&nbsp;
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> insert<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Startup&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$t0</span> <span style="color: #339933;">=</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$header</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getHeader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$header</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enotice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Couldn't get header.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$archiver</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Archiver<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DB_NAME</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">TABLE_NAME</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$archiver</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enotice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Archiver not found!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$archiver</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isLocked</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Archive is locked, that is all...&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$fpaths</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">listFiles</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLastInsertTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$nFiles</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fpaths</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nFiles</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Nothing to do...&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$fileCounter</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$records</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$fpaths</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$fpath</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Processing: &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fpath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #990000;">set_time_limit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$fileCounter</span> <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
      <span style="color: #000088;">$records</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRecords</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fpath</span><span style="color: #339933;">,</span><span style="color: #000088;">$records</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$records</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">MAX_RECORDS</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$fileCounter</span> <span style="color: #339933;">&gt;=</span> <span style="color: #000088;">$nFiles</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Archiving...&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DEBUG</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DEBUG: archiver-&gt;replace(records,header);<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DEBUG: <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span>Arrays<span style="color: #339933;">::</span><span style="color: #004000;">formatMatrixAscii</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array_slice</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$records</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</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: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$archiver</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$records</span><span style="color: #339933;">,</span><span style="color: #000088;">$header</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enotice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Couldn't archive!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ok.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$records</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DEBUG</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DEBUG: setLastInsertTime(<span style="color: #006699; font-weight: bold;">$t0</span>);<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLastInsertTime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$t0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Shutdown&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> listFiles<span style="color: #009900;">&#40;</span><span style="color: #000088;">$t0</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$limit</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$dl</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DirectoryListing<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDataDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$dl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRecursive</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$dl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIncludeFiles</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$dl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIncludeDirectories</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$dl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setUseFullPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$dl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLimit</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$files</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getListing</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$files</span><span style="color: #339933;">===</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enotice</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;getListing returned false: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDataDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #990000;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$files</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$t0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #000088;">$files</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$keepers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$files</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$fpath</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">filemtime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fpath</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$t0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$keepers</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$fpath</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$keepers</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// END: function listFiles($t0=null)</span>
&nbsp;
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> setLastAcquireTime<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> Filesystem<span style="color: #339933;">::</span><span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAcquireStateFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// END: function setLastAcquireTime($ts)</span>
&nbsp;
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> getLastAcquireTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$fpath</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAcquireStateFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fpath</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">intVal</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fpath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// END: function getLastAcquireTime()</span>
&nbsp;
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> setLastInsertTime<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> Filesystem<span style="color: #339933;">::</span><span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getInsertStateFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// END: function setLastInsertTime($ts)</span>
&nbsp;
&nbsp;
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> getLastInsertTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$fpath</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getInsertStateFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fpath</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">intVal</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fpath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// END: function getLastInsertTime()</span>
&nbsp;
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> enotice<span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notice</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> notice<span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #339933;">,</span><span style="color: #000088;">$isError</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$isError</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #990000;">error_log</span><span style="color: #009900;">&#40;</span>
        <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%s</span> - <span style="color: #009933; font-weight: bold;">%s</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">gmstrftime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;%Y-%m-<span style="color: #009933; font-weight: bold;">%d</span> %H:%M:%S&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #990000;">rtrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%s</span> - <span style="color: #009933; font-weight: bold;">%s</span><span style="color: #009933; font-weight: bold;">%s</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">gmstrftime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;%Y-%m-<span style="color: #009933; font-weight: bold;">%d</span> %H:%M:%S&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #990000;">rtrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>PHP_EOL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// END: class BaseProject</span></pre></td></tr></table></div>

<h2>wp-terminal</h2>
<p>Did not work as advertised.</p>
<p>Using these plugins with &lt; and &gt; present in the code is a pain!</p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2009/11/wordpress-plugins-playground/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>STDERR redirect into STDOUT redirect into file</title>
		<link>http://log.largevoid.com/2009/10/stderr-redirect-into-stdout-redirect-into-file/</link>
		<comments>http://log.largevoid.com/2009/10/stderr-redirect-into-stdout-redirect-into-file/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 02:00:08 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[redirect]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=12</guid>
		<description><![CDATA[When you want to redirect stderr to a file, you have choices.  Either redirect only stderr to a file, or redirect both stderr and stdout to the same file. The right way: Redirect stderr and stdout to [[file]]: [[command]] &#62; [[file]] 2&#62;&#38;1 Redirect stderr to [[efile]] and stdout to [[file]]: [[command]] 2&#62; [[efile]] &#62; [[file]] [...]]]></description>
			<content:encoded><![CDATA[<p>When you want to redirect stderr to a file, you have choices.  Either redirect only stderr to a file, or redirect both stderr and stdout to the same file.</p>
<p><strong>The right way:</strong></p>
<p>Redirect stderr and stdout to [[file]]:</p>
<p><code>[[command]] &gt; [[file]] 2&gt;&amp;1</code></p>
<p>Redirect stderr to [[efile]] and stdout to [[file]]:</p>
<p><code>[[command]] 2&gt; [[efile]] &gt; [[file]]</code></p>
<p><strong>The wrong way:</strong></p>
<p>Doesn’t do anything useful:</p>
<p><code>[[command]] 2&gt;&amp;1 &gt; [[file]]</code></p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2009/10/stderr-redirect-into-stdout-redirect-into-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Summing a list of numbers</title>
		<link>http://log.largevoid.com/2009/10/summing-a-list-of-numbers/</link>
		<comments>http://log.largevoid.com/2009/10/summing-a-list-of-numbers/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 02:00:40 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Scripts, Tricks and Hacks]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://log.largevoid.com/?p=10</guid>
		<description><![CDATA[awk '{sum += $0} END {print sum}' Example: % find . -type f -exec wc {} \; &#124; tr -s " " &#124; cut -f2 -d" " &#124; awk '{sum += $0} END {print sum}' What’s going on? I want to recursively count the number of lines present in all files contained by the current [...]]]></description>
			<content:encoded><![CDATA[<p><code>awk '{sum += $0} END {print sum}'</code></p>
<p>Example:<code><br />
% find . -type f -exec wc {} \; | tr -s " " | cut -f2 -d" " | awk '{sum += $0} END {print sum}'</code></p>
<p>What’s going on? I want to recursively count the number of lines present in all files contained by the current directory. Why? Sub-directories =&gt; namespaces, and I want to know how many lines of code exist in the entire project, namespaces and all.</p>
]]></content:encoded>
			<wfw:commentRss>http://log.largevoid.com/2009/10/summing-a-list-of-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  log.largevoid.com/cat/scripts-tricks-hacks/feed/ ) in 1.04237 seconds, on Feb 8th, 2012 at 1:02 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 8th, 2012 at 2:02 pm UTC -->
