DOSBox full screen crashes OS X Lion

Old games are a lot of fun to play. DOSBox makes it easier than ever to blow the dust off of an old game, pop the floppy disks into a USB floppy disk drive, and game like it’s 1990 again.

That was until I upgraded to Mac OS X 10.7 Lion. Suddenly, when I hit alt + enter DOSBox crashed :( Well if you’re running into that issue, here’s the fix!

  1. Install DOSBox and run it once. Exit, or if you’re feeling mean hit alt + enter and let it crash out.
  2. Edit ~/Library/DOSBox 0.74 Preferences (updating the version number to whatever version you have installed, of course)
$  vi ~/Library/Preferences/DOSBox\ 0.74\ Preferences
1. Scroll down to the output variable and updated it to use opengl. This switches the rendering engine to a less efficient but apparently more stable implementation.
...
fullresolution=original
windowresolution=original
output=opengl  #<--- change this line
autolock=true
sensitivity=100
...
  1. Save the file and enjoy your favorite old school game! theme_park_dosbox.png

Adding ops to your new freenode channel

So you’ve just registered a channel on irc.freenode.net for your group. No one wants a single point of failure, and you never know when you’ll win the lottery (or be hit by a bus) so you’d like to op your teammates. This way if anything happens to you (good or bad) your colleagues can kick troublemakers and keep the /topic fresh.

If you’re new to IRC interacting with nickserv and chanserv can be confusing at times. There are a ton of features many of which are laden with IRC jargon.

Here’s a step by step for adding your collaborators as operators to your channel:

  1. Each person that you’d like to op must be registered with nickserv.
  2. If you haven’t already, register your channel with chanserv
    /msg chanserv register ##bobs-awesome-channel
  3. Set op flags for each user. The little o gives them the ability to self op. The big O will cause them to be auto-oped upon joining the channel. This can be useful to keep troublemakers from acting up (since they know someone is watching them). You can set only the ability to become an op:
    /msg chanserv flags ##bobs-awesome-channel bobdole +o
    (notice) Flags +o were set on bobdole in ##bobs-awesome-channel.
    Or you can set ops and auto-ops
    /msg chanserv flags ##bobs-awesome-channel bobdole +oO
    (notice) Flags +oO were set on bobdole in ##bobs-awesome-channel.
  4. You can now verify that the user flags are set properly
    /msg chanserv flags ##bobs-awesome-channel
    (notice) Entry Nickname/Host          Flags
    (notice) ----- ---------------------- -----
    (notice) 1     jennymurphy           +votsriRfAF [modified 2 weeks ago]
    (notice) 1     bobdole               +oO [modified 7 seconds ago]
    (notice) ----- ---------------------- -----
    (notice) End of ##bobs-awesome-channel FLAGS listing.
    

And you’re all done!

If you’ve only set the little o flag, your users must tell chanserv to temporarily turn them into operators when they need it.

/msg chanserv op ##bobs-awesome-channel

That’s all I have for now. Happy IRCing! :)

The Google+ Platform 30 Second Experience

It seems like life becomes busier and busier every year. Between longer hours at work and increased obligations elsewhere, who has time to try out a new API? It’s 2012. We only have 3 years to perfect the flying DeLorean!

You say you don’t even have 5 minutes to play with one of the platform starter projects? Well hopefully I can give you a taste of the API in the time you just spent reading this paragraph. You don’t even have to write any code, I promise. (Although I make no promises about inspiration to code that this may cause.)

Since we’ve already wasted 30 seconds babbling, let’s dive into the API already. The easiest way to see the Google+ platform in action is to use the API Explorer. This tool provides point and click access to most of the APIs that Google offers including the REST APIs for Google+.

Since this may be your first time, we’ll keep it simple. Follow these steps to view your public Google+ profile.

  1. Navigate to the API Explorer. To make an API call we must first select the plus service. On the left pane scroll down to and select the plus API. The middle columns will update to display the available versions and methods. api_explorer_1.png
  2. Scanning through the available methods the profile.get method looks like a match, but it requires a userId, which we do not know. We can use the shortcut value of me, but we’ll need to authorize the API explorer to discover our userId. To do this make sure plus.me is selected from the drop down at the top of the window and click on the ‘Switch to Private Access’ link. This will trigger an OAuth popup. Grant the API Explorer permission. api_explorer_2.png
  3. Now that the API Explorer can determine our userId, all we need to do is specify me for the userId and to execute the query. api_explorer_3.png
  4. Upon execution the bottom of the API explorer, the history pane, will display the results of our request. Assuming it was successful we’ll see the HTTP headers from request and response as well as a JSON representation of our public Google+ profile. api_explorer_4.png

Congratulations! If you read fast enough 1 or fewer minutes have incremented on your clock and you’re already using the Google+ APIs. During these four steps we’ve witnessed many important features of the core REST APIs that make up the Google+ platform. We’ve completed the OAuth 2.0 dance to access private information, your userId via the plus.me scope, and observed a fetch of your public profile.

Now that you’ve had a taste of the JSON, you know you want to go grab a starter project, right? :D

Google+ Comments on your Static HTML Blog

Synchronize Comments

Our static HTML blog is pretty cool, but do you know what would make it cooler? Comments would. Discussions about entries can really bring a blog to life, but sadly they come at a cost. Not only do you need to worry about comments from spammers but you also have to expose potentially sensitive software to the outside world.

Fortunately for us, the Google+ public data APIs expose the comments on our activities. Since we’re already sharing our blog posts to Google+ we can use JavaScript to render the comments from the activity right in the blog entry. Not only does this offload the responsibility of spam control to Google, but it also allows us to retain our super simple static HTML blog.

Experiment with the APIs

Before we start writing code lets become comfortable with how the APIs behave. Google provides an API explorer, which is a great way to become familiar with APIs. You can find the API explorer here: https://code.google.com/apis/explorer/

We’ll use this tool to walk through the steps that our comments plugin will follow.

  1. On the left pane scroll down to and select the plus API. The updated view will now display the available methods in the third pane from the left. We can explore these methods and work out a flow for accessing the right comments. api_explorer_1.png
  2. Scanning through the available methods the comments.list method looks perfect, but we need an activity ID to call it. api_explorer_2.png
  3. Just above the comments.list method we find an activities.list method. This will allow us to list our recent activities and determine their IDs for which we can list the comments. api_explorer_3.png
  4. It looks like we need one more piece of information to list our activities: our userId. The easiest way to determine your userId is to copy it out of your Google+ profile URL. profile.png
  5. On the activities.list method paste in your userId and select the public collection. Clicking the execute button triggers the API call and renders the json response in the history pane at the bottom of the page. api_explorer_4.png
  6. The response object consists of some top level attributes and a collection of activities within the items array. Each entry in the items array has an activity ID. Copy the ID for your most recent entry.
  7. We can now switch to the comments.list method and supply the activity ID that we just copied. api_explorer_5.png
  8. With a click of the execute button the history pane on the bottom will be populated with a list of comments associated with that activity.

It looks like we’ve discovered our flow. We can implement a very simple comments integration by manually discovering the activity ID for our share on Google+ and then using JavaScript to fetch the comments associated with it. Once we’ve fetched the comments we can render them within the page.

Registering Our Application

Before we can use the APIs to access public data we must first register our application. Once we register our application we’ll receive an API key that we can use to make requests.

  1. Navigate to code.google.com’s API console: https://code.google.com/apis/console/
  2. Create a new project using the project drop down menu console_1.png
  3. Click on the ‘Services’ link in the API Console menu and toggle the Google+ APIs to ‘on’ console_2.png
  4. Click on the ‘API Access’ link in the API Console menu to access the keys for your new application.
  5. Below ‘Simple API Access’ note your ‘API Key’. We will use this to access the public data APIs below. console_3.png

Time to Code

In our entries we’ll place a div with a special class. We’ll then use JavaScript to replace this placeholder div with the comments for that entry. Here’s an example of a div that our JavaScript will look for:

<div class="g-comments-for z13zevjymuuge1zvl23lyv3a2n3owdxxd04"></div>

Our JavaScript will look for all divs on a page with the g-comments-for class. When it finds one it will fetch all of the comments for the activity whose ID is in the other class.

Create a new JavaScript file comments.js and source it from each blog entry. Within the JavaScript file create a namespace for our functions, because we like to be tidy. Next specify our API key. We’ll need that to make out API calls.

var commentr = commentr || {};
var apiKey = "AIzaSyA-H-eBvhWOyyjIJ2bWeaf1XAn855s8IRN";

Find all of the g-comment-for divs and extract the ID

// search for g-comments-for classes
commentr.go = function() {
    var fetchElements = 
         document.getElementsByClassName('g-comments-for');
    for(var i=0; i<fetchElements.length; i++) {
        var activityId = fetchElements[i].classList[1];
        commentr.fetchComments(activityId);
    }
}

Next, fetch the comments for each activity that we find. Since the Google APIs reside on a different domain name than our blog we’ll use the JSONP response format. For each response this will automatically call a method to inject the comments into our page.

// foreach fetch
commentr.fetchComments = function(activityId) {
    var fetchElement = document.createElement("script");
    fetchElement.src = 'https://www.googleapis.com/plus/v1/activities/' +
        activityId + '/comments?alt=json&pp=1&key=' + apiKey 
        + '&callback=commentr.praseComments';
    document.body.appendChild(fetchElement);
}


// when fetch completes, parse the response and insert the records
commentr.praseComments = function(resposneJson) {
    var activity = resposneJson.items[0].inReplyTo[0];
    var comments = resposneJson.items;

    //find element to insert into
    var insertionElements = document.getElementsByClassName('g-comments-for ' +
        activity.id);
    var insertionElement = insertionElements[0];

    var newContents = "";
    for(i=0; i<comments.length; i++) {
        var actor = comments[i].actor;

        var commentBody = comments[i].object.content;

        //do the insertion
        newContents += "<dt><a href='" + actor.url + 
            "'><img src='" + actor.image.url + "' /></a></dt>" + 
            "<dd><a href='" + actor.url + "'>" + actor.displayName + 
            "</a>: " + commentBody + "</dd>";

    }
    insertionElement.innerHTML = "<dl>" + newContents + 
        "</dl> <p class='g-commentlink'>Please comment on the <a href='" + 
        activity.url + "'>Google+ activity</a></p>";   
}

And finally we need to add register our plugin to execute after the page loads.

// Append our program to the window.onload
document.addEventListener("DOMContentLoaded", commentr.go, false);

Comments Integration in Action

That was pretty easy, wasn’t it? Now lets see it in action.

Using the API explorer we can find the activity ID of our most recently public entry. In this case it’s z13zevjymuuge1zvl23lyv3a2n3owdxxd04. Go back to the HTML code for that entry and add the magic div that inserts the comments.

<div class="g-comments-for z13zevjymuuge1zvl23lyv3a2n3owdxxd04"></div>

Reload the page and see the rendered comments!

result.png

What’s Next?

Our comments plugin was very easy to write, but this simplicity comes at a cost. It’s quite brittle and requires us to use the API explorer to discover the activity ID for each entry that we share. A good companion to this plugin would be a tool which fetches our most recent activities and renders a div that we can paste into our entries.

Code and Demo

See it in action on Baking Disasters

Access the code (without using copy and paste) on Google Project Hosting

One fine evening I was sitting in a Taiwanese café sipping some slightly too sweet tea. While I waited for my bite sized morsels of fried chicken to emerge from their sizzling oil bath, I decided to hack a bit in Ruby.

I could not start immediately, though. I needed some gems to start on my intended task. I attempted to install a gem only to see it fail. I tried a different one. It failed with the same error. Something was amiss.

$ gem install mysql2
ERROR:  While executing gem ... (Zlib::GzipFile::Error)
    not in gzip format
$

I immediately started to troubleshoot my ruby installation. Had I screwed it up somehow? I had just upgraded XCode.

After a few minutes of troubleshooting I figured out the problem. Ruby and gem were fine. My Internet connection was not. It had timed out and was again redirecting me to the terms of use page. Gem was trying to install the wifi terms of use for the cafe. This was why the gunzip failed ;) The solution involved pretty standard Internet connectivity troubleshooting:

  1. Open a web browser and navigate to http://www.google.com to trigger the terms of use page
  2. Once I accepted the terms I cleared my DNS cache with this command on OS X Lion: dscacheutil -flushcache
  3. I ran gem again and it worked!
$  gem install mysql2
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.11
1 gem installed
Installing ri documentation for mysql2-0.3.11...
Installing RDoc documentation for mysql2-0.3.11...

2nd Generation Drobo and 3TB Hard Disks

I love my Drobo. I know it’s the yuppie version of a home raid array, but it’s quiet enough to keep in my living room and it looks like something out of Tron.

Mine is a 2nd generation 4 bay Drobo that I’ve been using for a couple years. It’s worked well enough that my partner and I managed to fill it up! No problem, I thought, I’ll just swing by Fry’s Electronics and pick up a new shiny 3TB disk, right? Wrong.

I pulled out a lowly 1TB disk, popped in the new 3TB one and saw a red blinky light :( According to the docs, this indicates that my disk was dead on arrival. I refused to believe this. I thought, “This is a big drive, maybe I need to update the firmware?” It turned out to be a bit more complicated than this.

If your Drobo is blinking red on your brand new drive, follow these steps to fix it:

  1. Look at your Drobo Dashboard software. Does it look like something written in FoxPro or Tron? If it looks like Tron skip ahead to step 5. drobo-dash-1.jpg
  2. Upgrading Drobo Dashboard: Since you have the older, grayer Drobo Dashboard, there’s something you should know: it’s lying to you. It probably says your Drobo’s firmware is up to date. It’s wrong. To upgrade the firmware you must first upgrade the dashboard.
  3. Navigate to Drobo’s downloads page. Download the appropriate software. In my case this was the software under ‘Drobo Gen 2’ way down near the bottom of the page.
  4. Install the new dashboard. The specific instructions will depend on your platform. It should be easy so I won’t go through the specifics here. After the installation you may need to reboot.
  5. Upgrading your Drobo’s Firmware: Since you’re now using the new shiny Drobo Dashboard reminiscent of Tron, you can upgrade the firmware :D Simply fire up the Drobo Dashboard click on All Devices -> Status and follow the dialogs to upgrade to the latest firmware.

After your Drobo reboots it will accept your new hard disk. In as little as a day the blinking LEDs will go solid green and you will be able to enjoy your increased storage capacity. Grats!

AsciiDoc Syntax Highlighting and MacVim

I’ve recently joined the world of AsciiDoc. I’m also the kind of developer who leverages every tool she can find. Since there is no IntelliJ plugin for AsciiDoc, it looks like I’ll have to settle for MacVim as my editor since it supports syntax highlighting of just about everything.

AsciiDoc is not a built in type for the MacVim syntax highlighter, and while AsciiDocs is nice enough to attempt to install the vim highlighting during setup, I still had to complete a few manual steps.

  1. Follow the installation instructions through.
  2. If it does not exist already, create a ~/.vim folder for your user specific vim settings.
$ mkdir -p ~/.vim
  1. Copy the provided vim configuration files in their entirety from the distribution to your ~/.vim folder
$ cp -r ~/tools/asciidoc-8.6.5/vim/* ~/.vim
  1. Fire up MacVim and test out the syntax highlighting by opening the AsciiDoc user manual. How meta is that? :) asciidoc_meta.png

Ta da! Now get hacking! I mean docing!

Transferring your Number from AT&T GoPhone to Google Voice

Transferring your number to Google Voice is the best way to leverage all of the features available. It’s pretty easy to transfer from most providers, but I ran into a few bumps when transferring my AT&T prepaid GoPhone number. To make your transfer a little easier, here is what I learned.

  1. Realize that by transferring this number you will be forfeiting your remaining balance, so you may want to run it down first. Now that this disclaimer step is done, time to get to the actual steps!
  2. Get your account number. This is not on the website or on any documentation you have. You must call 611 from your cell phone, dial 0 at the menu and speak to a customer service representative. Your account number will be a 12 digit number in the form of ####-####-####.
  3. Create a Google Voice account and opt to transfer your cell phone number.
  4. During the flow when prompted for your cell phone information, provide the 12 digit account number in the field provided.
  5. Sit back and wait for the transfer to happen.
  6. If you’d like to use your handset as a forward target for Google Voice, you’ll need a new handset number. Once the transfer is complete, head on over to an AT&T store and ask for a new number for your cell phone. I’ve found the least confusing way is to show up with no SIM card and ask for a new one. They’re free with a new GoPhone plan.

And just like that you’re all set!

yourdomain.com/+: Google+ Profile From Your Domain

Google+ is pretty cool and getting cooler by the day. Circles are a great tool to connect with the people you’ve just met, but right now it’s a bit tricky to share your profile URL since they look something like this: https://plus.google.com/102817283354809142195 (that’s my profile if you’re wondering)

A lot of us already have a short, witty personal domain name, and on these domains the /+ path is almost always available. Wouldn’t it be cool if we could just tell people to find us at http://example.com/+?

Now that we have the awesome idea, how do we implement it? This will differ a bit based on how your web site is set up and how much access you have there.

With Apache .htaccess and mod_rewrite

If you have access to write .htaccess files on your web host, this is a great solution. If you do not know what a .htaccess file is, skip to the next option :)

  1. Create a .htaccess file in the root directory of your domain with the following contents:
RewriteEngine On
RewriteRule ^/?\+$ https://plus.google.com/NUMBER_PART_OF_YOUR_PROFILE [R=301,L]

On nginx

There are indeed web servers other than Apache. One popular alternative is the awesome nginx. I’ve never had the pleasure of using it, but luckily Chris Broadfoot was kind enough to share this nginx rewrite rule.

  1. Drop this configuration into your server’s configuration file.
server {
  server_name yourdomain.com;
  location ^/?\+$ {
    rewrite ^ https://plus.google.com/NUMBER_PART_OF_YOUR_PROFILE permanent;
  }
}

With JavaScript

What if you lack either SSH access or are not comfortable with mod_rewrite? All is not lost! If your website allows you to paste in some JavaScript code you can still set up a redirext. This method is not optimal, though, because it has a way of confusing web crawlers and primitive web browsers. In any case, here are instructions:

  1. Create directory + in the root of your domain.
  2. Add an index.html in that directory with the following contents:
<!doctype html>
<html>
<head>
<script type="text/javascript">
window.location="https://plus.google.com/NUMBER_PART_OF_YOUR_PROFILE_URL";
</script>
</head>
<body></body>
</html>

If you’d like to see this implemented on any other platforms, give me a hollar and I’ll add it :)

Thanks to:

Rails 3 Validator List

Ruby on Rails 3.0 expanded the set of available validators that can be passed to validates. Here they are in list form:

:acceptance => Boolean.
:confirmation => Boolean.
:exclusion => { :in => Enumerable }.
:inclusion => { :in => Enumerable }.
:format => { :with => Regexp, :on => :create }.
:length => { :maximum => Fixnum }.
:numericality => Boolean.
:presence => Boolean.
:uniqueness => Boolean.

Source: the Rails 3.0 release notes