Skip to content

Instantly share code, notes, and snippets.

kilimanjaro / test.c
Created Jul 1, 2021
ecl uncaught condition
View test.c
/* build and run: clang test.c -lecl -o test && ./test
Condition of type: SIMPLE-ERROR
No restarts available.
Top level in: #<process TOP-LEVEL 0x106c1af80>.
> ^D
View single-float-woes.lisp
(defun sample-variance (xs)
"Compute the sample variance of a list XS in a single pass. Just don't ask any questions..."
(loop :with sum := 0
:with sum-of-squares := 0
:for x :in xs
:for i :from 1
:do (incf sum x)
(incf sum-of-squares (expt x 2))
(return (/ (- sum-of-squares (/ (expt sum 2) i))
from collections import defaultdict
import numpy as np
from typing import Dict, Any, List, Union, Callable, Set, Iterable, Iterator, Optional, Tuple
from dataclasses import dataclass
class Image:
""" Representation of an image, along with metadata. """
import requests
EXAMPLE_CONFIG = "/Users/erik/Desktop/pspec/config.txt"
# NOTE: kwargs are explained here
def get_spectra(config_path, **kwargs):
with open(config_path, 'r') as f:
kwargs['file'] =
# install texlive dependencies
yum install -y perl-Tk perl-Digest-MD5
# download texlive installer
tar xzf install-tl-unx.tar.gz
# HACK pulling texlive profile from my github
# install from profile
View texlive.profile
# texlive.profile written on Mon Dec 9 18:40:07 2019 UTC
# It will NOT be updated and reflects only the
# installation profile at installation time.
selected_scheme scheme-custom
TEXDIR /usr/local/texlive/2019
TEXMFCONFIG ~/.texlive2019/texmf-config
TEXMFLOCAL /usr/local/texlive/texmf-local
TEXMFSYSCONFIG /usr/local/texlive/2019/texmf-config
TEXMFSYSVAR /usr/local/texlive/2019/texmf-var
kilimanjaro /
Last active Nov 12, 2019
Translate a pyquil program to a single einsum call
## What it is
## ----------
## Numpy has a standard function, einsum, which can be used to evaluate large
## nested summations. Here we show how to translate a pyQuil program consisting
## of only gate applications to a single einsum call.
kilimanjaro /
Created May 7, 2019
a simple game of tic-tac-toe
from dataclasses import dataclass
from typing import Tuple
EMPTY = ' '
def other(player):
kilimanjaro /
Created Apr 22, 2019
looking at 3-SAT phase transitions
from itertools import product
import random
def random_clause(vars):
"""Return a random 3-SAT clause."""
clause_vars = random.choices(vars, k=3)
modifiers = random.choices(["", "not "], k=3)
exprs = [f"{v}{x}" for x,v in zip(clause_vars, modifiers)]
clause = " or ".join(exprs)
return clause
kilimanjaro /
Created Mar 30, 2019
Regular Expressions in Python
"""Regular expression parser and interpreter.
One may check whether a string s matches a regular expression r by using the
`matches` function. To construct a regular expression object from its compact
textual form, use the `parse` function.
As a combined example,
>>> r = parse("a|b*(c)")
>>> matches(r, "bbbc")