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)

Wednesday, 30 September 2009

Finding directories over 10M on linux

here is a useful command to find directories over 10M on linux

du -h path | grep '.*[0-9][0-9]M'

replacing path with were you want to search i.e /root

OS X Increasing SHM

I've just been compiling postgresql on OSX 10.6 and when adding the data to the database just after installation it was bringing up a FATAL error saying not enough shm.

This never happened to me on 10.5 but to correct it do the following, create a file


and put the following in it


That will increase the memory limit by 4 times. It fixed the problem for me

Monday, 28 September 2009

phpmyadmin blank page

Recently I installed a new installation of phpmyadmin, for some strange reason when a file was created it would come up with a blank page.

Now I disable eval on my systems by default since I don't use it. Oddly enough phpmyadmin uses eval to parse the which was causing the problem. Damn...

Saturday, 26 September 2009

PHP PDO and localhost

Recently I created a database connection using PDO with the host of localhost, the dsn looks something like this


This threw this error

PDO::__construct() [pdo.--construct]: [2002] Invalid argument (trying to connect via unix://)
How odd, the solution change the dsn to mysql:host=;dbname=test strange but it works.

Monday, 21 September 2009

Snow Leopard PHP

Something I found noteworthy about Mac OSX 10.6 is that the PHP
version installed by default is 5.3

/usr/bin/php --version
PHP 5.3.0 (cli) (built: Jul 19 2009 00:34:29)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies

Sunday, 20 September 2009

pecl/ is using a unsupported protocal - This should never happen Error

I was just attempting to install APC and got this to fix
delete the lib/php/.channels directory in your php installation then run
pear channel-update

pear channel-update

Chroot SFTP

I found this article about using open ssh 5 to chroot users

MySQL Query Cache making things slow!

I've just been playing with some queries, I had a particular query
which was taking around 4-6 seconds to run which is way too long, so I
decided to play with the cache settings, the cache wasn't really
needed since the tables get updated frequently, for some odd reason
which I'm not sure what it is when I disabled the query cache (I set
it to on demand only) it sped the query up to only taking 0.1

Friday, 11 September 2009

Mac Time Machine and IMAP Mail

Since I've started using Apple Mail I've just done by first backup
using time machine, out of curiosity I wondered if it was backing up
my mail IMAP folders, I checked the backup and yes it did! Now to me
this seems silly since IMAP mail is kept on the server and I have
around 2.5 gigs of IMAP mail. So to time machine preferences I go to
stop it backing those up!

Thursday, 10 September 2009

PHP unset() and (unset)

When unsetting a variable in PHP if you use unset() then try and call the variable you will get an E_NOTICE error saying the variable is undefined if you use (unset) you won't. Both set the variable to NULL.

Tuesday, 8 September 2009

Mail 4.0 Multiple names on one account

As per the previous post you know I have an IMAP account with multiple emails, what I also like is to have multiple names for these, i.e Support, Information etc etc, this is achievable in but it's a little complicated here is what you need to do.

  1. Quit Mail
  2. In finder navigate to /users//Library/Preferences
  3. Duplicate the file (this creates a backup)
  4. Open the file it should open in property list editor
  5. Scroll down to MailAccounts and click the arrow (looks like this >)
  6. You will see a list of Item 0, Item 1 etc etc open each one and find the one that AccountName is the account you want to have multiple names
  7. Click the Item and click Add Child name it EmailAliases and make it an Array
  8. Click the EmailAliases and click Add Child, make it a Dictionary, it will be named Item 0
  9. Click the new Item 0 and click Add Child, set it to a string name it "name" (without "") set the value to whatever name you want to set it to i.e. "Support" (without "")
  10. Click the new Item 0 again and click Add Child again, set it to a string, name it "alias" (without ""), set the value to the email address to send from.
  11. Save the file and open Mail, you now can now send from the new name
  12. You may want to remove the email address you just added from the comma separated list in the account preferences in mail so you don't get a duplicate email address in the drop down list you can send from.

Mail 4.0 Multiple email address on one account

If like me you have multiple email addresses linked to a single IMAP account you may find this handy.

  1. In click Mail > preferences > accounts
  2. Choose the account you wish to have multiple addresses
  3. Add a comma separated list of address i.e.,,
  4. Close the preferences and click save, you can now send from multiple addresses for one account

HTML Signatures in Mail 4.0

Since upgrading to Snow Leopard I thought I'd give Apple Mail aka 4.0 another try. Normally I use Mozilla Thunderbird.

Firstly Mail doesn't allow you to create HTML signatures, but that doesn't mean it doesn't support them, here is how to create one.

  1. First open mail, then click Mail > preferences > signatures
  2. Click the + symbol to create a new signature then save it and quit mail.
  3. Create the html signature in whatever editor you like, then open it in safari
  4. Click file > save as in Safari
  5. Navigate to /users//Library/Mail/Signatures
  6. You will see a file with a long string of characters and numbers this is the signature you just created, click the file and press save this will overwrite this file
  7. Open mail, and you have your HTML Signature.

Sunday, 6 September 2009

iPhone/iPod touch notes syncing with mobileme

I am currently have a trial for apples MobileMe. Since I have an iPod touch and Mac it's handy to write a shopping list on the mac and then transfer it to my iPod.

Now since notes and MobileMe don't sync brilliantly (this is because notes are actually emails, one of apples weirder ideas) this is what I do.

First in go to preferences, composition and set the notes to be stored on mobileme, next create a rule saying if a message is a note move it to mobile me.

This will create a note folder on your mobile me web mail, when synced OTA this will also appear in your mail on your iPod. If you create a new note on your iPod using the notes app it will sync to the On My Mac folder when you connect it via iTunes, that's what the rule was for, highlight all notes and apply rules and it'll go to the correct place!