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 Grammer = { | |
"expression": unknown | |
} | |
type Expr<α extends Grammer> = α["expression"] | |
type Plus<α extends Grammer> = { | |
kind: "plus" | |
left: Expr<α> | |
right: Expr<α> |
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
class AsyncSemaphore { | |
struct waiter { | |
var continuation: CheckedContinuation<Void,Never> | |
var next: UnsafeMutablePointer<waiter>? | |
} | |
var value : Int | |
var waitList : UnsafeMutablePointer<waiter>? | |
var lock = os_unfair_lock() |
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 html.parser import HTMLParser | |
from typing import * | |
import json | |
class SAXText(NamedTuple): | |
text : str | |
Attrs = List[Tuple[str,Optional[str]]] | |
class SAXStartTag(NamedTuple): |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#include <iostream> | |
#include <stdio.h> | |
// better Expected monad in C++, using std::invoke | |
struct Error {}; | |
template<typename T> class Expected; | |
template<typename T> struct IdempotentExpectedStruct { |
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
#include <iostream> | |
#include <stdio.h> | |
// Expected monad in C++ | |
struct Error {}; | |
template<typename Enable, typename T, typename F, typename... Args> | |
struct Bind { | |
}; |
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/python3 | |
# In this example have 50 jobs to do concurrently, but only 10 are allowed to be | |
# done at a time. We use a semaphore to limit spawning the next task untill one | |
# of the 10 currently runninng ones finishes. At the end we gather up the results. | |
import asyncio | |
import os | |
import sys |
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/python3 | |
import asyncio | |
async def doitem(n, sem): | |
try: | |
print('foo', n) | |
await asyncio.sleep(1) | |
print('bar', n) | |
finally: |
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
#include <LiquidCrystal_PCF8574.h> | |
LiquidCrystal_PCF8574 lcd(0x27); | |
void setup() { | |
lcd.begin(20, 4); // initialize the lcd | |
lcd.home(); | |
lcd.clear(); | |
lcd.print("1234567890Hello&...."); | |
lcd.setCursor(0,1); |
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 adsk.core, adsk.fusion, adsk.cam, traceback | |
from adsk.core import * | |
from math import pi | |
def run(context): | |
ui = None | |
try: | |
app = adsk.core.Application.get() | |
ui = app.userInterface |
NewerOlder