zobie's blog I create software, I like music and I'm mildly(?) OCD.

6Jan/09

Setting up OpenID using my personal domain

If you haven't seen the site before, go take a look at Stack Overflow. Imagine digg hooking up with wikipedia and having a baby that looks kinda like a forum. Stack Overflow is that baby. It is designed as a place for software developers to collaborate and get questions answered. Very cool idea. Excellent implementation.

I've been a lurker on Stack Overflow since it opened up. Well, I dunno... my uid = 6937 so it was fairly early on. Anyway, a few times I've wanted to participate in the community, but I've always held back. I have never really gotten in to the whole OpenID thing, and OpenID is the only authentication that Stack Overflow uses.

Yes, I know that I already have OpenID accounts (obviously, since I was able to register with Stack Overflow), and it is really cool that my existing accounts with WordPress, Blogspot, Flickr, Google and WhateverElse.com are already setup as OpenIDs. The problem is that I am not really committed to any of those services. I registered zobie.com several years ago, and I use it for all of my permanent communication. Those other accounts, they're pretty much disposable.

I sign up for every new service I encounter just so I can check it out. (Yes, I use a different randomly generated password for each site.) Most of these websites never even get a second visit. Even the accounts I use frequently, like Gmail, aren't "permanent" identities in my mind.

What if Yahoo goes bankrupt and closes down Flickr? What if Gmail suddenly becomes really uncool, and people laugh at me for using it (like we laugh at people who still use Hotmail)? I was afraid that I'd start using one of these OpenIDs and then I wouldn't want to use that service any more. Fortunately for me, I figured out how to use my personal domain as an OpenID. It was really easy.

Before anyone points out my logical fallacy, I realize that, because I'm not actually hosting my own stuff, if myOpenID goes down, I'll still lose all of that data. Somehow, the risk doesn't seem as big if I'm using my own domain. I never claimed that my fear was rational. :)

Here's how easy it was to set up:

  1. Signup for a free account at http://myOpenID.com
  2. Click on the "Your Domains" link on the right of the screen enter your domain name
  3. Decide what url structure you want to use (either http://domain.com/user or http://user.domain.com)
  4. Before you can actually use your new OpenID, you'll need to verify that you own the domain. I just had to point some randomly generated subdomain at myopenid.com
  5. That's it!

And now, life is good. I can log in to any OpenID enabled website using my own domain. I can start participating in the Stack Over community!

14Dec/08

Managing WordPress Updates with Git

WordPress 2.7 was recently released so I started the process of updating the handful of WP instillations that I manage. Git has made this process a breeze! Here's how I do it.

  • To start a new project, use subversion to download the latest stable release of WordPress
  • Add that entire directory, including the .svn folders, to git. To keep subversion happy, make sure that all of the svn tmp directories are in git (use an empty .gitignore file to force git to add empty directories)
  • Before you make any changes, create a new branch in git called wordpress_base. You should never do anything with this branch other than update the WordPress code from subversion.
  • Switch back to master and change whatever needs changing (e.g. add themes, plugins, etc.). To make upgrades go as smoothly as possible you shouldn't modify the base WordPress files more than you absolutely have to but, adding themes and plugins should be no problem.
  • When everything is tested and ready to deploy, commit everything to git and push to the webserver

The command line will look something like this:

$ cd ~/Downloads
$ svn co http://svn.automattic.com/wordpress/branches/2.6/ new_blog
$ cd new_blog
$ git init
$ git add .
$ git commit -m "Import WordPress 2.6"
$ git branch wordpress_base
## Get the site completely setup, commit everything to git and
## push everything up to the server.

When you're ready to update WordPress:

  • Checkout the wordpress_base branch
  • Either 'svn up' or 'svn switch' to get the newest code
  • Check all of the changes in to git
  • Merge wordpress_base back in to master (I generally rebase then merge)
  • After everything in git has been committed, push, pull or do whatever fits your process to get the updated code from your development machine to the server
  • Don't forget to upgrade your blog database after the new code has been deployed by going to: http://myblog.com/wp-admin/upgrade.php
$ git checkout wordpress_base
$ svn switch http://svn.automattic.com/wordpress/branches/2.7
$ git add . && git ls-files --deleted | xargs git rm
$ git commit -m "Updated WordPress to version 2.7"
$ git checkout -b integration
$ git rebase master
$ git checkout master
$ git merge integration
$ git branch -d integration
## Make sure all conflicts have been resolved, test the new site and
## update plugins. Commit changes to git and push them to the server.

Tagged as: , , 1 Comment
2Dec/08

Migrating from svn to git

About a year ago I decided that it was time to try git. As a long-time user of SVN, CVS and even VSS *shudder*, I wanted to see what all the fuss was about. At first I didn't get it; having never used a DVCS before I just didn't grok the concept but I keep with it and one day it clicked. After a few weeks I was completely hooked and have since migrated most of my personal repositories from SVN (I haven't tried it under Windows so I haven't migrated my VisualStudio projects yet).

Not long after my conversion, we decided to start using git for a few projects at work. Since then we've been using both subversion and git on a self-hosted server. As anyone who gets git can tell you, after using a DVCS subversion can feel very limiting so we recently decided to migrate everything from subversion to git. We decided to host all of our repositories on github.

This is a long way to say that, over the past year I've migrated ~20 subversion repositories, of varying complexity, over to git. The process is not terribly difficult but there are multiple steps that you have to remember. I've kept a list of each step and thought that it might be useful to someone else (or perhaps myself when I need to do this again in a few months ;) ).

To migrate the subversion repository my_great_app to git first you'll create an empty git repository. Note that this just does the setup, no import happens at this point.

$ git svn init -s svn://svn.zobie.com/svn/my_great_app my_great_app
$ cd my_great_app

Now, if you want your new git history to look pretty, you need to create a text file that maps subversion users to git users. For this example I'll name the file ~/users.text; it should look something like this (svn user on the left, git user on the right):

(no author) = Unknown Author <unknown@zobie.com>
nate = Nate Zobrist <zobie@zobie.com>

Then you tell git about your authors file and start the import:

$ git config svn.authorsfile ~/users.text
$ git svn fetch

Honestly, I don't really understand the "fetch-all" option but on one of the larger repositories that I migrated, the initial import didn't seem to be complete. I started completely over and when I ran "git svn fetch" I included the "--fetch-all" option. This significantly increased the amount of time that the import took but it seemed to do the trick.

$ git svn fetch --fetch-all

At this point your entire subversion repository has been imported into git and we want to create a tag in git that corresponds to each of the tags in subversion:

$ git branch -r | sed -rne 's, *tags/([^@]+)$,\1,p' | while read tag; do echo "git tag $tag 'tags/${tag}^'; git branch -r -d tags/$tag"; done | sh

Then, for each svn branch, we create a branch in git:

$ git branch -r | grep -v tags | sed -rne 's, *([^@]+)$,\1,p' | while read branch; do echo "git branch $branch $branch"; done | sh

These two commands will import every tag and branch from subversion. Sometimes git finds branches that you didn't know existed. Just delete whatever branches and tags that you don't want persisted.

Now that the repository is setup like we want, we do some housework to shrink and compact the repository.

$ git repack -d -f -a --depth=50 --window=100

Then we remove the meta-data that was used by git-svn:

$ git config --remove-section svn-remote.svn
$ git config --remove-section svn
$ rm -r .git/svn

At this point you have successfully migrated your subversion repository into git! If you aren't going to push this repository to a centrally hosted server you can stop at this point and enjoy using your new git repository.

If you want to keep a copy of your repository on a self-hosted server then create a bare clone and copy it up. Then configure your new server as "origin." You'll be happiest if you make sure that the master branch is checked out before cloning the repository.

$ git checkout master
$ cd ..
$ git clone --bare my_great_app my_great_app.git
$ scp -r my_great_app.git zobie@git.zobie.com:/git/.
$ rm -rf my_great_app.git
$ cd my_great_app
$ git remote add origin ssh://git.zobie.com/git/my_great_app.git

Alternatively, if you want to push the repository to github, use the the clone url that they provide:

$ git remote add origin git@github.com:zobie/my_great_app.git
$ git push --all && git push --tags

The last thing that you need to do is to point your "master" branch to "origin/master". There is probably a way to do this from the command line but I don't know it. I can't give exact instructions for modifying the config but the process isn't difficult. Open .git/config and point your master branch to origin; it should look something like this:

[branch "master"]
	remote = origin
	merge = refs/heads/master

If you have other local branches that should track their remote counterpart, you will need to make a similar change for each.

You can test that everything is working:

$ git pull
$ git push

Assuming you don't get any errors, you're done!

Update 2009-01-13: Corrected an error in the sed regex. The '1' should be escaped.

Tagged as: , 12 Comments
11May/08

Clay Shirky on the Cognitive Surplus

http://blip.tv/file/855937

I really enjoyed this speech. It is a very insightful commentary about web 2.0 and the shift away from passive entertainment (i.e. TV) towards pastimes that require active involvement (e.g. editing Wikipedia, playing WoW, etc.).

Tagged as: , , No Comments
20Apr/08

Coworking seems like a great idea.

I hadn't heard of it before but I really like this idea of coworking:
http://query.nytimes.com/gst/fullpage.html?res=9801E7D81F3FF933A15751C0A96E9C8B63&sec=&spon=&pagewanted=all

For the last several months I have been working from home (which I love) but have frequently missed some of the niceties of an out-of-home office.

Tagged as: No Comments