Skip to content

Instantly share code, notes, and snippets.

View sampsyo's full-sized avatar

Adrian Sampson sampsyo

View GitHub Profile

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/

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,
@sampsyo
sampsyo / clopper_pearson.py
Last active October 31, 2018 16:21
the Clopper-Pearson method for getting a confidence interval for an estimated a Bernoulli parameter
import scipy.stats
import math
import random
def clopper_pearson(x, n, alpha=0.05):
"""Estimate the confidence interval for a sampled Bernoulli random
variable.
`x` is the number of successes and `n` is the number trials (x <=
@sampsyo
sampsyo / decidability.md
Created November 21, 2015 22:24
a silly answer to Colin's question

Assume, by way of contradiction, that we have an algorithm D for "decidability checking." We will use this algorithm to solve the halting problem.

Here's my algorithm for the halting problem:

  • Take as input a machine M. We need to check whether M terminates on all inputs.
  • Construct the following "problem" P, which takes as input another machine M': "If M terminates on all inputs, the problem is to decide whether M' halts. Otherwise, the answer to the problem is 'yes.'"
  • Run our decidability-checker D on P.

Since P is decidable iff M terminates on all inputs, we have solved the halting problem.

@sampsyo
sampsyo / fib.ts
Last active August 9, 2023 23:54
function inheritance in TypeScript
// This is a quick demonstration of "function inheritance" as described in
// this paper from Daniel Brown and William Cook.
// http://www.cs.utexas.edu/users/wcook/Drafts/2009/sblp09-memo-mixins.pdf
// Expressed in TypeScript (and without the monads).
// Syntax note: When you write function types in TypeScript, you need to name
// each parameter. But the names don't actually matter, so I just use _. You
// can read `(_:A) => B` as `a -> b` in ML or Haskell syntax.
// In Brown and Cook's Haskell, `type Gen a = a -> a` is a "generator." The
SOURCES := $(wildcard common/*.c) $(wildcard includes/*.c) $(wildcard *.c)
OBJECTS := $(SOURCES:%.c=%.o)
mycmd: $(OBJECTS)
$(CC) -o $@ $^
commit 615fc8bb5543bb2b88d4f97ebff74d1890f4dcc8
Author: Adrian Sampson <adrian@radbox.org>
Date: Thu Jul 16 09:57:49 2015 -0700
Remove all the ACCEPT stuff
diff --git a/svd3/common/calcSobel_dX.c b/svd3/common/calcSobel_dX.c
index 5dddfdb..0976948 100644
--- a/svd3/common/calcSobel_dX.c
+++ b/svd3/common/calcSobel_dX.c
from __future__ import print_function
import sys
import os
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
from __future__ import print_function
import sys
import os
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
import gi
from gi.repository import GObject, Gst
import urllib
import sys
import os
gi.require_version('Gst', '1.0')
file_path = sys.argv[1]