Skip to content

Instantly share code, notes, and snippets.


Charles Anderson cander

  • Monmouth, Oregon
View GitHub Profile
cander /
Created May 25, 2012
Bourne Basic - a BASIC interpreter implemented (painfully) in pure Bourne shell
# From: allbery@ncoast.UUCP (allbery@ncoast.UUCP)
# Subject: bournebasic
# Newsgroups: comp.sources.misc
# Date: 1987-08-18 18:54:12 PST
# Here's a useful BASIC interpreter written in Bourne shell.
# There's no manual but this demo shows the most salient features:
cander / gist:5267753
Last active Feb 12, 2016
How to write to the Google Plus moments.insert API endpoint from Ruby.
View gist:5267753
# This Sinatra endpoint is something I added to the Google Ruby quick-start
# web app -
# It demonstrates how to write to the moments.insert API, for which I
# couldn't find any Ruby examples.
post '/write_activity' do
# Check for stored credentials in the current user's session.
if !session[:token]
halt 401, 'User not connected.'
cander / gist:e22a84605d8c4a501a67
Created Oct 11, 2014
Vagrant file for Modern IE boxes
View gist:e22a84605d8c4a501a67
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrant file for Modern IE ( boxes
# This file is for Windown 7 running IE9, but there are other possibilities.
# NB: Vagrant wants to ssh into the VM, but these VMs don't have ssh. So,
# you'll get a timeout error message, which is safe to ignore.
# To use a different box, replace the config.vm.box_url with the URL and
# update the to some name you want to refer to it as.

Git Cheat Sheet

This isn't intended as an exhaustive reference for git. Rather, it's a collection of operations that I perform so rarely that I always have to look up how to do them.

Fetch Just One Remote Branch

(because I have a weak-ass Internet connection at home)

git fetch --no-tags <remote> <remote-branch-name>:<local-branch-name>

Abandon a Merge

git reset --hard HEAD

cander /
Last active Apr 12, 2016
Some information missing from the ElasticSearch Java client documentation - e.g., what imports are needed and a pointer to some JavaDocs.

Docker Cheat Sheet

All of these assume you're running as root. If not, preface them with sudo as needed.

List of Dangling Images

docker images --filter 'dangling=true' 

To remove them:

docker images -q --filter 'dangling=true' | xargs docker rmi
cander /
Last active May 23, 2018
A simple test program to fetch HTTPS URLs that have been problematic with older versions of Java
public class httpstest {
public static void fetchUrl(String urlStr, String msg)
try {
System.out.println("Opening " + urlStr);
URL url=new URL(urlStr);
cander /
Last active Mar 27, 2019
A personal cheat sheet for vim

Vim Cheat Sheet

FYI - this is not a general-purpose cheat sheet for vim. I've been using vim/vim for over 35 years.
So, this is more of list of random things in core-vim or various plugin-ins that I've recently started using or am strugging to remember when I need them.


Use exerberant ctags for best results. (It's not the default ctags program on MacOS.)

g-]          Search for the tag under the cursor and select between multiple possible matches.
cander /
Last active Mar 1, 2019
Slowly remove file files in a directory
# Slowly remove files from a directory
# Usage: [-dry-run] dir
# Removes files older than MIN_AGE_DAYS one at a time syncing and
# sleeping after every BATCH_SIZE files.
# A BATCH_SIZE of 300 will take at least 56 minutes to remove 1M files
cander / make-dir-hierarchy.rb
Last active Mar 6, 2019
Create a hierarchy of files and directories based on the output of find
View make-dir-hierarchy.rb
#!/bin/env ruby
# Given output from find(1) listing files and directories, reproduce that
# hierarchy with random data in the files.
# Usage: ruby make-dir-hierarchy.rb [find-output-file]
require 'securerandom'