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
sim.exe: top.v sim.cpp
verilator --cc --coverage --exe -Wno-lint -trace --top-module top \
--Mdir bench_dir $^
$(MAKE) -C bench_dir -f Vtop.mk
cp bench_dir/Vtop $@
clean:
rm -f bench_dir sim.exe
.PHONY: clean
@thoughtpolice
thoughtpolice / lguest-docs.c
Last active January 23, 2021 22:37
lguest documentation
// Extracted from Linux 4.0 by running `cd drivers/lguest && make Beer`.
// Pasted with syntax highlighting to make life easier.
{==- Preparation -==}
[ arch/x86/lguest/boot.c ]
/*
* A hypervisor allows multiple Operating Systems to run on a single machine.
* To quote David Wheeler: "Any problem in computer science can be solved with
* another layer of indirection."
*
@thoughtpolice
thoughtpolice / phabricator.nix
Created July 15, 2015 16:26
Extensive Phabricator module for NixOS (with Nginx frontend support)
/*
Example usage (in configuration.nix):
services.phabricator.enable = true;
services.phabricator.baseURI = "secure.example.org";
services.phabricator.baseFilesURI = "secure-files.example.org";
services.phabricator.extensions =
{ libphutil-scrypt = "git://github.com/haskell-infra/libphutil-scrypt.git";
libphutil-yubikey = "git://github.com/thoughtpolice/libphutil-yubikey.git";
@thoughtpolice
thoughtpolice / CoYoneda.hs
Last active December 27, 2019 01:52
CoYoneda = Yoneda
{-# 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 September 26, 2019 00:30
SymbiFlow for Nixpkgs
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 August 21, 2015 19:03
A complete example of a working Hydra build machine and other stuff.
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 August 1, 2019 12:56
Grab Fastly debugging info from cache.nixos.org
#!/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" \
#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 June 25, 2013 06:12
Über fast thread-local storage on OS X
#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 / 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",