Labels

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)

Monday, 31 May 2010

Windows Snipping Tool

Windows snipping tool is a program in windows vista (and probably windows 7) that allows you to take screen shots (snips) of selections of the screen (just like mac's grab). I could have sworn I blogged about this before but I can't find it.

Anyway it's really useful and it's found under Start > Programs > Accessories.

You need to have the "Tablet optional components" part of windows installed which can be added under "Control panel" > "Programs and features" > "Turn on/off windows components"

Saturday, 29 May 2010

Mac falling back to default Mach exception handler

I came across this warning in my mac console
com.apple.launchd.peruser.501[297] Warning (com.apple.ReportCrash) Falling back to default Mach exception handler. Could not find: com.apple.ReportCrash.Self

The solution, go to /System/Library/LaunchAgents and copy com.apple.ReportCrash.Self to ~/Library/LaunchAgents/

Then reboot. This also speeded up my login.

OS X Console warnings unable to create user DBs in /var/folders

Recently I was browsing my console for errors and noticed the following:

/System/Library/Frameworks/PubSub.framework/Versions/A/Resources/PubSubAgent.app/Contents/MacOS/PubSubAgent[793] Alert MDS Error: unable to create user DBs in /var/folders/Ko/Ko4nhsn0FmCj+CMp+uU4pU+++TI/-Caches-//mds

It was repeated a bunch of times for different apps, to fix it reboot your mac and hold the shift key which boots into safe mode which erases the db cache. Reboot again and everything works fine.

Removing 3rd party items from mobileme sync

Some 3rd party apps allow themselves to be synced with mobilme. If you delete the app the sync option remains, kinda annoying, to remove it follow the instructions here


The option key is your friend!


Thursday, 27 May 2010

MobileMe backup failing with a 401 error

Since some recent updates to mobileme my backup schedule kept failing, I checked the console log and it had a 401 unauthorised error. I spoke to mobileme support and they told me to log out of mobile me and log in with user test and password test which would fail and reset my preferences, then log back in as myself and try again. This fixed it! Yay go apple!

Friday, 21 May 2010

HFS+ Compression

In OS X 10.6 (Snow Leopard) Apple introduced HFS+ Compression, which basically compresses files on your hard drive in an invisible manner (aka the end user can't tell). Other systems (i.e. NTFS) have had this for years.

HFS+ Compression however doesn't have a tick box to enable it on a drive. Also any OS that mounts it that is pre 10.6 can't read the files (although file sharing still works).

I've written a script that will compress directories (one file at a time so if you have low disk space you only need as much as the largest file free).

It must be run as root and the first argument is the directory to scan (remember the trailing slash) I personally ran it on my /Applications/ folder and saved 30% space (6GB).

The script is below


#!/usr/bin/php



function hfsCompress($path)
{
  global $i;
  $dirs=scandir($path);
foreach($dirs as $d)
{
  if($d[0]!=".")
  {
    if(substr($d,-4)==".app" or !is_dir($path.$d))
    {
      echo $path.$d.PHP_EOL;
      $c=disk_free_space("/");
      echo "Current free space ".$c.PHP_EOL;
     exec("ditto --hfsCompression ".escapeshellarg($path.$d)." ".escapeshellarg("/tmp/ditto/$d"));
     exec("rm -rf ".escapeshellarg($path.$d));
     exec("mv /tmp/ditto/".escapeshellarg($d)." ".escapeshellarg($path.$d));
      $n=preg_replace("/((?![0-9]).)*/","",exec("du -d 0 ".escapeshellarg($path.$d)));
      $n=disk_free_space("/");
      echo "New free space ".$n.PHP_EOL;
      echo (($n-$c)/1024/1024)."MB space freed".PHP_EOL;
      echo (($n-$i)/1024/1024)."MB space freed so far".PHP_EOL;
      echo "Done with ".$path.$d.PHP_EOL;
    }
    else if(is_dir($path.$d))
    {
      hfsCompress($path.$d."/");
    }
  }
}
}
$path=$argv[1];
if(posix_getuid()!=0) exit("Must run as root");
if(!is_dir($path)) exit("This is not a directory");
exec("mkdir /tmp/ditto");


$i=disk_free_space("/");
echo "Initial free space ".$i.PHP_EOL;
hfsCompress($path);
exec("rm -rf /tmp/ditto");
$n=disk_free_space("/");
echo "New total free space ".$n.PHP_EOL;
echo (($n-$i)/1024/1024)."MB space freed".PHP_EOL;

Wednesday, 12 May 2010

EXT4

I've never formatted a partition in ext4 before here is how to do it, create it using fdisk as usual and set the type to linux (code 83) then type mkfs.ext4 /dev/<partition eg sdb1>

Monday, 3 May 2010

CSS absolute positioning and centering


When positioning a relative element normally you'd use margin:0 auto; this doesn't work on an absolute element...or does it? Well sort of, you need to add right and left positioning, so for dead center add right:0; and left:0; so you end up with

right:0;
left:0;
margin:0 auto;