Skip to content

Instantly share code, notes, and snippets.

@tofti
tofti / NotifyNotifyAll.java
Last active February 5, 2019 15:49
Creating deadlocks when using notify, rather than notifyAll.
package tofti.java.popularquestions;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.atomic.AtomicLong;
public class NotifyNotifyAll {
static class Buffer<T> {
static final int MAX_CAPACITY = 1;
@tofti
tofti / covid.py
Last active April 7, 2020 17:01
covid data plots
import requests
import matplotlib.pyplot as plt
import time
def main():
response = requests.get('https://covidtracking.com/api/states/daily')
data = response.json()
fig, subplots = plt.subplots(2, 2)
figure_row = 0
@tofti
tofti / Dockerfile
Created September 19, 2020 02:31
bitcoin node build environment
FROM ubuntu:latest
MAINTAINER Iain Toft
LABEL version="1.0" location="US" type="ubuntu-with-bitcoind"
ENV TZ=America/New_York
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone ; \
apt-get -y update; \
apt-get -y install sudo; \
apt-get -y install vim; \
apt-get -y install openssh-server; \
apt-get -y install tmux; \
@tofti
tofti / dictionary_to_bip39.py
Last active October 9, 2020 01:06
python full dictionary to bip39 word list
from urllib.request import urlopen
from hashlib import sha256
from os.path import expanduser
def main():
seed_words_url = 'https://raw.githubusercontent.com/bitcoin/bips/master/bip-0039/english.txt'
seed_words_file = urlopen(seed_words_url)
seed_words = seed_words_file.read().decode("utf8").split("\n")
seed_words_count = len(seed_words)