Skip to content

Instantly share code, notes, and snippets.

View rodw's full-sized avatar

Rod Waldhoff rodw

View GitHub Profile
@rodw
rodw / .gitignore
Created June 27, 2012 19:49
A General Purpose .gitignore file
######################################################################
# 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 / backup-github.sh
Last active February 8, 2024 10:49
A simple script to backup an organization's GitHub repositories, wikis and issues.
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
#-------------------------------------------------------------------------------
# NOTES:
#-------------------------------------------------------------------------------
# * Under the heading "CONFIG" below you'll find a number of configuration
# parameters that must be personalized for your GitHub account and org.
# Replace the `<CHANGE-ME>` strings with the value described in the comments
# (or overwrite those values at run-time by providing environment variables).
@rodw
rodw / gollum-wiki-tag-indexer.rb
Created July 10, 2012 19:46
wiki-tag-indexer - Processes a directory of Gollum wiki files updating special "tag" pages with a list of pages that contain that tag.
#!/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 / pid-file-daemon.sh
Created August 14, 2012 01:53
Bash script that uses a PID file to add daemon-like start/stop/status behavior to an arbitrary program.
#!/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 / example.js
Created February 8, 2013 04:44
Demonstrates a minor issue with node-html-encoder's `htmlEncode` and `htmlDecode` functions.
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 / directory-reader.coffee
Created October 10, 2013 02:52
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.
# 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 / figure2.gv
Created January 3, 2014 17:23
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
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 January 6, 2014 18:38
Example of a Dust.js layout using the bootstrap library, in response to https://twitter.com/ppnsanders/status/419888456014118914
<!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 / coffee-as-a-service-via-forever.sh
Created February 12, 2014 00:26
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.
#!/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 / pentagonal-graph-for-reinh.gv
Created March 8, 2014 22:47
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
//
// 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