Initializing a new Git repo (or, What is “failed to push some refs to”?)

This is another post to help me remember all the steps required to create a new remote Git repository. I am using a Mac for my local development and a WebDAV URL hosted on my ISP. (Text you type in is in bold.)

% mkdir bare
% cd bare
% git --bare init
Initialized empty Git repository in /Users/myhome/bare/
% git update-server-info
% cd ..

… now copy the everything in bare up to http://my.webdav.url.on.server.com. Back on our laptop let’s create the first commit to this remote repo …

% mkdir master
% cd master
% git init
Initialized empty Git repository in /Users/myhome/master/.git/
% git remote add origin http://my.webdav.url.on.server.com
% git push origin master
Fetching remote heads...
  refs/
  refs/tags/
  refs/heads/
error: src refspec master does not match any.
error: failed to push some refs to 'http://my.webdav.url.on.server.com'

… oh no! The push failed! If we add an empty commit this should work now …

% git commit --allow-empty -m "Initial commit."
Created initial commit 2342879: Initial commit.
% git push origin master
Fetching remote heads...
  refs/
  refs/tags/
  refs/heads/
updating 'refs/heads/master'
  from 0000000000000000000000000000000000000000
  to   23428790678ef8ee92f9ea713711d1832e71267b
    sending 2 objects
    done
% cd ..

… ah, much better. Now let’s test to see if we can clone it …

% mkdir clonetest
% cd clonetest
% git clone http://my.webdav.url.on.server.com
Initialized empty Git repository in /Users/myhome/clonetest/.git/
got 90cf9a181bb8abaa0cb0a48175ca4e3752dcdb38
walk 90cf9a181bb8abaa0cb0a48175ca4e3752dcdb38
got 4b825dc642cb6eb9a060e54bf8d69288fbee4904
% 

Success!

Safari 4: Alternate tab grips?

The new grips on the tabs for Safari 4 are functional but to me they connote resizing rather than moving/tearing-off. The handle metaphor might be better but it probably would look ugly. So I was doing some thinking about suggesting “gripping” using something with traction nubs on them. Here’s a set: the original as is today, a wedge-type grip, and a spot-type grip.

saf4_alt_grips.png

Safari 4: Recent Searches = productivity

saf4_rec_ser.png

I am finding that Safari 4′s new Recent Searches results is really handy. It’s not new functionality—we’ve had browsing history enabled for most browsers forever—but having it integrated into the search field fits better with my workflow. Often I find myself going back to a page I’ve just read (and closed) so having this history hint in my search field really is nice.

What I think would make this better is maybe doing a little highlighting of what you typed and the matching results like a lot of autosuggest dropdowns do.

saf4_rec_ser2.png

Installing the Haml bundle for TextMate

This is more for my benefit of forgetting how to install the Haml bundle for TextMate. (Surreptitiously borrowed from Barry Hess’ blog entry.)

  1. Ensure your bundles directory exists:
    mkdir -p ~/Library/Application Support/TextMate/Bundles/
  2. Go to your user TextMate bundles directory:
    cd ~/Library/Application Support/TextMate/Bundles/
  3. Check out the bundle from Macromates:
    svn co "http://macromates.com/svn/Bundles/trunk/Bundles/Ruby Haml.tmbundle"

The Macbook Air, first impressions

Ah, the new computer smell. The new Macbook Air is here!

I have been searching for a netbook for a while but when it came down to it I really didn’t just need another little computer device, I needed a lightweight version of my Macbook Pro. I didn’t want to give up my software environment; I have all of my Rails scripts set up for the Mac and I know that the Mac creates a development environment that is close enough to our staging and production servers that I can develop on the laptop with confidence that it will work on our ISPs.

Taking it out of the box it’s amazing how small this thing is. While it is still 3 lbs., that’s still 2.5 lbs. lighter than my Pro. So giving up the DVD, the big battery, and the screen realestate means that this thing feels feather-light.

The keyboard is responsive and has enough key travel to be comfortable. I’m not liking the backlighting as much as on my Pro’s gray-colored keys. There’s just something about the light poking out from under the keys.

Speaking of lighting, the automatic screen-dimming/keyboard-illumination detection is weird. By tilting the Air back and forth it responds quickly—a little too quickly. It means that while just shifting sitting positions the screen brightness changes a bit.

The pulldown flap on the right for the headphones, USB, and mini displayport is neat and tidy. It’s very very compact so anything other than iPhone/iPod headphones and a USB hub is probably a no-go. (See below for another note on the headphones.)

The solid state drive now is up to 128 GB, which means that after the operating system is installed and the system is up and running you’ll have about 96 GB left. Not a whole lot of space but definitely tons more breathing room than those puny 8GB SSDs in other netbooks—you can actually carry your work projects on this thing.

I was a bit worried that the compact screen would mean I’d feel claustrophobic but actually having 79% of the screen size I’m used to turns out not to be too bad.

iLife ’09 is awesome. The new music lessons are pretty cool. The newly redesigned interface is a bit confusing to me at the moment…

The SSD is really one of the key reasons I wanted this laptop (besides the lightness of the computer). I can’t say that I’m feeling its blistering speed right now, but I think the computer boots up much faster than my Pro. I’m just hoping that the SSD lives up to its promise of being the shock-resistant solution to my rough handling of laptop computers.

Speed-wise, the Air is snappy enough that I really haven’t noticed that much of a difference from the Pro. Granted, I haven’t tried to play any games or anything with serious graphics demands, but I’m confident that this little computer will keep up just fine.

Now for the weird/bad stuff. The bottom edge of the Air really digs into my forearms. The thing is blade-thin at the edge and instead of having a neatly-rounded or beveled edges it has a sharp ridge.

Also, there is this annoying buzzing sound that seems to happen intermittently when the fan isn’t running. Many people have pointed this out on the Apple forums here, here, and here. Some people thought it was the hard drive that was clicking, but my computer and the other computers have solid-state drives.

The mono speaker isn’t great, in fact because it only comes out one side it’s downright weird. It’s like when you have a head cold and your left ear is plugged up. Because the sound emanates from under the arrow keys it changes quality as you type. Then again plugging in the iPhone headphones solves these problems. (But since the jack is recessed a little bit behind the lip of the flap, good luck actually plugging in anything other than iPhone headphones into that jack. You’ll need some kind of an extension or a USB for the audio input/output.) But you didn’t get the Air because you wanted to be blastin’ tunes in the coffee shop, did you?

The pinch-zoom gesture works great on the iPhone, but on Safari it’s a mess. It is way too sensitive and ends up just making it a chore to resize the text so you can continue reading.

Finally, the LCD has these weird very light bands in them. I think it’s the LCD lighting. I can’t be sure.

UPDATE: After running the computer overnight and installing things the clicking sound went away. It’s almost like the fan was stuck and after the fan was running for a while things were sufficiently greased up. It’s actually spooky having a computer that makes no noise now.

JavaScript: the script object, disallowing globals

One thing that has always bugged me is that JavaScript allows the creation of globals willy-nilly. As a thought, what would really be nice is to have a method of registering with the browser/container which globals are allowed. But first, a related thought.

Right now we have the window object and the window.document object. Understandably, JavaScripts run in a browser window, so therefore there is a window object. But, when you really think about it, should the “window” be the real container?

I’d rather have a top top level script object that is the master JavaScript container object. It would represent the overall JavaScript VM. (Under that you’d have the window object.) But more importantly, what the script object could do is let you set/allow certain behavior. Take globals for instance:

By default the script would be running in “transitional” mode. But if you set it to “strict” then it would put it into strict mode, and then you’d also have to register globals to use them:

typeof script;           // Returns 'object'
script.mode;             // Set to 'transitional'
blah = 1;                // No errors.

script.mode = 'strict';  // Sets it to 'strict' mode 
                         // to disallow globals
                         
foo = 'bar';             // Would throw an error!

script.addGlobal('foo'); // Allows the foo name in
                         // the global space.
foo = 'bar?';            // No errors.

I think this would encourage people to use namespacing. Additionally it would give us a way to really interact with the VM via the script object. Stuff for thought…

Logging in Rails

I’m really starting to like logging in Rails. I wasn’t all that happy with the logs that Rails gives you to start with because they felt verbose and they didn’t rotate themselves. But after reading the Rails wiki I have a different opinion. It turns out logging is highly configurable, and because it uses the Ruby RollingFile class there are actually a lot of really nice options:

[:layout]    The Layout that will be used by this appender.
             The Basic layout will be used if none is 
             given.
[:truncate]  When set to true any existing log files will
             be rolled immediately and a new, empty log
             file will be created.
[:size]      The maximum allowed size (in bytes) of a log
             file before it is rolled.
[:age]       The maximum age (in seconds) of a log file
             before it is rolled. The age can also be given
             as 'daily', 'weekly', or 'monthly'.
[:keep]      The number of rolled log files to keep.
[:safe]      When set to true, extra checks are made to
             ensure that only once process can roll the log
             files; this option should only be used when
             multiple processes will be logging to the same
             log file (does not work on Windows)

Not only that but you can also change the format/pattern of the logs or even send email (see Logging::Appenders::Email which is downloadable here).

Note: Maintainable Software has a quick blurb on logging too: http://maintainable.com/articles/rails_logging_tips

The web as the OS: Palm Pre

The iPhone was really the first to truly crack the barrier of poor web browsing on mobile devices. Previous to that we all used to hate using the Internet to view almost-recognizable simulacrum of the normal web experience. The iPhone ushered in quality hardware (though arguably is still not the best it could be), a well thought-out interface, and a novel input system. Cheers to Apple and its brilliant engineers and designers. It is truly the computer in your pocket. But will the Pre raise the bar for mobile devices?

What intrigues me is that everything about developing for the Pre surrounds the web. While you have to learn Objective-C to program the iPhone, or use Java for the Gphone’s Android SDK, Palm’s Mojo application framework is HTML5/CSS-based:

Palm webOS applications are easy to write using Mojo, a new application framework based on the HTML5, CSS, and JavaScript standards that web developers already know and love.
[http://developer.palm.com/]

Granted, it does appear that Palm has inserted their own custom elements:

<div x-mojo-element=”ToggleButton” id=”my-toggle”></div>

It will be interesting to see what applications this new framework will engender. Also from Palm’s developer website:

O’Reilly is also hosting a webcast with Mitch Allen on February 25 at 10 a.m. PT to offer developers a preview of the webOS operating system and development environment, followed by a Q&A session.

Macbook Pro battery woes

After a frustrating day of trying to figure out why my new Macbook Pro 15″ battery wasn’t charging I decided to reset the SMC. The result: Success! I won’t have to take my laptop in for servicing after all.

Recently I’ve been noticing that my notebook battery just wasn’t holding charge. Having had it for 2 years it has really been used and abused for 166 cycle counts. Last weekend I finally made it back to the Apple Store and picked up a new battery. I thought the story would end there.

Sometime over the weekend I noticed things weren’t going swimmingly. The battery was charging, albeit really slowly. And today it finally stopped charging altogether. I thought maybe this was a deep cycle problem so I ran down the battery to 8% and then plugged in the power. However, the system profiler showed:

Health Information:
   Cycle count: 1
   Condition: Good
Battery Installed: Yes
   Amperage (mA): 0
   Voltage (mV): 11718

Seeing the Amperage at 0 was an issue of concern. A friend happened to be over at my apartment so I swapped batteries with her. Her battery in my MacBook did not charge; my new battery in hers did. I thought to my dismay that this meant I have something wrong with my charging circuitry and it was going to necessitate taking the laptop in for servicing.

A quick read through a few web forums pointed out that resetting the System Management Controller (SMC) might do the trick. So I cruised over to: http://support.apple.com/kb/HT1411

MacBook, MacBook Pro
If the computer is on, turn it off.

  1. Disconnect the AC Adapter and remove the computer’s battery.
  2. Press and hold the power button for 5 seconds and then release the button.
  3. Reconnect the battery and AC Adapter.
  4. Press the power button to restart the computer.

I did exactly that and held my breath.

After restarting I looked at the bottom of the laptop and the battery charging light was blinking. Excited, I opened up the system profiler again and looked at Power:

Health Information:
   Cycle count: 1
   Condition: Good
Battery Installed: Yes
   Amperage (mA): 3169
   Voltage (mV): 11718

Yes! It is charging! And now about an hour later the battery has gone from 8% to 46%. I’m beginning to wonder if the old battery still has some life in it yet; I’ll get it later when I head back out to my car where I left it.

Being a good sport: semantic HTML

I try my hardest to write semantic HTML. Sometimes it’s hard because when you develop applications—especially AJAX ones—the temptation is to simply put everything in DIVs. But things like headings, definition lists, and so forth are actually meaningful. Of course there’s ways to augment the data with microformats, but I still believe that there is a sort of organizational elegance to using elements they way they were intended.

One very good reason to use semantic tags is for WebAIM, Web Accessibility In Mind. Screen readers find headings to be significant. (As a side though, I’ve been thinking about how to do render ordered lists of results such that the item number is significant. e.g. page 1 shows results 1 – 25, page 2 shows the next 25 results and the <OL> tag actually begins with item number 26.)