Skip to content

Instantly share code, notes, and snippets.

View barberboy's full-sized avatar

Ben Barber barberboy

View GitHub Profile
@barberboy
barberboy / README.md
Created October 11, 2011 20:24
Docpad: Using Stylus with Nib

stylus.plugin.coffee is a plugin for [DocPad][] which provides an alternative way to use [Stylus][] and [Nib][].

This plugin (by default) compiles a stylus source file at src/styles/styles.styl and places the resulting styles.css file in out/styles.

The source file and output directory can be customized by placing a stylus.config.coffee file in the plugins directory that exports a config object. An example stylus.config.coffee file is attached to this gist.

This plugin requires stylus and nib to be installed. These can be installed locally in your project root with npm:

$ npm install stylus

$ npm install nib

if day in ["Monday", "Tuesday", "Wednesday", "Thursday"]
do_scream()
pull_hair_out()
else
relax()
go_camping()
if day is "Saturday"
sleep_late()
else
groan()
@barberboy
barberboy / README.md
Created August 17, 2012 15:47
Ninety-Nine Bottles of Beer

Ninety Nine Bottles of Beer

This is a coding exercise proposed by the estimable [Nathan Beenken] to code the song, "Ninety-nine Bottles of Beer", with the somewhat peculiarity of outputting the numbers in their English word form (ninety nine) rather than the simpler numeric form (99).

The exercise is two parts: 1) the song, and 2) the routine to convert numbers to their English word form.

@barberboy
barberboy / README.markdown
Last active December 17, 2015 17:18
Ajax Example

Ajax Example

This is a simple example of using ajax to fetch content and add it to the page.

@barberboy
barberboy / xhr-utils.js
Created February 2, 2015 18:04
XHR Utils
/**
* getJSON( path, callback )
* -------------------------
* Asynchronously fetch and parse a JSON file.
*
* - path : A String specifying the location of the JSON file.
* - callback( data ): A Function to be executed when the JSON file is retrieved
* and parsed. The function will be passed the following
* arguments:
*
@barberboy
barberboy / format-date.js
Created June 29, 2015 22:31
Format Date (based on PHP date format)
/**
* formatDate(date, format)
* ========================
* Returns a string representation of `date`, formatted according to the given
* `format` string based on [PHP date format](http://php.net/manual/en/function.date.php).
*/
var weekdays = 'Sunday Monday Tuesday Wednesday Thursday Friday Saturday'.split(' ')
var months = 'January February March April May June July August September October November December'.split(' ')
var pad = n => (+n < 10 ? '0' : '') + n
var formats = {
@barberboy
barberboy / README.markdown
Last active September 30, 2015 19:34
vNKvvY
@barberboy
barberboy / rock-paper-scissors.js
Last active April 24, 2018 14:49
Rock Paper Scissors
#!/usr/bin/env node
/**
* Rock Paper Scissors
* ====================
* Rock, paper, scissors on the command line with JavaScript/Node.js/readline.
*
* Usage
* -----
* Place somewhere in path and make it executable
* (`chmod u+x ~/bin/rock-paper-scissors.js`).
for(i=0;++i<101;)console.log(eval(String.fromCharCode(...'286925333f27273a2746697a7a27292b286925353f27273a2742757a7a27297c7c69'.match(/../g).map(n=>parseInt(n,16)))))