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)

Wednesday, 22 December 2010

TextWrangler Diff

Just found something cool, text wrangler for mac can diff between files click "Search" > "Find differences". Awesome!

Sunday, 19 December 2010

Stream BBC Radio to iPod touch/iPhone

If you want to stream BBC Radio to an iPod/iPhone then http://bbcstreams.com/tutorial has brilliant instructions on how to do it!

Tuesday, 14 December 2010

The disc can’t be used because the disc drive is not supported (error code 0x80020025)

If you get the following error when trying to burn a disk from finder on a mac "The disc can't be used because the disc drive is not supported (error code 0x80020025)" hold down the option key (alt) and right click the finder icon in your dock and click relaunch then try again!

Saturday, 11 December 2010

PHP 5.2.15 borked

I think I'm going to do more PHP testing before releasing...just upgraded to 5.2.15 and got killed by this bug http://bugs.php.net/bug.php?id=53516 dang how'd people miss that?

Saturday, 4 December 2010

Disable SSH PasswordAuthentication on a mac

On OS X 10.6 to disable SSH PasswordAuthentication edit /etc/sshd_config and set PasswordAuthentication to no and UsePAM to no (ensuring to uncomment the lines) then disable and re-enable remote login via the sharing system preferences pane.

Monday, 29 November 2010

Enable nat port forwarding in vmware fusion 3

If you have nat networking on vmware fusion 3 and want to enable port forwarding you need to edit /Library/Application Support/VMware Fusion/vmnet8/nat.conf at the bottom you'll see two sections [incomingudp] and [incomingtcp]

To add a port forwarding under whichever section you require add

<remoteport> = <vm ip address>:<vm port>

i.e. 8888 = 192.168.78.134:80 will redirect all traffic from 8888 to the vm with ip 192.168.78.134 to port 80

Then restart vmware fusion networking by running /Library/Application\ Support/VMware\ Fusion/boot.sh --restart

How to enable remote syslogd in OSX 10.6

If you have an apple airport under the airport utitlity advanced pane you'll see a Logging and Statistics tab, there contains a Syslog Destination Address, which basically logs info about your airport to the machine specified by the ip address so you can view it in the console.

However! By default syslogd on a mac isn't listening to enable it you need to edit /System/Library/LaunchDaemons/com.apple.syslogd.plist at the bottom you'll see "Un-comment the following lines to enable the network syslog protocol listener." so do what it says, then either reboot or run 
launchctl
unload /System/Library/LaunchDaemons/com.apple.syslogd.plist 
load /System/Library/LaunchDaemons/com.apple.syslogd.plist 
exit

That'll enable the remote syslog feature and you'll get messages like 

28/11/2010 18:29:26 <AIRPORTIP> <AIRPORTNAME> natpmp[-1] Debug Public address reported as <YOURIP> to <CLIENT>:5353

Tuesday, 23 November 2010

PHP namespaces and exceptions

If you are converting all php errors to exceptions or dealing with other exceptions via a try catch statement you must put the path to the namespace in the exception.

I.e.

<?php
namespace MyNameSpace;

try
{
//some code that causes an exception
}
catch (\Exception $e)
{

}
?>

If you don't add the \ it won't be caught.

Thanks to this blog for pointing it out http://onehackoranother.com/logfile/2009/01/php-5-3-exception-gotcha

Friday, 29 October 2010

Add hostname and ip address to bash prompt

It's useful to identify servers by hostname and ip address, adding this to your .bash_rc does both!

export PS1='\[\033[0;35m\]\h\[\033[0;33m\] \w\[\033[00m\]'`hostname`:`ifconfig|grep Bcast|awk ' { print $2 }'|awk -F":" ' { print $2 }'`'$ '


Tuesday, 26 October 2010

Convert spaces to tabs on linux, the easy way.

If you want to convert spaces to tabs in a text file on linux it's simple use unexpand sourcefile >  destfile

Sunday, 24 October 2010

gcc CFLAGS/CXXFLAGS

I'm compiling mysql using some CFLAGS and CXXFLAGS using a script, since the flags contained spaces I put them in quotes...weirdly enough this causes gcc to fail, the flags have to be exported without quotes.

Wednesday, 20 October 2010

Slow DNS in Safari and Firefox but not Opera and Chrome

I recently installed a new ubuntu server installation using vmware's nat interface, now I found when navigating via a domain name to the web server DNS resolution via Safari and Firefox were excessively slow (minutes) however chrome and opera didn't have the same issue. Turns out disabling mac's ipv6 fixes the issue.

dpkg-reconfigure interface

If say your keyboard configuration is broken and you need to use dpkg-reconfigure console-setup to fix it you may have a hard time using the default dialog interface to change it use dpkg-reconfigure -f readline console-setup which uses a simple readline interface.

Thursday, 14 October 2010

Mac Alt (option) key symbols and linux vmware fusion

I've recently started trying vmware fusion after problems with virtualbox and I've finally got around to figuring out why the alt (option) key then the 3 key doesn't bring up a # this is because by default ubuntu setup has it as the RIGHT alt key, you can change it by running dpkg-reconfigure console-setup and changing the AltGr key binding.

Mount LVM using ubuntu live CD

To mount lvm partitions on ubuntu live cd do the following

apt-get install lvm2
vgscan
This will show any logical volumes
vgchange -ay <name of logical volume from vgscan>
lvs
This will list the logical volumes
then just mount it as normal
mount /logicalvolume /path-to-mount-to

Friday, 8 October 2010

Mac tar delete

This is weird, the mac version of tar doesn't have a --delete option, looks like I'll switch to zip for this archive.

Wednesday, 22 September 2010

Big site web servers

Out of random curisoity while I waite for a database to populate I went and checked the server headers from various big websites, amazon's I thought was the best
Google: gws
Yahoo: Yts
Wikipedia: Apache (although I thought they used nginx but apparently they use apache with varnish as a cache)
Amazon: Server (yes that's what it says, Server.....)
Stackoverflow: Doesn't have a Server header...

Recover git deleted file

So you've deleted a file but it was tracked by git at some point and you want it back..well here's how to get it. First use git log to find it, in my case it was a pdf file

git  log --diff-filter=D --summary | grep "pdf\|commit"

The grep "pdf\|commit" filters all pdf files and commit lines, once you see the file you want, choose the commit before it and use git checkout (commit) (file path)

Git Less


By default git uses less to page it's output, to override this use git -c core.pager=" " i.e. git -c core.pager=" " log 

Tuesday, 21 September 2010

Clean up git repositories

If you're like me and have a git repo for each project and have a lot of projects then they could be chewing up some space. Here is a quick command to clean them all (garbage collect)


find . -type d -name '.git' -exec git --git-dir={} gc \;

The command finds all .git directories then executes git gc on the directory which packs and prunes your git repos.

Thursday, 16 September 2010

Recreate the mysql root user

Me being daft accidentally deleted my mysql root user...oops!

To fix it do the following:

1) kill `cat /path/to/mysql/pid/file.pid`
2) mysqld_save --skip-grant-tables &
3) mysqldump mysql > mysql.sql (this backs up your mysql users database)
4) echo 'drop table mysql.users' | mysql
5) kill `cat /path/to/mysql/pid/file.pid`
6) mysql_install_db (this will reinstall the mysql.users table with an empty root password)
7) (start mysql however you do on your system)
8) mysql_secure_installation (to set your password)
9) edit the mysql.sql dump file removing the root user from it then restore the file to restore your previous privilages

Monday, 6 September 2010

Disable GDM at bootup on ubuntu lucid


Ubuntu lucid replaces the old init system with upstart, this means you can't use update-rc.d gdm -f remove  to stop it starting up at bootup. So to disable it we need to edit the upstart files in /etc/init (note not /etc/init.d!) thanks to sisco311 on the ubuntu forums the solution is to edit /etc/init/gdm.conf and change

start on (filesystem
          and started hal
          and tty-device-added KERNEL=tty7
          and (graphics-device-added or stopped udevtrigger))
stop on runlevel [016]

to

start on (runlevel [3]
          and filesystem
          and started hal
          and tty-device-added KERNEL=tty7
          and (graphics-device-added or stopped udevtrigger))
stop on runlevel [0126]

Then reboot!

You can start gdm via service gdm start


Sunday, 5 September 2010

IE8 table and JQuery Toggle

JQuery's toggle function doesn't work in IE8 when on a td element (and probably a tr). Why ask Microsoft? Anyway to get around it I made a class called .hidden { display:none; } . And used toggleClass("hidden") instead.

Friday, 3 September 2010

Reduce the size of a virtual box vdi drive.

A lot of people suggest using vboxmanage --compact to shrink a virtual box vdi drive, now every time I try this it corrupts the drive, so after some googling I found a blog post from sun and they suggest an alternative, to clone the drive instead, so here's a step by step process.
(this is for a linux guest)
1) log into the guest, type cat /dev/zero > /zero.file; rm /zero.file; shutdown -h now in the terminal that will fill you free space with 0's then shutdown the machine
2) run vboxmanage clonehd /path/to/your/vdi /path/to/new/vdi this will clone the drive but it won't copy the 0's so it'll be smaller.
3) open virtual box, go to your machine's settings and swap the old drive with the new one.
All done!

Monday, 30 August 2010

XUbuntu acpi power off issues

I previously wrote about ubuntu acpi power off issues now recently I installed xubuntu's desktop since I needed a graphical interface, ever since the virtual box's acpishutdown function failed to work. The solution is to edit in the xubuntu system /etc/default/grub and add acpi=force to GRUB_CMDLINE_LINUX

Saturday, 14 August 2010

Virtualbox shared folder ownership

Virtualbox shared folders on linux guests accept the uid parameter in fstab (and the gid) handy for running scripts that require a write access from the web server (i.e. wordpress) an example fstab line is
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
projects /host vboxsf defaults,uid=1 0 0

Friday, 13 August 2010

Ubuntu not shutting down with acpi power button


Virtualbox has a command to cleanly shutdown virtual machines called acpipoweroff, my ubuntu virtual machine wasn't responding to this, to resolve the issue run apt-get install acpid on the ubuntu machine.

Monday, 26 July 2010

Avahi publish multiple domains on one host

If you want to publish multiple domains on one host avahi doesn't have a built in mechanism however there is a python script that will do what you need.

http://www.avahi.org/wiki/Examples/PythonPublishAlias

Friday, 23 July 2010

Highlight table column


For a site I've been requested to highlight a table column when it's selected. To do this use the following CSS (note this is CSS3 so won't work in older browsers).

Note the 1 inside nth-child is the column number in this case the first one

table tr td:nth-child(1)
{
background-color:#CCC;
}

Thursday, 15 July 2010

Komodo Edit about:config

Komodo edit is based on mozilla hence has an about:config file, to access it open a file, press ctrl-k then ctrl-v and type about:config in the box.

Sunday, 11 July 2010

XML Entities

When using DOMDocument in PHP with HTML entities you must use the unicode format, i.e. instead of &pound; use &#163; XHTML only supports the entities &lt; &gt; and &amp;

Friday, 2 July 2010

CSS border-radius and border-collapse

The border-raidus (tested in safari 5 and ff 3.6) doesn't work in a table's border-collapse has been set to "collapse"

Thursday, 17 June 2010

Debian ssh virtual box and ServerAliveInterval

Normally when I use SSH I have ServerAliveInterval set to keep the connection alive. Now my testing machine is a debian installation using virtual box, now for some reason when the server went idle and a SSH connection was open after a little while the whole server network just lagged, it responded fine to local input but all network traffic flaked. Turning off ServerAliveInterval has fixed it.

JQuery get query string

The following function returns the query string using JQuery

$.getQueryString = function()
{
str = new RegExp('\\?([^#]*)').exec(window.location.href);
if(!str) return [];
return str[1].split('&');
}

Monday, 7 June 2010

Single App Dock

This is kinda cool, I could see it being handy when wanting to focus on just one thing.

http://osxdaily.com/2010/06/07/enable-single-application-mode-in-mac-os-x/

Loading kernel modules at startup ubuntu (modprobe)

To make a kernel module load at bootup in ubuntu just add the name of the module to /etc/modules i.e. for fuse you would need to add "fuse" simple!

Sunday, 6 June 2010

Purging configuration files in ubuntu/debian

If you've uninstalled a bunch of apps in debian/ubuntu and want to purge the configuration files, use the following command

dpkg --list | grep '^rc\b' | awk '{ print $2 }' | xargs sudo dpkg -P


found at : http://www.debian-administration.org/users/fsateler/weblog/4

Friday, 4 June 2010

Weird vboxsf apache issue

This is the weirdest thing I've seen in a long time. I have a debian lenny virtual machine running apache on my mac. Now here's the weird bit, the apache document root is on my mac via a vboxsf mount. If I view a static file, edit the file then refresh, the file corrupts, the only way to fix it is to unmount/remount the vboxsf share...now here's what's odder, this only happens with apache, it doesn't happen on cherokee, but restarting apache doesn't fix it..so it's hard to pinpoint the issue.

SUCCESS!

After testing on a windows xp host and deciding I'm not going mad, I did some more googling and found this http://forum.virtualbox.org/viewtopic.php?f=3&t=1940&start=0 which leads to this http://httpd.apache.org/docs/2.0/faq/error.html#error.sendfile

How do I fix my problem? Simple add

EnableSendfile Off

In my httpd.conf

That simple..don't you hate it when you spend hours and the solution is a one liner...bah :P

Quickly quit mac apps

http://osxdaily.com/2010/06/04/quickly-quit-programs-using-the-application-switcher/

cool!

Wednesday, 2 June 2010

Virtualbox shared host folders fstab

The fstab entry for a virtualbox host shared folder is

       vboxsf   rw   0   0

i.e.

projects    /host    vboxsf   rw    0    0

Virtualbox vboxaddtions and debian

This is a reminder to myself the package required to install vboxadditions is build-essential and linux-headers-`uname -r`

Tuesday, 1 June 2010

MySQL auto increment and rollbacks

If you insert a row into a MySQL table that has a auto increment value and then roll it back so it doesn't get added the auto increment value still goes up. (Makes sense really but you might not think of it)

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;

Friday, 30 April 2010

Split Mac dmg files

If you need to split mac disk images into smaller files (say for upload/email) use the following command in terminal
hdiutil create -verbose -srcfolder "path to files to image" -nospotlight -format UDZO "path to temp image"
This creates a disk image which is compressed and doesn't have a spotlight index.
Next you need to run prinf password| hdituil segment -o "path to final image" -segmentSize 1g -encryption AES-256 -stdinpass "path to tmp image" This will segment the image with a maximum size of 1GB per segment and encrypt it using AES-256 the printf password sets the password to "password"

Monday, 26 April 2010

Ubuntu Manpages

http://manpages.ubunut.com has a new layout. Shiny!

Python dictionary iteration


To iterate through a python dictionary using a for loop use the following

for v in dict:
........

but if you want the key as well then use

for k,v in dict.items():
......

Thursday, 22 April 2010

Spotlight doesn't index some files


If spotlight isn't indexing some files (in my case applications) try the following

In terminal run:

find /Applications -name "*.app" -exec arch -i386 mdimport -d 1 {} \; 

This finds all applications in the /Applications folder and imports them into spotlight.

Saturday, 10 April 2010

Dock Spaces

Here's a cool way of adding spaces between icons in the dock on os x 10.5+ 

defaults write com.apple.dock persistent-apps -array-add '{ "tile-type" = "spacer-tile"; }'
killall Dock

Sunday, 4 April 2010

Friday, 2 April 2010

VMWare fusion boot camp cannot install ethernet driver

If your boot camp partition can't install the vmware fusion ethernet driver do the following

1) Shutdown and close vmware fusion
2) Go to /users/[your user]/Library/Application Support/Vmware Fusion/Virtual Machines/Boot Camp/%2Fdev%2Fdisk0/
3) Right click bootcamp partition and click show package contents
4) Open bootcamp.vmx in text edit
5) add the following line somewhere in the file ethernet0.virtualDEV = "e1000"
6) Save the file and restart vmware fusion.

The network bridge on device /dev/vmnet0 is not running.

I tried to connect my boot camp partion using vmware fusion to my network on bridged mode and got the following error "The network bridge on device /dev/vmnet0 is not running." to fix it type

sudo /Library/Application\ Support/VMware\ Fusion/boot.sh --restart


In Terminal (on mac) and press enter. Then try and reconnect.

Tuesday, 30 March 2010

Rsync

This is just a reminder to myself since I can never remember the arguments for putting files over ssh using rsync

rsync -avz -e 'ssh -p [port]' [localfile] [remoteuser]@[remotehost]:[remotepath]

OS X terminal colours

Here's how to add colour to the ls command in OSX's terminal http://www.geekology.co.za/blog/2009/04/enabling-bash-terminal-directory-file-color-highlighting-mac-os-x/

Thursday, 18 March 2010

OS X File Vault doesn't reclaim space when deleting files


When deleting files a few days ago with file vault enabled (your home directory is encrypted) on OS X I deleted 10+ gigs of files to make room for some photos and videos, but the space wasn't reclaimed when emptying the trash!

Normally when you log out OS X reclaims disk space on your encrypted home directory but for some reason it didn't work (I wonder if it was because I had so little free space less than a gig). Anyway to reclaim it log in as another user (i.e. root) and open terminal, type

hdiutil compact /Users/<your username>/<your username>.sparsebundle

and press enter, that will reclaim any disk space it can (I got 16 gigs back not bad :) ).

Additionally, file vault won't clean up if you're on battery power and time machine won't back up a file fault on battery power.

Friday, 12 March 2010

Wordpress theme caveat

If you have a wordpress theme and name a file home.php (make sense as a template for the home page) then have a static home page and other page for the blog, the blog will use the home.php template...weird.

Wordpress JQuery Hack

By default jquery for wordpress runs in no conflict mode, this means instead of 

$(document).ready(function(){});

you need to use

jQuery(document).ready(function($){});

Thursday, 11 March 2010

Gmail/Google Mail/Google Apps Mail Deleting Mail with Apple Mail

One annoying thing about the reccomended settings for gmail imap and apple mail is not to do anything special with deleted mails. Google's version of delete is "archive and don't worry about it"...my version of delete is...well delete and it's gone (if you saw the number of automated emails I get you'd know why I like to delete!).

Anyway thanks to this

http://5thirtyone.com/archives/862

It confirms my suspicions that you have to go into "Preferences" > "Accounts" > tick "Move deleted messages to trash" and tick "Store deleted messages on the server".

Then find your "Bin"/"Trash" mail box in apple mail, then click mailbox from the menu bar, then click use as, and click trash.

Disable IPV6 on ubuntu


I wanted to disable IPV6 on ubuntu (I don't use it).

How to do it? Use the following:

echo "net.ipv6.conf.all.disable_ipv6=1" > /etc/sysctl.d/60-noipv6.conf

That will disable it on reboot, and to disable on this session use

 sysctl -w net.ipv6.conf.all.disable_ipv6=1

thanks to http://www.linode.com/forums/viewtopic.php?t=5250&highlight=ipv6

To do the same on debian lenny add


alias net-pf-10 off
alias ipv6 off

To /etc/modprobe.d/00local

Thanks to http://www.debian-administration.org/article/Disabling_IPv6_under_a_2.6_kernel

Monday, 8 March 2010

SIOCADDRT: no such process

I've just configured an ubuntu server to have a static IP and when it booted the network didn't start...ahh! After running /etc/init.d/networking restart I got the error SIOCADDRT: no such process

Cryptic huh? Turns out I typed the IP address in wrong (put a 1 where a 2 should be...don't work on servers when sleep deprived).


Saturday, 6 March 2010

PHP Warning: PHP Startup: Invalid library (maybe not a PHP library)

I hadn't compiled the gd and mcrypt extensions into php and didn't want to recompile the whole thing so I did a phpize && compile && make && make install

When running php I got the following error

PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'gd.so' in Unknown on line 0

Ack!

Turns out that because I used sources that I compiled php with instead of a fresh untar'd copy it didn't compile properly...weird!

So if you ever see that error, try using fresh sources.

Wednesday, 3 February 2010

iPhoto Screensaver and Desktop Missing

The other day my fiancé had a strange problem with her iPhoto, being the sentimental type she wanted to have her screen saver and desktop as random pics from iPhoto, but the iPhoto option was missing from desktop and screensaver.

Ok so first I think permissions!...Nope they're all fine I ran disk utility, and used the install disk to repair the home directory ACLs I even went in and chmod'd the damn library.

After a while I gave up and called apple, they went through diagnostics, turned out it was just this single library that was busted, after an hour the engineer instructed me to create a new library and import stuff.

This while solving the problem left all the facebook albums missing, since my fiancé has a thing for facebook I couldn't just leave it at that, so this morning I had another crack.

Turns out some photo dates were corrupt (when I say corrupt I mean -2147483641/07/21221 an impossible date) after selecting all the corrupt photos and using "Batch Change" (note adjust date/time didn't work) and setting the date to today's date it fixed the problem! Yay.

I have left feedback with apple about the issue.

Monday, 25 January 2010

Hiding OSX dock icons

If you have a program that runs all the time but you don't want to see it's dock icon do the following:

Right click the app, click show package contents, then open the Contents folder, open the info.plist file and add a new key called LSUIElement and set it to value 1 then restart the app.

Sunday, 24 January 2010

Multi user git and websites

As you may know I use GIT for version control.

Recently a client asked me to allow them and others access to the site (uh oh this should be fun!)

Now currently I edit locally, commit to git, and upload files via sftp (makes sense). Now this isn't ideal for the multi user situation because of the following...

1) You need a remote repo to push to
2) Teaching people how to use sftp (not hard I know but it's something extra do to)
3) What happens if they upload via sftp but forget to commit to git?! Oh crap is what happens.

So after some googling I found the following:

http://joemaller.com/2008/11/25/a-web-focused-git-workflow/

It works wonders, with a few tweaks of course which are:

1) For multi-user access add each user as a linux user with git-shell
2) Add them all to the same group let's call it "git"
3) Make the git repo and the website group writable
4) chmod 06770 the .git directory so it's sticky this allows users to write to the files if they have the group permission bit and it makes new files retain the parent directories group

That way no SFTP and the only way to edit the site is via a git push so everything is logged.

Monday, 18 January 2010

Mac Reindex Spotlight


I recently used Onyx to clean up my mac, one of the things was rebuilding the spotlight index, oh boy was that a bad idea, spotlight which was uber quick and my main access to applications became slower than a moron convention. 

To fix it I tried the apple support idea of adding it to privacy then removing it, that did absolute squat, after googling I found this http://davecoyle.com/documents/leopard-when-spotlight-wont-reindex.htm worked a treat, here are the commands:

sudo rm -r /.Spotlight-V100
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
sudo mdutil -i on -E /

Note this is on Snow leopard the .Spotlight-V100 folder might be named something else in different versions.

Saturday, 16 January 2010

Mac RAID


One of my external hard drives might be on it's last legs (it's rather louder than usual and has been disconnecting itself randomly) so I've migrated most of the data to my next biggest drive, which brought to mind the idea of RAID, I've done it under windows and it wasn't the most pleasant procedure (ironically my mother board failed shortly after I did that). On a mac it seems quite simple an interesting article that explains it is found here http://www.frozennorth.org/C2011481421/E20060221212020/index.html

Here is the contents just incase that page ever goes missing and I want to use it



Our Mac G4 Cube finally bit the big one this week, so on Wednesday I went out and bought a brand-new Mac Mini (and a cheap flat-panel monitor).
Let me begin by saying that the Mini is probably the most amazing computer I've ever owned. It is an astonishingly capable machine, and until you see on in person, you just don't understand how tiny they really are. Imagine a stack of about six CD jewel cases: that's the size of the entire computer.

As had been my practice for the last few dead-Mac transitions, the first thing I did was extract the hard drive from the old computer, put it in an external USB case, and transfer the contents to the new computer. Mac makes it so utterly simple to transfer your life from one computer to another (literally two clicks) that it is truly a joy--especially if you've ever had to go through the pain and agony (as I have, several times) of doing it under Windows.

But I have a problem. Not a let's-call-my-geeky-friend kind of problem, but an I-should-enroll-in-a-12-step-program kind of problem. My problem is that every so often I see how utterly cheap hard drives are, and I can't resist buying a 250GB external drive for ten Cheerios boxtops plus $2.50 postage, or whatever the price happens to be that day. Never mind that I don't have a use for all that storage: it is just so cool that you can get so much for so little that I have to have it.

So combine that problem plus my practice of putting the hard drives from old computers into external cases, and I have this accumulation of external hard drives sitting around basically doing nothing.

Then the obvious idea hit me: Why not build a RAID array from all these external drives? At least then I'd have something coherent (a giant virtual disk with a goodly fraction of a terabyte) instead of a whole bunch of external drives.

I'd always known that Mac OS X comes with built-in RAID capability, but I never had the excuse to explore it.

RAID stands for Redundant Array of Inexpensive Disks (some people use the word "Independent" instead, but either is correct). It was originally designed by cash-strapped researchers to take advantage of the plunge in consumer-grade disk drive prices back in the 90's in order to build bigger, more-reliable virtual hard drives than they could actually afford, by binding together multiple small, unreliable drives.

In fact, a RAID array can provide a bigger, faster, and more reliable storage device than anything you could get from a single drive (no matter how much you wanted to spend), using cheap off-the-shelf drives. It is now the standard way to build large storage systems.

The RAID capability in OS X is relatively easy to set up (as such things go), but it is still a little geeky. It is hidden inside the "Disk Utility" program, and gives you three modes: "Mirrored" which lets you combine multiple drives into a single redundant drive with the capacity of the smallest drive of the set. Each drive contains the entire contents of the array, and if any one drive is functional, then the virtual drive works properly. In other words, you can combine three 80-GB drives into a single 80-GB drive, but any two of the three can break before the virtual drive stops working. "Mirrored" mode is for creating highly reliable virtual disks.

"Striped" combines multiple drives into a single larger drive, spreading the contents of the array across all drives in the array. This gives you both a bigger drive and faster access (since data is read from multiple disks simultaneously). But there's no redundancy: if any one drive in the array fails, the whole thing goes down.

"Concatenated" also combines multiple drives into a single larger drive, like the "Striped" mode, except that a given block of data is only written to a single drive. This has the advantage of letting you add new drives to the array after it is set up, so you can grow the array as needed, and you can combine drives of different sizes without wasting any space.

Right now, the built-in RAID doesn't include more sophisticated modes like N+1 redundancy (where, for example, five drives can be combined into an array with the capacity of four of the five drives, and any one of them can fail without taking the array down). But it does do a couple of other nifty tricks.

One is that you can set up the RAID using individual partitions on a given drive. For example, if you have an 80-GB drive and a 120-GB drive, and you want to set up a mirrored array (which has the capacity of the smallest drive in the array), normally you would lose 40 GB of capacity from the 120-GB drive. But under OS X, you can set up an 80-GB partition on the larger drive for the RAID, and leave yourself with an extra 40-GB partition to use for something else.

The other neat trick is that you can create hybrid arrays, where you combine arrays of arrays. Suppose, for example, that you had a bunch of drives sitting around of random sizes, and you wanted to create a single big array. Normally you would use the "Concatenated" type, but that has the disadvantage of being unreliable: if any drive in the array goes down, the entire array is toast. If you want reliability, too (sacrificing half the capacity), you can create two "Concatenated" arrays which are approximately the same size, then combine those two arrays into a single "Mirrored" array. Then if any one drive fails, the virtual array continues to function normally.

This is not as efficient (in terms of storage space) as N+1 redundancy, but it wins hands-down on flexibility, especially if your basic problem is not building a highly redundant data center, but simply making good use of a bunch of random hard drives sitting around.

So I'm setting two RAID arrays on our Mac Mini. One is a Mirrored array combining the Mini's internal drive and an 80-GB partition on an external drive. This is the boot disk, and has all our precious data like Quicken files, family photos, and the like. If we're careful, we should never lose important stuff.

The other array will be a Concatenated array which will probably have about 600GB capacity. Since this is unreliable storage, it is essentially a giant scratch disk for things we could afford to lose: backup images of CDs, working files for editing home video, and so forth.

So we'll have a small(-ish) virtual disk which will be highly reliable, and a huge virtual disk which will be unreliable.

Now I just need to go find some data.

Friday, 15 January 2010

Redis


I'm currently reading up on Redis as a nice way to store information as key value pairs in memory (instead of using memcached), and this tickled me.

Values can be strings (including binary data) of every kind, for instance you can store a jpeg image inside a key. A value can't be bigger than 1 Gigabyte.

Since this is an in-memory database (it does store on disk as well but everything is also in memory) I think 1 gig should be sufficient for everyone's needs

Monday, 4 January 2010

VMware Fusion OS X Guest Disk Size

By default VMWare fusion sets OS X guest disk size to 40GB, why I don't know I only use it for testing and have a bare OS X install which is no where near that in size. To reduce it find the *.vmdk file which is associated with the image, open it in a text editor (I like text wrangler) and remove excess lines under # Extent description the more you remove the smaller the disk.