Skip to content

Instantly share code, notes, and snippets.

View busticated's full-sized avatar

Busticated busticated

View GitHub Profile
@domenic
domenic / needs-a-name.js
Last active December 20, 2015 00:09
This needs a name
// Needs a clever name like "debounce" or "throttle" (but it's not either of those.)
function doOperationButOnlyReactIfItWasntCalledAgainInBetween(promiseOperation) {
var latestOperation = null;
return function () {
var deferred = Q.defer();
var operation = promiseOperation.apply(this, arguments);
latestOperation = operation;
operation.then(

Example output, where | is the cursor:

function () {
  |
};
foo(function () {
@wwqrd
wwqrd / Jakefile.js
Created November 14, 2012 13:47
Example Jakefile.js
namespace('test', function () {
desc('Run server tests');
task('server', [], function () {
jake.exec('mocha spec', function () {
console.log('Server tests passed');
complete();
});
});
desc('Run client tests');
@jboner
jboner / latency.txt
Last active May 7, 2025 10:07
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@jsocol
jsocol / gist:2696070
Created May 14, 2012 19:43
Bash prompt function
_prompt() {
local _prompt=$1
local _out=$2
local _default=$3
local _val=''
if [ $_default ]; then
_prompt="${_prompt} [${_default}]"
fi
read -p "$_prompt " _val
if [ $_val ]; then
@busticated
busticated / arena.js
Created March 28, 2012 03:35
AMDWTF: So you want to AMD...
define( [ 'jquery', 'mods/crazydot' ], function( $, CrazyDot ){
var dots = [];
var setup = function( cfg ){
while ( dots.length < cfg.count ){
dots.push( new CrazyDot( cfg.speed, 'body' ).move() );
}
};
var stopGame = function(){
@tbranyen
tbranyen / use.js
Created January 13, 2012 01:21
A RequireJS compatible plugin to provide shimming capabilities declaratively.
(function() {
var buildMap = {};
/* RequireJS Use Plugin v0.2.0
* Copyright 2012, Tim Branyen (@tbranyen)
* use.js may be freely distributed under the MIT license.
*/
define({
version: "0.2.0",
@sontek
sontek / snowjob.sh
Last active May 5, 2025 11:13
Make your terminal snow
#!/bin/bash
LINES=$(tput lines)
COLUMNS=$(tput cols)
declare -A snowflakes
declare -A lastflakes
clear
@weaksauce
weaksauce / .vimrc
Created November 18, 2011 18:15
vimrc from hn
" .vimrc
" Author: Karl Groll <[email protected]>
"
" Mostly stolen from Steve Losh
" (http://stevelosh.com/blog/2010/09/coming-home-to-vim/)
"
" Preamble ---------------------------------------------------------------- {{{
filetype off
call pathogen#runtime_append_all_bundles() " Enable 'Pathogen' plugin. (Vim plugin manager)
@jrburke
jrburke / basic.js
Created November 7, 2011 07:14
possible jquery plugin boilerplate
// Basic approach. Does not try to register in
// a CommonJS environment since jQuery is not likely
// to run in those environments. See next file
// if you want to opt in to CommonJS too.
(function(factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {