Skip to content

Instantly share code, notes, and snippets.

View okurka12's full-sized avatar
♥️

Vít Pavlík okurka12

♥️
View GitHub Profile
#!/bin/bash
#
# originally from ima2-sbirka repo
#
# brief:
# ------
#
# A script to convert a single svg file to pdf
# Usage: ./svg2pdf SVGFILE
@okurka12
okurka12 / bash-to-fish.sh
Created July 24, 2024 10:58
imports aliases from .bash_aliases to config.fish as abbreviations
#!/bin/bash
#
# imports aliases from .bash_aliases to config.fish as abbreviations
#
FISHCFG=~/.config/fish/config.fish
BASH_ALIASES=~/.bash_aliases
echo "" >> $FISHCFG
set autoindent
set guidestripe 80
#
# for fish shell:
# .. put it into ~/.config/fish/config.fish
# .. tested with fish 3.7.1
#
# cd's into a directory and creates it if it doesn't
# exist yet
#
# USAGE: cdd DIR
#
@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
Last active July 12, 2024 00:41
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 directory that doesnt exist yet
cdd () {
if [ ! -d "$1" ]; then
@okurka12
okurka12 / asciify_czech.py
Last active July 21, 2024 01:07
Replaces letters with diacritics in a czech text
#
# Prints stdin input without diacritics.
# Expects a text in czech language.
#
# Author: okurka12
#
# Date: 2024-07-21
#
# reads from stdin and outputs on stdout
#
@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`"""