Skip to content

Instantly share code, notes, and snippets.

View countdown.js
/**
*
* Simple Countdown Function
* @param {num} duration - in Milliseconds
* @param {string} elemID - DOM Object ID to show the Countdown
*
*/
function countdown(duration, elemID) {
var start = Date.now( );
@brachycera
brachycera / delete_local_indexedDB.js
Last active Oct 11, 2015
Delete all local indexedDB
View delete_local_indexedDB.js
window.indexedDB.webkitGetDatabaseNames().onsuccess = function(sender,args){
var r = sender.target.result;
for(var i in r)
{
indexedDB.deleteDatabase(r[i]);
}
};
@brachycera
brachycera / multipleCounting.sql
Created Sep 2, 2015
Multiple count within one query
View multipleCounting.sql
SELECT
SUM(CASE WHEN foo = '0' THEN 1 ELSE 0 END) AS bar_count,
SUM(CASE WHEN foo = '1' OR foo = '2' THEN 1 ELSE 0 END) AS baz_count
FROM
database
WHERE
baz = qux
GROUP BY baz
@brachycera
brachycera / niceDate.php
Last active May 27, 2020
Format mySql timestamp/date field values into many different variations
View niceDate.php
<?php
/**
* Convert a mySql timestamp / date value to a nice looking date
*
* @param string $date - mySql Database timestamp / date field value
* @param num/bol $layout - Date Layout values 1 to 7 for different styles:
* [1] eg. 01.Jan.1970, 00:10:01
* [2] eg. 01.01.1970
* [3] eg. 00:10
* [4] eg. 01 January 1970