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
#!/bin/sh | |
set -eu | |
inet=$(ip -br -4 address | grep ' UP ' | awk 'NR==1{print $3}') | |
if [ -n "$inet" ] | |
then echo "Scanning $inet" | |
else >&2 echo "inet not found"; exit 1 | |
fi | |
nmap "$@" "$inet" | GREP_COLORS='ms=1;97' grep --color=always -e ^ -e '^Nmap scan.*' |
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> | |
#include <string.h> | |
#include <time.h> | |
// header ---------------------------------------------------------------- {{{1 | |
typedef struct { | |
clock_t start; | |
clock_t end; | |
} Elapsed; |
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 | |
set -eu | |
### SETTINGS ### | |
certs_dir=~/certs | |
country=BR | |
state= |
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
#!/bin/sh | |
git add -A | |
git commit --no-verify -m 'stuff' | |
git push -f |
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 UnaryFn<T, R> = (param: T) => R | |
export function maybeCall<T, R>(fn: UnaryFn<T, R>): UnaryFn<T | null, R | null>; | |
export function maybeCall<T, R>(fn: UnaryFn<T, R>, value: T | null): R | null; | |
export function maybeCall<T, R>(fn: UnaryFn<T, R>, value?: T | null) { | |
if (value === undefined) { | |
return (v: T | null) => maybeCall(fn, v) | |
} | |
return value !== null ? fn(value) : null | |
} |
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
/** | |
* You have four horses, all of which travel at different speeds. | |
* In travelling from point A to point B, these horses take one, two, | |
* four and six hours respectively. | |
* | |
* One day, you decide to move all your horses from point A to point B. | |
* Howerver, you can only move a maximum of two horses at a time, and | |
* you need to ride a horse back to point A each time you return to move | |
* your other horses. Knowing you can only move as fast as the slowest | |
* horse you're travelling with, what's the fewest number of hours 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
export function* getCombinations<T>(arr: T[], size: number): Generator<T[]> { | |
if (size < 1) { | |
throw new Error('Combination size must be at least 1') | |
} | |
if (arr.length === 0) { | |
yield [] | |
} else if (size === 1) { | |
for (const el of arr) { | |
yield [el] |
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 function* permute<T>(arr: T[], m: T[] = []): Generator<T[]> { | |
if (arr.length === 0) { | |
yield m | |
} else { | |
for (let i = 0; i < arr.length; i++) { | |
const curr = arr.slice() | |
const next = curr.splice(i, 1) | |
yield* permute(curr.slice(), m.concat(next)) | |
} | |
} |
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
#!/bin/sh | |
set -eu | |
cd "$(dirname "$1")" | |
input=$(basename "$1") | |
output=${input%.glb}.usdz | |
exec docker run -it --rm \ |
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
💩: | |
@echo HOLY SHIT! |
NewerOlder