Skip to content

Instantly share code, notes, and snippets.

View callumlocke's full-sized avatar

Callum Locke callumlocke

View GitHub Profile
@callumlocke
callumlocke / time-require-calls.js
Created February 19, 2014 09:51
cd into a Node.js project, run node (CLI) and paste this in to time require calls
var modules = require('fs').readdirSync('node_modules').filter(function (name) {return name !== '.bin'});
modules.forEach(function (m) {
console.time(m);
require(m);
console.timeEnd(m);
});
@callumlocke
callumlocke / README.md
Last active August 29, 2015 14:17 — forked from mbostock/.block
@callumlocke
callumlocke / gist:2c4675abe6c364f0bcb7
Last active August 29, 2015 14:18
Bundle up an npm module to paste inline into Node.js code
# make sure you have these installed:
npm install --global browserify uglify-js
# example command for 'chalk':
echo "var chalk = (function(){var _ref;" `echo "_ref = require('chalk');" | browserify --bare - | uglifyjs` "return _ref;}).call(this);" > bundled.js
@callumlocke
callumlocke / is-simple-click.js
Last active August 29, 2015 14:23
Find out whether a click is really a click.
"use strict";
module.exports = function isSimpleClick(event) {
var isLeft = true;
var which = event.which;
if (!which && event.button != null) {
which = event.button & 1 ? 1 : event.button & 2 ? 3 : event.button & 4 ? 2 : 0;
}
@callumlocke
callumlocke / README.md
Last active August 29, 2015 14:25 — forked from mbostock/.block
<link rel="import" href="../ace-element/ace-element.html">
<link rel="import" href="../topeka-elements/category-images.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<link rel="import" href="../topeka-elements/category-icons.html">
<polymer-element name="my-element">
@callumlocke
callumlocke / format-date.js
Created September 11, 2015 12:39
Format a date object in this style: "July 21, 2014"
var monthNames = [
'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'
];
function formatDate(date) {
return (
monthNames[date.getUTCMonth()] + ' ' +
date.getUTCDate() + ', ' +
date.getUTCFullYear()
@callumlocke
callumlocke / test.html
Created December 15, 2011 15:46 — forked from aflatter/test.html
Webkit transitions on a newly attached element don't work. Probably related to http://code.google.com/p/chromium/issues/detail?id=82500
<html>
<head>
<title>Test</title>
<style type="text/css">
div {
position: absolute;
height: 200px;
}
.slide {
@callumlocke
callumlocke / new_bashrc.sh
Created August 13, 2012 09:52 — forked from josephwecker/new_bashrc.sh
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful. Now a repo: https://github.com/josephwecker/bashrc_dispatch
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# -- DEPRICATED --
# This gist is slow and is missing .bashrc_once
# Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch
# (Thanks gioele)
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?
@callumlocke
callumlocke / jquery-1.7-externs.js
Created September 14, 2012 12:12
jQuery 1.7 externs file for Google Closure Compiler
/*
* Copyright 2011 The Closure Compiler Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software