This file contains hidden or 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
/** | |
* First, we're going to declare two types to use for tagging validation, with a function to "run" during compile-time | |
* | |
* validate(a: T,b: U) returns Validated<T> if a and b mutually extend each other, if not it returns NotValidated<U> | |
* | |
* (by sending the left value in one case and the right value in another the type system is more likely to give "real" | |
* error messages and tell you what keys you are missing) | |
* | |
* Usage is: | |
* // this should fail at compile time based on the used values |
This file contains hidden or 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
""" | |
An implementation of the Fermat's library anagram detection | |
https://twitter.com/fermatslibrary/status/1275066521450975234 | |
Takes a list of line seperated words and uses prime factors to | |
encode letters and identify the equivalency classes. | |
Prints out the top 10 anagram classes for the provided word list | |
""" | |
from collections import defaultdict, Counter |
This file contains hidden or 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 python3 | |
from black import lib2to3_parse | |
from blib2to3.pytree import Leaf, type_repr | |
func_example = """ | |
def f(x, y): | |
# add two operands | |
return (x + y) # yes just this | |
""" |
This file contains hidden or 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
# /// script | |
# dependencies = [ | |
# "asgiref", | |
# "pandas", | |
# "numpy" | |
# ] | |
# /// | |
# this is a microbenchmark of async_to_sync, to get an idea | |
# of how much that mechanism itself costs in terms of latency |
OlderNewer