Skip to content

Instantly share code, notes, and snippets.

View sampsyo's full-sized avatar

Adrian Sampson sampsyo

View GitHub Profile
View reduced_iter_mult.futil
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
View index.js
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
View fixedpoint.js
// 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
View bars-with-average.json
{
"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
View feat.ml
(* 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. *)
View py3_path.py
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.
View fisr.py
"""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:
View schema.json
[
{
"union": [
{
"object": {
"tag": {
"literal": "schedule"
},
"attendees": {
"array": {
View DSLs.md

The GPU languages are all corrupted C variants where all safety is sacrificed in the name of low-level control. And the awkward dance for CPU–GPU communication is "stringly typed."

Verilog/VHDL are leaky abstractions with creaky tools; they're just very old languages with zero of the modern conveniences. Bluespec seems rad and I don't know why it's not more popular! Same with Chisel: https://chisel.eecs.berkeley.edu/

View 1942.diff
diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py
index 88c72cd..f570504 100644
--- a/beetsplug/fetchart.py
+++ b/beetsplug/fetchart.py
@@ -648,14 +648,15 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin):
'coverart', 'itunes', 'amazon', 'albumart'],
'google_key': None,
'google_engine': u'001442825323518660753:hrh5ch1gjzm',
- 'fanarttv_key': None
+ 'fanarttv_key': None,