Skip to content

Instantly share code, notes, and snippets.

Ben Alman cowboy

Block or report user

Report or block cowboy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Dockerfile
FROM ubuntu
RUN apt-get update
RUN apt-get install -y build-essential curl
# NodeJS >= 6.0
RUN curl -sL | bash -
RUN apt-get install -y nodejs
# ttfautohint
cowboy / pubsub-demo.js
Created Dec 16, 2010 — forked from rmurphey/pubsub-demo.js
Two approaches: "Traditional" vs Pub/Sub (via rmurphey)
View pubsub-demo.js
// Note that this uses my Pub/Sub implementation, which is slightly different than
// phiggins' in that jQuery custom events are used, and as such the first event handler
// argument passed is the event object.
// jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery
// The "traditional" way.
cowboy / synth.cpp
Created Sep 14, 2017 — forked from genericpenguin/synth.cpp
Arduino Synth
View synth.cpp
/* Arduino Synth from
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#ifndef sbi
cowboy / 0_reuse_code.js
Created Nov 30, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
cowboy / very-small-ie-detect.js
Created Aug 21, 2010 — forked from padolsey/gist:527683
Very small IE detect (aka type coersion ftw)
View very-small-ie-detect.js
// ----------------------------------------------------------
// 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 6) then:
// ie === 0
// If you're in IE (>=6) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
cowboy / gist:3086861
Created Jul 10, 2012 — forked from rmurphey/gist:3086328
What's wrong with Netmag's "Optimize your JavaScript" post
View gist:3086861

What's wrong with Netmag's "Optimize your JavaScript" post

I tweeted earlier that this should be retracted. Generally, these performance-related articles are essentially little more than linkbait -- there are perhaps an infinite number of things you should do to improve a page's performance before worrying about the purported perf hit of multiplication vs. division -- but this post went further than most in this genre: it offered patently inaccurate and misleading advice.

Here are a few examples, assembled by some people who actually know what they're talking about (largely Rick Waldron and Ben Alman, with some help from myself and several others from the place that shall be unnamed).

Things that are just plain wrong

  • Calling array.push() five times in a row will never be a "performance improvement." The author has clearly co
mobile: function() {
return"only all and (max-width: 480px)");
View shebangs
#!/ricky martin
View grunt-task-definition-options.js
// inside a gruntfile
grunt.registerTask('awesome', {
description: 'The most awesome task ever.',
type: 'multi',
main: function(grunt, arg) {
var files = grunt.file.expandFiles(grunt.util._.pluck(this.files, 'src'));
var success = this.task.listFiles(grunt, files);
grunt.log.writeln('Stuff happened...');
if (success) { grunt.log.ok(); } else { grunt.log.error(); }
cowboy /
Created May 23, 2012 — forked from rmurphey/
Self-Assessment for Bocoup's "Foundations of Programming with JavaScript" Training

Self-Assessment for Bocoup's "Foundations of Programming with JavaScript" training

This gist is aimed at helping you assess whether you'll be a good fit for Bocoup's "Foundations of Programming with JavaScript" training. This class is aimed at introducing you to fundamental concepts of development using JavaScript. In this class, you'll work through the process of building a simple game of hangman; along the way, you'll learn about functions, arrays, objects, and prototypes, and get a brief introduction to the jQuery library. You'll also learn about approaches that will help you write more maintainable code, and get introduced to tools for debugging and testing your JavaScript.

You can’t perform that action at this time.