<?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>James Fishwick</title>
	<atom:link href="http://jamesfishwick.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamesfishwick.com</link>
	<description>Web developer based in Charlottesvile, VA.</description>
	<lastBuildDate>Tue, 07 Feb 2012 03:06:14 +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>jolicloud as music server</title>
		<link>http://jamesfishwick.com/2012/jolicloud-as-music-server/</link>
		<comments>http://jamesfishwick.com/2012/jolicloud-as-music-server/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 03:02:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[media server]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://jamesfishwick.com/?p=287</guid>
		<description><![CDATA[<p>Got an old IBM Thinkpad T41, probably 6 or 5 six years old: Intel Pentium 1.6GHz, 748.8Mb RAM, 30GB harddrive. Had plans for some sort of media server: maybe VortexBox, maybe Plex, maybe XBMC (I didn&#8217;t really actually know much &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Got an old IBM Thinkpad T41, probably 6 or 5 six years old: Intel Pentium 1.6GHz, 748.8Mb RAM, 30GB harddrive. Had plans for some sort of media server: maybe VortexBox, maybe Plex, maybe XBMC (I didn&#8217;t really actually know much about any of these, just that they could run on old machines, and you know, <em>stream shit</em>). The machine has XP on it, completely wiped of any and all anything else than then day it was first turned on. So at first I just did some driver updates and installed iTunes and Chrome. iTunes was just playing our shared iTunes libraries via Home Sharing and I had Chrome for MOG. Whee, except even using MOG with the latest version of Chrome was horribly slow, and I realized more than ever what a sluggish, bloated POS iTunes has become.</p>
<p>So the laptop is old and slow, and we don&#8217;t really watch movies or TV or play video games. So these heavy duty media server installs are too much, clearly. We want to play music, and maybe be able to hop onto allmusic.com or wikipedia for some fact-checking. We want to use mainly web-based streaming apps like MOG, Spotify and last.fm, be able to listen to NPR and other podcasts, watch/listen to stuff on youtube, and play from our iTunes libraries remotely. Hmm, barring that last requirement, doesn&#8217;t it just sound like what I really need is a Chromebook (Google&#8217;s netbook? Say, can I install Chrome OS on my machine? <a href="http://lifehacker.com/5820358/how-to-turn-your-netbook-into-a-chromebook-with-chromium-os" target="_blank">No, but you can install Chromium OS and it might not work amazingly well</a>. Read through that post and its one of those that keeps us all afraid of Linux. But check the comments and enter Jolicloud OS!</p>
<p><img class="alignnone size-full wp-image-295" title="jolicloud-12-08-2010" src="http://jamesfishwick.com/wp-content/uploads/2012/02/jolicloud-12-08-2010.jpg" alt="" width="600" height="352" /></p>
<p><span id="more-287"></span></p>
<p>Joli OS is built on top of Ubuntu, tweaked for netbooks and other computers with limited disk storage, memory, and screen size. Joli OS was designed for easy installation, with Wi-Fi, Bluetooth, and 3G modem support all included. Jolicloud claims the OS supports 98% of netbooks with out-of-the-box compatibility but also works on a very large number of other devices, up to 10 years old: laptops, desktops and tablets. Bottom line is it just worked for me.</p>
<p>The natural comparison in look and function is iOS, the operating system used by the Apple iPad/iPhone, though with the folders and files and CLI of a conventional Linux install tucked deep away. The user interface is built primarily in HTML5 that includes an application launcher and a library of compatible applications with one-click installation and removal.</p>
<p>Boxee, Dropbox, VLC, Skype and Google Chrome are all featured as one-click installs. So are Gmail, Google Maps, Wikipedia, MOG and Facebook. Many of the applications available to Jolicloud users are, in fact, websites but really, of course, better thought of as applications. Open any of these up, and you get the website, e.g. Gmail, as program in a heavily tweaked full-screen browser, minus most of the browser toolbars and menus. You don&#8217;t need that browser stuff though for these web apps, so when you browse, you can just browser and not waste your tabs on the web apps.</p>
<p>The distinction is further broken down in your one-click dashboard apps (a mixture of mostly web-apps and some local programs) and &#8220;native&#8221; apps like gedit, terminal, gnome settings, etc. If you know what you&#8217;re doing you can add whatever to your installation and put shortcuts in your &#8220;local apps&#8221; folder on you application launcher/dash, but not your dash proper, which is annoying. For example, if you install last.fm as an app through Joli, it just gives you the web app, whilst there is a perfectly good linux port of the superior last.fm scrobbler program. So I added it through apt and I wish I could get it directly onto the main launching area rather than having to add it as a shortcut in a folder on my main area. But there are some workarounds like adding it to the little upper &#8220;taskbar&#8221; and I don&#8217;t foresee adding many other programs, since Joli makes intelligent choices about whether to give me the web app or real app otherwise.</p>
<p>Anyway, blathering on. Some tips and tricks for this setup soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesfishwick.com/2012/jolicloud-as-music-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>total directory size hold the extra foo</title>
		<link>http://jamesfishwick.com/2012/total-directory-size-hold-the-extra-foo/</link>
		<comments>http://jamesfishwick.com/2012/total-directory-size-hold-the-extra-foo/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 19:37:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CLI]]></category>
		<category><![CDATA[Code Snippet]]></category>

		<guid isPermaLink="false">http://jamesfishwick.com/?p=284</guid>
		<description><![CDATA[&#8230;]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash; title: ; notranslate">du -h | tail -n 1</pre>
]]></content:encoded>
			<wfw:commentRss>http://jamesfishwick.com/2012/total-directory-size-hold-the-extra-foo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bash find and boolean operators</title>
		<link>http://jamesfishwick.com/2012/linux-find-and-boolean-operators/</link>
		<comments>http://jamesfishwick.com/2012/linux-find-and-boolean-operators/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 17:02:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CLI]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[Note to Self]]></category>

		<guid isPermaLink="false">http://jamesfishwick.com/?p=271</guid>
		<description><![CDATA[<p>Just because it took me way too long this morning to figure out how Boolean operators work with <code>find</code>.</p>
<p>Suppose I want to find the files with .png and .jpg extensions.</p>
<p>Its not </p>
<p>but</p>
<p>The &#8220;-and&#8221; refers to one &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Just because it took me way too long this morning to figure out how Boolean operators work with <code>find</code>.</p>
<p>Suppose I want to find the files with .png and .jpg extensions.</p>
<p>Its not </p>
<pre class="brush: bash; title: ; notranslate">$ find /path/ -name '*.png' -and -name '*.jpg'</pre>
<p>but</p>
<pre class="brush: bash; title: ; notranslate">$ find /path/ -name '*.png' -or -name '*.jpg'</pre>
<p>The &#8220;-and&#8221; refers to one set of file names where both conditions are met (as if we didn&#8217;t use the boolean at all). The &#8220;-or&#8221; says I&#8217;m looking for either/both of two sets.</p>
<p>So to explain further: <span id="more-271"></span></p>
<pre class="brush: bash; title: ; notranslate">$ find . -iname david\ bowie\*ogg -type f &gt; david_bowie.m3u</pre>
<p>(This will find any files called, in one way or the other, &#8220;david bowie&#8230;.ogg&#8221; and write that list to a .m3u file.)</p>
<p>Per above this  is semantically equivalent to:</p>
<pre class="brush: bash; title: ; notranslate">$ find . -iname david\ bowie\*ogg -and -type f &gt; david_bowie.m3u</pre>
<p>And equivalent to:</p>
<pre class="brush: bash; title: ; notranslate">$ find . -iname &quot;david bowie*ogg&quot; -a -type f &gt; david_bowie.m3u</pre>
<p>So the <code>and</code> isn&#8217;t usually so helpful &#8211; <em>its implied by the succession or arguments</em>.</p>
<p>If you wanted to find all files that aren&#8217;t owned by a user, you could use the -not operator:</p>
<pre class="brush: bash; title: ; notranslate">$ find -not -user jfishwick</pre>
<p>It&#8217;s also possible to have one invocation of find perform more than one task with using &#8220;and,&#8221; &#8220;or,&#8221; or &#8220;not.&#8221; Use the &#8220;,&#8221; operator. The gotcha here is that <em>the value of the list returned is the value of the last expression</em>. The other values are thrown away unless we do something with them immediately.</p>
<p>So, to compile two lists, one containing the names of all .php files and the other the names of all .js files use:</p>
<pre class="brush: bash; title: ; notranslate">$ find ~ -type f \( -name \*.php -fprint php_files ,
                    -name \*.js -fprint javascript_files \)</pre>
<p>A summary of the operators, Listed in order of decreasing precedence:</p>
<pre class="brush: bash; title: ; notranslate">( expr )</pre>
<p>Force precedence.</p>
<pre class="brush: bash; title: ; notranslate">-not expr</pre>
<p>True if expr is false. With find, matches everything but this expressed value.</p>
<pre class="brush: bash; title: ; notranslate">! expr</pre>
<p>Same as -not expr. </p>
<pre class="brush: bash; title: ; notranslate">expr1 -and expr2</pre>
<p>expr2 is not evaluated if expr1 is false. So with <code>find</code>, only returns matches that meet both criteria.</p>
<pre class="brush: bash; title: ; notranslate">expr1 expr2</pre>
<p>And (implied); same as above</p>
<pre class="brush: bash; title: ; notranslate">expr1 -a expr2</pre>
<p>Same as expr1 expr2.</p>
<pre class="brush: bash; title: ; notranslate">expr1 -or expr2</pre>
<p>Or; expr2 is not evaluated if expr1 is true. With <code>find</code> return if either expression matches the list.</p>
<pre class="brush: bash; title: ; notranslate">expr1 -o expr2</pre>
<p>Same as expr1 -or expr2.</p>
<pre class="brush: bash; title: ; notranslate">expr1 , expr2</pre>
<p>List; both expr1 and expr2 are always evaluated. The value of expr1 is discarded; the value of the list is the value of expr2.</p>
<p>One last note, using <code>-exec</code> at the end of a long boolean chain will only effect the last option and expression.</p>
<p>If I try</p>
<pre class="brush: bash; title: ; notranslate">$ find -iname \*asx -or -iname \*clean.txt -or -iname \*dvdIt.txt -or -iname \*.qt.\* -or -iname \*.rt\* -or -iname \*scc -or -iname \*sdf -or -iname \*smi -or -iname \*srt -or -iname \*stl -exec rm -rf {} \;</pre>
<p>only the <code>*.stl</code> files would get deleted. To pass everything on, use <code>xargs</code>, natch.</p>
<pre class="brush: bash; title: ; notranslate">$find -iname \*asx -or -iname \*clean.txt -or -iname \*dvdIt.txt -or -iname \*.qt.\* -or -iname \*.rt\* -or -iname \*scc -or -iname \*sdf -or -iname \*smi -or -iname \*srt -or -iname \*stl | xargs rm -rf</pre>
]]></content:encoded>
			<wfw:commentRss>http://jamesfishwick.com/2012/linux-find-and-boolean-operators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On the Cloud</title>
		<link>http://jamesfishwick.com/2012/on-the-cloud/</link>
		<comments>http://jamesfishwick.com/2012/on-the-cloud/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 02:32:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://jamesfishwick.com/?p=267</guid>
		<description><![CDATA[<p>Yes, now running a Bitnami WordPress package on an Amazon EC2 instance. Still tweaking, but very cool stuff so far!&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Yes, now running a Bitnami WordPress package on an Amazon EC2 instance. Still tweaking, but very cool stuff so far!</p>
<div style='text-align:center;'>
<object type="application/x-shockwave-flash" width="400" height="300" data="http://www.vimeo.com/moogaloop.swf?clip_id=1335711&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=01AAEA">
	<param name="quality" value="best" />
	<param name="allowfullscreen" value="true" />
	<param name="scale" value="showAll" />
	<param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=1335711&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=01AAEA" />
	<param name="wmode" value="opaque" />
</object>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jamesfishwick.com/2012/on-the-cloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Download a list of HTML pages with dependencies</title>
		<link>http://jamesfishwick.com/2012/download-a-list-of-html-pages-with-dependencies/</link>
		<comments>http://jamesfishwick.com/2012/download-a-list-of-html-pages-with-dependencies/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 14:07:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CLI]]></category>
		<category><![CDATA[Code Snippet]]></category>

		<guid isPermaLink="false">http://www.jamesfishwick.com/?p=255</guid>
		<description><![CDATA[<p>Where &#8216;list.txt&#8217; is a list of URLs separated by line breaks.</p>
<p>If you aren&#8217;t interested in certain files, say images, there is a further flag to reject certain file types:</p>
<p>I love <a href="http://www.gnu.org/software/wget/manual/wget.html" target="_blank">wget</a>!</p>
<p><img class="alignleft size-full wp-image-257" title="gnu-head-sm" src="http://jamesfishwick.com/wp-content/uploads/2012/01/gnu-head-sm.jpg" alt="" width="129" height="122" /></p>
<p>&#160;&#8230;</p>]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash; title: ; notranslate">wget --page-requisites -i list.txt</pre>
<p>Where &#8216;list.txt&#8217; is a list of URLs separated by line breaks.</p>
<p>If you aren&#8217;t interested in certain files, say images, there is a further flag to reject certain file types:</p>
<pre class="brush: bash; title: ; notranslate">--reject=gif,jpg,png</pre>
<p>I love <a href="http://www.gnu.org/software/wget/manual/wget.html" target="_blank">wget</a>!</p>
<p><img class="alignleft size-full wp-image-257" title="gnu-head-sm" src="http://jamesfishwick.com/wp-content/uploads/2012/01/gnu-head-sm.jpg" alt="" width="129" height="122" /></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesfishwick.com/2012/download-a-list-of-html-pages-with-dependencies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Conditional Tags for Custom Post Types &amp; Taxonomies</title>
		<link>http://jamesfishwick.com/2012/conditional-tags-for-custom-post-types-taxonomies/</link>
		<comments>http://jamesfishwick.com/2012/conditional-tags-for-custom-post-types-taxonomies/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 01:34:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[Note to Self]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.jamesfishwick.com/?p=253</guid>
		<description><![CDATA[<p>Most WordPress instances used to power a full site or shop will hopefully take advantage of the power combination of Custom Taxonomies and Custom Posts. Often you want to style a list of your Custom Posts by Custom Taxonomy and &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Most WordPress instances used to power a full site or shop will hopefully take advantage of the power combination of Custom Taxonomies and Custom Posts. Often you want to style a list of your Custom Posts by Custom Taxonomy and have the single view styled in the same way, or perhaps have the same sidebar. You can do this with by leveraging the Template Hierarchy and registering tons of sidebars. However, before long, you can find your theme folder bloated with extra templates. I don&#8217;t like having tons of templates in my themes. Too much code duplication usually. Rather, I like to use Conditional Tags and <a href="http://codex.wordpress.org/Function_Reference/get_template_part" target="_blank">get_template_part</a>.  When dealing with Custom Taxonomies &#038; Post Types it may not be clear at first how one can best use Conditional Tags to good use. Lets take a look.</p>
<p><span id="more-253"></span></p>
<p>For a custom taxonomy page, you use <code>is_tax()</code>. By itself it returns true for any custom taxonomy archive page.</p>
<p>That might be enough, if not, there are arguments: </p>
<pre class="brush: php; title: ; notranslate">is_tax( $taxonomy, $term );</pre>
<p>$taxonomy is a Taxonomy slug or slugs, while $term The term(s) ID, Name or Slug.</p>
<pre class="brush: php; title: ; notranslate">
is_tax();
// When any custom taxonomy archive page is being displayed.

is_tax( 'wpsc_product_category' );
// When the archive page for taxonomy of 'wpsc_product_category' is being displayed.

is_tax( 'wpsc_product_category', 'audio' );
// When the archive page for taxonomy of 'wpsc_product_category' is being displayed and the 'wpsc_product_category' taxonomy term is 'audio

is_tax( 'wpsc_product_category', array( 'audio', 'video', 'download' ) )
// Returns true when the 'wpsc_product_category' taxonomy archive being displayed has a slug of either &quot;audio&quot;, &quot;video&quot;, or &quot;download&quot;.
</pre>
<p>It is a little less obvious how to use a Conditional Tag for a single instance of a Custom Post (in many instances this is the &#8220;single&#8221; you hit from clicking an instance of on the archive page above). </p>
<p><code>is_singular();</code></p>
<p>Using this with do arguments returns true when any of following return true: <code>is_single()</code>, <code>is_page()</code> or <code>is_attachment()</code>. This probably isn&#8217;t helpful. So pass in your Custom Post Type:</p>
<pre class="brush: php; title: ; notranslate">
is_singular('wpsc_product')';
</pre>
<p>One thing that you can&#8217;t do with the predefined Conditionals is determine whether your &#8220;single&#8221; (custom or not) in inside a custom taxonomy. We have to build our own, like so:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
function has_wpsc_product_category( $wpsc_product_category, $_post = null ) {
	if ( empty( $wpsc_product_category ) )
		return false;
	if ( $_post )
		$_post = get_post( $_post );
	else
		$_post =&amp; $GLOBALS['post'];
	if ( !$_post )
		return false;
	$r = is_object_in_term( $_post-&gt;ID, 'wpsc_product_category', $wpsc_product_category );
	if ( is_wp_error( $r ) )
		return false;
	return $r;
}
?&gt;
</pre>
<p>How to use:</p>
<pre class="brush: php; title: ; notranslate">
has_wpsc_product_category( 'audio' );
</pre>
<p>Of course, you would alter the function for your taxonomy. You could also pass in an array of terms and iterate thorough them, using <code>is_object_in_term</code> on each, and returning if any are true.</p>
<p>Finally, there is the issue of child terms in your custom taxonomy. Currently, <code>is_tax()</code> won&#8217;t return turn for child taxonomies. It only works for the explicit term. Bainternet has a <a href="http://wordpress.stackexchange.com/questions/12340/conditional-tag-affecting-taxonomy-term-and-its-children" target="_blank">great solution here</a>.</p>
<p>Finally, here is a real world usage, where I&#8217;m calling up a certain sidebar for a collection of views that relate to the eCommerce portion of a blog, where there is a Custom Post Type for products with a Custom Taxonomy for sorting them. There are also some pages relating to the cart and checkout, etc. It also sometimes becomes easiest and most practical just to put your complicated query on a Page and not get all worked up with conditionals or template overrides:</p>
<pre class="brush: php; title: ; notranslate">
&lt;div class=&quot;sidebar&quot; id=&quot;page-sidebar&quot;&gt;&lt;/div&gt;
            &lt;?php
			wp_reset_query();
			elseif ( is_page_template('page-wide.php') || is_page_template('page-donation.php') || is_page_template('page-contact.php') ) :; // no sidebar
			elseif ( is_tax( 'wpsc_product_category' ) || is_page(array('products-page','checkout','transaction-results','your-account')) || is_singular('wpsc-product') ) : // for eCommerce views
    			get_sidebar('store');
			elseif ( is_page() ) :
    			get_sidebar('page');
			elseif ( is_single() ) :
    			get_sidebar('single');
			else :
    			get_sidebar();
			endif;
			?&gt;

            &lt;/div&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jamesfishwick.com/2012/conditional-tags-for-custom-post-types-taxonomies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>check if checkbox/radio is checked using jQuery</title>
		<link>http://jamesfishwick.com/2012/check-if-checkbox-is-checked/</link>
		<comments>http://jamesfishwick.com/2012/check-if-checkbox-is-checked/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 16:33:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Note to Self]]></category>

		<guid isPermaLink="false">http://www.jamesfishwick.com/?p=238</guid>
		<description><![CDATA[<p><span id="more-238"></span><br />
To test if something <em>is not</em> checked:</p>
<p>Or more naturally:&#8230;</p>]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript; title: ; notranslate">
//returns true or false
$('&quot;input[type=radio]').is(':checked');

$(&quot;input[type=checkbox]:checked&quot;).each(
    function() {
       // do something at each checked radio or checkbox
    }
);
</pre>
<p><span id="more-238"></span><br />
To test if something <em>is not</em> checked:</p>
<pre class="brush: jscript; title: ; notranslate">
if ($(&quot;input&quot;).is(&quot;:not(:checked)&quot;))
</pre>
<p>Or more naturally:</p>
<pre class="brush: jscript; title: ; notranslate">
if ( ! $(&quot;input&quot;).is(':checked') )
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jamesfishwick.com/2012/check-if-checkbox-is-checked/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modernizr and jQuery and wp_enqueue_script oh my</title>
		<link>http://jamesfishwick.com/2011/modernizr-and-jquery-and-wp_enqueue_script-oh-my/</link>
		<comments>http://jamesfishwick.com/2011/modernizr-and-jquery-and-wp_enqueue_script-oh-my/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 22:38:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Note to Self]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.jamesfishwick.com/?p=232</guid>
		<description><![CDATA[<p>Some questions on the best way to use Modernizr with jQuery in the context of WordPress&#8230;</p>
<p>I want to be able to use jQuery in my <code>complete</code> callbacks. I, of course, want to be able to use <code>wp_enqueue_script</code>.</p>
<p><span id="more-232"></span></p>
<p>First, &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Some questions on the best way to use Modernizr with jQuery in the context of WordPress&#8230;</p>
<p>I want to be able to use jQuery in my <code>complete</code> callbacks. I, of course, want to be able to use <code>wp_enqueue_script</code>.</p>
<p><span id="more-232"></span></p>
<p>First, I know that its recommended to call all your <code>wp_enqueue_script</code> functions from inside the <code>wp_enqueue_scripts</code> action, but I&#8217;m just defining all of my scripts and calling them to be enqueued directly in my <code>header.php</code>. This is mainly to make my example easier, but also because I want my script references to be in my header markup, not buried in my <code>functions.php</code>. WordPress wants you to obfuscate stuff too much methinks! I suppose the best compromise would be to use <code>wp_register_script</code> for all my JavaScript in a function tied to <code>wp_enqueue_scripts</code> in my <code>functions.php</code>, and then just use <code>wp_enqueue_script</code> in the head with the sole <code>handle</code> argument. <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" title="Function Reference/wp enqueue script" target="_blank">Check the function reference in the codex for more on the above</a>.</p>
<p>Anyway, here is an example of what I like to do:</p>
<pre class="brush: php; title: ; notranslate">
wp_enqueue_script('jquery');
wp_enqueue_script('modernizr', 'http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.6/modernizr.min.js', 'jquery', false);
if ( is_singular() ) wp_enqueue_script('slideshow', get_template_directory_uri() . '/js/jquery.cycle.all.min.js', 'jquery', false);
wp_enqueue_script('lazyload', get_template_directory_uri() . '/js/jquery.lazyload.mini.js', 'jquery', false);
wp_enqueue_script('script', get_template_directory_uri() . '/js/script.js', array('jquery','modernizr'), false);
</pre>
<p>So, jQuery is given as a dependency for Modernizr. And <code>script.js</code> depends on both of those. Rather than putting my <code>Modernizer.load</code> inline, as seems to be the trend, I just include it this script, which serves as a catch all for various jQuery effects and other stuff. Here is the function:</p>
<pre class="brush: jscript; title: ; notranslate">
Modernizr.load({
  test: Modernizr.textshadow,
  nope : ['https://raw.github.com/heygrady/textshadow/master/jquery.textshadow.js'],
  complete: function() {
	 jQuery.noConflict();
	 jQuery('h2#desc, .page h2').textshadow();
  }
</pre>
<p>Note that you&#8217;ll almost positively need to call
<pre class="brush: jscript; title: ; notranslate">jQuery.noConflict();</pre>
<p> when using this setup.</p>
<p>A more complicated usage of these guys, would be be calling <code>wp_enqueue_script</code> inside your yep/nope callback. In such a case, you&#8217;d want to call your <code>Modernizr.load</code> function inline, maybe even between other &#8220;enqueue&#8221; calls.</p>
<p>First, you&#8217;ll need to register all your scripts in the way I mentioned at the onset. That is, hook a function to the<code>wp_enqueue_scripts</code> action in which you register all your scripts with <code>wp_register_script</code>. So, since I didn&#8217;t show this explicitly before:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
function my_scripts_method() { // you would probably be loading more than one here if you were using this technique
    wp_register_script('textshadow','https://raw.github.com/heygrady/textshadow/master/jquery.textshadow.js', false);
}    

add_action('wp_enqueue_scripts', 'my_scripts_method');
?&gt;
</pre>
<p>Next you&#8217;ll also add this function to your <code>functions.php</code>:</p>
<pre class="brush: php; title: ; notranslate">
function registered_scripts( $handles = array() ) {
    global $wp_scripts, $wp_styles;

    foreach ( $wp_scripts-&gt;registered as $registered )
        $script_urls[ $registered-&gt;handle ] = $registered-&gt;src;

    foreach ( $wp_styles-&gt;registered as $registered )
        $style_urls[ $registered-&gt;handle ] = $registered-&gt;src;

    if ( empty( $handles ) ) {

        $handles = array_merge( $wp_scripts-&gt;queue, $wp_styles-&gt;queue );
        array_values( $handles );

    }

    $output = '';

    foreach ( $handles as $handle ) {

        if ( !empty( $script_urls[ $handle ] ) )
            $output .= $script_urls[ $handle ] . ',';

        if ( !empty( $style_urls[ $handle ] ) )
            $output .= $style_urls[ $handle ] . ',';

    }

    $output = substr( $output, 0, -1 );

    echo $output;

}
</pre>
<p>Basically, this will allow you to reach into your registered scripts and style-sheets and call one out to be enqueued by it&#8217;s registered handle.</p>
<p>So, I could now do something like: </p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script&gt;
Modernizr.load([
  {
    test : Modernizr.textshadow,
    nope : [&lt;?php registered_scripts( array('textshadow') ); ?&gt;],
    complete: function() {
      jQuery.noConflict();
      jQuery('h2#desc, .page h2').textshadow();
    }
  }
]);
&lt;/script&gt;
</pre>
<p>and the &#8220;textshadow&#8221; polyfill would be enqueued, instead of just manually loaded.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesfishwick.com/2011/modernizr-and-jquery-and-wp_enqueue_script-oh-my/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Committing to WordPress svn via proxy</title>
		<link>http://jamesfishwick.com/2011/cant-commit-to-wordpress-svn-over-comcast-connection/</link>
		<comments>http://jamesfishwick.com/2011/cant-commit-to-wordpress-svn-over-comcast-connection/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 20:12:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Note to Self]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.jamesfishwick.com/?p=233</guid>
		<description><![CDATA[<p>Multiple times when I was recently updating my svn repository for my Jetpack Easy Playlists plugin, I wasunable to connect to the WordPress SVN repository and execute basic svn commands. Kept getting warnings that looked like this:</p>
<p>Strangely, I was &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Multiple times when I was recently updating my svn repository for my Jetpack Easy Playlists plugin, I wasunable to connect to the WordPress SVN repository and execute basic svn commands. Kept getting warnings that looked like this:</p>
<pre class="brush: bash; title: ; notranslate">svn: warning: Error handling externals definition for XXXX
svn: warning: PROPFIND of '/!svn/XXXX/default': could not connect to server (http://plugins.svn.wordpress.org)</pre>
<p>Strangely, I was able to browse the repository via my browser, as well as checkout other public svns. I&#8217;m not behind a proxy, with a normal COMCAST connection.</p>
<p>What gives and how did I get around it?</p>
<p><span id="more-233"></span></p>
<p>After I bit of research, I stumbled across this link: <a href="http://www.cybersprocket.com/2011/tips-tricks/is-comcast-playing-big-brother-with-your-internet/" title="  Is Comcast Playing Big Brother With Your Internet?" target="_blank">http://www.cybersprocket.com/2011/tips-tricks/is-comcast-playing-big-brother-with-your-internet/</a>.</p>
<p>You can read the poop there, but the long-and-short is that Comcast is doing &#8220;some sort of traffic shaping or other network manipulation&#8221; and making the internet fail. The solution offered is to connect through alternate connection. Nope, don&#8217;t have that. And how to setup a proxy for subversion?</p>
<p>First, you need a proxy to connect through. Here are three easy ways (for which you the end user will need evaluate the security of, ymmv):</p>
<p>1) <a href="http://tools.rosinstrument.com/proxy/" title="FREE PUBLIC PROXY SERVERS LIST" target="_blank">Look up a free public proxy</a></p>
<p>2) <a href="http://lifehacker.com/5484934/run-your-own-free-proxy-through-the-google-app-engine " target="_blank">Use the Google App Engine as a proxy server</a></p>
<p>3) Configure an Apache <em>development</em> (production not advised) server you &#8220;own&#8221; somewherw to run as your Proxy.</p>
<p>Add these directives somewhere in your Apache configuration file chain (httpd.conf, vhosts.d directory, etc.):</p>
<pre class="brush: bash; title: ; notranslate">Listen 8080

&lt;virtualhost _default_:8080&gt;
    ProxyRequests On
    ProxyVia On
    ProxyPreserveHost On

    &lt;proxy *&gt;
        Order deny,allow
        Deny from all
        Allow from xxx.xxx.xxx.xxx
    &lt;/proxy&gt;
&lt;/virtualhost&gt;</pre>
<p>This assumes you have mod_proxy installed. Port 8080 is arbitrary. Basically for an unmatched virtual host (i.e. any request that doesn&#8217;t match your other hosts you have set up) it will turn proxy on and proxy the request through. Obviously, &#8220;xxx.xxx.xxx.xxx&#8221; should be your own IP address.</p>
<p>Now, we need to route all subversion http requests via your proxy of choice:</p>
<p>Open up:</p>
<pre class="brush: bash; title: ; notranslate">~/.subversion/servers</pre>
<p>Find this section <em>in your globals</em>:</p>
<pre class="brush: bash; title: ; notranslate">
# http-proxy-exceptions = *.exception.com, www.internal-site.org
# http-proxy-host = proxy1.some-domain-name.com
# http-proxy-port = 80
# http-proxy-username = defaultusername
# http-proxy-password = defaultpassword
# http-compression = no
# http-auth-types = basic;digest;negotiate
# No http-timeout, so just use the builtin default.
# No neon-debug-mask, so neon debugging is disabled.
# ssl-authority-files = /path/to/CAcert.pem;/path/to/CAcert2.pem
</pre>
<p>Uncomment <code>http-proxy-host</code> and <code>http-proxy-port</code>. For host use a spare domain name you have mapped to your development server or just the proxy server IP. Then set the port to 8080 or whatever other port needs to be used.</p>
<p>Note: This doesn&#8217;t affect straight-up svn or svn+ssh requests.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesfishwick.com/2011/cant-commit-to-wordpress-svn-over-comcast-connection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>textutil use cases</title>
		<link>http://jamesfishwick.com/2011/textutil/</link>
		<comments>http://jamesfishwick.com/2011/textutil/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 16:12:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CLI]]></category>
		<category><![CDATA[Note to Self]]></category>
		<category><![CDATA[Production Automation]]></category>

		<guid isPermaLink="false">http://www.jamesfishwick.com/?p=207</guid>
		<description><![CDATA[<p>I don&#8217;t use my Mac as my main development/production workstation anymore, but its still my one-stop shop for all matter of text conversions.</p>
<p>While I have a very specific and regular use-case for <code>textutil</code>, namely converting Word .docs into &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t use my Mac as my main development/production workstation anymore, but its still my one-stop shop for all matter of text conversions.</p>
<p>While I have a very specific and regular use-case for <code>textutil</code>, namely converting Word .docs into barebones HTML or PDFS, there are plenty of features that make it a highly useful and general purpose tool. <code>textutil</code> can convert from/to txt, html, rtf, rtfd, doc, docx, wordml, odt and webarchive.</p>
<p>The basic syntax is:</p>
<pre class="brush: bash; title: ; notranslate">textutil -convert fmt filename</pre>
<p><span id="more-207"></span></p>
<p>So, we can convert a Microsoft Word format document into html by typing:</p>
<pre class="brush: bash; title: ; notranslate">textutil -convert html &quot;My Word Document.doc&quot;</pre>
<p>Executing this command will create an html file called MyWord.html. The HTML generated is 4.01, but you can cope! You&#8217;ll find a bit of CSS code, too, but otherwise it&#8217;s fairly clean&#8230; It will also take blank lines between text paragraphs and attempt to replicate the space using a
<pre class="brush: xml; title: ; notranslate">&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</pre>
<p> combo. Finally, I sometimes notice some weird spans and crap like
<pre class="brush: xml; title: ; notranslate">&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;      &lt;/span&gt;</pre>
<p>, but these usecases are only if your source docs have lots of soft returns and forced tabs. Look, its stillmuch, <em>much</em> better HTML than Word writes!</p>
<p>Again, fairly clean, but you&#8217;ll maybe want to to a couple universal search-and-replaces, or more preferably a proper run of <code><a href="http://tidy.sourceforge.net/" target="_blank">Tidy</a></code> to set your prefered DOCTYPE and blast the above tag soup. Also, the &#8220;-excludedelements&#8221; switch can help you out. This switch allows you to specify which HTML elements should not be used in the generated HTML.</p>
<p><strong>Some other help examples of <code>textutil</code></strong>:</p>
<p>Create an HTML document from a plain text file with the title and keyword tags set:</p>
<pre class="brush: bash; title: ; notranslate">textutil -convert html -title &quot;My HTML Page&quot; -keywords &quot;(web,php,'object orientated',physics)&quot; -author &quot;Jimmy James&quot; mytextfile.txt</pre>
<p>Find recursively in the current directory, by name, all the doc files. Execute the textutil &#8216;convert to text&#8217; command with the found files:</p>
<pre class="brush: bash; title: ; notranslate">find . -name *.doc -exec textutil -convert txt '{}' \;</pre>
<p>If you have multiple text documents that you want to join together into a single new file, use textutil&#8217;s built-in cat function:</p>
<pre class="brush: bash; title: ; notranslate">textutil -cat rtf file1.txt file2.txt file3.txt -output combinedFiles.rtf</pre>
<p>Use the <code>-info</code> flag to display information about a file. This displays the type, size, length (in characters), other metadata and an abstract from the contents of the text file:</p>
<pre class="brush: bash; title: ; notranslate">textutil -info &quot;My Word Document.doc&quot;</pre>
<p>File:  My Word Document.doc<br />
Type:  Word format<br />
Size:  26700 bytes<br />
Length:  4236 characters<br />
Title:  My Word Document<br />
Author:  Stephanie Fishwick<br />
Last Editor:  James Fishwick<br />
Company:  Fishwick Design<br />
Subject:<br />
Keywords:<br />
Created:  2010-11-02 17:56:00 -0500<br />
Last Modified:  2011-11-06 09:47:00 -0500</p>
<p>Convert a docx document to doc format.</p>
<pre class="brush: bash; title: ; notranslate">textutil -convert doc myFile.docx</pre>
<p>If you want to convert all of the files in a folder to one format you can type</p>
<pre class="brush: bash; title: ; notranslate">textutil -convert doc /path/to/location/*.docx</pre>
<p><em>Of course, check the <a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/textutil.1.html" target="_blank">man page</a> for all the goodness.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jamesfishwick.com/2011/textutil/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
