Skip to content

Instantly share code, notes, and snippets.

@vifon
vifon / beet-tag
Created December 19, 2016 23:51
"beet modify" wrapper for files out of the db
#!/bin/bash -e
# beet-tag --- "beet modify" wrapper for files out of the db
# The MIT License
# Copyright (C) 2016 Wojciech Siewierski
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@vifon
vifon / btrfs-migrate.py
Created December 27, 2016 16:07
btrfs-migrate
#!/usr/bin/env python3
"""Copy a bunch of incremental snapshots to a second btrfs.
"""
import argparse
import subprocess
def btrfs_send(target, snapshot, parent=None, dry_run=False):
"""Send a single snapshot to a target directory, optionally reusing
@vifon
vifon / keybase.md
Created February 24, 2017 13:21
keybase.md

Keybase proof

I hereby claim:

  • I am vifon on github.
  • I am vifon (https://keybase.io/vifon) on keybase.
  • I have a public key ASBYJ4jZ6inQvVTJ5Ci1ll087nHhQYtIMoWQjW5EjocIBgo

To claim this, I am signing this object:

@vifon
vifon / sedophile.py
Created May 27, 2017 17:52
sedophile
#!/usr/bin/env python3
# sedophile.py --- A library for those who like sed a bit too much.
# Copyright (C) 2017 Wojciech Siewierski
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
@vifon
vifon / lsblk.pl
Last active July 15, 2017 23:37
lsblk fix for Linux 4.8
#!/usr/bin/env perl
=head1 Fix lsblk on Linux 4.8
On Linux 4.8 the order of devices is screwed up. Let's sort it manually.
=cut
use warnings;
use strict;
@vifon
vifon / jinja-render.py
Created September 30, 2017 11:05
Jinja2 environment variable renderer
#!/usr/bin/env python3
from jinja2 import Template
import argparse
import os
def main(argv=None):
parser = argparse.ArgumentParser()
parser.add_argument('input_file', type=argparse.FileType('r'))
Index: b/ranger/gui/widgets/view_base.py
===================================================================
--- a/ranger/gui/widgets/view_base.py
+++ b/ranger/gui/widgets/view_base.py
@@ -112,15 +112,17 @@ class ViewBase(Widget, DisplayableContai
self.color_reset()
self.need_clear = True
hints = []
- for key, value in self.fm.ui.keybuffer.pointer.items():
- key = key_to_string(key)
@vifon
vifon / pod-refuck.pl
Last active May 24, 2018 12:27
Make the heavily nested Perl docs more readable (though invalid POD)
#!/usr/bin/env perl
use warnings;
use strict;
use 5.010;
use constant INDENT_WIDTH => 2;
my $indent_level = 0;
@vifon
vifon / dotify
Last active June 15, 2018 00:27
Toggle the leading dot in files
#!/bin/zsh
for file in "$@"; do
if [[ "$file:t" = .* ]]; then
mv -v -- "$file" "${file:h}/${${file:t}#.}"
else
mv -v -- "$file" "${file:h}/.${file:t}"
fi
done
@vifon
vifon / commands.py
Last active August 23, 2018 20:41
ranger 2-way chdir
# Patched from ranger commit 8d4808fc
class shell(Command):
escape_macros_for_shell = True
def execute(self):
if self.arg(1) and self.arg(1)[0] == '-':
flags = self.arg(1)[1:]
command = self.rest(2)
else: