Skip to content

Instantly share code, notes, and snippets.



  • Posadas, Misiones, Argentina
View GitHub Profile
fakuivan /
Last active Aug 28, 2020
Bash function to get the number of pages in pdf files
pdfpages () {
if [[ $# -ne 1 ]]; then
echo "$FUNCNAME: expected one argument, got $#"
return 1
local filename="$1"
while read line; do
if [[ "$line" =~ ^Pages:" "+([0-9]+)$ ]]; then
echo "${BASH_REMATCH[1]}"
return 0
fakuivan / .bashrc
Created Aug 24, 2020
Try to cd by swapping base by symlink
View .bashrc
# Try to cd by swapping base by symlink
cdlink () {
local relative
local base="$1"
relative=$(realpath --relative-to="$base" .) &&
cd "$base/$relative" &&
return 1 # Not sure how to check this was successful
declare -a HOME_SYMLINKS=( "/mnt/c/Users/fakui/Seafile" )
fakuivan /
Created Jul 28, 2020
A collection of helpers for plotting using sympy
from typing import Iterator, Tuple, Dict, Any, Iterable, Union, cast
from sympy import plot as splot
from sympy.plotting.plot import Plot
from matplotlib import pyplot
from itertools import filterfalse
from more_itertools import unzip
import random
import colorsys
Curve = Tuple[Any, Dict[str, Any]]
fakuivan / tasks.json
Last active Jul 19, 2020
vscode compile task for sourcepawn
View tasks.json
// See
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
"label": "Compile plugins",
"type": "shell",
"command": "${config:sourcepawnLanguageServer.sourcemod_home}/../spcomp64",
"args": [
fakuivan /
Last active Jul 7, 2020
Wraps an iterator so that StopIteration is only raised once
#!/usr/bin/env python3.8
from typing import TypeVar, Iterator
This is considered broken by the iterator protocol, however I think
that what's considered broken is to continue to _yield values_, where
with this we emphasize the fact that if ``StopIteration`` is raised
once, the iterator _should not be used_ further. Those are two
different things.
#!/usr/bin/env python3.8
from ipaddress import IPv6Network, IPv6Address
from typing import Optional, Tuple
from base64 import b32encode
# from
def mk6plane(nwid: int, nodeid: int
) -> Tuple[IPv6Network, IPv6Network, IPv6Address]:
Given a ZeroTier node and network ID, return
fakuivan /
Last active Jun 11, 2020
Finds valid JSON strings in a file. Useful for reconstructing broken files or reverse engineering data structures in protocols or embedded into binaries
#!/usr/bin/env python3.8
# different from the re module ( )
from ast import parse
from json import dumps
from typing import Any, List, NoReturn, TextIO, Tuple
import regex
import json
import sys
import argparse
# shellcheck disable=SC2030,SC2034,SC2031
split_output() {
local -n array="$1" || return $?;
# shellcheck disable=SC1090
. <({
err="$({ out="$("${@:2}")"; ret=$?; } 2>&1;
fakuivan /
Last active May 16, 2020
Algunas resoluciones para los trabajos prácticos propuestos por la cátedra de la materia "Señales y Sistemas"
#!/usr/bin/env python3.8
from sympy import Basic, Piecewise, Symbol, Eq, Mod, Heaviside, sympify, plot as splot
import numpy
from typing import Hashable, Tuple, Iterable, NamedTuple, Callable, Type
from matplotlib import pyplot as mplot
from sympy.physics.units.definitions import Hz
from sympy.physics.units.quantities import Quantity
from sympy.physics.units.prefixes import kilo
fakuivan / create_sidepanel_folder.bat
Created Mar 7, 2020
Creates a side panel entry for windows explorer
View create_sidepanel_folder.bat
@echo off
:: GUIDs were randomly generated using the command ``python3 -c "import uuid; print(str(uuid.uuid4()).upper())"``
set guid=C3AA96DB-679A-4D75-B53F-F9EBDFEBE6C3
set name=Seafile
set folder=%%userprofile%%\Seafile
set icon=%%programfiles(x86)%%\Seafile\bin\seafile-applet.exe,-2
:: set guid=92EB2F95-3564-4430-8022-4CAF93AB8D96
:: set name=Sync
:: set folder=%%userprofile%%\Sync
You can’t perform that action at this time.