Mac OSX gems

This page is mainly for my own reference, but others may find the content useful. It's a place for me to store little useful coding tricks for the OSX command line or clever PHP things etc.

Making an iso image file from the Leopard command line

If you want to make a cd image file from a directory:

hdiutil makehybrid -o ~/Desktop/ISOFILENAME.iso 'SOURCE' -iso -joliet

SOURCE - The target directory, note this is also the label of the iso disk image.
ISOFILENAME - The name of the iso file, note this usage will dump it to the dekstop.

Quickly making the contents of a web directory read write and execute for abosolutely everybody

Not to be used lightly...

chmod -R 777 *

Flash Gems (AS3)

Write to a dynamic text field called buttontext within the movie object 'button3'

button3.buttontext.text="Continue";

PHP Gems

Got a date in American format and want to output it as another (more sane) format?

$usa_date = "06/16/2009" // Actually 16th June 2009
echo date( 'd-m-Y', strtotime( $usa_date )); // Outputs 16-06-2009

Quickly grab form data into an array within the object or return false if there isn't one. Note, I realise that direct assignment would be neater, this is a framework within which to do some processing along the way, i.e validity checking etc.:

    if ($_POST) {
        foreach ($_POST as $key => $value) {
            $this->userinput[$key] = $value;
        }
    } else { 
        return false;
    }

For Recordsets, something similar can be done. A recordset result is turned into a 2 dimensional array with the row number as key 1, the column name as key2, and the content as the associated data. I.e.


$myarray['row_number']['column'] => 'data'
        $counter=0;
        do {
            foreach ($row_recordset as $key => $value) {
                $myarray[$counter][$key] = $value;
            }        
            $counter++;    
        } while ($row_project = mysql_fetch_assoc($project)); 

Javascript/ PHP

For having a popup box that checks whether a user really wants to do something, i.e. delete, the answer comes in 2 parts. Firstly, a javascript function acts as a prompt to direct the user to a confirm page or cancel page. The button onscreen isn't a normal link, it is best implemented as a div with a javascript 'onclick' event:

The javascript function that shows the popup is as follows.

function delete_confirm(display,delete_id)
{
 var answer= confirm("Do you really want to delete the " + display);
 if (answer== true)
 {
   window.location="/*confirm location, use get vars to make delete happen*/" + delete_id ;
 }
 else
 {
  window.location="/*default location*/" ;
  }
}

The calling 'button' looks something like:

..div class="deletebutton" onClick="delete_confirm(display, delete_id)">Delete

PHP can be used to dynamically write into the javascript calling function the ID of the item to be deleted.
Content

Active Domains

Active Domains are unique SEO optimising technology that delivers results through a network of optimised mini-sites to promote your business to specific groups.

Content

Web Optimisation

ginzola offer first class web optimisation services aimed at improving your organic site ranking. Our services can be tailored to meet many specific business objectives.

Content

Email Marketing

Email Marketing (mailshots) provide a valuable communication tool for your business. Ginzola provide a professional email distribution service that delivers.