Skip to content

Instantly share code, notes, and snippets.

View paulp's full-sized avatar
🤫

Paul Phillips paulp

🤫
  • CAZ, Inc.
  • Cascadia Autonomous Zone
View GitHub Profile
/*
* Copyright 2014–2016 SlamData Inc.
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@paulp
paulp / Dockerfile
Created March 8, 2018 23:03
urbit dockerfile
FROM alpine:latest
ENV TERM="vt100" \
APK="apk add --no-cache" \
EDGEREPO="http://dl-3.alpinelinux.org/alpine/edge/testing"
WORKDIR /root
RUN $APK bash curl-dev gmp-dev libuv-dev ncurses-dev openssl-dev \
&& $APK --virtual .build-deps apk-tools file git g++ meson re2c \
&& $APK --repository $EDGEREPO libsigsegv-dev \
@paulp
paulp / macports-bin.sh
Created March 8, 2018 20:55
Mine macports sqlite database for package of origin for each program in /opt/local/bin.
#!/usr/bin/env bash
#
DB="/opt/local/var/macports/registry/registry.db"
QUERY="select ports.name,files.path
from files
inner join ports
on files.id=ports.id AND files.path GLOB '/opt/local/bin/*'"
sqlite3 -list -separator ' ' "$DB" "$QUERY" \
object Test {
type List[A] = Option[Cons[A]]
final case class Cons[A](hd: A, tl: Option[Cons[A]]) {
def nth(n: Int): A = if (n == 1) hd else tl.get nth n - 1
}
def list[A](xs: A*): List[A] = if (xs.isEmpty) None else Some(Cons(xs.head, list(xs.tail: _*)))
def single[A](hd: A): Cons[A] = Cons(hd, None)
// (nth (rest (cons 1 nil)) 1)
@paulp
paulp / gsdv.sh
Created January 24, 2018 02:28
Use google's verbatim search and date range restriction simultaneously
#!/usr/bin/env bash
#
# Use google's date range and "verbatim" simultaneously
# Paul Phillips <psp@brb.fyi>
#
NAME="$(basename "$0")"
read -r -d '' USAGE << EOM
usage: $NAME [-s days] [-e days] [search terms]
@paulp
paulp / died.txt
Created September 20, 2017 03:08
Skull fracture.
Trench engulfment.
Worker electrocuted.
Worker fatally shot.
Worker was murdered.
Worker died in falll.
Possible heart attack.
Worker died in a fall.
Worker fell from lift.
Worker killed in fall.
@paulp
paulp / a.scala
Created September 19, 2017 15:23
property("longs are evenly-distributed") =
forAll { (seed: Seed, b: Base) =>
val base = b.value
def countZeros(s0: Seed, i: Int, seen0: Int): Int =
if (i <= 0) seen0 else {
val (x, s1) = s0.long
val n = (x & 0x7fffffff).toInt % base
val seen = if (n == 0) seen0 + 1 else seen0
countZeros(s1, i - 1, seen)
@paulp
paulp / a.scala
Created September 19, 2017 15:06
describe("addition") {
it("is communicative") {
forAll { (x: Int, y: Int) =>
(x + y) should equal (y + x)
}
}
}
describe("addition") {
it("is communicative") {
forAll { (x: Int, y: Int) =>
(x + y) should equal (y + x)
}
}
}
#!/usr/bin/env bash
#
set -euo pipefail
# set -x
export PROJECT SCOPE
# This setup echos the times to stderr as they accrue, then
# prints the whole list sorted by time to stdout when complete.