Skip to content

Instantly share code, notes, and snippets.

@brachycera
brachycera / niceDate.php
Last active May 27, 2020 17:02
Format mySql timestamp/date field values into many different variations
<?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
@brachycera
brachycera / multipleCounting.sql
Created September 2, 2015 17:51
Multiple count within one query
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 / delete_local_indexedDB.js
Last active October 11, 2015 22:33
Delete all local indexedDB
window.indexedDB.webkitGetDatabaseNames().onsuccess = function(sender,args){
var r = sender.target.result;
for(var i in r)
{
indexedDB.deleteDatabase(r[i]);
}
};
/**
*
* 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 / karma.conf.js
Last active October 11, 2015 22:27
Karma configuration File to run with gulp-karma - This setup is for an AMD project with Angular and RequireJS. The essential part to get Karma working, was to load Angular and requireJS test.config.js files before the project files. Plugins: karma-requireJS, karma-spec-reporter, karma-jasmine, karma-phantomjs-launcher
(function ( module ) {
'use strict';
module.exports = function( config ) {
config.set({
basePath : '../',
urlRoot: '/base/',
@brachycera
brachycera / outline.css
Created October 23, 2015 17:20
Remove yellow outline in Android Chrome & iOS Safari Browsers
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
@brachycera
brachycera / errors_tpl.html
Last active December 30, 2015 17:20
Angular 1.3.x Directive to fetch minlength Value from Input Text Field and show the Value in the ng-message for minlength Errors
<small class="error" ng-message="minlength" validate-minlength>Please enter at least {{requiredMinLength}} characters</small>
@brachycera
brachycera / install_gettext.sh
Created January 20, 2016 16:12 — forked from istepanov/install_gettext.sh
Compile and install gettext.so PHP extension for Mac OS X 10.8 Mountain Lion
#!/usr/bin/sh
# Scipt for installing mcrypt.so extension for PHP 5.3.13 (default PHP for OS X 10.8 Mountain Lion)
mkdir /tmp/gettext
cd /tmp/gettext
curl --location --progress-bar http://us.php.net/get/php-5.3.13.tar.gz/from/nl.php.net/mirror | tar -zx
brew update
@brachycera
brachycera / Export each as SVG.js
Created January 26, 2016 14:48 — forked from vieron/Export each as SVG.js
Export each as SVG. Modified some lines from the original by Aaron Beall (http://fireworks.abeall.com/extensions/commands/Export/Export%20SVG.jsf) to export each selected object as a separate SVG file.
// Fireworks JavaScript Command
// Exports current document state as SVG graphics format
// Install by copying to Fireworks/Configuration/Commands/
// Run via the Commands menu in Fireworks
// Aaron Beall 2010-2011
// Version
var VERSION = "0.6.1";
// Params
@brachycera
brachycera / svg_filters.svg
Last active August 18, 2018 16:47
Collection from SVG Filters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.