<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Gilles Ruppert]]></title>
  <link href="http://latower.com/atom.xml" rel="self"/>
  <link href="http://latower.com/"/>
  <updated>2012-10-31T12:35:45+01:00</updated>
  <id>http://latower.com/</id>
  <author>
    <name><![CDATA[Gilles Ruppert]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Disabling the GUI from loading in Ubuntu]]></title>
    <link href="http://latower.com/blog/2011/06/05/disabling-the-gui-from-loading-in-ubuntu/"/>
    <updated>2011-06-05T00:00:00+02:00</updated>
    <id>http://latower.com/blog/2011/06/05/disabling-the-gui-from-loading-in-ubuntu</id>
    <content type="html"><![CDATA[<p>A quick reminder to myself.</p>

<p>To disable the GUI in Ubuntu (i.e. to run it as a headless VM), do the following:</p>

<pre><code>sudo vim /etc/default/grub
</code></pre>

<p>Change: <code>GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"</code> to <code>GRUB_CMDLINE_LINUX_DEFAULT="text"</code></p>

<p>save, then run: <code>sudo update-grub</code> and restart.</p>

<p>To enable gui again, just change from <code>text</code> to <code>quiet splash</code>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Batch rename files on OSX/Unix]]></title>
    <link href="http://latower.com/blog/2010/11/26/batch-rename-files-on-osxunix/"/>
    <updated>2010-11-26T00:00:00+01:00</updated>
    <id>http://latower.com/blog/2010/11/26/batch-rename-files-on-osxunix</id>
    <content type="html"><![CDATA[<p>I had to rename a bunch of files in a directory by just changing a prefix. Perfect for the command line, no?
After a bit of googling (that exists as a verb now, doesn&#8217;t it? :-)) I found this article:<a href="http://lab.artlung.com/unix-batch-file-rename/">Batch File Rename By File Extension in Unix</a></p>

<p>All you need to do is iterate over all of the files in directory, and then rename by echoing the name &amp; running sed on it, i.e.</p>

<pre><code>for i in *; do mv $i `echo $i | sed 's/search/replace/'`; done
</code></pre>

<p>If you need to iterate over a tree of directories or only rename certain files, you can run this command</p>

<pre><code>for f in `find . -type f -name "filename"`; do mv $f `echo $f | sed "s/search/replace/"`; done
</code></pre>

<p>If you are using git, you can also exchange <code>mv</code> with <code>git mv</code>.</p>

<p>As always: backups and/or version control are your friends!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[find & sed: find and replace on the command line]]></title>
    <link href="http://latower.com/blog/2010/11/25/find-sed-find-and-replace-on-the-command-line/"/>
    <updated>2010-11-25T00:00:00+01:00</updated>
    <id>http://latower.com/blog/2010/11/25/find-sed-find-and-replace-on-the-command-line</id>
    <content type="html"><![CDATA[<p>Since using vim, I sometimes miss the great find and replace that TextMate offers, but fear not: find and sed fill the gap quite nicely:</p>

<pre><code>find . -type f -exec sed -i 's/search/replace/g' '{}' \;
</code></pre>

<p>To make sure your find and search are looking for the right things, you can do the following 1st:</p>

<pre><code>find . -type f -exec grep 'search' '{}' \;
</code></pre>

<p>This command tells find to search all files recursively and pass the to the sed stream editor, which in turn search and replaces all the occurrences (see the <code>g</code> flag at the end, which stands for global).</p>

<p>To avoid certain files, you can exclude them from the find command, i.e.</p>

<pre><code>find . -type f -not \( -name '*.json' \) -exec grep 'search' '{}' \;
</code></pre>

<p>This will recursively search all the files, but exclude files with the <code>.json</code> extension.</p>

<p>You can also make this more complex by excluding json and JavaScript files, i.e.</p>

<pre><code>find . -type f -not \( -name '*.json' -o -name '*.js' \) -exec grep 'search' '{}' \;
</code></pre>

<p>The <code>-o</code> is the logical or operator.</p>

<p>N.B: the <code>-i</code> argument for the sed command means &#8216;edit-in-place&#8217;. You can pass a value with it to create a backup. This might not be a bad idea. As with most (all?) Linux commands, you fly without a net &amp; there is no undo. Version control is the net I use.</p>

<p>I sometimes get confused about the exact syntax of the command, hence the quick post.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Creating patch files with git]]></title>
    <link href="http://latower.com/blog/2010/06/28/creating-patch-files-with-git/"/>
    <updated>2010-06-28T00:00:00+02:00</updated>
    <id>http://latower.com/blog/2010/06/28/creating-patch-files-with-git</id>
    <content type="html"><![CDATA[<p>Git has a built in way to create patches and <a href="http://wiki.github.com/rakudo/rakudo/steps-to-create-a-patch">Github has a great write up on this</a>.
The <code>git format-patch</code> command is useful if all your changes are committed and you want to create a patch of certain commits.</p>

<p>Sometimes however you have changes that you can&#8217;t or don&#8217;t want to commit for whatever reason. Git lets you easily create a standard patch file that you can apply on another clone or branch.</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># To create the patch</span>
</span><span class='line'>git diff --no-prefix &gt; path-to-patch/name-of-the-patch-file
</span><span class='line'>
</span><span class='line'><span class="c"># To apply the patch:</span>
</span><span class='line'>patch -p0 &lt; path-to-patch/name-of-the-patch-file
</span></code></pre></td></tr></table></div></figure>


<p>If you have an existing <code>git diff</code> output that didn&#8217;t use the <code>--no-prefix</code> argument, you can just apply the patch like this:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>patch -p1 &lt; path-to-patch/name-of-the-patch-file
</span></code></pre></td></tr></table></div></figure>


<p>Voila.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Updating the locate database on OSX]]></title>
    <link href="http://latower.com/blog/2010/03/27/updating-the-locate-database-on-osx/"/>
    <updated>2010-03-27T00:00:00+01:00</updated>
    <id>http://latower.com/blog/2010/03/27/updating-the-locate-database-on-osx</id>
    <content type="html"><![CDATA[<p><code>locate</code> is a very handy command to find files on the system. It is much faster than <code>find</code> since it keeps a database of all the system files. This database is periodically updated, but if you want to update it yourself, just use the following command:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>sudo /usr/libexec/locate.updatedb
</span></code></pre></td></tr></table></div></figure>


<p><a href="http://www.devdaily.com/blog/post/linux-unix/use-linux-locate-command">Here you can get a bit more information on this handy little command</a></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Integrating JSLint for vim]]></title>
    <link href="http://latower.com/blog/2009/10/03/integrating-jslint-for-vim/"/>
    <updated>2009-10-03T00:00:00+02:00</updated>
    <id>http://latower.com/blog/2009/10/03/integrating-jslint-for-vim</id>
    <content type="html"><![CDATA[<p>A couple of months ago I moved away from TextMate and started using vim for most of my text editing needs. I love TextMate, but I needed a powerful text editor that is also available on other operating systems.</p>

<p>Overall I love vim: it has a steep learning curve, but it&#8217;s very powerful.If you are touch-typing and loath the mouse as much as I do, it&#8217;s fantastic. But I found myself missing out on some of TextMate&#8217;s great bundles, and JSLint integration is one of them. After some googling around and looking at different solutions, this is the one that was easiest to install and I like the functionality.</p>

<p>First <a href="http://www.javascriptlint.com/download.htm" title="Download and install JSLint">download</a> &amp; install JavaScript Lint. On OSX &amp; Linux, you can do so by copying the resulting folder into your PATH. I put it in /usr/local/bin/.</p>

<p>Then <a href="http://www.vim.org/scripts/script.php?script_id=2578" title="Download JavaScript Lint vim plugin">get the JavaScriptLint vim plugin</a> by Joe Stelmach and restart vim.</p>

<p>Off you go. When you save a JavaScript file in vim, you will get a window with JSLint warnings. If you want to configure JSLint to show/hide certain errors, you can edit the config (<code>jsl.default.conf</code>) in the folder. You might want to backup the file before editing it.</p>

<p>Happy linting!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Upgrading the Subversion command line client on Mac OSX Leopard]]></title>
    <link href="http://latower.com/blog/2009/05/20/upgrading-subversion-on-osx/"/>
    <updated>2009-05-20T00:00:00+02:00</updated>
    <id>http://latower.com/blog/2009/05/20/upgrading-subversion-on-osx</id>
    <content type="html"><![CDATA[<p><ins datetime="2010-08-05T00:38:42+00:00">UPDATE: Since  I wrote this post, I found a couple of other ways of upgrading the Subversion command line client.</p>

<p>One option is to install the package via <a href="http://www.macports.org/">MacPorts</a> or <a href="http://mxcl.github.com/homebrew/">Homebrew</a>. If you use Homebrew, you probably don&#8217;t have to do anything else, as Homebrew sets up the symlinks automatically. If you install via MacPorts, you have the same issue as you do with the Collabnet installer.</p>

<p>Instead of creating symlinks though, you can also change the PATH environment variable. To do this, open <code>~/.bash_profile</code> or <code>~/.bashrc</code> in your favourite editor (<a href="http://www.vim.org/">vim</a>) and make sure that you have a line similar to this:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nb">export </span><span class="nv">PATH</span><span class="o">=</span>/opt/local/bin:/opt/local/sbin:<span class="nv">$PATH</span>
</span></code></pre></td></tr></table></div></figure>


<p>This will make sure that <code>/opt/local/bin/</code>, which contains the MacPorts installs, will be checked before any other locations. MacPorts <em>should</em> add this by itself. This makes sure that svn as installed by MacPorts will be used.</p>

<p>As before: you can check which svn binary you are using by typing <code>which svn</code> and <code>svn --version</code> in the terminal.</p>

<p>Hope this helps!</p>

<h2>Original post</h2>

<p></ins></p>

<p>OSX Leopard ships with Subversion 1.4.x by default. Since then, SVN has had 2 major upgrades (merge tracking anyone?). To make things easy, there is a binary available at <a href="http://www.open.collab.net/downloads/community/">Collab.net</a>. But unfortunately you need to do some work yourself.</p>

<p>The path of the built in Subversion command line client is different to the one that the Collab.net Community binary is installed to. The following steps will fix this.</p>

<p>Disclaimer - Be careful: when you use the Terminal you are flying without a safety net! No undo &amp; no restore from trash. Do this at your own risk and don&#8217;t forget to have an up-to-date backup!!!</p>

<ol>
<li>install the binary downloaded to Collab.net</li>
<li>open your Terminal and check which version of SVN you are using by typing <code>svn --version</code>. This should say 1.4.x</li>
<li>check which installed instance of SVN the OS is using by typing <code>which svn</code>. This will return the path to the SVN version you are using, which probably is <code>/usr/local/bin/svn</code></li>
<li>check whether the Collab.net version is installed by going to it: <code>cd /opt/subversion/bin</code>. Doing an <code>ls</code> should show you the subversion files</li>
<li>Backup the current svn location: by going to it (<code>cd /usr/local/bin</code>) and copying it to your desktop or wherever you fancy (<code>mv svn* ~/Desktop/</code>)</li>
<li>now you need to create <a href="http://en.wikipedia.org/wiki/Symbolic_link">symlinks</a> to the Collab.net binaries:

<ul>
<li><code>ln -s /opt/subversion/bin/svn svn</code></li>
<li><code>ln -s /opt/subversion/bin/svnadmin svnadmin</code></li>
<li><code>ln -s /opt/subversion/bin/svndumpfilter svndumpfilter</code></li>
<li><code>ln -s /opt/subversion/bin/svnlook svnlook</code></li>
<li><code>ln -s /opt/subversion/bin/svnserve svnserve</code></li>
<li><code>ln -s /opt/subversion/bin/svnsync svnsync</code></li>
<li><code>ln -s /opt/subversion/bin/svnversion svnversion</code></li>
</ul>
</li>
<li>That should be it</li>
</ol>


<p>The beauty is that you only need to do this once. The next time you upgrade your Subversion client, the symlinks will just point to the updated files and everything should be fine. As I said earlier though: only do this if you feel comfortable on the command line.</p>

<p><ins datetime="2009-05-27T23:06:12+00:00">UPDATE: I have been told that some people seem to have SVN installed in <code>/usr/bin/</code>. Just use the path that is returned by the <code>which svn</code> command. You might also need to use <code>sudo</code> to run some of the command (i.e. move).</ins></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[jQuery list paginator plugin - Elpaginator]]></title>
    <link href="http://latower.com/blog/2009/01/26/jquery-list-paginator-plugin-elpaginator/"/>
    <updated>2009-01-26T00:00:00+01:00</updated>
    <id>http://latower.com/blog/2009/01/26/jquery-list-paginator-plugin-elpaginator</id>
    <content type="html"><![CDATA[<p>I know it&#8217;s been a while. I started about 5 posts, but haven&#8217;t finished any of them&#8230; </p>

<p>Hopefully this makes up for it: as a treat for the new year, I thought a little jQuery plugin that I wrote would be handy for some people: please welcome Elpaginator!</p>

<h2>What it does:</h2>

<p>It looks for a <code>ul</code> or <code>ol</code> within a wrapper &amp; adds pagination depending on the maximum number of items specified.</p>

<h2>Features:</h2>

<ul>
<li>paginates if there are more items than the user specified</li>
<li>displays number of items left or pages, i.e. 1-10, 11-20, etc or 1, 2, etc</li>
<li>html of pagination is fully configurable (wrapper need to contain class of <code>page-list</code>!)</li>
<li>the number of the list item if ordered list is used is correct (uses start attribute that is deprecated, but there is no real alternative yet as IE6 &amp; 7 don&#8217;t support CSS for this yet)</li>
<li>support for <code>ul</code> &amp; <code>ol</code></li>
<li>very lightweight (less than 200 lines WITH lots of comments)
 </li>
</ul>


<p>You can find the <a href="http://svn.latower.com/main/trunk/elpaginator/jquery.elpaginator.js">elpaginator script</a> &amp; a <a href="http://svn.latower.com/main/trunk/elpaginator/index.html">demo page</a> in <a href="http://svn.latower.com/main/trunk/elpaginator/index.html">my svn repository</a>.</p>

<h2>Options</h2>

<p>This is how you initialise the pagination:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='js'><span class='line'><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#wrapper&#39;</span><span class="p">).</span><span class="nx">elpaginator</span><span class="p">();</span>
</span></code></pre></td></tr></table></div></figure>


<p>Possible Options are:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='js'><span class='line'><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#wrapper&#39;</span><span class="p">).</span><span class="nx">elpaginator</span><span class="p">({</span>
</span><span class='line'>  <span class="nx">MAX</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span>  <span class="c1">// maximum number of items per pagination</span>
</span><span class='line'>  <span class="nx">list</span><span class="o">:</span> <span class="s1">&#39;ol&#39;</span><span class="p">,</span>   <span class="c1">// whether it&#39;s an ul or ol. Default: ul</span>
</span><span class='line'>  <span class="nx">style</span><span class="o">:</span> <span class="s1">&#39;items&#39;</span><span class="p">,</span> <span class="c1">// other value is pages -&gt; show 1-5 6-10, etc, or 1, 2,</span>
</span><span class='line'>  <span class="nx">paginationHTML</span><span class="o">:</span> <span class="s1">&#39;&lt;div class=&quot;pagination&quot;&gt;&lt;ul class=&quot;page-list&quot;&gt;&lt;/ul&gt;&lt;/div&gt;&#39;</span><span class="p">,</span> <span class="c1">// HTML for the pagination. Is appended to the wrapper</span>
</span><span class='line'>  <span class="nx">paginationListItemHTML</span><span class="o">:</span> <span class="s1">&#39;&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/li&gt;&#39;</span> <span class="c1">// HTML for the pagination items</span>
</span><span class='line'><span class="p">});</span>
</span></code></pre></td></tr></table></div></figure>


<p>A live example of it working can also be seen on the new <a href="http://www.topgear.com/uk/tv-show">Top Gear site</a> (look at the sidebar for the lap times table).</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Splitting a long JavaScript String across multiple lines]]></title>
    <link href="http://latower.com/blog/2008/11/12/splitting-a-long-javascript-string-across-multiple-lines/"/>
    <updated>2008-11-12T00:00:00+01:00</updated>
    <id>http://latower.com/blog/2008/11/12/splitting-a-long-javascript-string-across-multiple-lines</id>
    <content type="html"><![CDATA[<p>Whilst reading a comment by <a href="http://www.mikedeboer.nl/">Mike DeBoer</a> on <a href="http://ajaxian.com/archives/how-to-structure-your-javascript-code#comment-268506">Ajaxian</a> about delimiting JavaScript strings with backslashes, I thought it&#8217;s worth mentioning it here as well, if only to remind myself.</p>

<p>String concatenation always creates a new string.</p>

<p>Thus, writing:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='js'><span class='line'><span class="kd">var</span> <span class="nx">str</span> <span class="o">=</span> <span class="s2">&quot;This is a long&quot;</span> <span class="o">+</span>
</span><span class='line'>  <span class="s2">&quot; string. That&#39;s why we want to &quot;</span> <span class="o">+</span>
</span><span class='line'>  <span class="s2">&quot; split it over several lines&quot;</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<p>is slower &amp; more memory intensive than writing:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='js'><span class='line'><span class="kd">var</span> <span class="nx">str</span> <span class="o">=</span> <span class="s2">&quot;This is a long\</span>
</span><span class='line'><span class="s2"> string. That&#39;s why we want to\</span>
</span><span class='line'><span class="s2"> split it over several lines&quot;</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Just be careful you don&#8217;t have trailing spaces as that will mess it up.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[JavaScript cookies made easy]]></title>
    <link href="http://latower.com/blog/2008/11/04/javascript-cookies-made-easy/"/>
    <updated>2008-11-04T00:00:00+01:00</updated>
    <id>http://latower.com/blog/2008/11/04/javascript-cookies-made-easy</id>
    <content type="html"><![CDATA[<p>Here is another little script that makes my life a bit easier. It consists of 3 methods that makes working with cookies very straight forward. This script is built on the shoulder of giants: <a href="http://www.quirksmode.org/js/cookies.html">PPK from Quircksmode</a> was the man who did the hard work.</p>

<p>However, rather than creating 3 methods that sit in the global namespace, I wanted to use a singleton object that would only add 1 global variable. Since there is no need for private methods, the object literal pattern is appropriate.
In my opinion the names of the methods make it very straight forward to use. Good names mean less looking up, mean less mistakes, mean faster development. Your Technical Project Manager will love you for it :-)</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='js'><span class='line'><span class="c1">// To create/set a cookie:</span>
</span><span class='line'><span class="nx">cookie</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">,</span> <span class="s1">&#39;value, 234); // last argument is number of days until expiry. If none is provided, it will get deleted when the browser is closed</span>
</span><span class='line'>
</span><span class='line'><span class="s1">// To get the cookie value:</span>
</span><span class='line'><span class="s1">cookie.get(&#39;</span><span class="nx">name</span><span class="s1">&#39;);</span>
</span><span class='line'>
</span><span class='line'><span class="s1">// To delete the cookie:</span>
</span><span class='line'><span class="s1">cookie.erase(&#39;</span><span class="nx">name</span><span class="err">&#39;</span><span class="p">);</span>
</span></code></pre></td></tr></table></div></figure>


<p>As always, you can <a href="http://svn.latower.com/main/trunk/cookies">download the latest version from my svn repository</a></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[TextMate & Subversion 1.5 update problem with conflict]]></title>
    <link href="http://latower.com/blog/2008/10/28/textmate-subversion-15-update-problem/"/>
    <updated>2008-10-28T00:00:00+01:00</updated>
    <id>http://latower.com/blog/2008/10/28/textmate-subversion-15-update-problem</id>
    <content type="html"><![CDATA[<p>We recently upgraded to Subversion 1.5 server at BBC Worldwide. I ended up upgrading my client at the same time with the latest OSX binary from Colabnet.
One weird thing started to happen though: whenever there were conflicts, TextMate wouldn&#8217;t allow me to use the &#8216;Resolve Conflicts with FileMerge&#8230;&#8217;.</p>

<p>Long story short: the interactive mode keeps TextMate from getting all the data so you don&#8217;t get the .rxxx &amp; .mine files which are needed for FileMerge to show you the differences.</p>

<p>To fix this is:</p>

<ol>
<li>go into your TextMate Subversion Bundle</li>
<li>go to the <code>Update to Newest (HEAD)</code> command and add <code>--non-interactive</code> after <code>'#{svn}' update</code></li>
</ol>


<p>You can see the resulting code here (change on line 14).</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
</pre></td><td class='code'><pre><code class='rb'><span class='line'><span class="n">require_cmd</span> <span class="s2">&quot;${TM_SVN:=svn}&quot;</span> <span class="s2">&quot;If you have installed svn, then you need to either update your &lt;tt&gt;PATH&lt;/tt&gt; or set the &lt;tt&gt;TM_SVN&lt;/tt&gt; shell variable (e.g. in Preferences / Advanced)&quot;</span>
</span><span class='line'>
</span><span class='line'><span class="s2">&quot;${TM_RUBY:-ruby}&quot;</span> <span class="o">-</span><span class="n">r</span> <span class="s2">&quot;$TM_SUPPORT_PATH/lib/shelltokenize.rb&quot;</span> <span class="o">&lt;&lt;</span><span class="no">END</span>
</span><span class='line'><span class="sh"> svn = ENV[&#39;TM_SVN&#39;] || &quot;svn&quot;</span>
</span><span class='line'><span class="sh"> ruby = ENV[&#39;TM_RUBY&#39;] || &quot;ruby&quot;</span>
</span><span class='line'><span class="sh"> support = ENV[&#39;TM_BUNDLE_SUPPORT&#39;]</span>
</span><span class='line'><span class="sh"> paths = TextMate.selected_paths_array</span>
</span><span class='line'>
</span><span class='line'><span class="sh"> # TODO: Ideally, we&#39;d like to use a tooltip for one and not others, but we can&#39;t switch from a tooltip</span>
</span><span class='line'><span class="sh"> # to dynamic HTML output (or maybe we could double-fork a process?)</span>
</span><span class='line'><span class="sh"> # if ((paths.size == 1) and not (File.directory? paths[0]))</span>
</span><span class='line'><span class="sh"> #   puts %x{#{svn} update #{TextMate.selected_paths_for_shell}}</span>
</span><span class='line'><span class="sh"> # else</span>
</span><span class='line'><span class="sh">     update = IO.popen(&quot;&#39;#{svn}&#39; update --non-interactive #{TextMate.selected_paths_for_shell}&quot;, &#39;r&#39;)</span>
</span><span class='line'><span class="sh">     format = IO.popen(&quot;&#39;#{ruby}&#39; -- &#39;#{support}/format_status.rb&#39;&quot;, &#39;w&#39;)</span>
</span><span class='line'><span class="sh">     update.each_line { |line| format.puts(line) }</span>
</span><span class='line'><span class="sh"> # end</span>
</span><span class='line'><span class="no">END</span>
</span><span class='line'>
</span><span class='line'><span class="c1"># force TM to refresh the current file..</span>
</span><span class='line'><span class="n">rescan_project</span>
</span></code></pre></td></tr></table></div></figure>



]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[jQuery plugin autoInputValue - default input values made easy]]></title>
    <link href="http://latower.com/blog/2008/10/25/jquery-plugin-autoinputvalue-default-input-values-made-easy/"/>
    <updated>2008-10-25T00:00:00+02:00</updated>
    <id>http://latower.com/blog/2008/10/25/jquery-plugin-autoinputvalue-default-input-values-made-easy</id>
    <content type="html"><![CDATA[<p>We all know the problem: the designers are struggling to get the form elements in the space they have or they decide that having labels next to input fields is not really necessary&#8230;
Instead the label is displayed inside the input field &amp; supposed to disappear when the user clicks or focuses on the field.</p>

<p>I&#8217;ve come across this quite often lately, so I quickly put a little jQuery plugin together to make my life a bit easier.</p>

<p>It works on input fields and it works just like any other jQuery plugin.</p>

<p>All you need to do is call the plugin with the selectors you are interested in, i.e. <code>$('input:text.email').autoInputLabel();</code></p>

<p>The options are specified in an object literal &amp; can be:</p>

<ul>
<li><code>blurColor</code> - colour of the text when the label is displayed</li>
<li><code>focusColor</code> - colour of the active text, i.e. user input</li>
<li><code>value</code> - the label that should be displayed</li>
</ul>


<p>By default, the plugin displays the value of the <code>value</code> attribute. If there is none, it checks whether there has been a value provided by the user. Otherwise it looks for the label associated with the input field (that is probably hidden, otherwise why would you use the plugin?). The label needs to be associated to the input field with the <code>for</code> attribute.</p>

<p>The plugin only works on <code>&lt;input type="text"&gt;</code> fields.</p>

<p>You can <em><a href="http://svn.latower.com/main/trunk/autoInputLabel">download the latest version from my public svn repository</a></em></p>
]]></content>
  </entry>
  
</feed>
