Skip to content

Instantly share code, notes, and snippets.

View thoughtpolice's full-sized avatar
👊
omae wa mou shindeiru

Austin Seipp thoughtpolice

👊
omae wa mou shindeiru
View GitHub Profile
@thoughtpolice
thoughtpolice / foundationdb-beta1-getting-started.template
Created February 7, 2019 03:14
Ancient CloudFormation FoundationDB template, discovered by completing an ancient trial
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "FoundationDB CloudFormation Test. **WARNING** This template creates one or more Amazon EC2 instances. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"InstanceType" : {
"Description" : "EC2 instance type",
"Type" : "String",
"Default" : "m1.large",
@thoughtpolice
thoughtpolice / decoder.sail
Created February 6, 2019 20:34
RV32IM Sail Decoder
/* -------------------------------------------------------------------------- */
/* -- LUI encoding ---------------------------------------------------------- */
union clause ast = LUI : Utype
mapping clause encdec_base = LUI(imm, rd) <-> imm @ rd @ 0b0110111
function clause print_insn LUI(imm, rd) = "lui " ^ rd ^ ", " ^ bits_str(imm)
/* -------------------------------------------------------------------------- */
/* -- AUIPC encoding -------------------------------------------------------- */
@thoughtpolice
thoughtpolice / default.nix
Created January 15, 2019 22:38
nix-shell file for picorv32 development.
# nix.shell: PicoRV32 Development Environment
#
# This file allows you to use the Nix Package Manager (https://nixos.org/nix)
# in order to download, install, and prepare a working environment for doing
# PicoRV32/PicoSoC development on _any_ existing Linux distribution, provided
# the Nix package manager is installed.
#
# Current included tools:
#
# - Synthesis: Recent Yosys and SymbiYosys
@thoughtpolice
thoughtpolice / llvm-static-musl.nix
Created January 11, 2019 00:34
Static C++17 binaries with Clang, Musl, and libc++, using Nix
{ useMusl ? false
}:
let
nixpkgs = import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/004cb5a694e39bd91b27b0adddc127daf2cb76cb.tar.gz";
sha256 = "0v5pfrisz0xspd3h54vx005fijmhrxwh0la7zmdk97hqm01x3mz4";
}) {};
pkgs = if useMusl then nixpkgs.pkgsMusl else nixpkgs;
@thoughtpolice
thoughtpolice / keybase.md
Created September 6, 2018 22:10
Keybase verification

Keybase proof

I hereby claim:

  • I am thoughtpolice on github.
  • I am aseipp (https://keybase.io/aseipp) on keybase.
  • I have a public key ASDlfufSsLCTJwDnY7DS0FG0jNbxCw0gtfJ73wSFVHp-gAo

To claim this, I am signing this object:

with import <nixpkgs> {};
let
source = lib.writeFile "something.cc" ''
#include <stdio.h>
int main(void) { printf("%d\n", 42); return 0; }
'';
in
stdenv.mkDerivation {
@thoughtpolice
thoughtpolice / example.nix
Created April 2, 2018 20:36
postgresql plugins
let
mkPlug = p: p.override { postgresql = config.services.postgresql.package; };
in {
enable = true;
package = pgsql;
dataDir = "/data/pgsql";
extraConfig = "shared_preload_libraries = 'timescaledb'";
extraPlugins = with pkgs; map mkPlug
[ postgis
a@link> nix run -f '<nixpkgs>' hello ~
[1 copied (0.2 MiB), 0.0 MiB DL]
[a@link:~]$ which hello
which: no hello in (/home/a/bin:/run/wrappers/bin:/etc/profiles/per-user/a/bin:/home/a/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin)
[a@link:~]$ exit
[1] a@link> nix run -f '<nixpkgs>' hello -c hello ~
Hello, world!
a@link>
f = mux cond1 r1
$ mux cond2 r2
$ mux cond3 r3
...
$ mux condN rN
$ default
where
cond1 = ...
cond2 = ...
cond3 = ...
@thoughtpolice
thoughtpolice / q.hs
Last active December 20, 2017 00:13
quotientBy
{-# OPTIONS_GHC -Wall #-}
import Data.List (groupBy, sortBy)
-- | Construct the set of equivalence classes for a given list of items, given
-- an equivalence relation to partition the input set by. The partition of all
-- equivalence classes among the items in a set \(X\) is also known as the
-- __quotient set__ or __quotient space__ of \(X\), defined by an equivalence
-- relation \(R\), and written \(X/R\).
--
-- Technically the quotient /could/ be defined in terms of @'Eq'@, but here we