Regex to reject an extension

If you want a regular expression to match anything except a certain extension (such as .png) : ^((?!\.png$).)*$

July 25, 2007 · 1 min · Dave Perrett

Set OS X Default Shell

You need to use Niutl to change your shell. In the terminal : $ sudo niutil -createprop . /users/dave shell /bin/zsh Alternatively, you can use the NetInfo Manager utility (in the Utilities folder). Select your user in the navigator, and change the value of the shell property. ...

July 25, 2007 · 1 min · Dave Perrett

Useful JScript Array Functions

A couple of useful array manipulation functions: clear, inArray and remove. Courtesy of Todd Ditchendorf ...

July 25, 2007 · 1 min · Dave Perrett

Add Dreamweaver Extensions

To colour-code a new extension ( .ctp CakePHP templates for example ), edit the file C:\Program Files\Adobe\Adobe Dreamweaver CS3\configuration\Extensions.txt and add the .ctp extension to the first line ( All Documents ) and the PHP Files section : ...

June 4, 2007 · 1 min · Dave Perrett

External Sessions in CakePHP

If you are using CakePHP in conjunction with an existing PHP application, chances are you need to import the normal application’s session into cake. Create a file called session_import.php or something similar in your cake app/config directory with the following contents : ...

June 4, 2007 · 2 min · Dave Perrett

Multiple DBs in CakePHP

Edit : To avoid confusion, cake has quite a nice mechanism for defining multiple DBs already (the database.php file), and if you only want to define a finite set of DBs, this is not the way to do it. This method is only useful if you want to have multiple DBs with the same structure (a database for each customer, for example). ...

June 4, 2007 · 7 min · Dave Perrett

Replacing text with sed

To replace all occurences of string1 in a file with string2 : $ sed -ri "s|string1|string2|" some_file.txt

May 16, 2007 · 1 min · Dave Perrett

Cocoa drag to dock to open

Go to Project->Edit Active Target->Properties (Tab) and enter the filetypes that you want your dock icon to respond to : ...

April 13, 2007 · 1 min · Dave Perrett

Quit cocoa app on window close

Add this method to your NSWindowController : -(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication { return YES; }

April 13, 2007 · 1 min · Dave Perrett

Cocoa NSTextView setHidden

If you’re trying to hide an NSTextView without success, be aware that setHidden only hides the NSTextView itself - it doesn’t hide the enclosing NSScrollView. Instead of doing this : [myTextView setHidden:YES]; you need to do : [[myTextView enclosingScrollView] setHidden:YES];

April 5, 2007 · 1 min · Dave Perrett