Skip to content

Instantly share code, notes, and snippets.

View carlmw's full-sized avatar

Carl Whittaker carlmw

  • London
  • 13:42 (UTC +01:00)
  • X @carlmw
View GitHub Profile
// I was just thinking it would be pretty useful to be able to listen for the wfl events
// in a context outside the WebFontConfig object. In particular
// today I found a situation where I needed to supply several handlers in different contexts.
// In the end I used a shim to dispatch a custom event via jquery.
var WebFontConfig = {
active: function(){
$(window).trigger('wf-active');
}
};
@carlmw
carlmw / gist:1987169
Created March 6, 2012 16:19 — forked from xbx/gist:1533842
My pre-commit hook for git, check non-ascii-files, jshint, csshint
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
@carlmw
carlmw / gist:2693576
Created May 14, 2012 11:59
YQL to retrieve a users upcoming events
select * from html where url="http://lanyrd.com/people/carlmw/" and xpath="//h2[contains(.,' attending')]/following-sibling::*[1]/ol/li"
@carlmw
carlmw / gist:4692242
Created February 1, 2013 16:11
RegExp to find those pesky trailing commas
,\s*\n+(\s*\/\/.*\n)*\s*[\}\)\]]
@carlmw
carlmw / gist:5421164
Last active December 16, 2015 10:38
Mocha setup
(function (global) {
var sandbox,
sinon = require('sinon');
global.should = require('chai').should();
global.expect = require('chai').expect;
require('sinon-mocha').enhance(sinon);
require('chai').use(require('sinon-chai'));
setGlobals();
namespace.detection = (function () {
return { touch: window.touch };
}());
@import 'bourbon';
$visual-grid: true; // Turn on the visual grid overlay
$max-width: 960px;
$grid-columns: 8;
$mobile-size: 480px;
$tablet-size: 768px;
$desktop-size: 960px;
a {
font-family: 'icon-webfont';
text-indent: -999em;
overflow: hidden;
display: block;
position: relative;
}
a:before {
position: absolute;
@carlmw
carlmw / gist:8477370
Created January 17, 2014 17:16
Ergh mod_rewrite
# /client/js/lang/d627ef21fbcfc0e9def32c187b37ffa9e5034019/en/date.json
RewriteCond %{REQUEST_URI} ^/client/js/lang
RewriteRule ^(client/js/lang)/([a-z0-9]+/)(.+)$ /$1/$3 [L]
# Desired:
# /client/js/lang/en/date.json
# Actual
# /client/js/lang/date.json
@carlmw
carlmw / gist:8647287
Last active January 4, 2016 16:29
Bootstrapping an Angular app in Shadow DOM
angular.module('guestApp', []).controller('guestCtrl', function($scope) {
$scope.bar = "I'm a guest app, please be nice.";
});
var el = document.createElement('x-editor');
var shadowEl = el.webkitCreateShadowRoot();
document.documentElement.appendChild(el);
shadowEl.innerHTML = '<div id="guest" ng-controller="guestCtrl">{{ bar }}</div>';
angular.bootstrap(shadowEl, ['guestApp']);