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 functools import wraps | |
def _run(iter_n, func, initial_args, initial_kwargs): | |
current_iter_params = [(initial_args, initial_kwargs)] | |
for _ in range(iter_n): | |
next_iter_params = [] | |
for args, kwargs in current_iter_params: | |
next_iter_params.extend( | |
next_iter_func_params for next_iter_func_params in func(*args, **kwargs)) |
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
var width = view.size.width; | |
var height = view.size.height; | |
var averageLengthFac = 0.7; | |
var angleInc = Math.PI/4; | |
var iterations = 12; | |
function drawLine(x1, y1, x2, y2, color) { | |
var line = new Path(new Point(x1, y1)); | |
line.strokeColor = color; |
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/env python3 | |
from functools import lru_cache | |
import sys | |
import os.path | |
import time | |
WATCH_INTERVAL = 1 | |
SCHEDULER_POLL_INTERVAL = 0.1 | |
PURGE_OLD_UIDS_INTERVAL = 100 * WATCH_INTERVAL |
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 collections import deque | |
def bfs(graph, start, goal): | |
# initialize state | |
queue = deque() | |
explored_vertex_to_path = {} | |
# utility functions | |
def mark_as_explored(vertex, parent=None): |
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
def dfs(graph, start, goal, path=None, visited=None): | |
path = path or [] | |
visited = visited or set() | |
path.append(start) | |
visited.add(start) | |
if start == goal: | |
return path |
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 collections.abc import Iterable | |
import urllib | |
def find_image_urls_in_markdown(s: str) -> Iterable[str]: | |
context = "" | |
alt_text_chars = [] | |
url_chars = [] | |
for char in s: | |
if context == "": |
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/env node | |
const { Buffer } = require('node:buffer'); | |
function main() { | |
console.log(`NodeJS version = ${process.versions.node}`); | |
console.log(`V8 version = ${process.versions.v8}`); | |
console.log("---------------------------------------------------") | |
measureStringConcat(); | |
} |
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
/* | |
* (c) 2024. This work is openly licensed via CC BY 4.0. | |
* Give credit by linking to the original Gist or https://github.com/0scarB/dev-ref/blob/main/ref-impls/c_test_framework/main.c. | |
*/ | |
#define _POSIX_C_SOURCE 1 | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> |