Skip to content

Instantly share code, notes, and snippets.

/* Use this to cause a function to fire no more than once every 'ms' milliseconds.
For example, an expensive mousemove handler:
$('body').mouseover(ratelimit(function(ev) {
// ...
}, 250));
*/
function ratelimit(fn, ms) {
var last = (new Date()).getTime();
@paulirish
paulirish / gist:292907
Created February 2, 2010 18:50
ascii art that's perfect for code comments
/* __
/ _)
.-^^^-/ /
__/ /
<__.|_|-|_|
*/
/*_/|
=0-0=
@isaacs
isaacs / comma-first-var.js
Created April 6, 2010 19:24
A better coding convention for lists and object literals in JavaScript
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
@defunkt
defunkt / clients.md
Created April 18, 2010 14:09
A list of Gist clients.

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@ericf
ericf / gist:856553
Created March 5, 2011 18:03
Hooking Ant up with CSSembed
<?xml version="1.0" encoding="UTF-8"?>
<project name="cssembed" default="build_css">
<!-- dirs -->
<property name="libdir" value="${basedir}/lib" />
<property name="sourcedir" value="${basedir}/source" />
<property name="outputdir" value="${basedir}/build" />
<!-- ant utils -->
@vasilisvg
vasilisvg / component-queries.md
Created October 12, 2011 13:07
Group media queries on component level, not on query level

Group media queries on component level

The common way to use media queries is to group all styling for a specific query. Leenull, a colleague of mine, came with the idea to use media queries on a component level. This might make make complex stylesheets easier to maintain.

I wonder what you think of it. Please let me know in the comments. Here's a link to a working example.

Grouping on a component level looks like this

.item1 {
/*
Error
at treachery (hell.js:49:11)
at fraud (hell.js:45:12)
at violence (hell.js:41:12)
at heresy (hell.js:37:12)
at anger (hell.js:33:12)
at greed (hell.js:29:12)
at gluttony (hell.js:25:12)
at lust (hell.js:21:12)
@nikcorg
nikcorg / berlin-jsconf-2014.md
Last active August 4, 2023 12:45
Slide decks of JSConf 2014
// per https://docs.npmjs.com/misc/scripts, npm exposes a bunch of variables to
// the environment prefixed with npm_config_*, npm_package_* and npm_lifecycle_*.
// Here's a list of all variables exposed in my setup.
npm_config_access=
npm_config_allow_same_version=
npm_config_also=
npm_config_always_auth=
npm_config_argv='{"remain":[],"cooked":["run","foo"],"original":["run","foo"]}'
npm_config_auth_type=legacy