Skip to content

Instantly share code, notes, and snippets.

👊
omae wa mou shindeiru

Austin Seipp thoughtpolice

👊
omae wa mou shindeiru
Block or report user

Report or block thoughtpolice

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thoughtpolice
thoughtpolice / CoYoneda.hs
Last active Dec 27, 2019
CoYoneda = Yoneda
View CoYoneda.hs
{-# LANGUAGE ExistentialQuantification, RankNTypes #-}
{-# LANGUAGE InstanceSigs #-}
module CoYoneda where
import Data.IORef
import Data.Set (Set, map)
import Control.Monad (liftM)
--------------------------------------------------------------------------------
-- Yoneda
@thoughtpolice
thoughtpolice / symbiflow.nix
Created Sep 26, 2019
SymbiFlow for Nixpkgs
View symbiflow.nix
with import <nixpkgs> {};
let
nextpnr-gui = pkgs.nextpnr; # gui by default on upstream
nextpnr-nogui = pkgs.nextpnr.override { enableGui = false; };
common-pkgs = with pkgs; [
symbiyosys yosys verilog verilator
icestorm trellis
z3 yices boolector
@thoughtpolice
thoughtpolice / snake-nginx.nix
Created Aug 21, 2015
A complete example of a working Hydra build machine and other stuff.
View snake-nginx.nix
let
# Wrap a nginx server block in an HTTPS site
wrapSSL = site: cert: key: block: ''
server {
listen 80;
listen [::]:80;
server_name ${site};
location /nginx_status {
stub_status on;
@thoughtpolice
thoughtpolice / fastly-cache-debug.sh
Created Aug 1, 2019
Grab Fastly debugging info from cache.nixos.org
View fastly-cache-debug.sh
#!/usr/bin/env bash
[ -z "$1" ] && echo "ERROR: must provide arg" && exit 1
CACHE_URL=${CACHE_URL:-"https://cache.nixos.org"}
curl -v \
-HFastly-Debug:1 \
-o /dev/null 2>&1 \
"$CACHE_URL/$1" \
@thoughtpolice
thoughtpolice / Assert.hs
Last active Jul 8, 2019
Formal verification of a Clash circuit, using Yosys/SymbiYosys.
View Assert.hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE TypeFamilies #-}
module Assert
( assertProperty
, initialAssume
, getReset
) where
import Clash.Prelude
View chacha20.c
#include "chacha20.h"
static unsigned int
L32(unsigned int x,unsigned int n)
{
/* See: http://blog.regehr.org/archives/1063 */
return (x<<n) | (x>>(-n&31));
}
static unsigned int
@thoughtpolice
thoughtpolice / fast-tls.c
Created Jun 25, 2013
Über fast thread-local storage on OS X
View fast-tls.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
/** Snipped from pthread_machdep.h */
#define __PTK_FRAMEWORK_JAVASCRIPTCORE_KEY4 94
extern __inline__ void *
_pthread_getspecific_direct(unsigned long slot) {
@thoughtpolice
thoughtpolice / llvm-static-musl.nix
Created Jan 11, 2019
Static C++17 binaries with Clang, Musl, and libc++, using Nix
View llvm-static-musl.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 / RegAlloc1.hs
Last active Apr 18, 2019
Simple register allocation, see "Essentials of Compilation" for more https://jeapostrophe.github.io/courses/2017/spring/406/notes/book.pdf
View RegAlloc1.hs
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PartialTypeSignatures #-}
module RegAlloc1
( -- * Types
Var
@thoughtpolice
thoughtpolice / foundationdb-beta1-getting-started.template
Created Feb 7, 2019
Ancient CloudFormation FoundationDB template, discovered by completing an ancient trial
View foundationdb-beta1-getting-started.template
{
"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",
You can’t perform that action at this time.