Wednesday, January 21, 2009

How to embed code snippets in your blog

Embedding code snippets in your blog can be tricky. Most blogs are set up with WYSIWYG editors, but when you paste your code snippet, the results may not be what you expected. In my case, I use Blogger.com, and I'm still using a default template. So, I've noticed that I don't have much real estate horizontally in the blog posting.

One of the first techniques I have tried is to simply wrap my code snippet with <blockquote> and <pre> tags. But since I have a set width on my blog, what can happen is this:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris molestie eros. Nullam at justo quis eros feugiat blandit. Nulla sed nunc. Sed quis purus. Suspendisse potenti. Phasellus in ante. Cras ut nibh. Nulla ut odio. Phasellus mauris. In eu lectus eu dolor egestas tempus. Integer aliquam. Phasellus accumsan. Sed iaculis lacus in lacus. Aliquam erat volutpat. Vestibulum nulla enim, pharetra sit amet, tincidunt et, bibendum id, magna. Aenean elit. Vivamus nunc. 


The code disappearing off to the right (in Firefox) was not desirable. So I got fancy. I decided wrapping the code snippet with <pre> and <code> tags looked better. Especially if I added some special magic to the <pre> tag:

<pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 90%;">


So, my previous example will now look like this:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris molestie eros. Nullam at justo quis eros feugiat blandit. Nulla sed nunc. Sed quis purus. Suspendisse potenti. Phasellus in ante. Cras ut nibh. Nulla ut odio. Phasellus mauris. In eu lectus eu dolor egestas tempus. Integer aliquam. Phasellus accumsan. Sed iaculis lacus in lacus. Aliquam erat volutpat. Vestibulum nulla enim, pharetra sit amet, tincidunt et, bibendum id, magna. Aenean elit. Vivamus nunc.


I still use this technique sometimes for smaller snippets of text, usually one-liners. But now my favorite way of embedding text is to use GitHub's Gist site. You just paste in your code at gist.github.com and then get the javascript to embed your code snippet. Now my example looks like this:



I like using GitHub because they have syntactical highlighters for many different languages. For example, here is a snippet in Ruby:



Note that there are other websites that do similarly, and GitHub is not unique. It just happens to be the one I prefer.

Friday, January 9, 2009

Thursday, January 8, 2009

Disabled Twitter timeline on my blogs

There is currently a problem with the Twitter badge on my blogs and many other blogs out there (not just WordPress or Blogger), so I've commented out the javascript until it gets fixed by Twitter. Every time the page is loaded the end user is prompted for a Twitter username and password. With everyone nervous about phishing, I decided to disable it for now until it is resolved.

Monday, January 5, 2009

Hudson versus Cruise search yields unexpected results

I just ran the following Google search to find articles comparing the continuous integration tools Hudson and CruiseControl:
hudson versus cruise

And I got this funny and unexpected result, Kate Hudson Vs Suri Cruise - Who Wore It Best?.

Sunday, January 4, 2009

JournalSpace is wiped out, gone, and up for auction on eBay.

Some really bad news for the JournalSpace bloggers out there. Five years of data lost because the JournalSpace company didn't have backups of their SQL Server database. Big oops. And it put the company out of existence, with their domain up for auction on eBay. So, let this be a wake up call, or simply a reminder, to back up your data or create a backup plan if you don't have one. I for one will be backing up my two blogs on Blogger.com. Here is more on the story: LiveJournal

Monday, December 1, 2008

Configuring VPN with Leopard (Mac OS X 10.5)

I finally figured out how to get my new MacBook Pro which is running OS X 10.5 (Leopard) to connect properly to my work's VPN. There are a few differences from OS X 10.4 (Tiger). First of all, there is no longer an Internet Connect application. You must open System Preferences > Network. Then click the little plus sign at the lower left corner to add a new interface. So, this allowed me to connect to the VPN, but my computer would not resolve any addresses and I couldn't ping my work machine. So, the second difference is that you need to open Set Service Order... (from the little gear menu also on the bottom left corner) and move your VPN to the top of the list. Voila! It works!

Tuesday, November 25, 2008

Two gotchas of the day

Okay, these are really from yesterday, but my head still hurts from banging it against the wall.

Gotcha number 1: Skype interferes with Apache. Or actually interferes with port 80. I was trying to evaluate TestLink 1.8, so I set up XAMPP on my computer and wondered why Apache would not start. Skype blocks port 80. Note to self: turn off Skype! You'll be more productive!

Gotcha number 2: a bad interpreter error on Linux usually means the end of line characters are messed up on the script. And in this case it is IBM that messed up the installation of their pznload.sh script. Nothing a little simple dos2unix can't fix, but I still pondered the meaning of this error for a good 20 minutes. Sigh.

Thursday, November 13, 2008

TestLink 1.8 Release Candidate is available

I see from the TestLink website that the 1.8 Release Candidate is available. I'm quite excited about the possibility of using the new TL API. I played with it a little bit when I evaluated 1.8 Beta. I may have to find a little chunk of time to install it and see how it is. The next release is scheduled for 3 weeks from now, so that gives me a little time to think about upgrade strategy here at work.

Wednesday, November 12, 2008

Importing tests from CSV into TestLink

Maybe because I'm not using Microsoft's Excel, but rather OpenOffice.org's Calc, I was not having so much luck following the TestLink instructions for creating an XML document of testcase from a spreadsheet that could be imported to TestLink. So, what I did was to create a conversion script that would take my tests that were formatted in a CSV file and then output the correct XML for TestLink. It's probably not as robust as it could be, as it doesn't have a bunch of error checking, but so far it is getting the job done. It allows empty steps and empty expectedresults, but will probably barf if you don't have a name or summary.



Once you convert your CSV file to XML, you can import the tests from the Specification view in TestLink. Ideally, since TestLink is open source, I would have liked to have added code to TestLink to allow it to import CSV from TestLink itself (and contribute it to the project), but I don't know PHP. I know there is a CSV lib in TestLink, but I haven't had the time to hack it yet. So, this is my temporary solution until I get chance to mess with the PHP. Which might be never.

Monday, November 3, 2008

Windows Installation and Uninstallation Testing with RegShot

My latest Phurnace blog entry is up. Check it out.

CodeWeaver's CrossOver giveaway canceled going forward

Looks like I downloaded my copy just in time. According to the CodeWeaver blog, going forward, their "Lame Duck" giveaways are being canceled. I haven't received my registration number yet, and I wonder if ever I will due to their technical difficulties last week. We shall see. The next step for me would be to finally buy that Intel MacBook I've been eyeing. I see a Christmas gift to myself....

Tuesday, October 28, 2008

CodeWeaver CrossOver giveaway

I downloaded my free copy of CodeWeaver's CrossOver that is free for today only. You have just a few more hours to download yours. I'm waiting for my free license key. The website got slammed today, so they say it may take a few days to fulfill. I'm curious to see how running Windows applications on a Mac works. I had heard of Wine, but I was not interested enough in setting it up. But it appears CodeWeaver makes it easier for you. Here is the original story.