Development


📖 Posts | 📎 Development, Linux | 🔖 backup, bash, batch, scripting

Shell script to Back up critical files (using RSYNC)

Following up from my article on backing up USB drives, this recipe backs up the critical files on my desktop to remote storage (a NAS device on my network). Note that PC2 is the desktop to be backed up, SLUG1 (192.168.1.2) is the NAS device and USER1 is the user id doing the backup. #!/bin/bash # Backup Key PC2 files to Slug1 # Sync 2007 picture folders ##rsync -rl /home/user1/pictures/2007/ [email protected]


📖 Posts | 📎 Development, Linux | 🔖 backup, bash, batch, scripting, usb

Automatically Backing up a USB Drive with RSYNC (KDE)

USB Drives of all kinds need to be backed up and the best backup is an automatic one (it’s the only way to make sure that it gets done!). So here is one recipe for doing just that using RSYNC and some BASH scripting magic. I’ve split this into two files. You don’t have to do this of course and one may well be better for you. I used two because I can run the second one manually as well.


📖 Posts | 📎 Development, Virtualisation | 🔖 virtualbox, cross-platform

Development Virtual Machine (VirtualBox)

I’ve been thinking ahead to a change of job recently. Knowing that I’ll be getting a new Windows based laptop and needing to have development capabilities and having developed a taste for Linux 😉 I’ve used my favourite VM tool VirtualBox (now owned by Sun) to create a sparlkly new OpenSUSE 11.0 virtual machine complete with Apache, MySQL, PHP, etc. as well as office tools such as Open Office, mind/concept-mapping and diagraming applications.


📖 Posts | 📎 Development | 🔖 mysql, sql

Update one table using data from another

If you want to update tbl1 with information from tbl2: UPDATE tbl1,tbl2 SET tbl1.col1=tbl2.colx WHERE …


📖 Posts | 📎 Development | 🔖 mysql, sql

Cannot directly use the IF function on a MySQL query that uses GROUP BY

Cannot directly use the IF function on a query that uses GROUP BY. This tip provides an alternative that is cross-db. It is extracted from: http://surfnet.dl.sourceforge.net/sourceforge/souptonuts/README_mysql.txt SQL Characteristic Functions: Do it without if, case, or GROUP_CONCAT. Yes, there is use for this … if statements sometimes cause problems when used in combination. The simple secret, and it’s also why they work in almost all databases, is the following functions: * sign (x) returns -1,0, +1 for values x < 0, x = 0, x > 0 respectively * abs( sign( x) ) returns 0 if x = 0 else, 1 if x > 0 or x < 0 * 1-abs( sign( x) ) complement of the above, since this returns 1 only if x = 0 Quick example:


📖 Posts | 📎 Development | 🔖 php

Defaulting optional parameters

If you have a function that takes an optional parameter – e.g. function blah($xx,$yy='Default',$zz){ …. You can use the function and ensure that the optional parm always takes the correct default (even if the definition changes) by passing a NULL to it. e.g. … $mydate=blah($something,NULL,$more); .


📖 Posts | 📎 Development | 🔖 php

Handle web parameters gracefully in PHP

Handle web parms (Call as: myParms('report');) # Ensures that the given parm is always set function myParms($var) { global $$var; if(isset($_REQUEST[$var])){ $$var=$_REQUEST[$var]; } else { $$var=''; } }