Skip to content

Instantly share code, notes, and snippets.

Avatar
🤫

Paul Phillips paulp

🤫
  • CAZ, Inc.
  • Cascadia Autonomous Zone
View GitHub Profile
@paulp
paulp / integer-division.z3
Created Jul 4, 2021 — forked from Rufflewind/integer-division.z3
Truncated integer division in Z3
View integer-division.z3
(declare-fun a () Int)
(declare-fun b () Int)
(declare-fun c () Int)
;; (assert (= a (div -7 -3)))
;; (assert (= b (div 7 -3)))
;; (assert (= c (div -7 3)))
;; (assert (= a (mod -7 -3)))
;; (assert (= b (mod 7 -3)))
;; (assert (= c (mod -7 3)))
@paulp
paulp / coronasuggestions.txt
Created Mar 20, 2020
google's suggestions in the USA and the UK, sent through comm.
View coronasuggestions.txt
a levels
advice
advice uk
africa
airborne
alabama
alaska
america
and asthma
and children
View app.hs
instance Monad f => Applicative (OptionalT f) where
pure = OptionalT . pure . Full
mf <*> ma = OptionalT $ do
optf <- runOptionalT mf
case optf of
Empty -> return Empty
Full f -> do
opta <- runOptionalT ma
return $ f <$> opta
View monad.hs
instance Monad f => Monad (OptionalT f) where
f =<< x = OptionalT $ runOptionalT x >>= \case
Empty -> return Empty
Full a -> runOptionalT $ f a
View gist:244846ffa026ac7bfed3bf57ea0398db
instance Monad f => Monad (OptionalT f) where
f =<< x = OptionalT $ runOptionalT x >>= \case
Empty -> return Empty
Full a -> runOptionalT $ f a
@paulp
paulp / chrome-dns
Created Aug 15, 2018
Visibility into chrome's internal dns
View chrome-dns
#!/usr/bin/env bash
#
output () {
pup 'tbody[id="dns-view-cache-tbody"] tr json{}' \
| jq -r '.[].children[] | select(.tag == "td").text' \
| ag --nocolor --literal .
}
@paulp
paulp / lazylist.scala
Last active Aug 15, 2018
interesting LazyList evaluation semantics
View lazylist.scala
% mscala -v 2.13.0-M4
Welcome to Scala 2.13.0-M4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_181).
Type in expressions for evaluation. Or try :help.
scala> val counter = {
| var count = 0
| () => {
| val res = try "x" + count finally count = count + 1
| try res finally println(res)
| }
View types.scala
object ttypes {
type ->[+A, +B] = (A, B)
type PairOf[+A] = A -> A
type SumOf[+A] = A \/ A
trait Interpret[T[_[_]]] {
type ^[Outer[_], Inner[_]] = Outer[T[Inner]]
trait Transform[F[_], G[_]] {
type FTF = F[T[F]]
View types.scala
/*
* 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 Mar 8, 2018
urbit dockerfile
View 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 \