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, hash::Hash}; | |
pub struct Memo<T, U, V> | |
where | |
T: Fn(U) -> V, | |
U: Eq + Hash + Copy, | |
V: Copy, | |
{ | |
f: T, | |
cache: HashMap<U, V>, |
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
type _ state = | |
| A : [`A] state | |
| B : [`B] state | |
| C : [`C] state | |
type (_, _) edge = | |
| AC : ([`A], [`C]) edge | |
| AB : ([`A], [`B]) edge | |
| BC : ([`B], [`C]) edge |
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
function createIvar() { | |
let set; | |
const get = new Promise(resolve => { set = resolve }); | |
return Object.freeze({ get, set }); | |
} |
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 json | |
import subprocess | |
import sys | |
def read_json(*args): | |
output = subprocess.check_output(*args) | |
return json.loads(output) | |
def pp(obj): | |
""" |
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
// Source: https://stackoverflow.com/a/42774138/558592 (slightly tweaked) | |
function powerset(arr) { | |
return (Array.from({ length: 1 << arr.length }, (_, k) => k) | |
.map(i => arr.filter((_, j) => i & (1 << j)))); | |
} |
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
c='print("c="+repr(c)+";eval(c)")';eval(c) |
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
""" | |
Download wallpapers from the FACETS website. | |
""" | |
import urllib.request | |
from urllib.error import HTTPError, URLError | |
from bs4 import BeautifulSoup | |
""" | |
Grab all images from the front page, and save them to a folder. |
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
def shift_letters(string, shift): | |
new_string = "" | |
for char in string: | |
if char.isupper(): | |
end_ord = 90 # Z | |
elif char.islower(): | |
end_ord = 122 # z | |
else: | |
# Skip non-letters |
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
/** | |
* smugmug.js is a script that grabs the download URLs for each of the images on | |
* a Smugmug gallery, and zips them up into a downloadable file. smugmug.js can | |
* be run as a bookmarklet or in the browser console. | |
* | |
* To run sumugmug.js as a bookmarklet, simply copy the code into a JavaScript | |
* minifier site like JSCompress (http://jscompress.com/), add `javascript:` | |
* to the beginning of the (now one-line) output, and then copy the code into | |
* the location or the URL section of a newly-created bookmark. | |
* |