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: | |
# | |
# +-------+----+ |
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 |
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`. |
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} |
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]; |
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", |
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'); |
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 | |
} |
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: |
View backup-github.sh
#!/bin/bash | |
# A simple script to backup an organization's GitHub repositories. | |
# NOTE: if you have more than 100 repositories, you'll need to step thru the list of repos | |
# returned by GitHub one page at a time, as described at https://gist.github.com/darktim/5582423 | |
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files | |
GHBU_ORG=${GHBU_ORG-"<CHANGE-ME>"} # the GitHub organization whose repos will be backed up | |
# (if you're backing up a user's repos instead, this should be your GitHub username); also see the note below about the `REPOLIST` definition around line 48 | |
GHBU_UNAME=${GHBU_UNAME-"<CHANGE-ME>"} # the username of a GitHub account (to use with the GitHub API) |
NewerOlder