Skip to content

Instantly share code, notes, and snippets.

@tux-00
tux-00 / timeit_fct.py
Last active March 21, 2017 15:46
Measure execution time of a function
import timeit
timeit.timeit(fct, number=10)
@tux-00
tux-00 / vim.md
Last active July 19, 2017 08:18
Vim

Replace and ask for confirmation

:%s/foo/bar/gc

@tux-00
tux-00 / install_neovim.md
Created August 1, 2017 12:44
Install neovim

Install package

apt-get install neovim

Create conf dir

mkdir -p ~/.config/nvim

Link with old vim config file

ln -s ~/.vimrc ~/.config/nvim/init.vim

Install vim-plug

curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

@tux-00
tux-00 / iptables.service
Created July 23, 2018 17:23
iptables systemd service file
[Unit]
Description=Add iptables rules
After=systemd-sysctl.service
Before=sysinit.target
[Service]
Type=oneshot
ExecStart=/sbin/iptables-restore /etc/iptables.up.rules
ExecReload=/sbin/iptables-restore /etc/iptables.up.rules
RemainAfterExit=yes
@tux-00
tux-00 / configparser_to_dataclasses.py
Created August 20, 2018 18:20
Converts python config parser to dataclasses (easier access)
import configparser
from dataclasses import dataclass
@dataclass
class Sections:
raw_sections: dict
def __post_init__(self):
for section_key, section_value in self.raw_sections.items():