Git: You have some suspicious patch lines…

December 29th, 2008 by Dan

So, I’ve run into this a few times now and it seems like bizarre behaviour to me. While committing, git complains about files which have trailing white space, or spaces followed by a tab. While this may not be the nicest formatting, enforcing this to be fixed before committing a file seems odd.

It turns out this is being caused by a pre-commit hook. There are two options you can go with to circumvent the issue.

git commit --no-verify .

The –no-verify will bypass the pre-commit hooks. This only works on the current commit thought, so you have to add the flag each time you want to commit.

I’ve found that if you

cd .git/hooks/
chmod -x pre-commit

will disable the pre-commit hooks permanently by removing the executable rights on the file.

Apparently they are disabled by default in newer releases.

Hope this helps someone else out as well.

Git Version Contron Graphical Tools

December 28th, 2008 by Dan

*Update 2009-05-05* Also check out my quick post on gitg, a gnome based UI for git.

One thing that I have found while working with git is that there isn’t a wide selection of graphical tools to interact with the repository. There is gitk which comes with a default install of git. This program gives you a visual representation of the workflow of the repository that you’re currently working on. From your checkout folder typing gitk should bring up a window similar to this one.


Read the rest of this entry »

Create a csv from MySQL output

December 10th, 2008 by Dan

Today I got asked to pull some information from a mysql database. Pretty simple, but the one minor catch was that the person asking wanted it in a spreadsheet. Thankfully this is pretty easy with mysql’s built in ‘INTO OUTFILE’ functionality.

select * from users where last_name LIKE "%smith%" order by first_name
INTO OUTFILE '/tmp/result.csv'

This will write the file /tmp/result.csv in a format that is readable by pretty much any spreadsheet program (Excel, OpenOffice, etc). If you have any specific requirements for your file format (say you want tab separate) play around with the options until you get it just right. As you can see you can do anything you would regularly do in a sql query (joins, where clauses, ordering, etc).

And there you have it, one happy person who can access their data in their favourite program

Setting up VPN Connection with gnome Network Manager

December 5th, 2008 by Dan

Recently for a project I’ve been working on at the office I had to set up a VPN connection to gain access to the client’s network. They already had vpn set up on their end (thankfully) however, oddly enough I didn’t have a vpn client. I noticed that the gnome Network Manager had a tab for VPN, however the add button was disabled. After a quick google, I found out that you just have to install the packages ‘network-manager-pptp’ and ‘pptp-linux’ to enable it.

sudo apt-get install network-manager-pptp pptp-linux
Network Manager Window

Did the trick and now it was just a matter of entering the server information, username, password. At this point I was still unable to connect to the network. I double and triple checked my info and it was all right. It turned out I had to enable Point to Point Encryption (makes sense) in the advanced section.

Use Point to Point encryption

Now, I have a nice little ‘locked’ icon on my network status bar.

VPN Connection in Network Manager

VPN Connection in Network Manager

Who knew it would be that easy?

Stress Testing Apache Using ab

November 30th, 2008 by Dan

If you’ve ever written a web-app you’ve probably wondered how well it will hold up once the world discovers your awesome service. Will it work if you get dugg? What happens if 200 people all try to access your site at once? This is where benchmarking can provide some useful numbers to give you an idea as to how your server will hold up.

Read the rest of this entry »