Skip to content

Instantly share code, notes, and snippets.


Ben Alman cowboy

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 / 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
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 / 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
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.

cowboy /
Created Apr 25, 2012 — forked from mikesherov/
getting grunt to work on windows with cygwin and git

Getting grunt to work with Cygwin and git on Windows is a bit difficult considering the cygwin package that is installed by git has an outdated version of node running on it. There are several issues to work through:

  1. Cygwin by default installs an old version of node.
  2. Open Cygwin shell
  3. which node tells you where the executable is
  4. node --version tells you if it's old
  5. cd to the directory listed by which node
  6. mv node.exe node.exe.bak
  7. download node from and install it
  8. Node installed through installer doesn't update PATH to point to correct version of node installed normally.