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
# Emoji grabber | |
# Grabs emoji from the HTML of discord messages | |
import fileinput | |
from pathlib import Path | |
import bs4 | |
import requests | |
from tqdm import tqdm |
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
fn show_error( | |
code: &[u8], | |
filename: &str, | |
message: &str, | |
span: std::ops::Range<usize>, | |
) -> io::Result<()> { | |
const ARROW: &str = "-->"; | |
let stdout = io::stdout(); | |
let mut h = stdout.lock(); |
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 zsh | |
setopt ERR_EXIT NO_UNSET PIPE_FAIL | |
unsetopt FUNCTION_ARGZERO | |
if [[ -z ${GIST_API_TOKEN:-} ]]; then | |
if [[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/gist-api-token.txt ]]; then | |
GIST_API_TOKEN=$(cat ${XDG_CONFIG_HOME:-$HOME/.config}/gist-api-token.txt) | |
else | |
printf 'No GIST API token provided!\n' |
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 sh | |
uglifyjs onlinegdb.user.js --mangle --compress expression |
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 bash | |
# shellcheck disable=SC2016 | |
set -euo pipefail | |
python3 -m pip freeze \ | |
| rg --invert-match '^-e' \ | |
| cut -d'=' -f'1' \ | |
| xargs python3 -m pip show \ | |
| rg --multiline 'Name: (\w+)\nVersion: (.+)' --replace '$1==$2' |
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 | |
import ast | |
class RewritePipe(ast.NodeTransformer): | |
def visit_Call(self, node: ast.Call) -> ast.expr: | |
if not isinstance(node.func, ast.Name) or node.func.id != "pipe": | |
return node | |
args = iter(node.args) |
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/awk -f | |
# Concatenate all of the input into one variable so that we can jump from | |
# anywhere and to anywhere | |
{ program = program $0 } | |
END { | |
# Due to awk not having a builtin ord() function, we have to create our own | |
# mapping from dict to ASCII value | |
for (i = 0; i <= 127; i++) ord[sprintf("%c", i)] = i |
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 | |
# vim: foldmethod=indent | |
import random | |
import sys | |
import typing as t | |
import attr | |
GRID_SIDE = 8 | |
MINE_DISTRIBUTION = 1 / 6 |
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
#include <assert.h> // assert | |
#include <stdlib.h> // calloc, free | |
/** A prefix tree | |
* An efficient key-value storage with string keys | |
* | |
* There exist two type of nodes: | |
* 1. node->symbol == 0 -> node where a key ended, has node->value | |
* 2. node->symbol != 0 -> node representing a character in a key, has node->child | |
* |
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
macro_rules! timed { | |
($expr:expr) => {{ | |
let start = ::std::time::Instant::now(); | |
let value = $expr; | |
let end = ::std::time::Instant::now(); | |
let elapsed = end.duration_since(start); | |
println!( | |
"Ran {:?} in {} seconds and {} milliseconds", | |
stringify!($expr), | |
elapsed.as_secs(), |
NewerOlder