Archive for the Geeking out Category

Update/rewrite I just installed the PHP Markdown Extra plugin in the blog, and it seems to be working

My main reason for wanting a Markdown plugin is to use the offline blogging capabilities built into Textmate, especially with the introduction of the new Blogmate plugin. If the site blows up … well, I guess if it blows up, you won’t be reading this anyway.

Oh - you might be wondering what Textmate/Blogmate connection is. Textmate is the coolest text editor in the world (although I know the emacs zealots will disagree) which has built in blogging capabilities. Blogmate is an extremely sweet plugin for Textmate that gives the blogging capabilities a nice GUI. I could use straight HTML with either of them, but both have the capacity to work with Markdown, and Markdown is a much cooler way of formatting text as you type.

I’m going to post a link to a you tube video. I vowed it wouldn’t happen, but I can’t resist this - if you grew up geeky (and if you are reading this, there’s a pretty good chance that you did), you’ll love it. Don’t watch if while you have a beverage in your mouth - cleaning up your keyboard and monitor is time consuming.

Via Brian Lamb - a Monty Python/Star Trek mashup

I’ve had some requests for my admin_delete_users_bookmarks_and_tags for Scuttle that I hobbled together some time ago. After going through all the files in my scuttle installation, I realized the only hack was that I changed the function isAdmin in the services/userservice.php from this:

function isAdmin($userid) { return false; //not implemented yet }to this:

function isAdmin($userid) { if ( ($userinfo = $this->getUser($userid)) ) { if ( $userinfo['uAdmin'] == 1 ) { return true; } } return false; }

This a really cheap and dirty hack because all it does is give admin privileges to the user with userid 1 in the database (which just happens to be my userid - substitute your own). All the other code was Scuttle 0.7.1 already, just waiting to be used. I don’t even know if this is a hack - more like a piece of duct tape over a leak in the hull of a boat. But it works. If anyone has a better hack, and honestly - a monkey sitting banging his/her head on the keyboard could do better than this - please leave it here or let me know.

UPDATE: Sadly, the spammers figured out a way around this, and even after shutting down registration the bad links kept showing up. The school’s social bookmarking site has been shut down indefinitely. Stinking spammers!

Thanks to Alan:

Hmmm - LISP is obscure, confusing enough to give the appearance of being complex, understood by very few people and used to simulate intelligence. Yep, that sounds like me!

If you’ve read this, consider yourself tagged - take the quiz. Is anybody a Python? That’s what I was hoping for.

I’ve been spending some of my free time (read that as “time when I should be working on other things but I’m procrastinating”) working on a Python script to implement some of the organizational strategies in David Allen’s Getting Things Done productivity system (if you haven’t, check out some sites like 43 Folders or Lifehack ). Tonight was a milestone in the scripting as I finished the parts of the script that will move all the items in my inbox that I’ve give an context (basically a category, if you’re not into the GTD lingo) into the correct context file.

If you don’t write programming code of any sort, you will not understand my elation since I have taken many hours to write a script that will do something that would take me 5 minutes to do by hand. My wife shares your curiosity, although she is polite enough to nod and smile when I have shown her what I have done. My fellow coders and scripters will understand why I am doing the dance of joy.

The TextMate connection is related to my quest for a text editor. On D’Arcy’s recommendation, I gave TextMate a 30 day test drive. As the demo deadline loomed, I realized that I could no longer live without TextMate. Tab triggers are the coolest thing in the world for coding HTML (or any kind of coding). I’ve written the Python script using TextMate, and I can run the script from right in the editor. The icing on the cake is that TextMate can be used as an offline blogging tool! In fact, I’m using it right now to write this entry. Pretty cool, huh?

I will release the final code once (if) I have finished. In fact, I’ll add that project to my GTD inbox right now.

This is a test post using TextMate, just because D’Arcy recommended it so highly. If it works, I just might end up buying TextMate instead of using Smultron.

By the way, one great feature of Smultron that I forgot to mention in my text editor review was full screen mode. The text editor can completely take over the screen, thus blocking out distractions on the desktop.

As part of my M.Ed. project, I’ll be building a web site. Most sane people would do this using Dreamweaver or some similar product. I, however, am not one of those people - I prefer to create web pages by hand-coding the HTML and CSS files. I suppose if I wanted to be uber-geeky about it, I would write my own text editor (in assembler, if I wanted to be really hard core about it), but I’ll stick with ones that are currently available for the Mac.

My requirements are fairly simple. I need a text editor that I can use to write HTML and CSS files. Any text editor could do this. Heck, I could use vi if I really wanted to geek out. I’d like to have an editor that did some of the coding automagically. I like to hand code, but I don’t mind using some tools that help to automate the typing. I could use the code editor in Dreamweaver - I’ve used it before and its actually very comfortable to use. Using Dreamweaver just to do handcoding is like buying a Ferrari just for driving to the local grocery store - a waste of money and not using the functionality to its fullest. Besides, with Dreamweaver I might decide to use the WYSIWYG mode, and that is the way to the dark side.

I also like to use some open source software, if possible. The free (as in beer) part certainly appeals to me, but so does the speechiness type of freedom. In my experience, a strong user community around an open source project is usually a better source of application support than the support available for commercial software. Also, if I am really stuck on something or I have suggestions to improve the program, I can contact the developer(s) directly. Try that with most commercial software! I did a little bit of research into this, and thought I should share the results with others. Lest you think I am being overly concerned with this, a good text editor is to a coder what power tools are to a carpenter. We can get good results with mediocre tools but its an easier job to do, and more fun, with good tools. Admittedly, my needs as a coder, not to mention my skills, are minimal but I still like to work with proper tools. OK - here are my thoughts on the text editors I reviewed. I won’t claim that I’ve done a thorough job of testing each editor, so some of these descriptions are based on limited experience.

  1. TextEdit Free with Mac OS (equivalent to NotePad in Windows). Nothing fancy for editing tools, just straightforward text editing. Free with all Macs, and apparently the source code is open and distributed with Xcode. TextEdit also has some nice word processing features, but I don’t need those. Rating: 1/5 (as an editor; for other uses it would rate 3.5/5)

  2. JEdit Nice editor, many good plugins available including an XML plugin that does automagic tag closing for HTML tags, and makes tag suggestions when creating tags (similar to Dreamweaver code editor). No built in auto XHTML file templating, but a macro was easily written to do the job. Macro recording (or writing, if you aren’t afraid of a little coding). Feels very Emacs-ish. Open source.

Rating: 4/5

  1. Smultron Open source, Mac OS only. It has a very Mac-ish look and feel to it, with the toolbar at the top. Multiple windows can be open simultaneously, with a pane showing a list of currently open documents. Keyboard shortcuts to move between open documents. There is a built including XHTML template. Full screen edit mode for distraction free writing/coding. Includes a command line tool - this editor has many command line connections, including ability to run shell commands, or run the file or selected text. It can auto-close tags, and can make text suggestions for partially completed word. This would make a really nice HTML editor. There is a lot of well-thought out functionality in this editor and may end up being my choice.

Rating: 4.5/5

  1. TextWrangler Proprietary, but free, from the good folks at Bare Bones Software. This is essentially a limited version of BBEdit. It excels at using regular expressions to transfrom text, but as an HTML editor it isn’t as fully featured for coding HTML as Smultron or JEdit. Has an Emacs-ish feel to it.

Rating: 3/5

  1. BBEdit The 500 pound gorilla of Macintosh text editors. I remember using BBEdit on my old (OS 8 era) Mac, and it was a joy to use as an HTML editor (I didn’t do much coding back then). I’m not sure if my memories of BBEdit are correct or if my expectations of an HTML editor have increased, but I find that BBEdit, like Text Wrangler, is an adequate HTML editor but not a particularly great one. The functionality in BBEdit is perhaps too much for my meagre needs, and it is verging on becoming bloatware (IMHO). It is also the priciest of the Mac text editors at US $125, which works out to $145 Canadian, quite a bit considering the availability of free editors like JEdit and Smultron, and the availability of lower price editors like TextMate. Rating: 4/5

  2. TextMate This is an newer text editor but unlike Smultron, TextMate costs 39 euros, which works out to about $60 Canadian. As an HTML editor, it is as sweet as candy. New (X)HTML documents can be created from a template, which is editable. Keyboard shortcuts are available for almost all standard functions such as moving word by word or to the end of the current line.

An interesting variation on keyboard shortcuts are tab triggers. These are short strings (such as ‘div’ to insert a new div tag) that activate an action when followed by a tab. I typed in ‘div’ followed by a tab, and a pair of div tags were created including a placeholder for an id property; if I want to use it, I tab then type in the id for the div, and if I don’t want it, I hit the delete key then a down arrow and I’m ready to add content inside the div tag. It took me about 30 seconds to create a snippet (piece of text that is used frequently) for a paragraph tag (which suprisingly is not included with the program, or at least I couldn’t find it), then another 10 seconds to assign a tab trigger for it. Sweet!

TextMate was the winner of the Apple Design Award for best developer tool in 2006.

Rating: 5/5

Final thoughts I’d narrow my choices down to JEdit, Smultron and TextMate. TextEdit has no pretense of being a programmer’s editor, even for something as simple as HTML, and would only be suitable if you liked to type everything out one character at a time. I need something with a little bit more HTML programming finesse. Text Wrangler and BBEdit have great text processing capabilities, but feel a little too emacs-ish for me (not to start a series of comment flaming, but I’m more of a vi guy), and aren’t especially welcoming for someone who just wants to do some productive HTML coding. I like JEdit. It is free software/open source. Its extensibility by plugins is terrific, and there seems to be a strong community (always a good thing for an open source project). I have used it in Linux and Windows environments, and will continue to do so. The Mac-ishness of Smultron and TextMate, as well as their design as coding tools, make them my clear choices. Given my preference to use free (as in both beer and speech) software, Smultron will be my first choice. I may still be lured to TextMate, definitely my favourite of the entire bunch.

This is just a quickie braindump post so I have some notes on a bit of tweaking I just did on the school’s installation of Scuttle, an open-source social bookmarking tool similar to del.icio.us.

The problem we were running into was a lack of administrative control to get rid of undesirable (spam) links in the bookmark collection. Looking through the code, I saw that Scuttle does have a stub admin function included, but it isn’t currently implemented.  In a disgustingly quick and dirty hack, I rewrote the code for the admin function so that anyone whose user ID number in the MySQL database is automagically the administrator (and that happen’s to be me in this installation). Nicely enough, once I did that I had edit and delete power over other user’s links - the author of Scuttle has obviously been planning to include some administration tools, and started building a bit of code to do the job.

Samples of code available upon request - if you leave a comment asking for it, I’ll post it up.

A few days ago, I got a BSOD on the old Wintel laptop. I’ve had the computer for nearly 4 years, and this is the first BSOD that I’ve got on it. Sadly, it may also be the last.

This particular BSOD informed me that my Windows registry was … well, I think I can summarize by saying that the registry is hooped! Thankfully, I’ve had the new Mactel laptop for over a month, and I’ve been using it for a lot of day to day stuff. The only hitch was that a lot of my files - from University, for school and some family pictures - were still on the hard drive of the old laptop. Most had not been backed up.

My first task, then, before I started poking around on the hard drive, was to back up all that stuff. Faced with a corrupted registry and an un-bootable computer, most people would probably give up, cry or call their local PC repair shop. Luckily, I had an old Ubuntu Live CD so I didn’t need to do any of these three things! A bit of googling gave me the instructions to mount the Windows (NTFS) hard drive (I’ll put instructions up soon if I remember) so I could copy the files over to a USB external 120 GB drive. This went smoothly.

Now that my data is safe, I am faced with a decision - what to do with the old computer? As I see it, I have three choices:

  1. Try to fix the registry. My computer creates restore points every week, so if I can move the old registry files and insert the repair registry files, I should be just fine. Sadly, I haven’t figured out how to do this yet using Ubuntu. I hear that Knoppix is good for this, so I may give it a try. Any other suggestions for repair CDs would be useful.
  2. Re-install the system from scratch. The CDs that came with the laptop will reformat the drive and re-install the original installation. Sadly, they will not allow me to do a simple fix of the registry as it currently exists.
  3. Remove the Redmond virus once and for all from the laptop, and just install Ubuntu. If I do this, I may just get a bigger hard drive while I’m at it.



I’m back in black, with a Mac
I’ve been too long, I’m glad to be back.
(with apologies to AC/DC)