erDiagram
ValidPaths {
int id PK
string path
string hash
int registrationTime
string deriver
int narSize
int ultimate
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
-- Rerun last command plugin | |
-- Unlike the python, this removes the scrollback in the terminal | |
local M = {} | |
-- Store the last terminal buffer job id | |
M.last_terminal_chan_id = nil | |
-- Function to record terminal job id when terminal is opened | |
local function record_terminal_id() | |
local buf = vim.api.nvim_get_current_buf() |
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 | |
# exit on first failure | |
set -e | |
# uncomment to enable debug mode | |
#set -x | |
# The location this script is run from | |
OG_DIR=$(pwd) | |
# The directory that this script is in |
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
BEGIN; | |
SET LOCAL "jwt.claims.whatever" to '[email protected]'; | |
SELECT the_name_of_your_function('yo-10'); | |
COMMIt; |
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
PY_FILES := $(shell find . -name '*.py') | |
venv: venv/bin/activate | |
venv/bin/activate: requirements.txt | |
test -d venv || python3 -m venv venv | |
venv/bin/python -m ensurepip | |
venv/bin/python -m pip install -r requirements.txt | |
touch venv/bin/activate | |
test: venv |
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
use log::info; | |
macro_rules! timeit { | |
($format_str:expr, $code:expr) => { | |
{ | |
let start = Utc::now(); | |
let out = $code; | |
info!( | |
$format_str, | |
(Utc::now() - start).num_milliseconds() |
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
use core::fmt::Debug; | |
fn quick_sort<T: Ord + Clone + Debug>(mut list: Vec<T>) -> Vec<T> { | |
if list.len() < 2 { | |
return list; | |
} | |
let pivot = list.pop().unwrap(); | |
let mut left: Vec<T> = vec![]; |
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
# Prints the time the log spans and how many bytes per second its memory has increased | |
import sys | |
logname = sys.argv[1] | |
with open(logname) as f: | |
first, *_, last = f | |
t0, m0 = map(int, first.split()); | |
t1, m1 = map(int, last.split()); | |
print(f'Time: [{(t1 - t0)/60:.2f}] at {((m1 - m0)/(t1 - t0)):.2f} B/s') |
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
function Deferred() { | |
const o = {}, | |
p = new Promise((resolve, reject) => Object.assign(o, {resolve, reject})); | |
return Object.assign(p, o); | |
} |
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
// Usage: | |
// dev with: dot -Tx11 this_file.dot | |
// output with: dot -Tpng this_file.dot > out_file.png | |
// change "png" above to desired output format | |
digraph asyncio { | |
"so you wanna run some asyncio code?" -> "do you want to run the code sequentially?"; | |
"do you want to run the code sequentially?" -> "are you within an async block?"[ label="yes" ]; | |
"are you within an async block?" -> "use await" [ label="yes" ]; | |
"are you within an async block?" -> "is there already an event loop running in the current thread?" [ label="no" ]; | |
"is there already an event loop running in the current thread?" -> "use asyncio.run" [ label="no" ]; |
NewerOlder