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
addEventListener("fetch", (event) => { | |
event.respondWith( | |
handleRequest(event.request).catch( | |
(err) => new Response(err.stack, { status: 500 }) | |
) | |
); | |
}); | |
async function handleRequest(request) { | |
const url = getUrl(request) |
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.10 | |
# -*- coding: utf-8 -*- | |
import asyncio | |
import sys | |
import importlib | |
from functools import reduce | |
from typing import Any | |
def import_from_string(import_str: str) -> Any: |
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 | |
import html | |
import inspect | |
import os | |
import traceback | |
import typing | |
from baize.typing import WSGIApp, Environ, StartResponse, ExcInfo | |
from baize.wsgi import Request, Response, HTMLResponse, PlainTextResponse |
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
wget -c http://ftp.apnic.net/stats/apnic/delegated-apnic-latest | |
cat delegated-apnic-latest | awk -F '|' '/CN/&&/ipv4/ {print $4 "/" 32-log($5)/log(2)}' | cat > ip.txt |
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 _xxsubinterpreters | |
from typing import List | |
from inspect import cleandoc | |
SharedValue = int | float | bool | bytes | str | None | tuple["SharedValue", ...] | |
class Interpreter: | |
def __init__(self, id: int): |
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 ipaddress | |
def ip_range( | |
start_ip: ipaddress.IPv4Address, end_ip: ipaddress.IPv4Address | |
) -> list[ipaddress.IPv4Network]: | |
if start_ip > end_ip: | |
raise ValueError("Start IP must be less than end IP") | |
res = [] |
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
addEventListener("fetch", (event) => { | |
event.respondWith( | |
handleRequest(event.request).catch( | |
(err) => new Response(err.stack, { status: 500 }) | |
) | |
); | |
}); | |
async function handleRequest(request) { | |
const { host, pathname } = new URL(request.url) |
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
Y = lambda g: (lambda f: g(lambda arg: f(f)(arg))) (lambda f: g(lambda arg: f(f)(arg))) | |
if __name__ == "__main__": | |
fib = Y(lambda f: lambda n: (1 if n < 3 else f(n-1) + f(n-2))) | |
print(fib(10)) |
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 { Ai } from './vendor/@cloudflare/ai.js'; | |
export default { | |
async fetch(request, env) { | |
const ai = new Ai(env.AI); | |
// prompt - simple completion style input | |
// let simple = { | |
// prompt: 'Tell me a joke about Cloudflare' | |
// }; |
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
""" | |
https://peps.python.org/pep-3333/ | |
""" | |
from types import TracebackType | |
from typing import ( | |
Any, | |
Callable, | |
Iterable, | |
List, | |
Optional, |
NewerOlder