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
| macro_rules! fearless { | |
| ($t:ty) => { | |
| std::sync::Arc<std::sync::Mutex<$t>> | |
| }; | |
| ($e:expr) => { | |
| std::sync::Arc::new(std::sync::Mutex::new($e)) | |
| }; | |
| (clone $e:expr) => { | |
| std::sync::Arc::clone(&$e) | |
| }; |
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 class TripMap<K, V> { | |
| private map: Map<number, V>; | |
| constructor() { | |
| this.map = new Map<number, V>(); | |
| } | |
| private generateKey(...items: any[]): number { | |
| return [...new Set(items)] | |
| .map((x) => this.hash(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
| aclocal | |
| aclocal-1.16 | |
| activate-global-python-argcomplete | |
| acyclic | |
| add-apt-repository | |
| add-shell | |
| addgnupghome | |
| addgroup | |
| addpart | |
| addr2line |
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 TreeNode<V extends number = number, L = null, R = null> = { | |
| value: V; | |
| left: L; | |
| right: R; | |
| }; | |
| type BinarySearchTree<T = null> = { | |
| root: T; | |
| }; |
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
| use std::cmp::Ordering; | |
| use std::collections::BinaryHeap; | |
| const INF: u32 = u32::MAX; | |
| #[derive(Copy, Clone, Eq, PartialEq)] | |
| struct Edge { | |
| weight: u32, | |
| vertex: usize, | |
| } |
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
| interface Logger { | |
| void error(String message, Throwable t); | |
| } | |
| class ConsoleLogger implements Logger { | |
| private final String className; | |
| ConsoleLogger(String className) { | |
| this.className = className; | |
| } |
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 { promises as fs } from 'fs'; | |
| import { v4 as uuidv4 } from 'uuid'; | |
| import { Mutex } from 'async-mutex'; | |
| interface Document { | |
| [key: string]: any; | |
| } | |
| interface Index { | |
| [key: string]: { [value: string]: string[] }; |
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
| #!/usr/bin/env bash | |
| declare -A board | |
| for ((i=1; i<=7; i++)); do | |
| for ((j=1; j<=6; j++)); do | |
| board[$i,$j]=' ' | |
| done | |
| done | |
| check_winner() { |
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
| fn main() { | |
| // create a new binary tree | |
| let mut root = TreeNode::new(1); | |
| let left_child = TreeNode::new(2); | |
| let right_child = TreeNode::new(3); | |
| root.set_left(left_child); | |
| root.set_right(right_child); |
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
| async function processItems(items, fn) { | |
| const errs = []; | |
| let i = 0; | |
| const workers = Array(25) | |
| .fill() | |
| .map(async () => { | |
| while (i < items.length) { | |
| await fn(items[i++]).catch((e) => errs.push(e)); | |
| } | |
| }); |