M-x Kelsin

A Hacking Blog

Bash Completion in OS X

I realized today that I don’t have bash completion turned on in OS X. A quick search for the file I’m used to in Ubuntu (/etc/bash_completion) didn’t turn up anything. I quickly found that bash_completion is available in mac ports (which I use a lot). I quickly ran “sudo port install bash_completion”. The text that was printed after the install advised me to put a line into my start files which I added into my bashrc. Now bash completion works great.

An easy way to check if you do have bash completion turned on is to try and autocomplete a directory name after typing cd on the prompt. For example, in my ~/Documents folder I had one file and one directory starting with M. If I type “cd M” and hit tab I will see the file and the folder if I don’t have completion and only the folder if I do.

Rewriting Commit History

Recently at work I was working on a small bug fix git branch that had MANY small commits doing relatively the same thing. I really wanted to go through and clean up the commit messages to make them uniform and actually needed to change some of the commits too.

By google searching I found this stack overflow question that gave me my answer. This user wrote about how using rebase –interactive can be used to specify any number of commits to edit. You basically call git rebase --interactive COMMIT where COMMIT can be HEAD^ to just do one commit, or any SHA1 or branch reference as normal. Git will open your $EDITOR with a file listens all commits in question. You can then edit this temporary file to tell git what commits to let you edit and which ones to drop completely or merge into the commit above them (which you can do manually via edit as well). Then git will play through your commits that you’ve said you want to edit one at a time, and drop you into a shell to let you do anything you want. Sometimes you want to edit just the commit message so you just git commit --amend and change the message. Other times you want to undo the last two commits and redo them git reset HEAD^^ and then edit and commit again.

Also just to remember this (recently discussed at work as well):

  • git reset HEAD^ undoes the last commit and places changes as changes in the working tree.
  • <li><code>git reset --hard HEAD^</code> removes the commit changes completely (not form the git data store, but completely from your working tree at least)</li>
    <li><code>git reset --soft HEAD^</code> puts the changes into a "staged" state. This makes it east to add to a commit while you have many other edited files in your tree (Maybe even more changes to a changed file that you don't want to add into this commit)</li></ul>

    Demon's Souls Mini-Review

    I’ve only played the first level of Demon’s Souls so far but it’s very fun.

    I started a Knight Templar and Caitlin started a Thief. Both play very differently and start with different gear / weapons. It’s very clear that the many pre-reviews of this game that talked about the weapon system being fun were pretty accurate.

    So far the graphics have been great, the game play is great. The game IS HARD. You die a lot on your way to figuring out how to beat obstacles. I had to give in to some of my OCD and just realize that this was part of the game. The game is made with the idea that you WILL lose all of your souls multiple times while trying to play a level. In a sense the game can be thought of as a Japanese shooter in disguise. You practice and practice at the levels until your skill at the game improves and is able to play it flawlessly. It’s awesome!

    Instant PhpBB3 Speed Improvements

    Recently at work we’ve installed a php accelerator onto one of our php apps. We were having load problems on the box (Moodle installs) and the accelerator helped solve the problem. This got me thinking and I decided to install an accelerator on my Linode in order to speed up my World of Warcraft guild forums (a phpbb3 install)

    After doing some reading I decided to try out Xcache. I don’t have ANY opinions on which accelerator is better (this isn’t the one we chose at work for Moodle). I chose this one for the SOLE reason that Debian Lenny had it in the repository. Installing it was DEAD simple:

    sudo aptitude install php5-xcache
    sudo /etc/init.d/apache2 restart

    Can’t get any simpler. Now my phpbb forum pages load INSTANTLY. It’s absolutely amazing and awesome.

    This is making me want to move this blog over to the Linode very fast!

    Git Ignoring already committed (tracked) files

    In my current local development environment for work I don’t have access to our authentication mechanism. Our rails site uses a cookie from our main site. In order to ignore this I commonly edit my controllers with a line like:

    self.current_user = User.find(5)

    (This is just a snippet and doesn’t include the code that allows for the current_user method, this post is NOT about authentication in rails). This allows me to just work on features without having to do some complicated cookie copying and other stuff I’d rather not mess with.

    I use magit on emacs to do my git management and I hate seeing that this controller has a change in it (same with using “git-status”). I don’t want to accidentally commit this change either. The simple answer to this is to tell git to mark this file as “not changed”. I found this post that told me about this feature. This feature exists in order to help people with slow filesystems but it works great for this use as well:

    git update-index --assume-unchanged path/to/file

    Now the files don’t show up in any status commands or when I commit with “git commit -a”. These files will cause git to gracefully error when merging in a branch that changes these files (so you can manually handle it) and it will remove this flag if you manually “git add” these individual files.

    The problem I ran into is that I want an easy way to check what files are setup like this. I couldn’t find a git command to do this already so I added these aliases:

        marked-unchanged = !git ls-files -v | grep ^[a-z]
        mu = !git ls-files -v | grep ^[a-z]

    Now both “git marked-unchanged” and “git mu” show me a list of files that are set this way so I don’t forget. I want to add magit commands to show this and set this as well but that will be another day and another post.