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
use std::collections::HashMap; | |
use std::fmt; | |
use std::io; | |
use std::num::ParseFloatError; | |
use std::rc::Rc; | |
/* | |
Types | |
*/ |
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
{ | |
"nodes": { | |
"nixpkgs": { | |
"locked": { | |
"lastModified": 1692698134, | |
"narHash": "sha256-YtMmZWR/dlTypOcwiZfZTMPr3tj9fwr05QTStfSyDSg=", | |
"owner": "NixOS", | |
"repo": "nixpkgs", | |
"rev": "a16f7eb56e88c8985fcc6eb81dabd6cade4e425a", | |
"type": "github" |
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 __future__ import annotations | |
from typing import Any | |
from abc import ABCMeta | |
# Quit is an example of a sentinel. | |
# I want "class Quit(Sentinel): pass" to produce the same thing. | |
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
# Based on https://youtu.be/fCoQb-zqYDI | |
# This passes `mypy --strict`, which is cool. | |
from __future__ import annotations | |
from typing import NamedTuple, Tuple, Callable, TypeVar | |
A = TypeVar('A') | |
B = TypeVar('B') |
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 combinations | |
import matplotlib.pyplot as plt | |
from matplotlib.patches import Rectangle | |
from matplotlib.text import Text | |
def dobble(p): | |
cards = [[] for i in range(p**2 + p + 1)] | |
cards[0].append(0) | |
for i in range(p+1): | |
for j in range(p): |
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
#!/usr/bin/env python | |
from __future__ import division, print_function | |
import sys | |
import os | |
from os.path import join, abspath, exists, expanduser | |
from contextlib import contextmanager | |
import hashlib | |
import cStringIO | |
import json |
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
#!/usr/bin/env python | |
""" | |
Use byzanz to create a GIF screencast of a specific window. | |
Required tools: | |
sudo apt-get install byzanz x11-utils xdotool | |
A tip: use an extra-long duration (-d 100), record your shot, and use | |
gimp to shorten the duration of the last frame. You need to rename the layer | |
from "Frame 123 (100000 ms) (combine)" to "Frame 123 (1000 ms) (combine)". |
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
""" | |
Allow an application to activate a running instance of itself instead of | |
starting another instance. | |
""" | |
import sys | |
import gtk | |
import dbus.service | |
from dbus.mainloop.glib import DBusGMainLoop |
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 __future__ import division | |
import numpy as np | |
from scipy.optimize import brentq | |
from fipy import Grid1D, CellVariable, Viewer, TransientTerm, DiffusionTerm | |
import matplotlib.pyplot as plt | |
D=1. | |
dx = 0.1 | |
nx = 1000 |