Tested on Win & GNOME
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 socket | |
def whois(cmd: str, whois_server="whois.iana.org", port=43): | |
# Connect to the service host | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.connect((whois_server, port)) | |
# Send a single "command line", ending with <CRLF>. | |
sock.send(cmd.encode("utf-8")) | |
sock.send("\r\n".encode("utf-8")) |
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 http.client | |
import urllib.parse | |
import json | |
import ipaddress | |
def rdap_fetch_bootstrap( | |
obj_type: str, bootstrap_server_base="https://data.iana.org/rdap", fetch_url=None | |
): | |
if not fetch_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
from tkinter import * | |
# zip values until all arguments are exhausted | |
def zip_nostop(*iterables): | |
lists = [list(iterable) for iterable in iterables] | |
lens = [len(l) for l in lists] | |
for i in range(max(lens)): | |
tup: list = [] | |
for iterable in iterables: |
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 { useRef, Ref } from 'react' | |
import { refFactory } from './refFactory' | |
const ExampleButton = (props: { ref: Ref<HTMLButtonElement> }) => { | |
const { ref: refFromProps } = props | |
const refHook = useRef<HTMLButtonElement | null>(null) | |
const refCallback = (element: HTMLButtonElement) => { | |
console.log('Ref Callback', element) |
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 numpy as np | |
from PIL import Image | |
def blend_multi(images: list[Image.Image]) -> Image.Image: | |
img_arrs = np.array([np.asarray(img) for img in images]) | |
out = np.mean(img_arrs, axis=0) | |
return Image.fromarray(out.astype(np.uint8)) |
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 Deserialized<T> = T extends Array<infer U> | |
? Array<Deserialized<U>> | |
: T extends string | number | boolean | |
? T | |
: "toJSON" extends keyof T | |
? T["toJSON"] extends (...args: any) => any | |
? ReturnType<T["toJSON"]> | |
: { [K in keyof T]: Deserialized<T[K]> } | |
: { [K in keyof T]: Deserialized<T[K]> }; |