Skip to content

Instantly share code, notes, and snippets.

@ellotheth
ellotheth / Makefile
Last active December 21, 2015 13:49
Linux makefiles for Coursera's 'Algorithms I' class, derived from https://class.coursera.org/algs4partI-003/forum/thread?thread_id=63#post-432
# Make one of these per source directory, assumed to be a child of
# the common.mk directory.
# List the classes to be compiled here
CLASSES = HelloAlgo
# Anything you want to throw on the command line for `make run`
CMDLINE = 1024 100
MAKEFILE_DIRECTORY := $(dir $(word 1,$(MAKEFILE_LIST)))
@ellotheth
ellotheth / PercolationVisualizer.java
Last active December 21, 2015 16:09
The PercolationVisualizer class from Coursera's Algorithms I course, modified for text-only output. It uses ANSI escape codes for colors and screen clearing. Laggy demo: http://www.playterm.org/r/MjAxMy0wOC90dHlyZWNvcmQtMTM3NzU1MDgyNXw4MHgyNA==
/****************************************************************************
* Compilation: javac PercolationVisualizer.java
* Execution: java PercolationVisualizer input.txt
* Dependencies: Percolation.java StdDraw.java In.java
*
* This program takes the name of a file as a command-line argument.
* From that file, it
*
* - Reads the grid size N of the percolation system.
* - Creates an N-by-N grid of sites (intially all blocked)
@ellotheth
ellotheth / algo-i-setup.sh
Last active December 21, 2015 17:18
Setup script for Coursera's Algorithms I class. Downloads the relevant files and massages them into a /path/to/class/{bin,lib} structure.
#!/bin/bash
# Load class materials for Coursera's 'Algorithms I' course into the directory
# specified on the command line. Files will be downloaded directly from the
# class book site, maven and ellotheth's Makefile samples. Where appropriate,
# hard-coded paths (in e.g. source files and shell scripts) will be replaced
# by the user-specified path.
#
# USAGE
# $ chmod +x algo-i-setup.sh
@ellotheth
ellotheth / keybase.md
Created February 21, 2014 20:43
keybase.io identity proof

Keybase proof

I hereby claim:

  • I am ellotheth on github.
  • I am gemma (https://keybase.io/gemma) on keybase.
  • I have the public key with fingerprint 417B 9F99 B7C0 4CCE BD06  777D 0BC6 BB96 5AA6 F296

To claim this, I am signing this object:

func killProcessTree(parent int) {
// get child processes
out, _ := exec.Command("ps", "-o", "pid", "--no-heading", "--ppid", strconv.Itoa(parent)).Output()
// if the child processes have any children, get them first
for _, child := range strings.Split(string(out), "\n") {
if pid, _ := strconv.Atoi(strings.TrimSpace(child)); pid > 0 {
killProcessTree(pid)
}
@ellotheth
ellotheth / main.go
Last active August 29, 2015 14:19
Mockable interface methods in Go, maybe
type InterfaceThing interface {
MockableMethod() int
TalksToMockableMethod() bool
}
func MockableMethod() int {
// i do things that are annoying to test, like run exec.Cmd or talk to a database!
return 0
}
@ellotheth
ellotheth / stylish.css
Last active November 3, 2015 22:25
Twitter hearts are stupid
@-moz-document domain("twitter.com") {
.HeartAnimationContainer {
visibility: hidden;
}
.HeartAnimationContainer:after {
content: '🍺';
content: '🍻';
content: '🍸';
@ellotheth
ellotheth / dep init -v
Created June 2, 2017 16:30
Trying dep's Glide import
Importing configuration from glide. These are only initial constraints, and are further refined during the solve process.
Detected glide configuration files...
Loading /home/ellotheth/go/src/github.com/wondernetwork/go-wiu-backend/glide.yaml
Loading /home/ellotheth/go/src/github.com/wondernetwork/go-wiu-backend/glide.lock
Converting from glide.yaml and glide.lock...
Using ^1.1.0 as initial constraint for imported dep github.com/DataDog/datadog-go
Trying 1.1.0 (0ddda6b) as initial lock for imported dep github.com/DataDog/datadog-go
Using b79fee2 as initial hint for imported dep github.com/mikespook/gearman-go
Using 29cc868 as initial hint for imported dep gopkg.in/mgo.v2
Searching GOPATH for projects...
@ellotheth
ellotheth / proof.md
Created January 11, 2025 11:59
keyoxide identity proof

openpgp4fpr:417b9f99b7c04ccebd06777d0bc6bb965aa6f296