Get Familiar with Ruby using EdgeCase’s Ruby Koans

EdgeCase has published a great walkthrough of the various Ruby language features. They call it Ruby Koans.  The Ruby Koans are a a collection of broken tests.  Each broken test is designed to teach you something about the Ruby language.  Many are fill-in-the-blank, eg:

  def test_every_object_has_different_id
    obj =
    another_obj =
    assert_equal __, obj.object_id != another_obj.object_id

To pass this koan/test, you’d replace the “__” with true, because new instances of objects have new object_ids.

I wouldn’t recommend this for people new to programming, but if you’re like me and used Ruby a few years ago but have fallen out of practice, it’s a perfect re-introduction.  If you’re new to Ruby but have a solid background in other languages, this may be of use as well.

OS X: Image Capture opens when you plug in your iPhone

Want to stop Image Capture from opening every time you plug your iPhone, iPod, or iPad in, and perhaps have iTunes open instead?  At some point in the recent past I must have accidentally set this option, but having not intentionally done so, I couldn’t recall how to set the default back to iTunes.

To disable Image Capture: With the device plugged in via USB, open Image Capture.  In the bottom left corner of the main application area, you should see the name if your iDevice and the text “Connecting this iPhone opens:” followed by a dropdown.  Click No Application.

To make iTunes open when you plug in your device: Open iTunes with your iPhone/iPad/iPod connected.  Select your device under Devices in the left column.  In the main window, scroll down to Options.  Check “Open iTunes when this iPhone is connected.

Android browser CSS position: fixed bug (solved)

There’s a very annoying bug in Android browsers that’s not intuitive to fix: Sometimes position:fixed just doesn’t work right.  For me this manifested as the browser thinking that the bottom of the page was about 40px higher than it actually was, but only in landscape mode.

Without further ado, the fix is simple: set your meta viewport tag to not allow user-scaling.

<meta name="viewport" content="width=100%; initial-scale=1; maximum-scale=1; minimum-scale=1; user-scalable=no;" />


Conditionally Display High Resolution Images in HTML/CSS for Retina Displays

It’s really easy to do but I tend to forget how to do it since it’s only applicable to mobile projects:

Let’s say you have: 200px by 100px image.png and the same image twice as large (400px by 200px) called image_highrez.png.

First, we can’t just use a plain ol’ <img> tag. We have to use the commonly done trick of creating a div with the same height/width as the image, then setting the background to the image. Anyone who’s used CSS sprite sheets should be very familiar with this process.


<div id="our-image"></div>


div#our-image {
  background-image: url(image.png);
  height: 100px;
  width: 200px;

@media only screen and (-webkit-min-device-pixel-ratio: 2) {
  div#our-image {
    background-image: url(image_highrez.png);
    background-size: 200px 100px;
    -webkit-background-size: 200px 100px;


dyld: Library not loaded: @executable_path/../.Python


You’re trying to use a virtual environment created on a different computer, or you’ve upgraded / reformated your machine and you’re using the virtenv from your backup of the old machine.

Now you try to do a pip install but you get the following error:

dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /your/project/path/./bin/python
  Reason: image not found


The python executable or libraries in the virtualenv directory are not compatible with your current architecture. This happened to me when I reformatted my Macbook to run OS X 10.7 Lion from an older version of OS X.

To fix, you’ll need to create a new virtual env. What you can do is freeze the packages the current virtualenv is using (if you’re not doing this already), and then install them in the new virtual environment.

pip freeze -E your_old_environment > requirements.txt
pip install -E your_new_environment -r requirements.txt

Now use your new virtual env as you did your old one. it’s also good practice to keep a file with the latest contents of pip freeze in your code repository, in case you need to build new virtualenvs in the future (or deploy them).