Skip to content

Instantly share code, notes, and snippets.

View sampsyo's full-sized avatar

Adrian Sampson sampsyo

View GitHub Profile
@sampsyo
sampsyo / problem.bril
Created December 19, 2023 21:36
unreduced test case for Bril bug #295
@main(b0: bool, b1: bool) {
jmp .start;
.end:
print x_0_2;
print x_1_2;
ret;
.l_1_3:
jmp .end;
.l_1_2:
x_1_2 : int = const 0;
@sampsyo
sampsyo / reduced.futil
Last active December 6, 2023 14:32
partially reduced test case for a Calyx pretty printer bug
import "primitives/core.futil";
component stats(flow: 0, @go go: 1, @clk clk: 1, @reset reset: 1) -> (@done done: 1) {
cells {
count_0_sto = std_reg(0);
eq_1 = std_eq(0);
}
wires {
group count_0_sto_incr_group {
count_0_sto.write_en = 1'd1;
}
import "primitives/core.futil";
component main() -> () {
cells {
q = std_reg(4); //multiplier (11)
//will use these shifters and adders
add_3bits = std_add(3);
@sampsyo
sampsyo / index.js
Created March 5, 2018 13:58
a Metalsmith config
var Metalsmith = require('metalsmith');
var markdown = require('metalsmith-markdown');
var layouts = require('metalsmith-layouts');
var sass = require('metalsmith-sass');
var metadata = require('metalsmith-metadata');
var inplace = require('metalsmith-in-place');
var ignore = require('metalsmith-ignore');
var metadataPat = require('./metalsmith-metadata-pattern');
var marked = require('marked');
@sampsyo
sampsyo / fixedpoint.js
Created February 16, 2017 02:49
a fixed-point combinator in JavaScript
// Z = \t. (\f. t (\z. f f z)) (\f. t (\z. f f z))
function Z(t) {
return ( (f) => t((z) => (f(f))(z)) ) ( (f) => t((z) => (f(f))(z)) );
}
function fact_template(f) {
return function(n) {
if (n <= 1) {
return 1;
} else {
@sampsyo
sampsyo / bars-with-average.json
Created February 15, 2017 19:41
Dominik's example with a reference line at the average
{
"description": "A simple bar chart with embedded data.",
"data": {
"values": [
{"a": "A","b": 28},
{"a": "B","b": 55},
{"a": "C","b": 43},
{"a": "D","b": 91},
{"a": "E","b": 81},
{"a": "F","b": 53},
@sampsyo
sampsyo / feat.ml
Last active October 27, 2016 15:16
GADTs for features
(* General features. This starts out as an "empty" type, which we'll then
extend. We also define feature values and feature vectors. *)
type 'a feat = ..
type 'a value = 'a feat * float
type 'a fvec = 'a value list
(* Domain adaptation. *)
import sys
import os
PY2 = sys.version_info[0] == 2
def py3_path(path):
"""Convert a bytestring path to Unicode on Python 3 only. On Python
2, return the bytestring path unchanged.
"""This is a Python transcription of the famous Quake III "fast inverse
square root" function. Run the script to see a quick comparison with an
"exact" square root.
"""
import struct
import math
# From:
[
{
"union": [
{
"object": {
"tag": {
"literal": "schedule"
},
"attendees": {
"array": {