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
| type ElementLike = string | Element; | |
| type ElementChildren = ElementLike | Array<ElementLike> | Iterator<ElementLike>; | |
| const svgTagNamesLookup = new Set([ | |
| 'svg', | |
| 'g', | |
| 'defs', | |
| 'use', | |
| 'line', |
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
| from typing import Callable, Iterable | |
| import sys | |
| import subprocess | |
| import shutil | |
| import re | |
| import cv2 as cv | |
| import numpy as np | |
| import pytesseract as tess |
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
| def chunker[T](seq: Iterator[T], size: int): | |
| it = iter(seq) | |
| while True: | |
| chunk: list[T] = [] | |
| for _ in range(size): | |
| try: | |
| val = next(it) |
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
| #include <stdint.h> | |
| #include <stdio.h> | |
| uint8_t utf8_encode(uint32_t c, uint8_t *b) { | |
| if (c < 0x80) | |
| return *b = c, 1; | |
| int8_t h; | |
| uint8_t u; | |
| for (h = 0xC0, u = 0; c & h; c >>= 6, h = h >> 1, ++u) | |
| b[u] = 0x80 | (c & 0x3F); |
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
| export type Point = { | |
| x: number | |
| y: number | |
| } | |
| export const lerp = (min: number, max: number, r: number) => min + (max - min) * r | |
| export const bezier = (ps: Array<Point>, t: number) => { | |
| const resolve = (start: number, end: number): Point => { | |
| if (end - start === 1) return ps[start] |
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
| class SysCall(int): | |
| def __new__(cls, i: int): | |
| return super().__new__(cls, i) | |
| def __await__(self): | |
| return (yield self) | |
| async def test3(): | |
| for i in range(7): | |
| d = await SysCall(i) | |
| print(f'-- {d}') |
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
| #include <stdio.h> /* scanf, printf */ | |
| void printb( long v, unsigned char w, unsigned char f ) { | |
| unsigned long m; | |
| unsigned char b, x; | |
| m = 1u << w - 1; | |
| while ( m ) { | |
| b = !!( v & m ); | |
| x = b != f; | |
| putchar( '0' + x ); |
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
| const s = '' | |
| const row = 4 | |
| const pr = 2 * (row - 1) | |
| const res = [] | |
| for (let i = 0, c = 0; i < row; i += 1) { | |
| const pr1 = 2 * i | |
| const pr2 = pr - pr1 | |
| for (let j = i, t = true; j < s.length; c += 1, j += pr1 && pr2 ? (t = !t) ? pr1 : pr2 : pr) | |
| // to encode: c and j | |
| // to decode: j and c |
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
| import json | |
| with open('.glitch-assets') as hand, open('.glitch-assets.clean', 'w') as writer: | |
| db = [] | |
| for line in hand: | |
| # parse json entry | |
| data = json.loads(line) | |
| if 'deleted' in data: | |
| # delete item from collection | |
| db = [ | |
| item |
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
| # list all directory | |
| find -L / -regextype awk -regex '^/(sys|dev|proc)' -prune -o -type d -print | |
| # and pipe it to one of the following command | |
| awk 'length > x {x = length; y = $0} END {print y}' # get longest path | |
| awk -F '/' 'NF > x {x = NF; y = $0} END {print y}' # get deepest path |
NewerOlder