Skip to content

Instantly share code, notes, and snippets.

View jamiel's full-sized avatar

Jamie Learmonth jamiel

View GitHub Profile
Verifying my Blockstack ID is secured with the address 17Qd1UmHZpdmNPhwFenAPTSJqTXWBookFJ https://explorer.blockstack.org/address/17Qd1UmHZpdmNPhwFenAPTSJqTXWBookFJ
0x50dAc4CFd68C4166E01354783E4B4b8BfAc13757
@jamiel
jamiel / gist:3915888
Created October 19, 2012 02:14
Simple alias for searching Symfony2 projects faster
# Add to your ~/.bashrc
# Usage: sgrep <mysearch> .
# Use from the root of your Symfony2 project
alias sgrep="grep -r --exclude-dir=vendor --exclude-dir=app/cache --exclude-dir=app/logs"
@jamiel
jamiel / gist:3134380
Created July 18, 2012 05:26
Yet another javascript gotcha
Auto-filling Array Keys
=======================
var foo = new Array();
foo[500] = 'bar';
console.log(foo.length); // 501
// And it gets worse:
@jamiel
jamiel / gist:3096567
Created July 12, 2012 08:03
Bash - Testing re-assigning of arrays
#!/bin/bash
#
# Test script to test bashes handling of re-assigned arrays
FOO[0]='foo';
FOO[1]='bar';
BAR=$FOO
echo "Loop main array"
@jamiel
jamiel / gist:1950093
Created March 1, 2012 14:17
Why does count(false) == 1 in PHP?
Why does count(false) == 1 in PHP?
----------------------------------
If you have ever been caught out by doing if (count($var)) and wondered why this
passes when a previous assignment failed and set this to false, the reason is
actually quite simple. count() was designed to be used with arrays, and so values
are always cast to an array internally before checking the number of elements. If
you cast a boolean to an array it will be come an array with one element set to the
value of the boolean. See:
@jamiel
jamiel / gist:1950031
Created March 1, 2012 14:07
New background image not loading after jQuery fadeOut / fadeIn
fadeIn rendering bug (background image)
---------------------------------------
I was experiencing an issue in Chrome and Internet Explorer where intermittently the
background image would fail to load after a a fadeIn. Narrowed this down to a rendering
issue rather than a logic error and was able to fix it by resetting the background image
after the fade like so:
$('#wrapper').css('background', $('#wrapper').css('background'));
@jamiel
jamiel / gist:1711933
Created January 31, 2012 18:08
PHP 5.3 namespaces have taken away the biggest advantage of autoloading
PHP 5.3 namespaces have taken away the biggest advantage of autoloading
-----------------------------------------------------------------------
When autoloading was introduced into PHP, the PHP world rejoiced as we no
longer needed to require every class we wanted to use in our current file
at the top of our code. With the introduction of namespaces this advantage
has been completely reversed, where unless you are writing all your code in
a single namespace (unlikely) you will end up needing to "use" every class
you want to include.
Ctrl+v Ctrl+i