This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* build and run: clang test.c -lecl -o test && ./test | |
output: | |
Condition of type: SIMPLE-ERROR | |
msg | |
No restarts available. | |
Top level in: #<process TOP-LEVEL 0x106c1af80>. | |
> ^D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) | |
:finally | |
(return (/ (- sum-of-squares (/ (expt sum 2) i)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
@dataclass | |
class Image: | |
""" Representation of an image, along with metadata. """ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
API_ENDPOINT = "https://psg.gsfc.nasa.gov/api.php" | |
EXAMPLE_CONFIG = "/Users/erik/Desktop/pspec/config.txt" | |
# NOTE: kwargs are explained here https://psg.gsfc.nasa.gov/helpapi.php | |
def get_spectra(config_path, **kwargs): | |
with open(config_path, 'r') as f: | |
kwargs['file'] = f.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# install texlive dependencies | |
yum install -y perl-Tk perl-Digest-MD5 | |
# download texlive installer | |
wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz | |
tar xzf install-tl-unx.tar.gz | |
# HACK pulling texlive profile from my github | |
wget https://gist.githubusercontent.com/kilimanjaro/b876f13ffdcd5557aa9fc6660e6fe7b0/raw/4247c52e555190d97e753a9ec7970d933cc898a3/texlive.profile | |
# install from profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
TEXMFHOME ~/texmf | |
TEXMFLOCAL /usr/local/texlive/texmf-local | |
TEXMFSYSCONFIG /usr/local/texlive/2019/texmf-config | |
TEXMFSYSVAR /usr/local/texlive/2019/texmf-var |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## einsum_compiler.py | |
## | |
## 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. | |
## | |
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass | |
from typing import Tuple | |
PLAYER_X = 'X' | |
PLAYER_O = 'O' | |
EMPTY = ' ' | |
def other(player): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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") |
NewerOlder