Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jaikdean on github.
  • I am jaikdean (https://keybase.io/jaikdean) on keybase.
  • I have a public key ASAjfMpHHVIFJhkGdVH83X5uDttjAXF8-Y_O1ir2mS10Tgo

To claim this, I am signing this object:

@jaikdean
jaikdean / Instructions.md
Last active December 14, 2015 21:29
Bash script to base64 encode the given file and output a CSS background-image declaration

Usage

In a terminal, run ./base64enc.sh /path/to/file.png

@jaikdean
jaikdean / gist:4952061
Created February 14, 2013 11:00
Testing whether PHP hoists `global` statements
<?php
$foo = 'set globally';
function testGlobals()
{
$foo = 'set locally';
global $foo;
}
@jaikdean
jaikdean / index.html
Created January 28, 2013 11:58
Annoying subpixel rounding behaviour causing overflow:hidden to appear broken in Chrome 24
<!doctype html>
<html>
<head>
<title>Subpixel rounding annoyance</title>
<style>
.container {
position: absolute;
top: 20.5px;
left: 20.5px;
overflow: hidden;
@jaikdean
jaikdean / ShorthandBoxModelSniff.php
Created March 14, 2012 14:52
PHP_CodeSniffer sniff for CSS to find box model styles which can be optimised using shorthand
<?php
/**
* Shorthand box model value sniffer
*
* @package SkylabCodeSniffer
* @author Jaik Dean
**/
/**
@jaikdean
jaikdean / gist:1759218
Created February 7, 2012 11:24
jQuery Ketchup validator for UK postcodes
$.ketchup.validation(
'ukpostcode',
'Please enter a valid UK postcode',
function(form, el, value){
var tidyValue = value.replace(/\s+/g, '');
var pattern = /^(GIR0AA)|((([A-PR-UWYZ][0-9][0-9]?)|(([A-PR-UWYZ][A-HK-Y][0-9][0-9]?)|(([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))))[0-9][ABD-HJLNP-UW-Z]{2})$/i;
return pattern.test(tidyValue);
}
);
@jaikdean
jaikdean / gist:853059
Created March 3, 2011 16:41
Doctrine inheritance stupidity
# THIS DOESN'T WORK
Atom:
columns:
title: { type: string(255) }
News:
columns:
article: { type: text }
inheritance:
@jaikdean
jaikdean / MooTools 1.3 Element.removeTag
Created January 7, 2011 11:59
This allows you to destroy an Element but leave its contents, including other Elements and text nodes, in its place.
Element.implement({
removeTag: function(){
var childNodes = this.childNodes;
for (var i = childNodes.length - 1; i >= 0; i--) {
if (childNodes[i].nodeType == document.TEXT_NODE) {
this.appendText(childNodes[i].nodeValue, 'after');
} else {
document.id(childNodes[i]).inject(this, 'after');
}