Skip to content

Instantly share code, notes, and snippets.

View miloslavnosek's full-sized avatar

Miloslav Nosek miloslavnosek

View GitHub Profile
@miloslavnosek
miloslavnosek / _.md
Created June 4, 2023 20:16 — forked from dAnjou/_.md
Automatically unlock KeePass database with GNOME Keyring

(Tested with KeePassXC on Fedora 25)

By default when using GNOME Keyring you have a keyring that is unlocked when you log in (usually called "Login"). You can make use of that by storing a KeePass database password in this keyring and using it to automatically unlock your KeePass database.

Store the KeePass database password in GNOME Keyring. You'll have to set a label and at least one attribute/value pair. The label is displayed in a GNOME keyring manager (e.g. Seahorse), the attribute/value pair should be a unique identifier because it's needed for the lookup. I suggest to use keepass as attribute and the database name as value (make sure it doesn't contain any spaces).

secret-tool store --label="KeePass <database_name>" keepass <database_name>

Then create a script to launch and immediately unlock your KeePass database.

@miloslavnosek
miloslavnosek / 0_weather.sh
Last active May 1, 2023 13:51
Scrape hourly weather for given day and location
#!/bin/sh
declare -A locations=(
["berlin"]=2-2950159
)
default_location=${locations["berlin"]}
if [[ $1 != '' ]]; then location=${locations[$1]}; else location=${default_location}; fi
if [[ $2 != '' ]]; then day_from_now=$2; else day_from_now=0; fi
@miloslavnosek
miloslavnosek / flac-to-mp3.sh
Created October 24, 2021 07:24
Flac to MP3 320kbps conversion via ffmpeg
#!/bin/bash
for a in ./*.flac; do
< /dev/null ffmpeg -i "$a" -ab 320k -map_metadata 0 -id3v2_version 3 "${a[@]/%flac/mp3}"
done
@miloslavnosek
miloslavnosek / win_to_wsl_path_replacer.exs
Last active June 20, 2021 16:22
Replaces classic string with Windows path to WSL path
defmodule WinToWslPathReplacer.PathHandler do
@moduledoc """
Takes care of converting Windows to WSL path string
"""
def convert(path) do
path
|> String.replace("C:", "/mnt/c")
|> String.replace("D:", "/mnt/d")
|> String.replace("\\", "/")
|> String.replace("\n", "")
@miloslavnosek
miloslavnosek / simple_interval_backup.exs
Last active April 25, 2021 08:00
Elixir script for backing up directories in intervals
defmodule SimpleIntervalBackup.Time do
@moduledoc """
Interval time related helpers
"""
def minutes_to_millis(minutes) do
minutes * 60000
end
end
defmodule SimpleIntervalBackup.Interval do