Skip to content

Instantly share code, notes, and snippets.

@athanclark
athanclark / .travis.yml
Last active April 19, 2020 17:40
Travis-CI config for PureScript v0.13.6 - Bower, Pulp, Spago, Psc-Package, Purp
node_js:
- "node"
language: node_js
install:
- npm install -g purescript pulp bower spago psc-package purp-bin-simple
- bower install
- spago install
- psc-package install
script:
- pulp test
@athanclark
athanclark / Main.hs
Created March 11, 2018 18:03
Adopting an orphan Haskell Async thread
{-# LANGUAGE
ScopedTypeVariables
#-}
module Main where
import Control.Monad (forever)
import Control.Concurrent (threadDelay)
import Control.Concurrent.STM (TMVar, atomically, newEmptyTMVarIO, takeTMVar, putTMVar)
import Control.Concurrent.Async (Async, async, link, cancel, wait)
@athanclark
athanclark / build.sh
Created April 24, 2017 16:15
Make a Software Foundations PDF suitable for printing
#! /bin/bash
# make sure you have wkhtmltopdf installed, and you're in the `sf` directory
ls | grep "\.html" | sed "s/\.html//" | while read -r; do echo "Building ${REPLY}.html to ${REPLY}.pdf"; wkhtmltopdf "${REPLY}.html" "${REPLY}.pdf"; done
# this uses a rough linear translation of the `deps` page. Command found from http://stackoverflow.com/questions/2507766/merge-convert-multiple-pdf-files-into-one-pdf
pdfunite index.pdf deps.pdf Preface.pdf Basics.pdf Induction.pdf Lists.pdf Poly.pdf Tactics.pdf Logic.pdf IndProp.pdf ProofObjects.pdf IndPrinciples.pdf Rel.pdf Maps.pdf Imp.pdf ImpParser.pdf Extraction.pdf ImpCEvalFun.pdf PE.pdf Equiv.pdf Hoare.pdf HoareAsLogic.pdf Hoare2.pdf Smallstep.pdf Auto.pdf Types.pdf Stlc.pdf UseTactics.pdf UseAuto.pdf StlcProp.pdf MoreStlc.pdf Norm.pdf Typechecking.pdf References.pdf Sub.pdf Records.pdf RecordSub.pdf Postscript.pdf out.pdf
<!DOCTYPE HTML>
<html><head><meta charset="UTF-8"><title>Main</title><style>html,head,body { padding:0; margin:0; }
body { font-family: calibri, helvetica, arial, sans-serif; }</style><script type="text/javascript">
(function() {
'use strict';
function F2(fun)
{
function wrapper(a) { return function(b) { return fun(a,b); }; }
wrapper.arity = 2;

I woke up on May 28th, 2014, on vacation with my family in the middle of the desert, to find a copy of my private source code plastered across the bitcointalk message board. Announced as a "new optimized version" of the Monero currency miner, it was enthusiastically adopted by cryptocurrency miners across the world. And in the process of doing so, my daily profit from the Monero Mining Project dropped by over five thousand dollars per day.

But let's start at the beginning, when I started getting in to a loose collaboration with three people I've never met---one whose name I'm not even confident I really know---with hundreds of thousands of dollars worth of a nebulous new cryptocurrency at stake.

It started with a cryptic note from someone I'd met online, with a link to a bitcointalk.org message board discussion for a new currency called "bitmonero". His note said only:

"this looks interesting."

From prior collaborations with him, I knew he had a good nose for opportunities in cryptocurrencies. Within

dependencies:
cache_directories:
- "~/.stack"
pre:
- wget https://github.com/commercialhaskell/stack/releases/download/v1.2.0/stack-1.2.0-linux-x86_64.tar.gz -O /tmp/stack.tar.gz
- mkdir /tmp/stack/
- tar -xvzf /tmp/stack.tar.gz -C /tmp/stack/
- sudo mv /tmp/stack/stack-1.2.0-linux-x86_64/stack /usr/bin/stack
override:
- stack build --no-system-ghc --install-ghc
git clone ... /opt/letsencrypt
cd /opt/letsencrypt
sudo apt-get install apache2
sudo ufw disable
./letsencrypt-auto --apache -d myDomain.com -d www.myDomain.com
Failed authorization procedure. guiding-hand.online (tls-sni-01): urn:acme:error:connection ::
@athanclark
athanclark / Foo.elm
Created May 3, 2016 21:00
Case matching thrashing
module Foo where
import Date exposing (Month (..))
compareMonth : Month -> Month -> Order
compareMonth m1 m2 =
case (m1, m2) of
(Jan, Jan) -> EQ
(Jan, _) -> LT
(Feb, Jan) -> GT
@athanclark
athanclark / students.js
Created May 16, 2015 22:21
Syntax error on line 12...?
'use strict';
angular.module('myApp.students', [])
.controller('StudentsCtrl', [function() {
var students = {};
var idCount = 0;
// create :: {name, grade} -> id
this.create = function(student) {
@athanclark
athanclark / needless-duplication.js
Created May 16, 2015 21:57
How can I reduce this duplication?
// lookupKey :: id -> [{id, name, grade}] -> Maybe {id, name, grade}
function lookupKey(id, map) {
var index = 0;
while (index < map.length()) {
if (map[index].id === id) {
return map[index];
} else {
index++;
}
}