I find myself back in ruby land for a bit and it was time to help some of my
co-workers get RVM running on Mavericks. Having recently figured this out (and
needing to share it with more co-workers) I figured I’d share it with everyone.
These instructions will show you how to install RVM on Mavericks for a single
user. And, it’s all pretty easy so no worries. We can handle this.
First off, make sure you don’t already have RVM. Just look in your home
directory and make sure there is not a folder called .rvm.
If there is a folder called, this you can either remove it (scorched earth,
baby!) rename it, or go find another blog post on how to repair it.
Now, install RVM.
Once this is done you can verify everything is installed by checking the .rvm
Hooray! It’s installed. But it doesn’t work. Well, that’s because we ain’t
done. You also need to add some stuff you the end – and this is import –
the end of your startup scripts. If RVM finds that it is not at the top of
the $PATH environment variable it’ll work but nag you like an old lady. Just
put it as the end.
I put them in .bashrc but you might put them in .bash_profile. Just make sure
they are the last thing to execute. Remember. Old lady.
Once you do that, open a new terminal and install some rubies.
One of the people I have the distinct pleasure of working with at
Pillar is Dan
Wiebe. He loves to code more than anyone I have
ever met. He is smart, focused, and just ever so slightly crazy.
And every Tuesday evening Dan goes to prison.
No, he’s not on work release. He’s there to teach about a dozen inmates how to
code. In all fairness, Dan isn’t actually teaching them to code, they are doing
that themselves. However, he is there to provide direction, experience, and
wisdom. He is there to provide the perspective of the outside as it relates to
coding, to help give them a skill that they can use if and when they get out,
and – I think – more then anything to provide them some hope.
Prisoners are people that much of the world wants to turn their back on. If
people think of them at all they assume that they are all “bad people” and they
deserve to be there. I can’t refute the argument that they deserve to be there
as, in many cases, it is true. However, in my experience, there are no “bad
people”. There are only bad choices. And when you start to interact with
prisoners you quickly realize that the number of steps between you and them
really isn’t that many. A bad choice or two and you could end up in the same
place as them.
My father spent time in prison when I was a kid. He made plenty of bad choices
and I know for a fact that he deserved the time he spent in prison but I would
never say that he was a bad man. He wasn’t even my biological father, but he
raised me as his own and cleaned up his life because of his love for me and my
In most cases, prisoners will be released one day and they need to be able to
function in society. They will need a job. They will need to be able to work
with others. Technology may have passed them by while in prison and they will
need time and assistance in adjusting.
My cousin spent ten years in prison. I remember when his sister and I first
picked him up. We gave him a cell phone so he could talk to his mother. He kept
moving the cell phone from his ear to his mouth and back again because he
didn’t understand how the microphone could pick possibly up his voice without
being in front of his mouth. He had never used a phone without a handset.
While in prison my father got sober and it helped to keep him that way. While
in prison my cousin studied horticulture and was able to get a job within weeks
of getting out. They were able to do this because people were willing to go
inside and help them.
So, last month, I decided to help Dan and go to prison too.
Fortunately, Dan has a good forum for introducing people to working with
prisoners. He calls it “Coding in the Clink”. In a sense it is like a
Coderetreat in prison. Lots of people gather for the
day to practice their skills. There is food provided. We test drive our code.
But the pairing is always aligned prisoner to visitor. The prisoners code with
each other all the time, they need an outside perspective. A visitor could pair
up with another visitor any time they wanted. There is no reason to come to
prison to pair with someone you could meet with at Panera.
The format is also different. The coding is in Java for reasons Dan explains
elsewhere. We normally
pair on a machine for an iteration and the next pair on that machine picks up
the code where it was left off instead of deleting and starting over. At the
end of the day we come back to our original machine with our original pairing
partner to see how the code we started changed over the course of the day.
Also, we do not code the Game of Life as the longer format requires a longer
exercise. At the Coding in the Clink that I attended, I was quite please to be
working on the Evercraft Kata
that George Walters (who was also in
attendance) and I put together a couple of years ago. That made this event a
But it wasn’t the only special thing. Uncle
was there as well as his son Micah. They paired with the prisoners and provided
instructive feedback during the retrospectives. Muy cool!
I personally paired with five prisoners that day. Three stand out in my mind.
One had been a programmer before he came to prison – he was sharp and we wrote
much code. One had been programming for a week – we spent our session teaching
him some basics. Another was studying electrical engineering at college when he
came to prison 20 years ago – I worked with him last and we spent our session
refactoring a mess we had inherited.
Lunch was pizza and pop, another way in which Coding in the Clink varies from a
Coderetreat. But we socialized for a good bit and talked about what we were
learning and teaching and doing. It felt like a Coderetreat as we were just
geeks discussing what we enjoy.
Looking at all this from the point of view of the prisoners, this was a
wonderful day. They got to meet and pair directly with Uncle Bob, they had a
room full of visitors (some of them women – woohoo!), they got to work on an
exercise with the folks who created it, and they got pizza and Mountain Dew for
From my point of view, the whole event wasn’t about my kata, or Uncle Bob being
there, or hacking all day, or even pizza. Those things were cool and I enjoyed
myself very much. But really, I wasn’t there for those reasons.
I was there because there are no bad people just bad choices. I was there
because the people on the inside needed my help. I was there because they are
I’m going to continue going to prison with Dan. Others helped the people in my
life when they were in prison. People that I don’t even know. People that
wanted to be part of the solution. I want to be part of the solution too.
OK. Let’s say you’ve got some big, bulky, enterprisey application. This
application consists of an outer page (probably called index.jsp or something
like that) that never moves and assorted iframe tags for portlets and tabs.
The first through you probably have is “Ewwww, iframes, really?” You’re second
thought is probably that this is an application very much like the one Guy
works with. And, I hope, your third thought is one of sympathy for me since I
have to work on such an application. But I digress, como siempre.
Also, this application has session data that needs to be shared between
portlets and tabs and across tabs and all other sorts of complex interactions.
And, you want to do this client side for performance reasons. How, pray tell,
can you do this without writing spaghetti code?
If you’re really smart (and you are, right?) you’re probably just saying that I
should use HTML5 Local Storage and be
done with it. Great idea! I even wrote
ProtonDB, a framework to make this
sort of thing super-easy. But, alas, I’m stuck in Enterpriseland and HTML5 is
not permitted because it’s new and we fear newness because it is fraught with
risk and uncertainty.
But, I do have an elegant solution to the problem and the key lies in the fact
that the parent page doesn’t move. And since it doesn’t move it can simply hold
of code and import the .js file in all HTML pages (i.e. each portlet, tab, and
the outer page)
This code is simple and complex. Make sense of that! It assigns session if it
hasn’t been assigned yet. Since the outer page loads first, it gets defined
there initially because session doesn’t exist, and parent.session doesn’t
exist. All of the iframes then evaluate this same code and session doesn’t
exists but parent.session does. And, just in case someone has defined this
already we’ll always assign session to session if it exists.
To use the code simply modify the session object. For example:
Now I like to know what I’ve put in session so that I have a feel for how big
it is. So I actually use a slightly more complex pattern. I define a session
object with explicit accessors so the code tells me what’s stored there. And I
use a closure so no one can mess with my internal state and they have to go
through the defined session object. Here’s the code:
In this case, you would use the code like this:
A little extra code, sure, but I think the value add is worth it.
While I hope you don’t have to use this pattern and can instead just enjoy
HTML5 goodness, if you need it, here it is. Enjoy!
I’ve been working on a simple test case for a disconnected HTML5 application
for the iPhone/iTouch off and on for the past couple of weeks. It’s a points
calculator for a popular weight loss program who shall remain anonymous.
Anyhow, I thought this would be a handy tool for my wife and I and it would be
a nice and simple application to test a disconnected HTML5 application from the
So, I present to you Puntos. Full source
code is available on github but here’s how
I wrote it.
The application I developed is not remarkable. In fact, it is a simple math
problem. Peruse the source if you want details on how it works. The important
part is that it has the following files:
Just create the files for your application (or copy mine) and make it do what
Step #2: Make it iPhone Friendly
If you want it to be a cool iPhone HTML5 application, you have to provide an
icon from the iPhone desktop. You can do this by creating a file called
iphone-icon.png and placing it in the root of you project. This little file
is the favicon.ico of the Apple Mobile world. It is a 45 pixel by 45 pixel
PNG that your iPhone or iTouch will use if you decided to save a link to a
website on your desktop.
So, just create this file with your favorite image editing program (I used
Gimp) and save it with the other files.
Step #3: Add the Caching Magic
Here’s where the fun comes in. We can finally make the application
disconnected. The magic lies in an attribute on the html tag pointing the
browser to a cache.manifest file. This file then tells the browser which files
to cache and serve up when there isn’t a network connection.
So, simply add something like this to your HTML file.
This tells your browser to load up the file in the manifest attribute. The
filename can be anything but I would recommend having it end in .manifest as
this makes setting up the content type later much easier.
The cache.manifest is simplicity itself:
It simple contains the words CACHE MANIFEST at the top and lists all the files
needed by the application.
You might note that I did not include the index.html and you would be
correct. This is because the browser will assume that the file you loaded in
the initial request is part of the cache.manifest. No need to specify.
However, if you have several HTML files, you will need to specify them all in
your cache.manifest as there is no way to know which file you entered the
Step #4: Serving Up text/cache-manifest
It turns out that the cache.manifest file must be served up with a content
type of text/cache-manifest. It also turns out that most web servers aren’t
configured by default to do this since this is all bleeding edge and stuff.
So, you need to add it yourself. If you are using an apache server you can add
the content type to your .htaccess file. Add the following line and you
should be golden.
Step #5: Access the Application from Your iPhone & Troubleshoot
Your application should now work. So go access it. Then turn on Airplane Mode
and refresh the application. I should reload gorgeously. If it doesn’t, go back
and troubleshoot. But you knew that already.
One caveat though. I had a hell of a time trying to get the application to work
disconnected until I rebooted my iTouch (I don’t have an iPhone because I’m
lame). So, if everything looks like it should work but isn’t then you might
want to try turning off your iPhone by pressing and holding the power button
until it shuts down completely.
So, those are the steps I followed to get my first disconnected iPhone
Now go out and write me a game or something.
Also, for more information on HTML5 and disconnected applications check out
this fine website.
OK. Just spent 3 hours of my life that I will never get back trying to
troubleshoot and issue with Windows 7 and USB devices that I was having.
Figured it out so I thought I would share the problem and solution.
Whenever I would plug a new USB device in, it would not be detected by Windows.
Instead I would get a driver not found error and no amount of troubleshooting
on Windows’ part would help. This affected a new keyboard and mouse I purchased
(Logitech MK520) and an old headset that I had lying around. It was also
affecting my iPod but I didn’t realize that until after the fact.
In the case of my mouse and keyboard I would see in Device Manager a device
names USB Receiver with an annoyed looking yellow icon resting upon it. No
amount of messing with the icon helped.
All very frustrating because the hardware would detect the new keyboard and
mouse. When I booted the system and accessed the BIOS menu the keyboard worked.
The mouse was listed as detected. Everything seemed fine.
After much searching of the web in frustration. (Did I mention it was
frustrating) I finally found some people actually having the same problem. No
solutions, mind you, but the same problem. I determined from the gist of all
this posts that it was something to do with the USB drivers. Not the mouse
drivers or the keyboard drivers or the headset drivers but the core USB drivers
from Windows 7.
So I removed them all in Device Manager and rebooted so they could be
reinstalled. This worked – briefly. When the drivers were gone the mouse
started working. But Windows quickly fixed that and reinstalled the drivers and
I was back to a non-functioning mouse and keyboard.
Finally I came across some forum posts suggesting that
usb.pnf should exist in Windows\inf
and if they didn’t that would cause this issue. So, I Googled to find the files
and copied them in. Then I removed the annoyed USB Receiver driver and detected