Skip to content

Instantly share code, notes, and snippets.

Jonathan Halterman jhalterman

Block or report user

Report or block jhalterman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jhalterman / CancellableFuture.scala
Last active Jan 29, 2020
A cancellable Scala Future
View CancellableFuture.scala
package net.jodah.cancellablefuture
import java.util.concurrent.atomic.AtomicBoolean
import scala.concurrent._
import scala.concurrent.duration.Duration
import scala.util.{Failure, Success, Try}
object CancellableFuture {
def apply[T](body: => T)(implicit executor: ExecutionContext): CancellableFuture[T] = new CancellableFuture(body)

Keybase proof

I hereby claim:

  • I am jhalterman on github.
  • I am jhalterman ( on keybase.
  • I have a public key whose fingerprint is 43F6 97A7 C494 AD19 CFCA 48F4 489D 4D97 977C 14CE

To claim this, I am signing this object:

View minscalaactors.scala
Copyright 2012 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
jhalterman /
Last active May 27, 2017
Experiments in thread aware exceptions
import java.util.Arrays;
public class ThreadAwareExceptionTest {
static class ThreadAwareThread extends Thread {
Throwable entryPoint;
ThreadAwareThread(Runnable runnable) {
jhalterman /
Last active Aug 11, 2016
The tiniest key / value store (from Designing Data-Intensive Applications:
db_set () {
echo "$1,$2" >> database
db_get () {
grep "^$1," database | sed -e "s/^$1,//" | tail -n 1
jhalterman /
Last active Jan 6, 2019
An exponentially weighted moving average implementation that decays based on the elapsed time since the last update, approximating a time windowed moving average.
* An exponentially weighted moving average implementation that decays based on the elapsed time since the last update,
* approximating a time windowed moving average.
public class MovingAverage {
private final long windowNanos;
// Mutable state
private volatile long lastNanos;
private volatile double average;
jhalterman /
Created Mar 4, 2016
Disable syntax highlighting in Github pages

Add the following to your _config.yml:

    disable : true
jhalterman / gist:44d488ee7f7248ab728b
Last active Dec 8, 2015
How to replace the non-replaceable white base bulbs on a pre-lit GE Christmas tree
View gist:44d488ee7f7248ab728b
Pre-lit GE Christmas tree strands have a common failure - the white base bulbs may burn out, and unfortunately they are not intended to be replaced. Here's how to replace them.
* Cut a ring around the rim of the green plastic socket that the white bulb plugs into, just below the glass part of the bulb. I used a small hacksaw for this - it takes about 2 minutes. Once you've cut a ring, you should be able to pull the white bulb/insert out.
* Pull the glass part of the bulb out of the white base. It might help to fold down/straight the two copper wires first.
* Remove a glass insert from a replacement bulb and insert it into your white bulb base, then bend the two copper wires back into place.
* Re-insert the white bulb base and you're good to go.
* Ostensibly, these bulbs are supposedly to limit the load on the strand, but a quick voltage test shows they don't really do anything special.
View try-until-success.clj
(defn try-until-success
"Accepts a try-fn to try a failure-fn to call upon failure, supplying the failure/exception. The try-fn is retried
until no failure is thrown."
[try-fn failure-fn]
(loop []
(if-let [result (try
(catch Exception e
(failure-fn e)
View jepsen-foundationdb-cas-test.clj
(deftest create-cas-test
(let [test (run!
:name "foundationdb"
:os ubuntu/os
:db db
:client (cas-register)
:model (model/cas-register)
:checker (checker/compose {:html timeline/html
You can’t perform that action at this time.