A quick and dirty utility to mint DOM elements and avoid using react as long as possible for prototypes :)
h("div", {style:{width:"10em", height:"10em", backgroundColor:"red"}},[
h("div", {},"hey"),
h("div", {},"there"),
])A quick and dirty utility to mint DOM elements and avoid using react as long as possible for prototypes :)
h("div", {style:{width:"10em", height:"10em", backgroundColor:"red"}},[
h("div", {},"hey"),
h("div", {},"there"),
])| from dataclasses import dataclass | |
| import functools | |
| from typing import Callable | |
| @dataclass | |
| class ReprFunc: | |
| func:Callable | |
| name:str|None | |
| arg_names:list | |
| def __call__(self, *args, **kwargs): |
| // place in ./.devcontainer folder | |
| { | |
| "name": "Python 3", | |
| "dockerFile": "dockerfile", | |
| "features": { | |
| "ghcr.io/raucha/devcontainer-features/pytorch:1": {},// not sure if these are needed? | |
| "ghcr.io/devcontainers/features/nvidia-cuda:2": {} // not sure if these are needed? | |
| }, | |
| "runArgs": ["--gpus","all"], // apparently this is the magic that makes cuda work in docker desktop for windows |
| /** | |
| * Hash a file without loading the whole thing into memory | |
| * @param {File} file | |
| * @param {"SHA-256"|"SHA-1"} algo | |
| */ | |
| export async function hash_file_in_chunks(file, algo = "SHA-256") { | |
| const chunk_size = 1000 * 1024 * 1024; // 100MB | |
| const count_chunks = Math.ceil(file.size / chunk_size); | |
| const output = new ArrayBuffer(32*count_chunks); |
| #! ./python | |
| import json | |
| import sys | |
| from pathlib import Path | |
| import subprocess | |
| def get_staged_files(): | |
| """Get list of files that are staged for commit.""" | |
| try: | |
| result = subprocess.run( |
Automates reloading a website during development; served using vanilla Deno server using a websocket.
| from __future__ import annotations | |
| import subprocess | |
| from pathlib import Path | |
| from typing import Optional | |
| import os | |
| from dataclasses import dataclass | |
| from deprecated import deprecated | |
| from pandas import Timestamp |
| # This works... but cant read the output array in the final step! :( | |
| # Experimental! | |
| UserLib ← &ffi ⊂□"User32.dll" | |
| GdiLib ← &ffi ⊂□"Gdi32.dll" | |
| KernelLib ← &ffi ⊂□"Kernel32.dll" | |
| MessageBoxA ← UserLib {"int" "MessageBoxA" "long" "const char*" "const char*" "unsigned int"} | |
| # MessageBoxA {0 "Yes Please" "About to Take A Screenshot" 0} | |
| GetSystemMetrics ← UserLib {"int" "GetSystemMetrics" "int"} | |
| GetDeviceContext ← UserLib {"long long" "GetDC" "long"} |
| import pandas as pd | |
| import asyncio | |
| from aiohttp import ClientSession, TCPConnector | |
| @pd.api.extensions.register_series_accessor("aiohttp") | |
| class AiohttpAccessor: | |
| def __init__(self, pandas_obj): | |
| self._obj = pandas_obj | |
| async def _fetch_text(self, url: str, session): |
| # pairwise coefficient of interpolation | |
| Interp ← ÷:⊃(-≡⊢|≡/-)◫2 | |
| MarchingSquares ← ( | |
| : | |
| ⊃( | |
| ≡(◫2)Interp | |
| | ◫2⍜⍉Interp | |
| | ≡≡(°⋯♭)◫2_2> # types | |
| | ≡°⍉⍉⊞⊟∩(⇡-1)⊃(⊢⇌|⊢)△ |