Skip to content

Instantly share code, notes, and snippets.

View krijnhoetmer's full-sized avatar

Krijn Hoetmer krijnhoetmer

View GitHub Profile
@krijnhoetmer
krijnhoetmer / gist:1109243
Created July 27, 2011 12:21
CSS 'build' thingy
<?php
$src = 'foo { border-radius: 4px; }
bar { box-shadow: 5px 0 0 rgba(0, 0, 0, .5);
baz { background-image: url(img/baz.png); }
quux { background-image: url(img/quuz.png#!); }';
preg_match_all('/url\((.*\.png)\)/U', $src, $matches);
foreach ($matches[1] as $match) {
$src = str_replace($match, 'data:image/png;base64,' . base64_encode(file_get_contents($match)), $src);
@krijnhoetmer
krijnhoetmer / amsterdam-tracking.js
Created April 14, 2016 09:17
Thanks to this “nifty” script, async GA tracking on amsterdam.nl links makes sure you have to click certain links twice if you block trackers and stuff. Yay.
// Thanks to this “nifty” script, async GA tracking on amsterdam.nl
// links makes sure you have to click certain links twice if you
// block trackers and stuff. Yay.
$.fn.analyticsPushEventClick = function(obj, href, category, async) {
$(this).on("click", function(event) {
return analyticsPushEvent(event, obj, href, category, async);
});
};
analyticsPushEvent = function(event, obj, href, category, async) {