Skip to content

Instantly share code, notes, and snippets.

View fakuivan's full-sized avatar

fakuivan

  • Posadas, Misiones, Argentina
  • 17:01 (UTC -03:00)
View GitHub Profile
@fakuivan
fakuivan / install.sh
Created July 17, 2022 04:16
Install Magic Wormhole on Termux
# Source: https://www.reddit.com/r/termux/comments/ubtuua/hi_i_need_help_with_this_problem_any_ideas/
# binutils and libsodium are required to build pynacl
# while rust is required to build cryptography
pkg install python rust libsodium binutils
export CARGO_BUILD_TARGET=aarch64-linux-android
pip install magic-wormhole
@fakuivan
fakuivan / tplink_tlsg108e_v1_config_backup.md
Created February 20, 2022 20:07
TP-Link TL-SG108E V1 config backup format
@fakuivan
fakuivan / README.md
Last active June 12, 2021 21:27
Helper script for running VcXsrv from WSL

Helper script for running VcXsrv from WSL

Add it to .bashrc

# Autostart VcXsrv
. <(~/vcxserv_helpers.sh ~/.vcxsrv.port)
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
% Evaporado ;0;10;20;30;40;50;60;70;80;90;100
Temperatura (°C) ;32;53;69;88;102;115;126;137;154;177;182
@fakuivan
fakuivan / gray.hs
Created April 30, 2021 22:09
Algorithm implemented in Haskell for generating Grey codes
-- generalized n-ary gray code generator
gray :: (Integral a) => [b] -> a -> [[b]]
gray elems 1 = map (:[]) elems
gray elems n =
concat $ zipWith ($) prependers $ flipN $ gray elems (n-1)
where flipN = (take $ length elems) . (iterate reverse)
prependers = [ map (elem:) | elem <- elems ]
@fakuivan
fakuivan / free_var.py
Created April 28, 2021 00:18
Free variable function pairs in python
from typing import overload, Any, Tuple, Callable, TypeVar
T=TypeVar('T')
@overload
def free_var(initial: T) -> Tuple[Callable[[T], T], Callable[[], T]]: ...
@overload
def free_var(*, like: T) -> Tuple[Callable[[T], T], Callable[[], T]]: ...
def free_var(*args, **kwargs):
#!/usr/bin/env python3.9
from itertools import chain
from typing import Iterator
import argh
ichain = chain.from_iterable
def up_to_multiple(mul: int, val: int) -> int:
"""
Rounds a value up to the nearest multiple
"""
@fakuivan
fakuivan / import_hp_prime_backups_to_git_repo.sh
Created March 6, 2021 20:53
Small script to port xcas program changes made throughout hp prime backups to a git repo
#!/usr/bin/env bash
decode_hp_xcas_program () {
python3.8 -c '
import sys
enc = "utf-16le"
delims = ("#cas".encode(enc), "#end".encode(enc))
print(((lambda conts: conts[conts.find(delims[0])+len(delims[0]):conts.rfind(delims[1])])(
open(sys.argv[1], mode="rb").read())).decode(enc))' \
"$1"
@fakuivan
fakuivan / Dockerfile
Last active July 17, 2023 19:55
Basic rtsp stream recorder written on bash (python exists for a reason)
FROM alpine:3
RUN apk add --no-cache ffmpeg inotify-tools bash python3 coreutils tzdata
RUN mkdir /app
WORKDIR /app
COPY ./recorder.sh ./util.sh /app/
ENTRYPOINT [ "/app/recorder.sh" ]
@fakuivan
fakuivan / apply_rules.sh
Last active February 28, 2021 19:57
Sets flow rules on a zerotier controller from a capabilities and rules file, abuses jq <3
#!/usr/bin/env bash
eval_on_ztncui () {
# shellcheck disable=1090
(source ~/containers/ztncui.sh && ztncui-compose exec -T ztncui bash -c "$1"); return $?
}
# Arguments are escaped, last argument gets the address of the server prepended, auth token is added to the header
curl_on_ztncui () {
# shellcheck disable=2016