Skip to content

Instantly share code, notes, and snippets.

@mgrabovsky
mgrabovsky / dj.py
Last active May 5, 2021 18:28
A basic file encryption utility in Python using the cryptography.io library. Uses ChaCha20Poly1305 for authenticated encryption and PBKDF2 with SHA-2 to derive a secure key from a password.
#!/usr/bin/env python
import argparse
from cryptography import exceptions
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
from cryptography.hazmat.primitives.hashes import SHA256
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from getpass import getpass
import os
import sys
@mgrabovsky
mgrabovsky / base.css
Last active September 13, 2017 18:14
ČSFD stats vis
/*! normalize.css v3.0.2 | MIT License | git.io/normalize */
html {
font-family: sans-serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body { margin: 0; }
@mgrabovsky
mgrabovsky / index.md
Last active August 25, 2018 00:27
JavaScript and static typing

This is an incomplete list of tools that aid in detecting type errors in JavaScript and statically typed languages that compile to JavaScript.

  • Flow is a type checker with gradual typing capabilities, classes, parametric polymorphism with constraints (bounded polymorphism), function overloading, union and intersection types, and modules.

  • TypeScript is a typed superset of JavaScript (todo: which version? ES6/7?) backed by Microsoft.It features contextual typing, interfaces and classes, parametric polymorphism (generics with

@mgrabovsky
mgrabovsky / .block
Last active April 10, 2016 08:44 — forked from mbostock/.block
Collapsible Tree
license: gpl-3.0
@mgrabovsky
mgrabovsky / Makefile1
Last active July 22, 2016 12:36
Self-documenting Makefile
#:This list
.PHONY: ?
?:;@for file in "Makefile $$(perl -lne 'print for m|^include\s+(.*)$$|g' Makefile)"; do \
perl -0777 -ne 'while (m/#:\s*(.*?)\n\.PHONY:\s*(.*?)\n/sg) { print "make $$2\t# $$1\n"; }' "$${file}"; \
done | sort -u | column -ts $$'\t'
# Source: https://github.com/gtramontina/sourcing/blob/023cae5/Makefile#L68-L72
@mgrabovsky
mgrabovsky / matematicky-seminar.md
Last active August 26, 2019 10:56
Seznam titulů vydaných v edicích Matematický seminář a Matematika pro vysoké školy technické SNTL
  1. Vlach, M.: Základní numerické metody (1971)
  2. Kohout, V.: Diferenciální geometrie (1971)
  3. Havrda, J.: Matematické programování (1972?)
  4. Kufner, A.: Geometrie Hilbertova prostoru (1973, 1975?)
  5. Beran, L.: Grupy a svazy (1974)
  6. Vlach, M.: Optimální řízení regulovatelných systémů (1975?)
  7. Ježek, J.: Univerzální algebra a teorie modelů (1976?)
  8. ???
  9. Boček, L.: Tenzorový počet (1976)
  10. Pondělíček, B.: Algebraické struktury s binárními operacemi (1977)
@mgrabovsky
mgrabovsky / gist:cbcc9c1fc81f371716f5
Created April 22, 2015 19:07
All GCC sanity warning flags
gcc -v --help 2>&1 | awk '/-W/ && !/=/ && !/[oO]ptions/ && !/larger-than/ { print $1 }'
@mgrabovsky
mgrabovsky / respekt-prepare.sh
Last active August 29, 2015 14:17
Speed up a bunch of MP3 using ffmpeg
for %i in (input/*.mp3) do @ffmpeg -i "input/%i" -filter:a "atempo=1.33" -vn "%i"
@mgrabovsky
mgrabovsky / gist:7912279
Created December 11, 2013 15:22
Generate a sequence akin to 1, 2, 5, 10, 20, 50, ... Useful for log scales and such.
import itertools
([1, 2, 5][i % 3] * 10**(i // 3) for i in itertools.count(0))