2009-11-18

Sneak Attack: Debugging in Python

Nice intro to debugging in Python using pdb.

Back to flipping out...

2009-11-03

Setting up gitosis on OS X

What is gitosis?

gitosis is a wrapper around git that makes it easier share repositories, especially as it relates to managing access rights.

Why Should I Care?

The benefit that made me check it out is that I don't have to create an account on my dev machine for every single developer to whom I'd like to give access to some of my git repos.

Assumptions

  • You installed git and python from MacPorts.
  • You have enabled "Remote Login" in the "Sharing" Preferences pane.
  • You have a public key (typically generated via ssh-keygen); see the man pages for more details.

Installation

Preliminary Steps
  1. Create a git user
  2. Add git to the list of users who can ssh in
  3. Configure git's .bashrc (NOT .bash_profile) so port-installed apps are on the PATH. Mine looks like
    export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin/:$PATH
    export MANPATH=/opt/local/share/man:$MANPATH

Installing gitosis
  1. cd /tmp
  2. mkdir src
  3. cd src
  4. git clone git://eagain.net/gitosis.git
  5. cd gitosis
  6. python setup.py install
  7. sudo chmod 755 /Users/git/repositories/gitosis-admin.git/hooks/post-update

Configuration

Setting up Admin Access

Add yourself as an admin (member of the gitosis-admin group) by executing sudo -H -u git gitosis-init < ~/.ssh/id_dsa.pub. This will use your public key as input into gitosis-init and set you up as an admin.

Cloning the Admin Repo

Try git clone git@`$HOST`:gitosis-admin.git. It should work. If it doesn't, and complains about the other end unexpectedly hanging up, the $PATH for git is probably misconfigured. Make sure you configured .bashrc, because .bash_profile won't stick around.

Configuring a New Repo

You make configuration changes to gitosis by editing your local clone of gitosis-admin and FIXME kbd pushing them back. Let's add a new repo.

  1. Open up gitosis.conf in your editor of choice
  2. Add an entry like the one below
  3. Save
  4. git push
    [group fabfour]
    members = john paul george ringo
    writable = the_monkeys_are_hacks

Breaking It Down
    [group fabfour]

We're defining a new group, named fabfour.

    members = john paul george ringo

Adding john, paul, george, ringo as members of the fabfour group.

    writable = the_monkeys_are_hacks

Listing the_monkeys_are_hacks as the only writable repo for the fabfour group. In case you're saying "Wait, I don't have a the_monkeys_are_hacks repo!" don't worry, that's coming next. You have to do all of this before you try to push anything to gitosis.

Populating Your New Repo
  1. If the repo doesn't exist, create it
    1. mkdir the_monkeys_are_hacks
    2. cd the_monkeys_are_hacks
    3. git init
    4. Do Work Here and Commit It
  2. Add your new gitosis-managed repo as a remote; inside your repo, execute git remote add origin git@`$HOST`:the_monkeys_are_hacks.git

  3. Push to it; inside your repo, execute git push origin master:refs/heads/master

If the last step fails with an inscrutable error, there's a good chance you forgot to chmod the post-update hook.

Actually Letting John and the Gang Access the Repo

Before john, paul, george, or ringo can actually get into the server, you need to add their public keys under gitosis-admin/keydir. I'm going to wave my hands concerning how you get the public keys, but they need to be added to gitosis-admin/keydir and they need to be named using the convention username.pub, so we'd have:

  1. cd gitosis-admin
  2. cp /tmp/john.pub keydir/
  3. cp /tmp/paul.pub keydir/
  4. cp /tmp/george.pub keydir/
  5. cp /tmp/ringo.pub keydir/
  6. git add keydir/john.pub keydir/paul.pub keydir/george.pub keydir/ringo.pub
  7. git ci -m "Adding the keys for the Fab Four"
  8. git push

Want More?

  • Check out this extremely detailed (non-Mac-specific) guide.

Back to flipping out...

2009-10-14

Note to Self: apropos finds man entries

Ever get that feeling that there just has to be something built right into the shell that will solve the problem you're facing, but have no idea what that something might be? Enter apropos. It searches the man page blurbs for entries that match your keywords, which can be regular expressions. How is it that more people don't talk about features like this?

Back to flipping out...

2009-09-28

Sneak Attack: Functional Java

How is this the first time I've heard of Functional Java?

Back to flipping out...

2009-09-25

Note to Self: nohup a Running Process

nohup -p pid

see also

Back to flipping out...

2009-09-24

Sneak Attack: 10 Useful Usability Findings and Guidelines

I wish more people would pay attention to things like this. It's not like most of that information is new, but it still gets ignored far too often.

Back to flipping out...

2009-09-22

Sneak Attack: Python is not Java

One of the (in Internet time, at least) golden oldies. Re-reading this makes me cringe when I think back.

Back to flipping out...