Archive for June, 2010

Change Host for a Git Origin Server

Hopefully this isn’t something you need to do. The server that I’ve been using to collaborate on a few git projects with had the domain name expire. This meant finding a way of migrating the local repositories to get back in sync.

Update: Thanks to @mawolf for pointing out there is an easy way with recent git versions (post Feb, 2010):

git remote set-url origin ssh://newhost.com/usr/local/gitroot/myproject.git

See the man page for details.

If you’re on an older version, then try this:

As a caveat, this works only as it is the same server, just with different names.

Assuming that the new hostname is “newhost.com”, and the old one was “oldhost.com”, the change is quite simple.

Edit the .git/config file in your working directory. You should see something like:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = ssh://oldhost.com/usr/local/gitroot/myproject.git

Change oldhost.com to newhost.com, save the file and you’re done.

From my limited testing (git pull origin; git push origin; gitx) everything seems in order. And yes, I know it is bad form to mess with git internals.

A/B Testing Overview

A/B Testing is how sites like Amazon, Yahoo, Google, Facebook and others became the best in the world. They used data to drive decisions about content, layout, wording and other aspects of their sites.

Smashing magazine covers the details of A/B testing in this post.

At its core, A/B testing is exactly what it sounds like: you have two versions of an element (A and B) and a metric that defines success. To determine which version is better, you subject both versions to experimentation simultaneously. In the end, you measure which version was more successful and select that version for real-world use.

37signals tested the headline on its pricing page. It found that “30-Day Free Trial on All Accounts” generated 30% more sign-ups than the original “Start a Highrise Account.”

Dustin found that “You should follow me on Twitter here” worked 173% better than his control text, “I’m on Twitter.”

Along with its other A/B tests, CareLogger increased its conversion rate by 34% simply by changing the color of the sign-up button from green to red!

The article covers the results from others of testing, as well as details on how to get started for your own site.

What I find interesting is that the tools that used to require significant investment in time and development are increasingly available as easy to use, free solutions.

Using TextMate with Google Docs

The new Google Command Line opens up some interesting possibilities. One that I wanted to explore was using TextMate to edit basic Google Docs.

First, install Google’s Command Line tool. Details are on their wiki for each OS. There are lots of tips in the comments and even a packaged installer. (I used ports to install)

The next step is to create a symlink from the “mate” command to “mate_wait”. What this does is default the wait argument to true. This is needed for the Google script to detect changes to your document.

sudo ln -s /usr/bin/mate /usr/bin/mate_wait

You can now open a document in TextMate:

google docs edit --title "Ideas" --editor "mate_wait"

If you select a title for a document that doesn’t exist, it will be created. Once you close the file in TextMate, control returns to the shell and the document is updated on Google’s servers.

You are only able to edit in text only mode. So it works best on documents without any formatting.

To list your existing documents, try:

google docs list

RSpec XHTML Validation of Views

A great way to learn is to read other people’s code. And in that vein, Chris Lowe has a great post on suggested OSS Rails apps to look into.

One technique I picked up from simply_agile is to validate the HTML output by your views. That way, bad HTML isn’t introduced.

To start with, you need to install the assert_valid_xhtml plugin and the libxml-ruby gem.

In your spec/spec_helper.rb file, add the following inside the config block:

config.include ValidateXhtml

And at the end of the file, outside the config block, include the following:

describe "a standard view", :shared => true do
  it "should be successful" do
    response.should be_success
  end

  it "should be valid" do
    response.should be_valid_xhtml
  end
end

Now in your view specs, include the following line:

it_should_behave_like "a standard view"

And that’s it. Now each view will be tested for valid xhtml when you run your specs.

There are a lot of other great techniques scattered through the projects mentioned in the original post. And if you want more details on good practices for RSpec, check out the RSpec Book.

Learning Chinese - continued

Since my last post, I’ve spent a fair bit more time on improving my Chinese. Some recent changes to my routine have improved the speed at which I’ve been learning.

Great Wall at Badaling, China

Lingt

I already use flash cards, but am now spending more time using Lingt.com. They run an online language learning program, that includes audio and writing. My accuracy is improving on words I swore I already knew, but turns out I didn’t know that well.

The site also includes badges and incentives to keep you coming back each day. They remember what you’ve been studying and only allow you to study a certain amount each day, keeping your memory fresh. This is a key part to their success. They’ll replay words at the point where you forget them, increasing the effectiveness of your time.

Reading

This was so simple I couldn’t believe it. To get good at reading Chinese, start reading Chinese.

It has always been my goal to be able to read Chinese content on the web. However, I had also believed that my Chinese wasn’t yet good enough.

Reading Kató Lomb’s book was enlightening. She taught herself more than 16 languages. In her book, she outlines her techniques.

The one that stood out for me was her dedication to reading material in the desired language, well before you can fully understand it. Instead, aim for getting the gist of it on the first read. Don’t look up every word in a dictionary, rather look up those that re-occur lots. Then re-read the book.

For the past few months, I’ve been trying to read two books in Chinese. I find both interesting and I’m learning a lot of Chinese as I go. It doesn’t (yet) feel like reading, but more like attempting a crossword puzzle.

When I started, it would take me around half an hour to muddle through a paragraph. Now, I can often get through between a half and a full page.

One caveat, you do need to allocate time to it. I aim for half an hour a day. Kató suggests that you should be spending at least 12 hours a week on learning a new language.

Shopping, Chinatown, Singapore

Talking

I read a great article recently on learning Chinese. The interesting part for me was to look at finding Chinese speakers who’s English is worse than my Chinese. This makes sense once you think about it; I just hadn’t thought about it.

I still have yet to action this particular plan, and am keeping it on my todo list for now.