Skip to content

Instantly share code, notes, and snippets.

View saulshanabrook's full-sized avatar
🏊

Saul Shanabrook saulshanabrook

🏊
View GitHub Profile

Proposal to remove the top level function command and replace it with frel and constructor (pending bikeshedding on new names):

frel

Any function that returns a primitive sort, you must now make with frel.

For example:

  • $l$: lifespan of the item in years
  • $a$: current age of the item
  • $p$: current price of item
  • $r$: inflation rate per year (as a number > 1 i.e. 1.03)
  • $f$: initial reserve for the item
  • $y_i$: amount set aside for the item at year $i$

We would like to have a capital improvements plan where our:

@saulshanabrook
saulshanabrook / README.md
Created October 19, 2016 14:20
Saving Web Crypto Keys using indexedDB

This is a working example on how to store CryptoKeys locally in your browser. We are able to save the objects, without serializing them. This means we can keep them not exportable (which might be more secure?? not sure what attack vectors this prevents).

To try out this example, first make sure you are in a browser that has support for async...await and indexedDB (latest chrome canary with chrome://flags "Enable Experimental Javascript" works). Load some page and copy and paste this code into the console. Then call encryptDataSaveKey(). This will create a private/public key pair and encrypted some random data with the private key. Then save both of them. Now reload the page, copy in the code, and run loadKeyDecryptData(). It will load the keys and encrypted data and decrypt it. You should see the same data logged both times.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@saulshanabrook
saulshanabrook / tmp.sh
Created October 17, 2022 17:23
Configure CPython Mac
#!/usr/local/bin/fish
set fish_trace on
# https://stackoverflow.com/questions/57746792/homebrews-llvm-fatal-error-stdio-h-file-not-found-on-macos
set LLVM_PATH "/usr/local/opt/llvm"
set LLVM_VERSION "21.6.0"
set -x PATH "$LLVM_PATH:$PATH"
set -x SDKROOT (xcrun --sdk macosx --show-sdk-path)
set -x LD_LIBRARY_PATH "$LLVM_PATH/lib/"
set -x DYLD_LIBRARY_PATH "$LLVM_PATH/lib/"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"id": "root",
"children": [
{
"id": "0",
"x": -38.5,
"y": -16,
"width": 77,
"height": 32
},
mode browser n type mean confidenceInterval
open firefox 0 100 n outputs each of a div 2.5732290683420116 3.8240364815126204
open firefox 0 one output with 100 n divs 1.010023894412375 0.10920438045006321
switch firefox 0 100 n outputs each of a div 1.4223837673259567 0.35645723854657835
switch firefox 0 one output with 100 n divs 1.0427466384309414 0.3645977355738751
open firefox 5 100 n outputs each of a div 1.0473409536852676 0.4919644275027175
open firefox 5 one output with 100 n divs 1.11596088676786 0.2767693224037376
switch firefox 5 100 n outputs each of a div 1.009349877791352 0.10665425922817721
switch firefox 5 one output with 100 n divs 1.0025889409915483 0.24335132357646194
open firefox 10 100 n outputs each of a div 1.011304775132308 0.06804069429668422
"""
Functions and tools to unify types.
Note that this uses dicts as ordered sets in many places so that input and output
has the same ordering, so that git diffs are better
"""
from __future__ import annotations
import typing
import collections