Skip to content

Instantly share code, notes, and snippets.

View xkr47's full-sized avatar

Jonas Berlin xkr47

View GitHub Profile
@xkr47
xkr47 / btrfs-info.sh
Created December 5, 2023 10:47
Dump all kinds of info for btrfs mounts
#!/bin/bash
[ "$#" = 1 ]
r () {
echo -ne "\033[1m------ "
echo -n "$@"
echo -e "\033[m"
"$@"
}
@xkr47
xkr47 / fmt_write.rs
Last active December 14, 2022 13:27
UTF-8 -emitting fmt::Write wrapper for io::Write
struct FmtWriter<W: std::io::Write>(W);
impl <W: std::io::Write> std::fmt::Write for FmtWriter<W> {
fn write_str(&mut self, s: &str) -> fmt::Result {
self.0.write_all(s.as_bytes()).map_err(|_| fmt::Error)
}
}
@xkr47
xkr47 / README.md
Last active November 28, 2021 10:10
VDR 2.4.0 channels.conf for DVB-C channels of Karis Telefon / Karjaan puhelin 2021-11-26

VDR 2.4.0 channels.conf for DVB-C channels of Karis Telefon / Karjaan puhelin 2021-11-26

Produced using w_scan -fc -c FI -Q1 -S1 -o21 using w-scan version 20170107-2

@xkr47
xkr47 / git-fetch-sha
Last active July 26, 2021 08:41
Fetch commit by SHA from remote even if not attached to a branch — useful for e.g. force-pushed PRs whose earlier commits are no longer directly available
#!/bin/bash
# by Jonas Berlin 2021 from https://gist.github.com/xkr47/a82d710092847a39901a563b22e82b4b
# 1. Place in e.g. $HOME/bin/git-fetch-sha
# 2. Run "git fetch-sha" for usage
set -e
remote="$1"
sha="$2"
@xkr47
xkr47 / libera.irssi
Last active September 28, 2023 09:39
How to add the libera.chat network to irssi
Replace all <....> parts with your specific details
/network add -nick <nick> libera
/server add -network libera -auto -ssl irc.libera.chat 6697
/connect libera
/query NickServ
register <password> <email>
<copypaste line from email>
/network add -autosendcmd "" -sasl_username <user> -sasl_password <pass> -sasl_mechanism PLAIN libera
/channel add -auto <channel> libera
@xkr47
xkr47 / README.md
Last active June 16, 2023 07:11
Script for moving/renaming files/directories arbitrarily in whole git history of single branch, using perl expressions

Install into PATH e.g. $HOME/bin/ as "git-filter-mv" and chmod a+rx git-filter-mv

It works with any special characters in filenames like tabs and linefeeds. It works with empty commits.

Based on example from git-filter-branch manpage.

If you want to print debug messages, use STDERR e.g. print STDERR "File: $_\n";

Examples:

@xkr47
xkr47 / git-alias.sh
Last active September 25, 2020 06:32
"git alias" command for adding/removing/editing git aliases conveniently
#!/bin/bash
set -eo pipefail
usage () {
cat <<'EOF'
usage:
git alias [<options>]
git alias [<options>] name
git alias [<options>] name newvalue
@xkr47
xkr47 / Cargo.toml
Last active June 19, 2020 18:39
Seriously funny rust error message
[package]
name = "x"
version = "0.1.0"
edition = "2018"
[dependencies]
dbus = "0.8.1"
@xkr47
xkr47 / README.md
Last active November 11, 2019 12:20
Simple calculator in https://raku.org/ language, with support for time durations & base 2..36

Example session:

2+3

Result: 5₁₀

5d

Result: 5,00:00:00 = 5.000000 days
         120:00:00 = 120.000000 hours
@xkr47
xkr47 / doodle.css
Last active September 24, 2019 09:36
Fix Doodle to use full screen width and to stop resetting the horizontal scrolling when scrolling "outside" the vote table
.d-pagesContainer {
max-width: unset !important;
}
.d-expandableScrollContainer {
overflow: visible !important;
background: white;
max-width: unset !important;
width: unset !important;
}
#d-participationPage #d-metadataView .d-pollMetadataRow, #d-participationPage #d-metadataView .d-pollHiddenButton.d-silentButton {