<?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>The Spoony Blog &#187; Tools</title>
	<atom:link href="http://adamrosenfield.com/blog/category/tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://adamrosenfield.com/blog</link>
	<description>Just until I can come up with a better name</description>
	<lastBuildDate>Sun, 15 Apr 2012 04:01:09 +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>Google search keyboard shortcuts</title>
		<link>http://adamrosenfield.com/blog/2011/10/10/google-search-keyboard-shortcuts/</link>
		<comments>http://adamrosenfield.com/blog/2011/10/10/google-search-keyboard-shortcuts/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 18:01:35 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://adamrosenfield.com/blog/?p=237</guid>
		<description><![CDATA[For quite some time, Google&#8217;s experimental search offered a &#8220;Keyboard shortcuts&#8221; experiment, where you could navigate search results with vi-style key bindings (j and k to navigate up and down search results, o or Enter to open a link, and / to move the cursor back to the search box). It seems they have recently [...]]]></description>
			<content:encoded><![CDATA[<p>For quite some time, <a href="http://www.google.com/experimental/index.html">Google&#8217;s experimental search</a> offered a &#8220;Keyboard shortcuts&#8221; experiment, where you could navigate search results with vi-style key bindings (<em>j</em> and <em>k</em> to navigate up and down search results, <em>o</em> or <em>Enter</em> to open a link, and <em>/</em> to move the cursor back to the search box).</p>
<p>It seems they have recently removed that experiment, as they sometimes do.  I don&#8217;t know exactly when that happened, but <a href="http://web.archive.org/web/20110421185656/http://www.google.com/experimental/index.html">The Wayback Machine</a> puts it at somewhere between April 21 and now.  But despite Google&#8217;s removing the experiment, the keyboard shortcuts had still been working just fine for me—until, that is, I revisited the page linked to in the first paragraph.  Even just visiting that page, without taking any action, removed the shortcuts.  The Accessible View experiment also provides similar keyboard shortcuts, but it does other things I don&#8217;t like, such as highlighting the currently selected search result blue.</p>
<p>I took a peek into the JavaScript on that page, and though it was optimized and obfuscated, it wasn&#8217;t enormously complicated.  It was doing stuff with the <code>PREF</code> cookie, but the cookie&#8217;s content was highly opaque.  There was a handy <code>_toggle()</code> function which took the name of a feature to toggle.  The two currently available experiments, Instant on Images and Accessible View, which pass in the names <code>'ImagesInstant::PublicOptIn'</code> and <code>'Axs'</code> to <code>_toggle()</code>.  Archive.org tells me that the keyboard shotcurts experiment used the name <code>'BetaShortcuts'</code>.</p>
<p>So, the obvious next step was to see if running <code>_toggle('BetaShortcuts')</code> on that page would fix up my cookie to give me back my keyboard shortcuts.  I fired up the web console from Firefox&#8217;s <a href="https://addons.mozilla.org/en-US/firefox/addon/web-developer/">Web Developer add-on</a> and ran that command:</p>
<pre>&gt; _toggle('BetaShortcuts')
TypeError: h("e_" + b) is null</pre>
<p>D&#8217;oh.  It&#8217;s trying to do something with the page&#8217;s DOM—ordinarily, when you click the &#8220;Join this experiment&#8221; button, it changes the button text to &#8220;Leave this experiment&#8221;, but there&#8217;s no button for the BetaShortcuts experiment to change the text for.  The <code>h()</code> function is just a thin wrapper around <code>document.getElementById()</code>.  Well, let&#8217;s try hacking around this by renaming one of the other buttons:</p>
<pre>&gt; h("e_Axs").id="e_BetaShortcuts"
"e_BetaShortcuts"
&gt; _toggle('BetaShortcuts')
undefined
GET http://www.google.com/url?(various opaque parameters) [HTTP/1.1 204 No Content 88ms]</pre>
<p>Close the page, and voila!  Keyboard shortcuts work again.</p>
]]></content:encoded>
			<wfw:commentRss>http://adamrosenfield.com/blog/2011/10/10/google-search-keyboard-shortcuts/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Making p4 and Cygwin play nice</title>
		<link>http://adamrosenfield.com/blog/2009/11/02/making-p4-and-cygwin-play-nice/</link>
		<comments>http://adamrosenfield.com/blog/2009/11/02/making-p4-and-cygwin-play-nice/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 03:57:01 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://adamrosenfield.com/blog/?p=51</guid>
		<description><![CDATA[Say you&#8217;re a developer doing development on Windows, and say you&#8217;re using Perforce (better known as p4) for source control. Let&#8217;s also say you have *nix background and like using Cygwin to keep you from going insane. What are your options for interacting with p4? Fortunately, Perforce provides a binary compiled against Cygwin. You can [...]]]></description>
			<content:encoded><![CDATA[<p>Say you&#8217;re a developer doing development on Windows, and say you&#8217;re using <a href="http://www.perforce.com">Perforce</a> (better known as p4) for source control.  Let&#8217;s also say you have *nix background and like using <a href="http://www.cygwin.com">Cygwin</a> to keep you from going insane.  What are your options for interacting with p4?</p>
<p>Fortunately, Perforce provides a binary compiled against Cygwin.  You can download that, drop it in your <code>$PATH</code>, and be on your merry way.</p>
<p>But I happen to like <a href="http://www.perforce.com/perforce/products/p4win.html">P4Win</a> as a graphical client, and P4Win doesn&#8217;t play nicely with the Cygwin p4.  Why?  Client roots.  With P4Win (or any other non-Cygwin client, for that matter), your client root is a Windows-style path, e.g. <code>C:\path\to\root</code>.  But Cygwin sees things differently.  It wants your client root to be something like <code>/cygdrive/c/path/to/root</code>.</p>
<p>So, if you have a client set up with P4Win and try to interact with the command line p4 in Cygwin, you&#8217;ll get messages like this:</p>
<pre>'awesomecode.cc' is not under client's root 'C:\path\to\root'</pre>
<p>You can get around this by using absolute paths, e.g.:</p>
<pre>p4 edit $(cygpath -wa awesomecode.cc)</pre>
<p>That gets tiresome very fast, though.  But you, fearless reader, you are in luck!  I have just the solution for you!  It turns out that all p4 needs is a little persuasion to change its <code>PWD</code> environment variable.  I whipped up a little C program that fixes up its <code>PWD</code> and exec&#8217;s the real p4, so it no longer gets confused.</p>
<p>You can download my program <a href="http://adamrosenfield.com/files/p4.zip">here</a>.  Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://adamrosenfield.com/blog/2009/11/02/making-p4-and-cygwin-play-nice/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Not your average regex find-and-replace</title>
		<link>http://adamrosenfield.com/blog/2008/12/25/not-your-average-regex-find-and-replace/</link>
		<comments>http://adamrosenfield.com/blog/2008/12/25/not-your-average-regex-find-and-replace/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 02:46:57 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://adamrosenfield.com/blog/?p=22</guid>
		<description><![CDATA[I was reading through some of the Coding Horror archives, and came across this post examining Microsoft Visual Studio&#8217;s use of regular expressions in its find-and-replace dialog. Visual Studio has support for all of the usual regex constructs but throws in a lot of its own quirky constructs too. I suppose they could be useful [...]]]></description>
			<content:encoded><![CDATA[<p>I was reading through some of the <a href="http://www.codinghorror.com">Coding Horror</a> archives, and came across <a href="http://www.codinghorror.com/blog/archives/000633.html">this post</a> examining Microsoft Visual Studio&#8217;s use of regular expressions in its find-and-replace dialog.  Visual Studio has support for all of the usual regex constructs but throws in a lot of its own quirky constructs too.  I suppose they could be useful if you learned to use them.</p>
<p>But this post isn&#8217;t about Visual Studio.  Jeff&#8217;s post contained an intriguing link to <a href="http://steve-yegge.blogspot.com/2006/06/shiny-and-new-emacs-22.html">Steve Yegge&#8217;s blog</a>, where Steve goes over some of the new features in Emacs 22.  And despite my being a long-time emacs user, I was pleasantly surprised to learn that <b>you can use elisp with find-and-replace</b>.  </p>
<p>Now at first, this may not seem like a big deal.  You can do a lot with a plain vanilla find-and-replace (<code>M-x replace-string</code> and <code>M-x query-replace</code> (also bound to <code>M-%</code>)), and regex find-and-replaces (<code>M-x replace-regexp</code> and <code>M-x query-replace-regexp</code> (also bound to <code>C-M-%</code>)) are damn powerful.  But sometimes, when a sed script won&#8217;t do, an elisp find-and-replace can save you a lot of pain.</p>
<p>To do an elisp find-and-replace, do a regular <code>replace-regexp</code>, and set the replacement expression to <code>\,</code> (backslash-comma) followed by an elisp expression.  You can use backreferences <code>\1</code> through <code>\9</code> as string variables, and you can use <code>\#</code> as an integer variable that is the total number of replacements made so far.</p>
<p>Steve has <a href="http://steve-yegge.blogspot.com/2006/06/shiny-and-new-emacs-22.html">a number of great examples</a> which I&#8217;m not going to repeat here, so I encourage you to go over there and eat &#8216;em up.</p>
<p>I was eager to try them out, and seeing as how Emacs 22 is over <a href="http://en.wikipedia.org/wiki/Emacs#Release_history">two and half years old</a>, I figured my current Emacs install would be up-to-date.  Not so &#8211; my MacBook was still running Emacs 21.2.1, which came installed when I bought it in 2006.  Fortunately, with <a href="http://www.macports.org/">MacPorts</a> installed (<b>HIGHLY</b> recommended for anyone running OS X), upgrading was <em>almost</em> as easy as running</p>
<p><code>sudo port install emacs</code></p>
<p>I did <code>install</code> instead of <code>upgrade</code> because my emacs install was the default one that came installed and I hadn&#8217;t migrated it into MacPorts yet.  I said it was <em>almost</em> that easy because after it installed and I went to run it, the old Emacs 21 ran instead, even though the MacPorts binaries directory <code>/opt/local/bin</code> precedes <code>/usr/bin</code> in my $PATH.  It turns out that bash uses a <a href="http://www.cyberciti.biz/tips/how-linux-or-unix-understand-which-program-to-run-part-i.html#hashtables">hash table</a>, of which I was previously unaware, to cache where frequently used commands are located to avoid searching your $PATH frequently.  To fix this, just run <code>hash -d emacs</code> to delete its binding for emacs (or <code>hash -r</code> to clear the entire table), and you&#8217;re good to go!</p>
]]></content:encoded>
			<wfw:commentRss>http://adamrosenfield.com/blog/2008/12/25/not-your-average-regex-find-and-replace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wireless tools for Mac OS X</title>
		<link>http://adamrosenfield.com/blog/2008/09/01/wireless-tools-for-mac-os-x/</link>
		<comments>http://adamrosenfield.com/blog/2008/09/01/wireless-tools-for-mac-os-x/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 03:28:05 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://adamrosenfield.com/blog/?p=12</guid>
		<description><![CDATA[I&#8217;ve been having some trouble with my MacBook on a certain wireless network. OS X has some pretty good GUI tools for configuring the wireless Airport, but sometimes you need a good command line tool for debugging. Linux has a pretty good set of tools for this: Wireless tools for Linux. Despite OS X&#8217;s being [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been having some trouble with my MacBook on a certain wireless network.  OS X has some pretty good GUI tools for configuring the wireless Airport, but <strong>sometimes you need a good command line tool for debugging</strong>.  Linux has a pretty good set of tools for this: <a href="http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html">Wireless tools for Linux</a>.  Despite OS X&#8217;s being built on Unix, no such tools are available.</p>
<p>Upon googling for <a href="http://www.google.com/search?q=command+line+wireless+tools+mac+os+x">command line wireless tools os x</a>, the first hit was <a href="http://osxdaily.com/2007/01/18/airport-the-little-known-command-line-wireless-utility/">exactly what I was looking for</a>.  At the moment that site is down, but <a href="http://www.google.com/url?sa=t&#038;source=web&#038;ct=clnk&#038;cd=1&#038;url=http%3A%2F%2F74.125.95.104%2Fsearch%3Fq%3Dcache%3ALwEcuDdZaBMJ%3Aosxdaily.com%2F2007%2F01%2F18%2Fairport-the-little-known-command-line-wireless-utility%2F%2Bcommand%2Bline%2Bwireless%2Btools%2Bmac%2Bos%2Bx%26hl%3Den%26ct%3Dclnk%26cd%3D1%26gl%3Dus%26client%3Dfirefox-a&#038;ei=Noy8SMPiCZT8NNGKkfoC&#038;usg=AFQjCNGMFHpUlQe54wVc0T8tGVf2s-9zNg&#038;sig2=Mi9L47Knr8zzMy5A75vy6w">Google&#8217;s cache</a> saves the day.</p>
<p>It turns out that OS X comes with a nifty little tool called <code>airport</code>, but it&#8217;s not on the default path and buried deep inside the file system.  I added to my path:</p>
<div class="srccode">
<pre>% sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport</pre>
</div>
<p>To print a list of wireless networks currently in range:</p>
<div class="srccode">
<pre>% airport -s</pre>
</div>
<p>To print the current wireless status:</p>
<div class="srccode">
<pre>% airport -I</pre>
</div>
<p>To connect to a specific network SSID:</p>
<div class="srccode">
<pre>% airport -A&lt;SSID&gt;</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://adamrosenfield.com/blog/2008/09/01/wireless-tools-for-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

