tag:blogger.com,1999:blog-81063922024-02-08T05:27:40.949-08:00majusculegavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.comBlogger34125tag:blogger.com,1999:blog-8106392.post-67588935562908506102008-09-02T19:44:00.001-07:002008-09-02T19:44:41.586-07:00Mac OS X Web Programmers Toolkit<h2>Free (gratis)</h2>
<ul>
<li><a href="http://rsug.itd.umich.edu/software/fugu/"
title="Research Systems Unix Group: Fugu">Fugu</a> -
Secure FTP. SCP etc. Hasn't really been updated in a while
but it works pretty well. Allows you to edit remote files
with your favorite local text editor.
</li>
<li><a href="http://www.barebones.com/products/textwrangler/"
title="Bare Bones Software | TextWrangler">TextWrangler</a> -
Decent text editor from the makers of BBEdit. Major deficiency is
that it doesn't support nested languages (e.g. Javascript within HTML,
HTML within PHP, etc.).
</li>
<li><a href="http://homepage.mac.com/roger_jolly/software/"
title="OS X Software">RegExhibit</a> -
Interactively test regular expressions
</li>
<li><a href="http://sourceforge.net/projects/locomotive"
title="SourceForge.net: Locomotive">Locomotive</a> -
Ruby on Rails in a box. A single standalone application that
includes Ruby, MySQL, a web server, and an application to manage
them all.
</li>
<li><a href="http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg"
title="MySQL :: MySQL 5.0 Downloads">MySQL 5.0</a>
</li>
<li><a href="http://www.postgresql.org/download/macosx"
title="PostgreSQL: Mac OS X packages">PostgreSQL</a>
</li>
<li>
<a
href="http://cocoamysql.sourceforge.net/"
title="CocoaMySQL - A MySQL GUI for Mac OS X">CocoaMySQL</a>
</li>
<li>
<a href="http://aquamacs.org/"
title="Aquamacs: Emacs for Mac OS X">Aquamacs Emacs</a> -
Holy union of emacs and Aqua. Normal emacs key bindings work (e.g.
C-e end of line). Normal Aqua keybindings work (e.g. Cmd-a select all).
Includes various elisp functions to bring emacs closer to the 21st
century. All in a nice OS X native application with lots of polish.
</li>
</ul>
<h2>Not Free</h2>
<ul>
<li><a href="http://macromates.com/"
title="TextMate — The Missing Editor for Mac OS X">TextMate</a> -
Best text editor ever. (Sorry emacs).
</li>
<li>
<a href="http://www.panic.com/transmit/"
title="Panic - Transmit 3 - The next-generation Mac OS X FTP client!">
Transmit</a> - Best FTP/SFTP/SCP client ever. Allows me to edit
remote filew seemlessly with TextMate. These days I'm often
connected to the internet intermittently or with high latency.
Editing files in this idiom (which seems to be almost unique to
the Mac) is the best way around that.
</li>
</ul>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com9tag:blogger.com,1999:blog-8106392.post-2071694084500815652008-08-26T18:47:00.001-07:002008-09-09T11:44:51.492-07:00emacs deficiencies<p>I want to like emacs more than I do. But it's hard. It's missing all kinds of features that I've gotten used to from more modern text editors. There are many basic operations that, although common in other editing programs and easy enough to implement in emacs-lisp, have never found their way into standard emacs. For instance, why aren't there built-in functions for:</p>
<ul>
<li>count-words-[buffer|region]</li>
<li>unfill-paragraph</li>
<li>kill-entire-line (this function is standard in xemacs)</li>
<li>kill-to-beginning-of-line (equivalent to M-0 C-k)</li>
</ul>
<p>I mean honestly, it's the feakin' 21st century here. It's not like counting the number of words in your buffer is a fringe use-case.</p>
<p> <span style="text-decoration:line-through;">Also, how hard would it be to support soft-wrapped text? And why can't I bind commands to the capital letter key combos (e.g. C-N in addition to C-n)?</span> longlines-mode will get you a close-enough approximation of soft-wrapped text and it should be possible to bind commands with the shift modifier. I just can't get it working on my Mac but I think it's a Terminal.app configuration issue.</p>
<p>The biggest issue I have with emacs however is that it doesn't support multiple major modes at once. This is a big problem for anyone programming with embedded languages – particularly web programmers – as it means that when you're editing HTML with Javascript or CSS, emacs can only be in one (major) mode at a time. So even if it has support for all the different languages in a given buffer, emacs can't switch modes as you move around in the buffer from one language section to another.
</p>
<p>There <em>is</em> a project called <a href="http://mmm-mode.sourceforge.net/">MMM</a> (Multiple Major Modes) that's trying (or tried, it hasn't been updated since 2004) to remedy that problem but it's an add-on, has limited language support, and requires customization for every language combination that you want to use.
</p>
<p>Okay, enough with the complaining. Let's try something a little more constructive. Here are some useful bits of emacs-lisp to rectify some of my complaints. I found all of them with Google so I can't take credit for anything below. Apologies for the line truncation that's happening in the <pre> tags. Something lame with blogspot templates going on there.</p>
<h2>Kill Away</h2>
<pre>
(defun unfill-paragraph ()
(interactive)
(let ((fill-column (point-max)))
(fill-paragraph nil)))
</pre>
<pre>
<span style="color:#aaa;">
;; No longer neccessary. See <a href="#update">update</a> below
(defun kill-entire-line ()
"Kill this entire line (including newline),
regardless of where point is within the line."
(setq kill-whole-line t)
(interactive)
(beginning-of-line)
(kill-line)
(setq kill-whole-line nil))
;; If you care to bind it
(global-set-key [(control ,)] 'kill-entire-line)
</span>
</pre>
<h2>Counting words</h2>
<pre>
;; This one is nice and simple but has a
;; slightly awkward output. E.g.
;; Word count: 325 occurances.
(defun wc ()
(interactive)
(message "Word count: %s"
(how-many "\\w+"
(point-min) (point-max))))
;; Nice version from Robert J. Chassell's
;; /Programming in Emacs Lisp/
;; Available at http://www.gnu.org/software/emacs/emacs-lisp-intro/
(defun count-words-region (beginning end)
"Print number of words in the region."
(interactive "r")
(message "Counting words in region ... ")
;;; 1. Set up appropriate conditions.
(save-excursion
(let ((count 0))
(goto-char beginning)
;;; 2. Run the while loop.
(while (and (< (point) end)
(re-search-forward "\\w+\\W*" end t))
(setq count (1+ count)))
;;; 3. Send a message to the user.
(cond ((zerop count)
(message
"The region does NOT have any words."))
((= 1 count)
(message
"The region has 1 word."))
(t
(message
"The region has %d words." count))))))
;; Count the words in the entire document
(defun count-words-buffer ()
"Count all the words in the buffer"
(interactive)
(count-words-region (point-min) (point-max) )
)
</pre>
<h2>Longlines.el (aka soft-wrap)</h2>
<p><a href="http://www.emacswiki.org/cgi-bin/wiki/longlines.el">Most excellent elisp code</a> to simulate soft-wrapping in emacs. Basically, hard-returns are inserted when text is loaded or typed into a buffer but all such returns are removed when the buffer is saved to disk.</p>
<h2>Shell Mode Improvements</h2>
<p>I have my shell set to use a colorized prompt. With default setting, emacs shell mode renders a colorized prompt pretty poorly. <a href="http://amitp.blogspot.com/2007/04/emacs-color-in-shell-buffers.html" title="Amit's Thoughts: Emacs: color in shell buffers">Amit Patel's blog</a>I has some useful settings</p>
<pre>
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(setq comint-prompt-read-only t)
</pre>
<h2><a name="update">Update: (2008-09-09)</a></h2>
<p>Well eat me and get big: emacs22 addresses some of my complaints. First, kill-entire-line is a standard command. It's supposed to be bound to C-S-<backspace> but I can't get it to work on my Mac in Terminal.app. I suspect Terminal.app is doing something non-kosher to the shift-ctrl combo but I'm not sure. In any case, it should be possible to bind commands to capital letters.</p>
<p>Second, longlines support is standard. M-x longlines-mode and you're set. </p>
<p>Haven't checked it out yet but Flymake seems like it should be awfully cool. It's supposed to do on the fly compile/syntax checking.</p>
<p>You can cycle through open buffers with C-x left and C-x right.</p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com6tag:blogger.com,1999:blog-8106392.post-51543701498311926432008-07-23T16:51:00.001-07:002009-05-15T17:13:42.305-07:00Where art thou iTerm?<p>UPDATE(2009-05-16): I found a fix for the broken meta-key problem on the iTerm bug tracker. Check out: http://sourceforge.net/tracker/index.php?func=detail&aid=1294192&group_id=67789&atid=518973</p>
<p>UPDATE(2008-09-26): iTerm released an update on Sept 24th. It seems to fix the mouse selection problem mentioned below but I still can't get the alt key to act as a Meta key in either local or remote connections. Key combos using alt just print out non-ASCII characters.</p>
<p>Leopard has a pretty decent terminal emulator in Terminal.app and I use it all the time. But before Leopard, Terminal.app left much to be desired and so I used a third party freebie called <a href="http://iterm.sourceforge.net/index.shtml">iTerm</a>. The biggest advantage over Terminal.app was that you could open a bunch of terms in tabs instead of needing a separate window for each. Now Terminal.app has tabs and that seems to have killed interest in iTerm. As of this writing, the "News" section on the iTerm webpage hasn't had any postings in a year and a half.</p>
<p>I find this a little sad. iTerm still has some things going for it that haven't found their way into Terminal.app (and may never). I miss Full screen mode. I miss iTerm's ability to override the color values for ANSI colors. The default blue color (used for directories) is essentially unreadable on a black background so with iTerm I lightened up the blue. I can't do this in Terminal.app so I'm back to squinting at directory names. I also think iTerms handling of bookmarks and tabs was more intelligent than Terminal but that's almost a quibbling issue.</p>
<p>So why don't I still use iTerm? Three reasons. First, iTerm has weird mouse selection behavior. When you select a line of text with the mouse moving from left to right, you have to be sure to position the cursor all the way to the left of the first character you want to select. I used to end up missing the first character all the time until I managed to override my habits. Right to left selection works fine. Second, I could never get the meta/alt/option key to work correctly in remote terms. I use Meta-d and Meta-backspace in bash quite often and I could never get it to work on remote connections to my Linux machines. It's easy to get working on Terminal.app. Lastly, iTerm has never supported .term files. These are a little known secret of Terminal.app that have been around since at least 10.3 (though they may go all the way back to 10.0). They allowed me to create files that would initiate ssh connections to particular machines. I used to keep a directory in my dock with a bunch of .term files in it so that I could right-click and jump to any machine that I needed to work on. Then I started using Quicksilver and dispensed with the Dock folder altogether. I could open a new Terminal.app window with an ssh connection to my workstation just as quickly as I could type Cmd-Space ws [enter]. </p>
<p>So iTerms's source is freely available on sourceforge. Maybe when I get several months of free time I can hack in those features. Go open source. When you find yourself frustrated with a product, all it takes is a degree in Computer Science, years of professional experience, and several months to get up to speed on a codebase.</p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com2tag:blogger.com,1999:blog-8106392.post-76004600239945934932008-07-16T12:47:00.001-07:002008-07-23T16:51:48.022-07:00ANSI Color Codes in C++<p>I finally got around to figuring out how to get C++ to output text in
different colors (assuming your output system (terminal) supports it). It's <a
href="http://deathray.us/code/color_output.html" title="color-output.cc">not at
all difficult </a>, it just requires knowing the string representations of the
ANSI color codes. I haven't tried it with C/printf but I can't see why it
wouldn't work the same way.</p>
gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com12tag:blogger.com,1999:blog-8106392.post-20669705515211960592008-06-18T16:05:00.001-07:002008-07-16T12:42:14.185-07:00HP 35s<p>I've been wanting another RPN calculator to use at work so after months of
ignoring the HP35s that was sitting in my Amazon wish list, I finally ponied up
and bought one.</p>
<p>It arrived today and boy is it disappointing. I don't know if it's supposed
to harken back to HP's glory days but its RPN mode is pretty hobbled. The stack
is only 4 levels deep(!) and the top and bottom positions clone when the stack
is shifted up and down. Very annoying and quite different from the HP that I
bought about 15 years ago (and still use at home).</p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com1tag:blogger.com,1999:blog-8106392.post-60109321107851547102008-01-29T16:19:00.001-08:002008-07-16T12:28:06.812-07:00Old issues of Wired<p>Fuck. A bad day.</p>
<p>One positive thing: I drew up a list of old issues of Wired that I’d like to
have because they featured articles by Bruce Sterling or Neal Stephenson. Then,
I ransacked the library of back issues that someone has discarded here at the
office. I found most of the isses I was looking for. The articles themselves
I’ve mostly already read on-line but this way I get the photos and layout.</p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-81210934770232441852008-01-25T15:30:00.001-08:002008-01-25T15:30:49.656-08:00David Foster Wallace article on talk radio<a href="http://www.theatlantic.com/doc/200504/wallace">Brilliant.</a>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-82940055105484806432008-01-17T15:01:00.001-08:002008-07-16T12:30:21.654-07:00DeskThe desk I’m stitting at is a featureless white rectangle with rounded corners.
It supports a pair of giant flat-panel monitors, taller than they are wide and
with edges flush, so the pair looks like a giant, luminous book, opened before
me. The rest of the surface looks like a battle ground between the Rectangles
and the Cylinders. The Rectangles have piles of paper, a notebook, the monitors,
a clipboard and no fewer than three sizes of sticky paper pads. The Cylinders
count among their members: a cup, a tin of tea leaves, a medicine bottle (with
one tiny cyindrical pill inside), a can of compressed air and a handful of pens.
I seem to be in league with the Rectangles. Every day I produce more of them and
drain the contents of the Cylinders.gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-56715240821630420952007-11-13T17:36:00.001-08:002007-11-13T17:36:35.376-08:00On the prospects of creating a headless Firefox<p>I've often wondered how hard it would be to make a headless version of Firefox. HTTPUnit is nice and all but if you want to ensure that everything is behaving as it does in a real browser there's nothing better than using a real browser.</p>
<p>So setting aside all questions as to difficulty does the idea of a headless Firefox even make conceptual sense? You'd at least need some way to script or control the behavior externally. But let's imagine you designed a feature where by hovering over an event you triggered an Ajax request or caused some DOM fragment to be constructed on the fly. In order to get the headless browser to do that you'd need to either have to tell it to simulate the mouse movement or tell it to artificially fire the hover event for the element in question.</p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com2tag:blogger.com,1999:blog-8106392.post-23387150335040471412007-10-30T19:19:00.000-07:002007-12-20T21:45:50.982-08:00(Lesser known) things I like about Leopard<ol>
<li>
Calculator.app sports a fully functional RPN mode. It's had RPN mode
since Panther but it always seemed like a shoehorned afterthought.
Switching to RPN never produced any change in the UI and RPN really
demands a multi-line display. Now it has one. There's one quirk I've
noticed: when you type a number and press enter, the number gets pushed
up the stack (as it should) and then gets duplicated on the line below
(not as it should). As soon as you begin to type a new number, the
doubled entry disappears but it should never have appeared in the first
place.
</li>
<li>Calculator.app can now also display digit seperators.</li>
<li>
The Airport menu (from the drop-down in the menu bar) now shows lock
icons next to those networks which are protected. You can see at a
glance if there are any available networks that are open.
<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"
href="http://bp3.blogger.com/_evHShtm_GMA/Ryfmiwgjh-I/AAAAAAAAAsY/bn4t36K6cwY/s1600-h/wireless.png">
<img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;"
src="http://bp3.blogger.com/_evHShtm_GMA/Ryfmiwgjh-I/AAAAAAAAAsY/bn4t36K6cwY/s320/wireless.png"
border="0" alt=""id="BLOGGER_PHOTO_ID_5127320185595987938" /></a>
</li>
<li>Hitting command-backspace from any NSTextEdit field will delete
from the cursor to the beginning of the line. This means TextEdit gets
the "feature" I most miss when I'm away from TextMate.</li>
<li>iCal.app no longer changes the size of your window when you switch
from (say) month view to week view.</li>
</ol>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-15888259092096484612007-10-24T12:20:00.001-07:002008-07-16T12:34:34.294-07:00ECMAScript 4 Overview (final draft)<p>The final draft of the Overview that describes what's going to be in Javascript 4 (E4) is <a href="http://www.ecmascript.org/es4/spec/overview.pdf" title="">online as a pdf</a>.</p>
<p>Interestingly, this represents a point of departure from previous Javascript updates in that the group will provide a "reference implementation" in ML! And I though all that time I spent working in ML back in college would surely go to waste.</p>
<p>You can grab the standard SML release for Mac (as a DMG even) from <a href="http://smlnj.cs.uchicago.edu/dist/working/110.60/smlnj-for-intel-mac-110.60.dmg" title="">here</a>.</p>
gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-59368504090051876202007-09-13T16:08:00.001-07:002008-07-16T12:33:33.449-07:00Bike to Work<p>I biked to work last Friday. No different from any other Firday at previous
jobs except that I now work 42 miles from home. So <a
href="http://deathray.us/geodata/rides/sf2g.html">my
commute</a> took 3 hours.
</p>
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&hl=en&geocode=&q=http:%2F%2Fdeathray.us%2Fkml%2Fsf2g-bayway.kml&ie=UTF8&ll=37.586965,-122.251407&spn=0.330365,0.334495&t=h&output=embed&s=AARTsJpmUKqO98MpkHkzywYA4PVlDCkp3A"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&hl=en&geocode=&q=http:%2F%2Fdeathray.us%2Fkml%2Fsf2g-bayway.kml&ie=UTF8&ll=37.586965,-122.251407&spn=0.330365,0.334495&t=h&source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>
<p><a href="http://deathray.us/kml/sf2g-bayway.kml">Download the KML file.</a></p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com1tag:blogger.com,1999:blog-8106392.post-68502887967525426372007-07-09T09:48:00.000-07:002007-10-25T09:48:54.999-07:00New Job (@ Google!)I've started a new job at Google!gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-46830314688265958222007-03-14T23:33:00.001-07:002007-11-28T23:03:05.852-08:00BBEdit Comes Around<p>We programmers spend a <em>lot</em> of time editing text and tend to feel pretty strongly about the relative merits of various text editors. For the better part of two jobs - spanning nearly four years - I lived and breathed in <a href="http://www.barebones.com/products/bbedit/">BBEdit</a>, “the programmer’s text editor”. It’s always seemed like a good product but even then it was already quite old and it seemed like its designers were resting on their laurels somewhat. The interface looked about the same as it had when my friend was using it in college on OS 9 back in 1998. There didn’t seem to be much work going on to create innovative features or even to copy ones that had started to crop up in other editing programs. But it still had an impressive feature list and at the time was by far the best tool for creating HTML/XML/CSS on Mac OS X.</p>
<p>But somewhere along the way I noticed <a href="http://macromates.com/">TextMate</a>. I saw a screencast for some Ruby on Rails demo and they were using snippets - type a keyword, hit some expansion key, get a whole bunch of templated text for free. I didn’t know the TextMate name for it but I knew the feature: it was the thing I most missed from a Java editing program that was a one time favorite on Windows. I decided to give TextMate a try even though it wasn’t free and even though I’d already shelled out big bucks for BBEdit (well, truth be told, the Reagents of the University of California shelled out the big bucks for BBEdit).</p>
<p>Over the years I’ve probably married about a dozen different text editors so it’s not a tremendously big deal for me to switch to something new. The muscle memory takes a little overcoming but it’s nothing horrific, especially if you’re not also switching platforms to something where the modifier keys are totally different.</p>
<p>It didn’t take long before I was hitched to TextMate. With the exception of occasional forays into emacs I’ve been using it exclusively for about 2 years. I switched and never looked back. Until today.</p>
<p>I was reading a blog which suggested that BBEdit had finally updated their interface so that it looked less out of place on OSX than does a disco ball at a funeral. So I downloaded the trial version (8.6) and gave it a spin.</p>
<p>There’s plenty to like</p>
<ol>
<li><p>The icon looks less like ass. I was using BBEdit when they switched from their chestnut of an icon to something that looked like a beta placeholder for the image it was replacing.</p>
<p><img src="http://designweenie.com/images/2004/bbedit-icons.png" alt="classic" title="" /></p>
<p>Either the whole thing was a play from the people that brought us New Coke and Coke Classic or they’ve seen the light: the newest version looks like the old except rotated a few degrees.</p></li>
<li><p>Rumors of interface polishing are true. The changes are rather minor but still welcome.</p></li>
<li><p>They’ve revamped their Glossary tool. Now it’s called Clippings and it works much like snippets in TextMate. The expansion key (F5) is a little awkward, especially on laptops. And where TextMate allows you to cycle through various pre-defined locations in the expansion text by repeatedly pressing the the same key (tab) that expanded the text in the first place, BBEdit uses Ctrl-` to cycle through positions. F5 still seems like a bad choice but having a different key command to cycle through the positions actually seems like a good idea. One annoying thing about TextMate’s snippet system is that you can’t expand a snippet if you’re still tabbing through the positions of a snippet you just expanded. It will interpret “tab” as a request to move to the next position instead of searching for an expansion. The BBEdit team seems to have made a better choice in this matter.</p></li>
<li><p>They’ve added support for a few more languages including Markdown and, get this, SQL. Yeah, it’s 2007 and they’re just getting around to adding SQL. Still they did it well and have support for multiple SQL variants like PL/SQL and MySQL.</p></li>
<li><p>They’ve added a preview window just like TextMate and SubEthaEdit. If you keep it open while you type it will refresh the preview automatically whenever you stop typing for a second or two. You don’t need to save the document to use it. Yeah, it’s just like TextMate and yes, it feels like they’re copying but it’s still a worthwhile addition.</p></li>
<li><p>Code folding. I make very little use of this feature but I’m sure it has its fans.</p></li>
</ol>
<p>As long as they were out copying features I wish they’d copied a little more. There is still no equivalent to TextMate’s themes. The syntax highlighting engine still doesn’t support things like making keywords boldface. It still has pretty poor support for editing files with mixed languages (like PHP inside HTML). It still needs an organizational concept as functional and powerful as TextMate’s bundle system.</p>
<p>I’m not going to move back to BBEdit any time soon but these recent changes are enough to entice me into checking back on it in a few months. If nothing else, BareBones seems to have recognized that they’ve been squandering their name recognition and an enormous lead and that if they want to remain competitive they’ll need to start making radical changes. I think they made a couple of large mistakes when they moved to OS X. They ported the code but didn’t seem to do much to avail themselves of all that Objective C and Cocoa would provide. Even if they wanted to exploit the undeniable advantage of their extensively optimized and highly debugged text engine, they should have recognized that the arrival of OS X meant that others less encumbered than they would be able to make full use of everything from XCode to Cocoa to Objective C to the UNIX shell, and that this might allow a hypothetical upstart to move so quickly that any initial lead could evaporate before you could say “reality distortion field.”</p>
gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-11729041828323172312007-03-13T22:50:00.001-07:002008-08-27T09:30:07.234-07:00Pardon the interruption<p>I am typing this entry using <a href="http://www.red-sweater.com/marsedit/">MarsEdit</a> 1.1.5(207), of which I just downloaded a trial version. It seems you can edit your posts in whatever text editor you choose but I need to see if I can specify that markdown formatting is to be applied as part of the post procedure or if that’s something that’s only available while you’re previewing your post in MarsEdit.</p>
<p>This sentence should begin a new paragraph and <em>this</em> word should be italicized. </p>
<p>Update: it turns out markdown syntax is recognized by MarsEdit’s built-in preview window but there doesn’t seem to be any way to configure it to run your post through markdown prior to submitting it to your blog. Even more mysterious, there doesn’t seem to be any way to <em>manually</em> convert your markdown-formatted post into HTML suitable for posting. It’s lucky that I have a licensed copy of TextMate and that MarsEdit will allow me to edit my post there.</p>
gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-31055791851561799162007-03-01T21:48:00.000-08:002007-03-15T20:45:51.191-07:00iTerm goes full screen<p>I started using iTerm pretty regularly at work a few months ago because it supported multiple tabs. I flirted with the program long before that but it seemed too unstable back then so I gave it up and went back to Terminal.app. The stability has improved a lot since then but there has always been one feature I found missing: full screen support.</p>
<p>Until now.</p>
<p>I didn't even notice when it happened but the most recent versions of <a href="http://iterm.sourceforge.net/">iTerm</a> now sport a great full screen mode.</p>
<p>Like a lot of programmers (and sysadmins) I spend a good deal of time working in a terminal. At work, a lot of us do. The crowd seems to be split between:</p>
<ol>
<li>those who think full-screen mode is the coolest thing since screensavers</li>
<li>those who make fun of the first group</li>
</ol>
<p>I'm such a fan of full-screen mode that I've long kept GLTerminal on my machine just for those instances where I want to work in a terminal without any distractions.</p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-88112573621248412072007-01-31T22:25:00.000-08:002007-01-31T23:09:09.554-08:00XSL[T|-FO]<p>My friend (and co-worker, and constant source of distraction) Kirt was poking around the company intranet today and came across a document detailing interview questions for “XSLT Developers”. When I was doing Java for a living I used XSLT quite a lot and eventually became quite good at using it effectively. Naturally, I was curious to see what we had to say about the qualifications of a good XSLT developer, especially since as far as I know, we don’t now, nor have we ever, used the slightest bit of XSLT for any part of our entire system.</p>
<p>Using the document to conduct an actual interview would have made for a pretty miserable experience which - since we’ve never used it and are unlikely to ever use it - I’m okay with. But it reminded me that there is a lot of confusion about what XSLT is and isn’t. XSLT and XSL are not synonymous. XSLT is a language for transforming XML documents. XSLT is but one of two components of the larger XSL, the other being XSL-FO: which is a language for specifying visual display. XSL is just a unifying term, a shorthard for saying “XSLT plus XSL-FO.” <a href="http://en.wikipedia.org/wiki/Xsl">Wikipedia’s</a> article on XSL disagrees with at least two points here but I won’t go into it other than to say that Wikipedia (though I love it so) is wrong.</p>
<p>I think that part of the reason why XSL and XSLT are used interchangeably is that in the beginning, XSLT pretty much <em>was</em> all of XSL. Sure, XSL-FO was envisioned early on but it took a long time to get a standard and it took a <em>really</em> long time to get an implementation. XSLT had a standard and multiple implementations while XSL-FO was nothing more than a dim idea. If you started using XSLT back then, you could be forgiven for thinking that was all there was to XSL.</p>
<p>The other point of confusion about XSLT is that it’s nothing more than a glorified variable substitution engine with horrid syntax. It’s syntax is retched and you certainly <em>can</em> use it to simply plug variables into an output template but XSLT is a lot more capable than that. It took me a long time to see and even longer to really understand that XSLT is basically a functional programming language. </p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-6348284747056753382007-01-22T21:30:00.000-08:002008-08-27T08:36:36.154-07:00lisp on OS X<p>I’ve decided (finally) to learn lisp. I don’t know if it will
<a href="http://www.catb.org/~esr/faqs/hacker-howto.html#skills1">make me
a better programmer</a> but if even half of what
<a href="http://www.paulgraham.com/avg.html">Paul Graham says
about it</a> is true, it has to be the best programming language ever written. =)
</p>
<p>Mac OS X doesn’t ship with a lisp interpreter but there are several
free implementations out there. After ruling out the ones that cost
money and the ones that have icky IDEs that run in X11 and the ones that
depend on things like Fink, you’re really only left with two options.</p>
<ol>
<li><a href="http://trac.clozure.com/openmcl">Clozure CL</a> (formerly known as OpenMCL)</li>
<li><a href="http://www.sbcl.org/">SBCL</a> (Steele Bank Common Lisp)</li>
</ol>
<p>I went with SBCL because it works on both PowerPC and intel. Installing it
is pretty easy. You do need to have the Developer Tools installed on your computer as the install process makes use of gcc.</p>
<ol>
<li><a href="http://sbcl.sourceforge.net/platform-table.html">Download
the “binary” for the platform of your choice</a> </li>
<li>Uncompress/untar the bz2 file</li>
<li>Fire up Terminal.app</li>
<li>cd to the directory that you extracted from the tar file</li>
<li>Run the following commands:
<pre>INSTALL_ROOT=/usr/local
sudo sh install.sh</pre>
</li>
</ol>
<p>That’s all there is to it. At this point you can run the lisp interpreter
(sbcl) or bring up the man page for it.</p>
<p><strong>UPDATE</strong> (27 August 2008): <a href="http://trac.clozure.com/openmcl">Clozure CL</a> now supports both PPC and x86-64. CCL has always had better integration support for Mac OS X so it may now be a better choice for Mac users than SBCL. I haven't used it much but I plan to put it through it's paces.</p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com3tag:blogger.com,1999:blog-8106392.post-8617830602145564042007-01-17T21:59:00.000-08:002007-01-22T21:27:33.313-08:00Sunnis and Shiites<p>If you pay attention to the news, it’s nearly impossible to go a day without hearing about Sunnis and Shiites. Assuming you start out knowing nothing about them, it only takes a few news stories to figure out the most pertinent facts: they’re Islamic groups that seem to hate each other. But the news outlets never tell you anything about <em>why</em> Sunnis and Shiites don’t get along. If you want to understand that, you have to do a little research of your own.</p>
<p>The best and most succinct description I’ve read comes from Thomas L. Friedman’s <a href="http://www.amazon.com/Beirut-Jerusalem-Revised-Thomas-Friedman/dp/0374158959/sr=8-2/qid=1169099766/ref=pd_bbs_2/002-4243179-6280818?ie=UTF8&s=books"><em>From Beirut to Jerusalem</em></a></p>
<blockquote>
<p>The Muslims of the world have long been divided between Sunnis, who
are the majority, and Shiites. In the seventh century, shortly after
the death of Islam’s founder, the prophet Muhammad a dispute arose
over who should be his successor as spiritual and political leader,
known as caliph. One group, the majority, argued that Muhammad’s
successor should be appointed through the process of election and
consensus by the elders of the community, as was the tradition of the
desert. <em>Sunna</em> in Arabic means tradition, and those who held this view
became known as the Sunnis.</p>
<p>A minority faction, however, argued that Muhammad’s successors should
come exclusively from his own family and their descendants. They
insisted, therefore, that his first cousin and son-in-law—Ali—be
appointed as leader of the community. Those who held this view became
known in Arabic as the Shia or “partisans,” of Ali. The Shiites were
clearly influenced by the notion of divine-right monarchy of
pre-Islamic Persia (Iran). The Sunnis eventually defeated the
supporters of Ali and installed their own chosen caliphs.
Nevertheless, the Sunni-Shiite split has continued down through the
ages of Islam, and a whole body of theological and even cultural
differences developed, distinguishing Shiites from Sunnis. Summarizing
these differences, Islam expert Edward Mortimer observed in his book
<em>Faith & Power</em>: “Sunni Islam is the doctrine of power and achievement.
Shi’ism is the doctrine of opposition. The starting point of Shi’ism is
defeat: the defeat of Ali and his house…. Its primary appeal is
therefore to the defeated and oppressed. That is why it has so often
been the rallying cry for the underdogs in the Muslim world …
especially for the poor and dispossessed.”</p>
</blockquote>
<p>Iraq happens to be one of only two Islamic countries (Iran is the other) where the Shia constitute a majority of the population (about 60 percent). This does nothing to help explain the Iran-Iraq war but does help illuminate why many other Islamic states seem supportive of the Sunni insurgency.</p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-1165458318989554792006-12-06T18:19:00.000-08:002007-09-19T11:28:03.547-07:00Mac Pro Optical Drive Door Problem<p>I recently became the proud new father of a Mac Pro 2xDual Core Xeon. It basically rocks the pants off the machine that it replaced - a poky 533Mgz G4.</p>
<p>But it has developed a slight problem with the little sliding door that protects the optical drive innards. It normally slides down when the tray slides out and then back up again after the tray goes back in. But mine now gets stuck when it's down. Like a depressive alcoholic, it just sits down there and sulks long after the tray has gone back home.</p>
<p>I can trick it back up again by raking my finger over the left side of the door a few times. I can't be the only one having this problem so I thought I'd pass it along.</p>
<h2>Update 2007-09-19</h2>
<p>I have not had a problem with the door for several months. Not sure what caused the problem to go away.</p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-1154065184937859862006-07-27T22:10:00.000-07:002006-07-27T22:39:44.993-07:00New Job<p>I’ve changed jobs. Actually, I changed jobs some time back (April to be specific) but I have more or less forgotten about this blog in the interim.</p>
<p>So I’m no longer with Tagged.com. I don’t want to even get into the reasons why I left. It would just remind me how unhappy I was there.</p>
<p>For the time being, I’m contracting for a company called PodShow. It was co-founded by <a href="http://curry.com/">Adam Curry</a>, who was one of the early VJs at MTV. He’s an interesting guy but he lives with his family in London most of the time so he’s not often in the office. The other co-counder - Ron Bloom - basically runs the company. The two of them got very rich with their first start-up, Think New Ideas, which I believe they sold for $400 million.</p>
<p>Marc Frochtzweig and Stephen Rodriguez were two excellent product designers that I worked with at Tagged and they both moved to PodShow. They in turn brought me in. Ostensibly, I was going to be working on creating some address book importers for the big webmail providers (e.g. gmail, hotmail). I had just spent a lot of time doing similar work for Tagged so I was pretty versed in the way the webmail providers worked.</p>
<p>Before starting however, I took a vacation to Amsterdam and when I came back, they were more interested in having me design an email <em>sending</em> system. From there, I moved on to other administration tools and that’s basically become my domain.</p>
<p>Apparently, PodShow is interested in making me a full-time engineer but so far, they’ve failed to make it happen. They pay me awfully damn well as a contractor though so I’m not really complaining. But I bet I’ll change my tune come April 15th.</p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com1tag:blogger.com,1999:blog-8106392.post-1140073548060173542006-02-15T23:05:00.000-08:002006-02-15T23:05:48.073-08:00Hell is upgrading Oracle versions<p>We're migrating from Oracle 9i running on a single box (in MTS mode) to an
Oracle 10g RAC cluster. For those that don't know, RAC is Real Application
Server and it's (supposed to be) one of the ways that you create a highly
scaleable Oracle system. Before we began I naively thought the migration
would... a) cost a fortune, b) be a pain in the ass for the DBAs and IT folks
but c) be relatively painless for us software engineers. To make a long story
short, I was right about the first two points.</p>
<p>The problems for us stem from the sequence generation facilities. In Oracle
you can configure the sequence generator to work in different ways but the way
we've had it working for over two years is to generate numbers one right after
the other. The numbers that come out of our sequences are in order and there
are essentially no gaps between successive items.</p>
<p>One of the side-effects of this approach is that you can treat any such
sequence-backed column as a kind of time-stamp; you can order records by their
effective creation date just by sorting on the sequence-backed field.</p>
<p>When you move your database to a system that runs on multiple machines (i.e.
RAC) you basically lose the ability to have your sequences work this way. More
precisely, you <em>can</em> configure them to work that way but doing so means that
the nodes in your cluster will need to constantly coordinate with one another
and the ensuing chatter will take a big bite out of your performance.</p>
<p>So in switching to RAC we lost the comfort of being able to assume that
successive sequence values would go in increasing order. Calling
sequence_name.NEXTVAL three times in a row might get you: 47, 38, 52.</p>
<p>We had to hunt down every query in our application that ordered by a sequence-
backed field. That in itself is no easy task when you have thousands of
queries scattered across hundreds of files, some written in PHP, some in Java
and some in PL/SQL. The most sophisticated tool available was grep and we had
to manually inspect dozens of candidate queries to figure out which ones to go
after.</p>
<p>Then began the hard work of actually fixing the queries. We had to change all the "ORDER BY" clauses to use a different field (or set of fields), specifically a DATE field. Unfortunately, a lot of the underlying tables didn't have any appropriate field so in those cases we needed to modify the schema. The problem then arises of what do with the millions of existing rows that were created before we needed to record the date. We ended up giving them an arbitrary date in the past but that just meant that the "ORDER BY" clause now needed to act on <em>two</em> columns instead of one.</p>
<p>All in all, it took three developers about two weeks.</p>
<p>* <em>I started writing this post months ago but it got waylaid and forgotten.
In finishing up I've tried to write in a manner consistent with my
thoughts and experiences at the time of inception. I'd like the post to approximate my thoughts at the time</em></p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-1140069841951558562006-02-15T21:58:00.000-08:002006-02-15T22:04:01.953-08:00Been a long time<p>So let's see how long it's been since my last post...<em>three months</em>? Yikes.
I'd appologize but then I don't seem to have any readers. I'm writing here to
a future version of myself.</p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0tag:blogger.com,1999:blog-8106392.post-1132121196257306152005-11-15T22:03:00.000-08:002007-09-19T11:23:34.289-07:00Compilling Spidermonkey on OS X<p>
For the foreseeable future my professional life will involve a lot of
messing around with <a href="http://greasemonkey.mozdev.org/">browser
scripting</a> and <a href="http://httpunit.sourceforge.net/">browser
simulators</a>. Recently, I got interested in the javascript engines
created by the folks at Mozilla. Turns out there is not one but
<em>two</em> seperate engines: one called SpiderMonkey that's written in
C (and used in the actual Mozilla-based browsers) and one written in
Java called Rhino (used by HttpUnit among other projects).
</p>
<p>
Building SpiderMonkey on my Mac turned out to be very easy but since I
couldn't find any up-to-date instructions (the README says to use
CodeWarrior) I figured I'd write up a simple walkthrough.
</p>
<ol>
<li>
First, <a href="http://ftp.mozilla.org/pub/mozilla.org/js/">download
the source</a> files. I grabbed the only non-Rhino file I could
find which happened to be <code>js-1.5.tar.gz</code>
</li>
<li>Unzip/untar the file you just downloaded</li>
<li>
Fire up Terminal.app and cd your way into the <code>/src</code>
directory within the directory you just un-tarred.</li>
<li><code>make -f Makefile.ref</code></li>
<li>
In a few minutes you should have a sub-directory called
<code>Darwin_DBG.OBJ</code>
</li>
<li>
Within that there's an executable called <code>js</code> which is
the standalone javascript interpreter.
</li>
</ol>
<p>
That's pretty much it. I moved the executable to <code>/usr/local/bin</code>
but of course that's optional. You can create javascript files and run them
using the js command and they just work. The one issue I haven't been
able to figure out is why I can't create XmlHttpRequest objects like so
<code>var ro = new XMLHttpRequest();</code>.
</p>
<p>
If anyone can figure that out I'd love to know what else I need to be
doing.
</p>
<h2>update</h2>
<p>
I feel stupid. Of <em>course</em> the javascript interpreter won’t
have any way to make XMLHttpRequests. All sorts of browser magic is going
on in the background to make that shit happen. The network connection is
the least of it. When you make an Ajax request it looks to the server just
like a normal page request, complete with cookies and everything.
</p>
<h2>update 2 Feb 2007</h2>
<p>
You might want to check out <a href="http://developer.mozilla.org/en/docs/Introduction_to_the_JavaScript_shell">this page</a> to get a feel for what you can do in
the js interpreter.
</p>
<p>
Also looks like they updated the spidermonkey tar-ball to 1.6. <a href="http://developer.mozilla.org/en/docs/New_in_JavaScript_1.6">Here’s a page</a> that includes the new features in 1.6. I’m a fan of the new functional constructs like <code>map() filter()</code> and <code>reduce()</code>.
</p>
<p>
Once you have the interpreter up and running, try this...<code>[1,2,3].map(function (a) { return a*2; });</code>
</p>gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com4tag:blogger.com,1999:blog-8106392.post-1129439756302997742005-10-15T22:11:00.000-07:002005-11-15T22:13:17.716-08:00answer to linked list problemThe answer is that you start both pointers at the head of the list and you move them both down it but you move the second pointer (call it B) twice as fast as you move pointer A. If there is a cycle, you'll eventually detect it.
Set A to head if list.
Set B to A->next. If B->next = A, you have already detected a cycle.
Otherwise, advance B one node and compare to A again.
Now advance A one node.
Advance B two nodes, comparing to A each time.gavin hurleyhttp://www.blogger.com/profile/17010494394838796820noreply@blogger.com0