MySQL backup script

I’ve recently been learning more and more about bash scripting and the cool functions and features that are included, that i’ll probably never use…

I recently had to set up a cron to backup all MySQL databases but I didn’t want them in one huge file.

So I’ve written a little script, that is probably not entirely efficient, but serves it’s purpose for us:

This was tested on a SuSE 11 server, might need some tweaking on other dists.

Ruby on Rails: image_submit_tag and :confirm

I was told about an issue today with the image_submit_tag not supporting the :confirm method on the element:

so I thought I’d share a quick fix which would be the actual javascript returned by the function:

Hope this can save some people time…

submitEvents – Javascript form submission handler

Something that I seem to be doing a lot lately, is writing a handler for processing the submission of a form, and since mootools is the JS framework of choice, I’ve written this little class that handles the onsubmit of a form and adds some useful features.

  • Confirmation – Provides an Ok, Cancel input box before proceeding further
  • Submit Button – Disable and change the text on a submit button
  • Information Div – Display a div that lets the user know something is happening
  • Undo – Undo the changes (re-enable a previously disabled submit button, change the information div) that have been carried out by the class
  • AJAX – Submit the form using AJAX instead of the ‘old fashioned’ way

All these should be easily implemented using the class.

Examples are provided in examples.html.

As previously, this work is released under the creative commons share alike license.

Download submitEvents 0.1 (31.9k) (Includes mootools 1.2)

Edit: I really do dislike internet exploder… The above version failed in IE6 (mootools’ form.toQueryString() function). I’ve updated the code to 0.11 which can be found here:

submitEvents 0.11 (32.8k) (Includes mootools 1.2)

Edit 2: Ok, so my hatred for IE, although deserved, was unnecessary in this situation…

I’ve updated the code to use mootools .bind(this) on the ajax onComplete function, this fixed the main problem with IE6 and makes the code look much cleaner. Also the examples file is now PHP instead of static HTML and returns a var_dump of $_POST when the form is submitted.

PS. This will be the final update to this post!

submitEvents 0.2 (32.3k) (Includes mootools 1.2)

DB

Here’s a little script I’ve wanted to make for a while, but have only just finally got the motivation to work on.

It’s a lightweight Database wrapper with functions similar to Ruby on Rails’ ActiveRecord.

When I discovered the __call() method I wanted to make my own version in PHP, so here it is!

It supports most basic functions, all based on the MySQL set of PHP functions, no other wrapper is required (PEAR etc.). There is not (yet?) any automatic mysql_real_escape_string or anything, although that could easily be added if required, my assumption is you’ve done that kind of thing already before passing anything to it.

It’s only a first draft, so any comments, questions or pointing out any typo’s in the code, (yeah, there are likely to be a few…) would be muchly appreciated.

This work is free under the Creative Commons Share Alike 2.0 license.

Download:

DB_0.1.tar.gz (4.84Kb)

Edit: Think next on my list is TextMate syntax highlighting and maybe the non-default template…

First!

Will I really ever use this?

Who knows… But maybe I’ll keep a log of all the cool stuff I find…