Skip to content

Instantly share code, notes, and snippets.

Rod Waldhoff rodw

  • Alexandria, Virginia
View GitHub Profile
@rodw
rodw / pentagonal-graph-for-reinh.gv
Created Mar 8, 2014
Graphviz DOT file that generates the image @reinh is looking for in the tweet at https://twitter.com/ReinH/status/440955529494413313 Renders as http://ow.ly/i/4PO8v
View pentagonal-graph-for-reinh.gv
//
// Run this graph definition through the dot rendering engine.
//
// E.g.:
// dot -Tpng pentagonal-graph-for-reinh.gv -o image.png
// or
// dot -Txlib pentagonal-graph-for-reinh.gv
//
// Also note that if you don't care about the exact orientation,
// the "out of the box" rendering with the circo engine is pretty
@rodw
rodw / example.js
Created Feb 8, 2013
Demonstrates a minor issue with node-html-encoder's `htmlEncode` and `htmlDecode` functions.
View example.js
var Encoder = require('./lib/encoder.js').Encoder;
var encoder = new Encoder('entity');
console.log('');
console.log('Generally, when no characters need to be encoded,');
console.log('htmlEncode() returns input string.');
console.log('');
console.log('For example,');
console.log(' encoder.htmlEncode("Foo")');
console.log('yields');
@rodw
rodw / figure2.gv
Created Jan 3, 2014
somewhat brute force solution to the question raised in this tweet: https://twitter.com/silentbicycle/status/418760644066676736 output from `dot -Tpng figure2.gv` at http://ow.ly/i/4bZ8B
View figure2.gv
digraph fig2 {
splines=line # makes edges straight rather than curved
ranksep=0.2 # controls distance between rows
# create a record-type node representing the row of numbers
# (the `<x>` bit declares a port we can point edges to)
n [shape=record label="{<a>58}|{<b>82}|{<c>16}|{<d>85}|{<e>65}|{<f>5}|{<g>67}|{<h>26}"]
# create some dummy rows, each with one false node per element in n
node [shape=point height=0 style=invis];
@rodw
rodw / bootstrap-layout.html.dust
Created Jan 6, 2014
Example of a Dust.js layout using the bootstrap library, in response to https://twitter.com/ppnsanders/status/419888456014118914
View bootstrap-layout.html.dust
<!DOCTYPE html>
<html lang="en">
{+html_head}
<head>
<meta charset="utf-8">
{+html_head_title}<title>{+page_title}PAGE TITLE{/page_title}</title>{/html_head_title}
@rodw
rodw / .gitignore
Created Jun 27, 2012
A General Purpose .gitignore file
View .gitignore
######################################################################
# derived from https://gist.github.com/3006349
######################################################################
# also see https://github.com/github/gitignore
######################################################################
## STUFF TO CUSTOMIZE - you probably don't want all of these.
######################################################################
@rodw
rodw / gollum-wiki-tag-indexer.rb
Created Jul 10, 2012
wiki-tag-indexer - Processes a directory of Gollum wiki files updating special "tag" pages with a list of pages that contain that tag.
View gollum-wiki-tag-indexer.rb
#!/usr/bin/env ruby
# wiki-tag-indexer - Processes a directory of Gollum wiki files updating
# special "tag" pages with a list of pages that contain that tag.
#===============================================================================
# QUICK-START INSTRUCTIONS
# ------------------------
#
# 0. If you haven't already, clone the git repository containing your wiki.
# E.g., if you're on GitHub, use something like:
@rodw
rodw / directory-reader.coffee
Created Oct 10, 2013
Here's a little CoffeeScript routine that will recursively read the file-system, generating an object that represents a complete directory tree. This gist should be executable. You can run it with: `coffee directory-reader.coffee [FILENAME]` to dump a JSON representation of the object to stdout.
View directory-reader.coffee
# Here's a little CoffeeScript routine that will recursively
# read the file-system, generating an object that represents
# a directory tree.
# The returned object will contain the following attributes:
#
# * `file` - the basename of the file.
# * `dir` - the directory containing the file.
# * `types` - an array containing zero or more of
# "File", "Directory", "SymbolicLink", "BlockDevice",
@rodw
rodw / pid-file-daemon.sh
Created Aug 14, 2012
Bash script that uses a PID file to add daemon-like start/stop/status behavior to an arbitrary program.
View pid-file-daemon.sh
#!/bin/bash
# Uses a PID file to add daemon-like behavior to an arbitrary program.
################################################################################
usage() {
echo "Usage: `basename $0` PROGRAM {start|stop|restart|force-stop|force-restart|status} [PIDFILE|PID]" >&2
echo "Where: PROGRAM is an executable file." >&2
echo " PIDFILE is the file that contains (or will contain) the PID." >&2
echo " PID is a process id to use in place of a PIDFILE." >&2
}
@rodw
rodw / coffee-as-a-service-via-forever.sh
Created Feb 12, 2014
This is an example of a (bash) shell script that uses the forever module to start and stop a CoffeeScript application as if it were a service.
View coffee-as-a-service-via-forever.sh
#!/bin/bash
# This is an example of a (bash) shell script that uses the forever module ([1])
# to start and stop a CoffeeScript application as if it were a service.
#
# [1] <https://github.com/nodejitsu/forever>
# ASSUMPTIONS
################################################################################
# 1) You've got a CoffeeScript program you want to run via `forever`.
@rodw
rodw / draw-histogram.sh
Created Feb 26, 2018
bash script that generates an ASCII-art histogram (bar chart) from input data.
View draw-histogram.sh
#!/bin/bash
#-------------------------------------------------------------------------------
# draw-histogram - generates an ASCII-art histogram (bar chart) from input data.
#-------------------------------------------------------------------------------
# Expects a series of lines of the form `<category-name> <count>` to passed
# via stdin.
#
# Generates a table the looks something like the following:
#
# +-------+----+
You can’t perform that action at this time.