Cowell Computer Consulting

I've moved my blog to http://blog.lukecowell.com because this blog software is getting old and difficult to maintain.

Tags: (none)

How to fix failing time machine backups due to a corrupt disk image

Posted by Luke Cowell on April 02, 2010 at 05:05 PM

I do time machine backups through a USB disk attached to my Airport Extreme unit. Over time the disk image that I'm backing up to seems to become corrupt. Time Machine requires that if you're backing up to a disk image that it was unmounted cleanly or it pass a fsck before it will mount the image and use if for a backup.

The simplest solution is to start backing up to a new disk image, but this doesn't give you the same access to all your previous backups.

Here are the steps I took to fix the disk image, so I can continue backing up to the same image.

Mount the disk image in read write and do not mount the volume

hdiutil attach -noautofsck -nomount -readwrite location_of_your_image.sparsebundle

When you mount, fsck might be called on the image, but you want to kill that process.

Get the info about your attached disk image here:

hdiutil info

Call this fsck command and put your device number in place of the one I have here.

fsck_hfs -rfy /dev/disk1s2

-r means to rebuild that catalog btree (more options can be found in the fsck_hfs man page.

You may need to run this a couple of times before the image is marked as clean.

Tags: (none)

Static Pages in Rails

Posted by Luke Cowell on February 11, 2010 at 09:22 AM

I just read an interesting post on how to handle static pages in rails and I had a different approach that I wanted to share. There's lots of different ways to do this and each method has its own merit.

When I say static page, I mean any page that doesn't fit into your other controllers. This might be an about us or a contact page or anything else that might not require a dedicated controller to handle.

In routes.rb, I would set something like this up:

map.static '/static/:id', :controller => "static", :action => "show"

We can grab the name of the page from params[:id] in the controller. Feel free to change the name 'id' some something else if it gives you that wrong feeling to treat something as an id that isn't really an id.

Next, I define a controller called static.


class StaticController < ApplicationController
  def show
     short_name = params[:id]
     begin
       render short_name
     rescue ActionView::MissingPageTemplate
       render :file => "#{RAILS_ROOT}/public/404.html", :status => 404
     end
   end
end

So, what's happening here? We know we have an params[:id] or the route wouldn't match. We then call a begin block, so that we can rescue the exception. Which, in our case, is if someone passes an invalid filename through or the page hasn't yet been defined under app/views/static/pagename.html.erb. We just handle it as a 404.

What about if we want our static pages to live in a namespace without /static at the beginning ? ie. /about instead of /static/about

Define a regular expression that matches all the pages you want to support.

STATIC_PAGES = %w(about contact fun_facts)
STATIC_REGEXP = %r{#{STATIC_PAGES.join("|")}}

Then, in your routes file use the requirements parameter to match only these pages.

map.static ':id', :controller => "static", :action => "show", :requirements => {:id => STATIC_REGEXP}

This is just another approach and there are lots of ways to do this. I was inspired by Yehuda Katz to write this as he recently wrote a post about giving back to the community. Also, be sure to check out his posts about rails 3.

Tags: (none)

Fix for inDesign CS3 crashes

Posted by Luke Cowell on October 01, 2009 at 12:17 PM

If inDesign is crashing when you quit it, launch it, when you activate fonts or at any other time, you should consider removing or replacing the following file:

$HOME/Library/Preferences/Adobe\ InDesign/Version\ 5.0/InDesign\ Defaults

It appears to contain font information among other things. You care about this because if you were to have activated a corrupt font, or a font with a duplicate postscript name, your problems may continue even after you resolve the font issue because that font will still be cached in here.

eg.

...
@Semibold
@MyriadPro-Semibold
@Myriad Pro Semibold
@Semibold
@Myriad Pro Semibold
8@Version 2.007;PS 002.000;Core 1.0.38;makeotf.lib1.7.9032
@Semibold Italic
@MyriadPro-SemiboldIt
@Myriad Pro Semibold Italic
@Semibold Italic
...
Tags: (none)

iPhone recovery mode vs. DFU mode

Posted by Luke Cowell on September 26, 2009 at 06:46 AM

DFU mode and recovery mode are different. Here's how to get tot either one.

To put your phone in DFU mode:

  • Turn your iPhone off
  • press and hold the home and sleep/wake button for 10 seconds
  • release the sleep wake button and hold the home button for 10 more seconds

To put your phone in recovery mode follow these steps:

  • Disconnect the USB cable from the iPhone
  • Turn your iPhone off
  • Press and hold the home button while connecting the USB cable to your device.
  • iTunes should now display a message to indicate you are in recovery mode
Tags: (none)