MySQL Quick reference

To save the mysql username & password you use via command line, use the following;

Add ~/.my.cnf file with the following content


For DB Dumps via command line (in *nix);

mysqldump dbname | gzip -c > myfilename.sql.gz

Resoring DB;
gunzip -c myfilename.sql.gz | mysql dbname

Simpla Admin – opening tabs from URLs

simpla.jquery.configuration.js - line 50 onwards
url_tab = unescape(self.document.location.hash);
if(url_tab != '') {
url_tab = url_tab.substring(5); // #tab- = 5
if($('ul.content-box-tabs li a[href=#' + url_tab + ']').length > 0) {
$('ul.content-box-tabs li a[href=#' + url_tab + ']').addClass('current');
$('.content-box-content div#' + url_tab).show();
} else {
$('ul.content-box-tabs li a.default-tab').addClass('current'); // Add the class "current" to the default tab
$('.content-box-content div.default-tab').show(); // Show the div with class "default-tab"

This will take index.html#tab-id-of-tab and open the tab with the id of ‘id-of-tab’. the ‘tab-‘ part at the start is so the browser doesn’t scroll down to the tab which is opened by itself.


DataTables – post row-rendering;

$(document).ready(function() {
$(‘#example’).dataTable( {
“fnRowCallback”: function( nRow, aData, iDisplayIndex ) {
/* Bold the grade for all ‘A’ grade browsers */
if ( aData[4] == “A” )
$(‘td:eq(4)’, nRow).html( ‘<b>A</b>’ );
return nRow;
} );
} );

More bed-time reading – looks to be of some use as well for multiple search fields (eg. text field and dropdown box and this and that, etc). is something also to implement for keeping track of which rows were selected\ initial column sorting

  "aaSorting": [[ 2, "asc" ]]

Uploadify & PHP Sessions

Secured sites need the following parameter passed across;

session_id: <?= session_id() ?>

And somewhere in the code it should pick this up out of the $_REQUEST variable and set it … basically the problem lies in flash (what uploadify uses) not using the same session data as your browser, thus in flash’s eyes you seem logged out and it can’t do much in the way of sending files to where they need to go.

jQuery Tricks with Facebox

To use focus() and datepicker(..) properly with facebox, these need to be added in using the reveal.facebox(…) event AND use the #facebox tag as well (facebox does a copy of the content to put in it’s popup window and you can’t have two boxes focused at the same time now can we?!)

$(function() {
 $(document).bind('reveal.facebox', function() {
 $('#facebox #new_date').datepicker({dateFormat: 'dd/mm/yy'});
 $('#facebox #new_date').focus();

Thanks goes to for this trick! 🙂