Skip to content

Instantly share code, notes, and snippets.

View okurka12's full-sized avatar
♥️

Vít Pavlík okurka12

♥️
View GitHub Profile
@okurka12
okurka12 / utils.sh
Created June 9, 2024 10:25
utilities for POSIX shell
# ask if something is ok, exit if it's not
# if OPTION_Y variable is "-y", do nothing
prompt_confirm () {
if [ "$OPTION_Y" != "-y" ]; then
printf "%s (y/n) " "$*"
read -r PROCEED
if [ "$PROCEED" != "y" ]; then
echo "abort"
exit
fi
@okurka12
okurka12 / customize-bash.sh
Last active June 9, 2024 12:00
retrieve & update my .bashrc or .bash_aliases
#!/bin/sh
ALIASES_URL=https://gist.githubusercontent.com/okurka12/cc3769db8e6f57dfdf091428095b7e00/raw
ALIASES_BACKUP=.bash_aliases.old
ALIASES_NEW=.bash_aliases.new
# ask if something is ok, exit if it's not
# if OPTION_Y variable is "-y", do nothing
prompt_confirm () {
@okurka12
okurka12 / cdd.sh
Created June 8, 2024 11:23
a bash function to mkdir & cd
#
# a bash function to mkdir and cd
# add to the end of .bashrc
#
# author: vit pavlik
#
# command to change directory to a diractory that doesnt exist yet
cdd () {
if [ ! -d "$1" ]; then
@okurka12
okurka12 / asciify_czech.py
Last active March 15, 2024 09:39
Replaces letters with diacritics in a czech text
#
# Prints the contents of `original_string` without diacritics.
# Expects a text in czech language.
#
# Author: okurka12
#
# Date: 2024-03-11
#
PRINT_BLOAT = False
@okurka12
okurka12 / snap.bat
Created January 24, 2024 00:13
Creates a snapshot of a file.
@echo off
setlocal enabledelayedexpansion
rem
rem Usage: .\snap.bat
rem
rem Upon invocation, copies `name.ext` to `name_1.ext`.
rem If `name_1.ext` already exists, copies to `name_2.ext`,
rem then `name_3.ext` and so on...
rem
@okurka12
okurka12 / kmp_prefix.py
Created January 23, 2024 00:16
Generation of the prefix table for the Knuth-Morris-Pratt algorithm
#
# part of the knuth-morris-pratt algorithm:
# generation of the prefix table/fail vector
#
# víteček 🔥💯 (okurka12), January 2024
#
def ppre(s: str) -> set[str]:
"""returns a set of all proper prefixes of `s`"""
@okurka12
okurka12 / .bash_aliases
Last active June 3, 2024 02:41
my favorite bash aliases
#
# My favorite aliases for bash
#
# for vanilla debian installations (where there's no poweroff cmd)
alias shutdown='sudo systemctl poweroff'
alias poweroff='sudo systemctl poweroff'
# those can be uncommented directly in .bashrc but why not have it here
alias grep='grep --color=auto'
@okurka12
okurka12 / exams.py
Created December 18, 2023 07:14
decide which exams to skip to have calmer examination period
# Author: víteček 🔥💯 (okurka12)
#
# The script tries to pick the right exams according to the defined criteria
# and it does so randomly
#
# exam dates are hard-coded below in the `exams` list
#
from random import shuffle
# Wishest thou to embark upon the logging endeavor?
@okurka12
okurka12 / enviro.bat
Last active August 23, 2023 15:34
a windows batch script that opens various shells and a text editor in the specified directory
:: Author: Vit Pavlik (okurka12)
:: Date: 2023-08-23
:: this is a script `enviro.bat` to be located in %userprofile%. it's purpose
:: is to run all necessary tools/editors/shells needed for various projects
:: why %userprofile%?
:: %userprofile% where the windows run dialog's "current directory" is.
:: what I mean is programs can be run from %userprofile% with the windows
:: run dialog window, even though %usrprofile% is not in path.
@okurka12
okurka12 / c_tabular_macro.c
Created July 22, 2023 04:29
Tabulkove makro v C
/******************************************************************************/
/* TABULKOVA MAKRA */
/******************************************************************************/
/**
* tak jak nam je ukazoval dr. Peringer 2. 5. 2023 na prednasce
* pry to objevil nekde v kodu GCC
*/
#undef ROW /* to be defined later */