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

[Client]
user=myusernamehere
password=mypasswordhere
host=localhost
database=mydbnamehere

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

Compressing;
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

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 – http://www.datatables.net/usage/callbacks

http://datatables.net/forums/comments.php?DiscussionID=1478&page=1#Comment_7568 looks to be of some use as well for multiple search fields (eg. text field and dropdown box and this and that, etc).

http://datatables.net/examples/server_side/select_rows.html is something also to implement for keeping track of which rows were selected\

http://datatables.net/examples/basic_init/table_sorting.html initial column sorting

$("#example").dataTable({
  "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 http://groups.google.com/group/facebox/msg/aea0ba1522bf13a3 for this trick! 🙂

Babovka (Cake)

Ingredients:

  1. 240g butter
  2. 1 & 1/4 cup sugar
  3. 5 Eggs (separate whites from yolks)
  4. 2 & 1/4 cups plain flour
  5. 1 cup milk
  6. 2 teaspoons baking powder
  7. 1/2 teaspoon grated lemon rind
  8. 1 teaspoon vanilla essence
  9. 1/3 cup cocoa powder
  10. oil for pan

Method

  1. Mix butter & sugar
  2. Add eggs yolks
  3. Beat till light & creamy
  4. Mix in flour & milk alternatively
  5. Add baking powder into last 1/2 cup of flour
  6. Blend in lemon peel & vanilla
  7. Fold in stiffly beaten egg whites
  8. Pour 1/2 batter into another bowl and add in chocolate
  9. Pour in batter in 4 alternating light & dark layers
  10. Cut through with a spoon for marbled effect
  11. Bake in preheated 200 degrees oven for 60-75 mins
  12. Cool in pan for 15 mins, then turn out
  13. Sprinkle in icing sugar