css (1) jQuery (7) linux (38) mac (70) php (29) python (1) svn/git (9) trac (4) ubuntu (1) virtualbox (6) vista (2) windows (14)

Tuesday, 29 December 2009

One thing I love about linux

One thing I love about linux is if you delete a file it doesn't stop working.

For example, I just upgraded nginx from a 0.6 branch to 0.7 on a server, unfortunately it fluffed up a bit, does this mean the server crashes, no! As long as I don't restart the process the server keeps on ticking. Which is great it means I can restore a backup without worrying about the site being down.

Thursday, 24 December 2009

BlackMagicTicketTweaksPlugin Ticket Type Permissions

The BlackMagicTicketTweaksPlugin I adopted at Trac Hacks has been updated to include the option to deny access to ticket types depending on user permissions check it out.

Tuesday, 22 December 2009

Overriding OS X Software Install Requirements

If you ever want to override OS X software install requirements when rummaging through the packages check for an Info.plist file and a *.dist file they will have requirements for example hardware could be

MacBookPro4,1 (which is mine)

Or it might specify a specific version of OS X i.e. 10.5

Anyone that tries this and succeeds in installing the software, it's your own fault if it screws up your machine.

Monday, 21 December 2009

Trac Hacks Private Tickets Plugin - Report Patch

When using the Private Tickets plugin from trac hacks and viewing a report it shows the total number of matches not the number the user can actually see.

I've reported it as a bug and written a patch.

PDO BindParam quirk

Here's a quirk of PDO's bindParam

If you bind a variable index to the statement and change the value of the index it won't update the statement.

Automatic Trac Login

If you own website A and want users of website A to be automatically logged into your Trac website B then use the following concept:

Generate a random float between 0 and 1.

MD5 hash that number

SHA1 that hash.

Set a cookie with the name "trac_auth" and value of the SHA1 you just generated

Open a SQLite connection to the trac database (assuming you're using sqlite if not use mysql/postgresql/whatever you're using).

Run the following SQL queries:

DELETE FROM auth_cookie WHERE name=<Site A's unique identifier>

INSERT INTO auth_cookie (cookie,name,ipnr,time) VALUES (<SHA1>,<Site A's unique identifier>,<user's ip addres>,<current unix timestamp>)

And you're done.

PDO SQLite Permissions

Now you'd expect to require write permissions to the sqlite database you're writing to but you also need write permissions to the folder that contains it, otherwise when you try and write you will get the error

unable to open database file

Sunday, 20 December 2009

OS X Keychain and SSH Keys

If you connect to SSH servers from OSX you can save your password in the keychain, a way of prompting ssh to always ask for the password even if it's in the keychain is to add

IdentitiesOnly yes
To the ~/.ssh/config file

Saturday, 19 December 2009

Linux Memory Swapping

If you want to reduce the amount of swapping (or at least attempt to) your linux machine does use the following command.

sysctl -w vm.swappiness=30

(the lower the number the lass chance of swapping).

The number represents wether linux will swap or attempt to free memory, the lower the number the more chance of freeing memory. Of course if all your RAM is in use this command won't do squat.

To make the change permanent (aka after reboot) do the following

echo "vm.swappiness=30" > /etc/sysctl.d/60-swappiness.conf

To clear your swap you can type

swapoff -a; swapon -a;

Thursday, 17 December 2009

Installing apache modules after compilation

If you've already compiled an apache and want to add another module that is included in the apache source, do the following.

Go to the source you downloaded, enter the modules directory, find the mod_xxxxxx.c file of what you want to build and use the following command

apxs -i -c -n mod_xxxx.c

i.e. to compile mod_auth_digest use

apxs -i -c -n mod_auth_digest.c

Converting from subversion (svn) to git

Recently I've been migrating from Subversion (SVN) to GIT. Why? Well mainly because GIT doesn't require a server running in the background and you can have local working copies containing a full history.

So here's how to do it.

First go to the directory where you want your local files to be, if this is the same as your svn working copy location then delete all files (including the .svn folder).

Create an authors.txt file which contains the svn usernames you use i.e.

joe = Joe Bloggs <>

You must put the email part in or it won't work.

Next run the following command

git svn clone <repo url> -T trunk -t tags -b branches -A authors.txt .

Poof you're done. That clones a subversion repository setting the trunk to /trunk branches to /branches and tags to /tags

Note: if you are on a case insensitive file system and don't empty the working directory then you may get warnings about overwriting files i.e. CHANGELOG and changelog, this appears to be because svn doesn't care about case but git does (correct me if I'm wrong but this happened to me on Mac OS X with HFS+ Journaled not case sensitive file system).

Thanks to for the command

Tuesday, 15 December 2009

Warning: SUID file "" has been modified and will not be repaired.

If when repairing permissions on Mac OS X you get the error Warning: SUID file "<file name>" has been modified and will not be repaired. Then to fix it download the latest Combo Update for your OS (i.e. at time of writing for me it's 10.6.2 It should clear up most if not all the permission problems.

Thursday, 10 December 2009

JQuery element positions

Here's something handy, if you want to find the position for an element in relation to the window in JQuery use $("element").offset(); it will return a JSON object like { "left": 100, "top": 20}  which you can access by $("element").offset().left; and $("element").offset().top; handy for positioning tooltips!