<?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>*in some cases &#187; Tech</title>
	<atom:link href="http://www.insomecases.com/words/category/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.insomecases.com/words</link>
	<description>raising two girls, living without nuts, seeds, milk, or eggs, and random other things</description>
	<lastBuildDate>Sun, 13 Nov 2011 17:41:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Custom JavaScript String Functions</title>
		<link>http://www.insomecases.com/words/2011/04/15/custom-javascript-string-functions/</link>
		<comments>http://www.insomecases.com/words/2011/04/15/custom-javascript-string-functions/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 18:11:02 +0000</pubDate>
		<dc:creator>Loïc</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[camel case]]></category>
		<category><![CDATA[dashed]]></category>
		<category><![CDATA[trim]]></category>
		<category><![CDATA[underscored]]></category>

		<guid isPermaLink="false">http://www.insomecases.com/words/?p=370</guid>
		<description><![CDATA[I&#8217;ve created some missing native JavaScript String function to trim, convert to camel case, to underscored and to dashed formats. Here is the trim() function (gist page): And the toCamelCase() function (gist page): And the toDashed() function (gist page): And &#8230; <a href="http://www.insomecases.com/words/2011/04/15/custom-javascript-string-functions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve created some missing native JavaScript String function to trim, convert to camel case, to underscored and to dashed formats.</p>
<p>Here is the trim() function (<a href="https://gist.github.com/920776" target="_blank">gist page</a>):</p>
<pre class="brush: jscript; title: ; notranslate">
/**
 * trim: removes leading and trailing white space
 */
String.prototype.trim = function () {
	return this.replace(/^\s+|\s+$/g, &quot;&quot;);
};
</pre>
<p>And the toCamelCase() function (<a href="https://gist.github.com/920765" target="_blank">gist page</a>):</p>
<pre class="brush: jscript; title: ; notranslate">
/**
 * toCamelCase: converts string to camel case
 */
String.prototype.toCameCase = function () {
	return this.replace(/^\s+|\s+$/g, &quot;&quot;)
		.toLowerCase()
		.replace(/(\s[a-z0-9])/g, function ($1) {
			return $1.replace(/\s/, '').toUpperCase();
		})
		.replace(/\W/g, '');
};
</pre>
<p>And the toDashed() function (<a href="https://gist.github.com/920801" target="_blank">gist page</a>):</p>
<pre class="brush: jscript; title: ; notranslate">
/**
 * toDashed: converts string to dashed
 */
String.prototype.toDashed = function () {
	return this.replace(/^\s+|\s+$/g, &quot;&quot;)
	.toLowerCase()
	.replace(/-/g, '')
	.replace(/(\s[a-z0-9])/g, function ($1) {
		return $1.replace(/\s/, '-');
	})
	.replace(/[^a-z0-9-]/g, '');
};
</pre>
<p>And finally, the toUnderscored() function (<a href="https://gist.github.com/920816" target="_blank">gist page</a>):</p>
<pre class="brush: jscript; title: ; notranslate">
/**
 * toUnderscored: converts string to underscored
 */
String.prototype.toUnderscored = function () {
	return this.replace(/^\s+|\s+$/g, &quot;&quot;)
	.toLowerCase()
	.replace(/_/g, '')
	.replace(/(\s[a-z0-9])/g, function ($1) {
		return $1.replace(/\s/, '_');
	})
	.replace(/[^a-z0-9_]/g, '');
};
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.insomecases.com/words/2011/04/15/custom-javascript-string-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Showing selected drop-down option in WordPress archive select menu</title>
		<link>http://www.insomecases.com/words/2011/03/10/showing-selected-drop-down-option-in-wordpress-archive-select-menu/</link>
		<comments>http://www.insomecases.com/words/2011/03/10/showing-selected-drop-down-option-in-wordpress-archive-select-menu/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 17:30:17 +0000</pubDate>
		<dc:creator>Loïc</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.insomecases.com/words/?p=352</guid>
		<description><![CDATA[I needed to show as selected, the option in the WordPress archives drop-down menu (&#60;select&#62;) corresponding to the current page address. One possibility was to alter the get_archives_link(&#8230;) function in the /wp-includes/general-template.php. Doing so meant the modification would get over &#8230; <a href="http://www.insomecases.com/words/2011/03/10/showing-selected-drop-down-option-in-wordpress-archive-select-menu/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I needed to show as selected, the option in the WordPress archives drop-down menu (&lt;select&gt;) corresponding to the current page address. One possibility was to alter the <em><strong>get_archives_link(&#8230;)</strong></em> function in the <strong><em>/wp-includes/general-template.php</em></strong>. Doing so meant the modification would get over written if WordPress were updated, so I opted to add a custom modifier in the <em><strong>functions.php</strong></em> file of the custom WordPress 3.0 theme I was creating.</p>
<p>Here&#8217;s my custom modifier function from my <em><strong>functions.php</strong></em> file:</p>
<pre class="brush: php; title: ; notranslate">
function get_archives_option_mod ( $link_option ) {
   preg_match (&quot;/value=[\'\&quot;](.+?)[\'\&quot;]/&quot;, $link_option, $url);
   $requested = &quot;http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}&quot;;
      if ($requested == $url[1]) {
         $link_option = str_replace(&quot;&lt;option value=&quot;, &quot;&lt;option selected=\&quot;selected\&quot; value=&quot;, $link_option);
      }
      return $link_option;
   }
add_filter(&quot;get_archives_link&quot;, &quot;get_archives_option_mod&quot;);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.insomecases.com/words/2011/03/10/showing-selected-drop-down-option-in-wordpress-archive-select-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My git frequent commands</title>
		<link>http://www.insomecases.com/words/2010/09/15/my-git-frequent-commands/</link>
		<comments>http://www.insomecases.com/words/2010/09/15/my-git-frequent-commands/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 19:40:06 +0000</pubDate>
		<dc:creator>Loïc</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.insomecases.com/words/?p=338</guid>
		<description><![CDATA[I&#8217;m writing this only for my own usage, so I have a place to find them when I need them. Do all of the following from within the local git project folder. Initializing a repository Then create your repository on &#8230; <a href="http://www.insomecases.com/words/2010/09/15/my-git-frequent-commands/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing this only for my own usage, so I have a place to find them when I need them. Do all of the following from within the local git project folder.</p>
<p>Initializing a repository</p>
<pre class="brush: bash; title: ; notranslate">git init
git add *
git commit -m 'initial commit'
</pre>
<p>Then create your repository on Github: my_repo_name with my_user_account</p>
<pre class="brush: bash; title: ; notranslate">git remote add origin git@github.com:my_user_account/my_repo_name.git
git push origin master</pre>
<p>Checking what is not yet committed:</p>
<pre class="brush: bash; title: ; notranslate">git status -s</pre>
<p>Adding all new/updated files:</p>
<pre class="brush: bash; title: ; notranslate">git add *</pre>
<p>Adding a file by name:</p>
<pre class="brush: bash; title: ; notranslate">git add /path/to/file</pre>
<p>Committing the additions:</p>
<pre class="brush: bash; title: ; notranslate">git commit -m 'comment for this commit'</pre>
<p>Pushing the updates:</p>
<pre class="brush: bash; title: ; notranslate">git push</pre>
<p>Updating a local repository with remote content:</p>
<pre class="brush: bash; title: ; notranslate">git remote update</pre>
<p>Another useful one to delete remote files that were deleted locally:</p>
<pre class="brush: bash; title: ; notranslate">for i in `git status | grep deleted | awk '{print $3}'`; do git rm $i; done</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.insomecases.com/words/2010/09/15/my-git-frequent-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why use Google hosted jQuery</title>
		<link>http://www.insomecases.com/words/2010/03/04/why-use-google-hosted-jquery/</link>
		<comments>http://www.insomecases.com/words/2010/03/04/why-use-google-hosted-jquery/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 20:45:28 +0000</pubDate>
		<dc:creator>Loïc</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.insomecases.com/words/?p=235</guid>
		<description><![CDATA[Here are the benefits of using the Google hosted jQuery libraries: By using the Google hosted jQuery libraries, since many applications use the Google infrastructure, when someone comes to your application, the Google hosted files may already be loaded into &#8230; <a href="http://www.insomecases.com/words/2010/03/04/why-use-google-hosted-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here are the benefits of using the Google hosted jQuery libraries:</p>
<ul>
<li>By using the Google hosted jQuery libraries, since many applications use the Google infrastructure, when someone comes to your application, the Google hosted files may already be loaded into the visitor&#8217;s browser cache.</li>
<li>The subtle performance issue associated with the transfer of cookie data is revolved because your domain  is different from Google&#8217;s  (i.e.,: not google.com), so no cookie data or other verbose headers will be sent up, saving precious bytes.</li>
<li>By loading the jQuery libraries from Google, the HTTP requests for those libraries don&#8217;t compete with the requests for assets from your domain, speeding up the overall page load time:<br />
<em>&#8220;Browsers typically limit the number of concurrent HTTP connections per server to be 2. If a browser session has two HTTP connections already</em> [for a given server]<em>, any further connection requests will have to wait until one of these two HTTP connections is finished.&#8221;</em> — Source: <a href="http://www.openajax.org/runtime/wiki/The_Two_HTTP_Connection_Limit_Issue" target="_blank">OpenAjax Alliance</a></li>
<li>Google hosted files are compressed using GZIP.</li>
<li>Google has a distributed CDN at various points around the world, so the files are &#8220;close&#8221; to the visitor.</li>
<li>Google servers are fast.</li>
</ul>
<p>Here&#8217;s the drawback:</p>
<ul>
<li>In the highly unlikely event that Google&#8217;s CDN goes down, the missing jQuery libraries will prevent your jQuery dependent page from loading correctly. The fix for this is to alternatively load the jQuery library from somewhere else. Microsoft now hosts the jQuery library on their CDN.</li>
</ul>
<p>Here&#8217;s an example of alternate loading. Try loading from Google. Check for the presence of the jQuery function. If it isn&#8217;t there, load jQuery from Microsoft.</p>
<div class="code">
&lt;script src=&#8221;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&#8221; type=&#8221;text/javascript&#8221;&gt;&lt;/script&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;</p>
<pre class="brush: jscript; title: ; notranslate">
if (typeof jQuery !== 'function') {
    document.write('&lt;scri' + 'pt type=&quot;text/javascript&quot; src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js&quot;&gt;&lt;/scri' + 'pt&gt;');
}</pre>
<p>&lt;/script&gt;
<div>
If both Microsoft and Google are down, then the world must be at an  end, so your site not loading is the least of your problems.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.insomecases.com/words/2010/03/04/why-use-google-hosted-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iPhones can do anything!</title>
		<link>http://www.insomecases.com/words/2009/05/12/iphones-can-do-anything/</link>
		<comments>http://www.insomecases.com/words/2009/05/12/iphones-can-do-anything/#comments</comments>
		<pubDate>Tue, 12 May 2009 15:18:17 +0000</pubDate>
		<dc:creator>Loïc</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.insomecases.com/words/2009/05/12/iphones-can-do-anything/</guid>
		<description><![CDATA[I just downloaded the free WordPress iPhone App, from the iTunes App store, and within two minutes I was writing this post. I&#8217;m having a vision of a new world, in the not too distant future, where us humans will &#8230; <a href="http://www.insomecases.com/words/2009/05/12/iphones-can-do-anything/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just downloaded the free WordPress iPhone App, from the iTunes App store, and within two minutes I was writing this post. I&#8217;m having a vision of a new world, in the not too distant future, where us humans will evolve to have sharper finger tips, and really great close up vision (within 6-7 inches from the eyes). </p>
<p>Is the future of personal computing going to be held in your pocket? Are we going to give up the big and clunky desktops and their sleeker cousins, the laptops altogether? We can already do pretty much everyting from our palms. </p>
<p>Good job Apple ! Keep it up. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.insomecases.com/words/2009/05/12/iphones-can-do-anything/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SSH and SCP with keys instead of passwords</title>
		<link>http://www.insomecases.com/words/2008/06/10/ssh-and-scp-with-keys-instead-of-passwords/</link>
		<comments>http://www.insomecases.com/words/2008/06/10/ssh-and-scp-with-keys-instead-of-passwords/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 05:45:32 +0000</pubDate>
		<dc:creator>Loïc</dc:creator>
				<category><![CDATA[Bash/Shell Scripts]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.insomecases.com/words/?p=69</guid>
		<description><![CDATA[I&#8217;m writing about this bit of useful shell scripting, mostly so I know where to find it when I might need it again. I needed to set up automatic backups using a shell script in Mac OS X, to copy &#8230; <a href="http://www.insomecases.com/words/2008/06/10/ssh-and-scp-with-keys-instead-of-passwords/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing about this bit of useful shell scripting, mostly so I know where to find it when I might need it again.</p>
<p>I needed to set up automatic backups using a shell script in Mac OS X, to copy (scp) tarballs from a mounted network drive on my Mac to a remote Linux environment. The only problem was the ssh authentication — the remote Linux server seemed to want a password every time. I remembered a friend of mine had done this a while back, and I started digging around. Here&#8217;s the summary of how you can set up your machine to be recognized by the remote machine,</p>
<p>1. On my Mac (Leopard), using the Terminal App, I ran,</p>
<pre class="brush: bash; title: ; notranslate">ssh-keygen -t rsa</pre>
<p>This outputs the following,</p>
<pre class="brush: bash; title: ; notranslate">Generating public/private rsa key pair.
Enter file in which to save the key
(/Users/[username]/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):</pre>
<p>I left that blank,</p>
<pre class="brush: bash; title: ; notranslate">Enter same passphrase again:</pre>
<p>Left that blank too,</p>
<pre class="brush: bash; title: ; notranslate">Your identification has been saved in
/Users/[username]/.ssh/id_rsa.
Your public key has been saved in
/Users/[username]/.ssh/id_rsa.pub.
The key fingerprint is:
... finger print string here ...
[username]@[machine].local</pre>
<p>Basically, this created two files in my user folder&#8217;s .ssh/ folder,</p>
<pre class="brush: bash; title: ; notranslate">.ssh/id_rsa</pre>
<p> (This is the private key — guard it well)</p>
<pre class="brush: bash; title: ; notranslate">.ssh/id_rsa.pub</pre>
<p> (This is the public key — pass it along)<br />
2. I SSHed into the remote server to make sure my user account&#8217;s folder over there contained a .ssh/ folder. It didn&#8217;t, so I created one,</p>
<p>SSHed into remote server:</p>
<pre class="brush: bash; title: ; notranslate">ssh user@remote</pre>
<p>I was prompted for my password,</p>
<pre class="brush: bash; title: ; notranslate">user@remote's password:</pre>
<p>Once I was in, I created the .ssh/ folder,</p>
<pre class="brush: bash; title: ; notranslate">mkdir .ssh</pre>
<p>Then I exited the remote server.</p>
<p>3. Then I had to transfer my public key over to the remote server. I ran the following from my home folder,</p>
<pre class="brush: bash; title: ; notranslate">ssh user@remote &quot;cat &gt;&gt; .ssh/authorized_keys&quot; &lt; .ssh/id_rsa.pub</pre>
<p>Again, I was prompted for my password,</p>
<pre class="brush: bash; title: ; notranslate">user@remote's password:</pre>
<p>When it was done adding my public key, it logged me out.</p>
<p>Now when I run,</p>
<pre class="brush: bash; title: ; notranslate">ssh user@remote</pre>
<p>I no longer get prompted for a password, I just go right in. This means my backup script, using scp, can run as a cron job.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.insomecases.com/words/2008/06/10/ssh-and-scp-with-keys-instead-of-passwords/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZIP Code Nerdiness</title>
		<link>http://www.insomecases.com/words/2007/10/02/zip-code-nerdiness/</link>
		<comments>http://www.insomecases.com/words/2007/10/02/zip-code-nerdiness/#comments</comments>
		<pubDate>Tue, 02 Oct 2007 17:57:14 +0000</pubDate>
		<dc:creator>Loïc</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://insomecases.com/words/2007/10/02/zip-code-nerdiness/</guid>
		<description><![CDATA[I&#8217;ve been playing around with some web services, trying to gather ZIP code data, but quickly realized that it would take forever to gather up all of the US ZIP codes—there are just under 80,000 of them. So I bit &#8230; <a href="http://www.insomecases.com/words/2007/10/02/zip-code-nerdiness/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with some web services, trying to gather ZIP code data, but quickly realized that it would take forever to gather up all of the US  ZIP codes—there are just under 80,000 of them. So I bit the bullet and bought a ZIP code database.</p>
<p>With that, I created a simple <a href="http://www.insomecases.com/zip-code-lookup/index.php">ZIP code look-up tool</a>, which displays the city, state, latitude, longitude, etc. for any given ZIP code.</p>
<p>I got even more nerdy, and added a <a href="http://www.insomecases.com/zip-code-lookup/distance.php">distance calculator tool</a> that gives you distance between two ZIP codes. It&#8217;s using <a href="http://en.wikipedia.org/wiki/Haversine_formula" target="_blank">the haversine formula</a>, which gives the great-circle distances between two latitude/longitude point.</p>
<p>Here&#8217;s are the PHP functions that I use to do the calculation:</p>
<pre class="brush: php; title: ; notranslate">
function haversine($lat1, $long1, $lat2, $long2, $earth){
  //Point 1 cords
  $lat1 = deg2rad($lat1);
  $long1= deg2rad($long1);
  //Point 2 cords
  $lat2 = deg2rad($lat2);
  $long2= deg2rad($long2);
  //Haversine Formula
  $dlong=$long2-$long1;
  $dlat=$lat2-$lat1;
  $sinlat=sin($dlat/2);
  $sinlong=sin($dlong/2);
  $a=($sinlat*$sinlat)+cos($lat1)*cos($lat2)*($sinlong*$sinlong);
  $c=2*asin(min(1,sqrt($a)));
  $d=round($earth*$c);
  return $d;
}
function getMiles($lat1, $long1, $lat2, $long2){
  return haversine($lat1, $long1, $lat2, $long2, 3960);
}
function getKilometers($lat1, $long1, $lat2, $long2){
  return haversine($lat1, $long1, $lat2, $long2, 6371);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.insomecases.com/words/2007/10/02/zip-code-nerdiness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

