Skip to content

Instantly share code, notes, and snippets.

View frafra's full-sized avatar

Francesco Frassinelli frafra

View GitHub Profile
@frafra
frafra / did-i-forget-to-backup-something.py
Last active August 29, 2015 14:08
Check if there are missing files in your backup (based on filenames)
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2014 Francesco Frassinelli
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
from datetime import date
for y in [2015]:
for m in range(12):
for d in [1, 19]: # first monday, third friday (7*2+5)
print(date(y, m+1, (7-date(y, m+1, 1).weekday())%7+d))
@frafra
frafra / conway-bruteforce.py
Created November 9, 2014 11:36
Conway's game of life: looking for repeating patterns
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2014 Francesco Frassinelli <fraph24@gmail.com>
#
# pylife is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#!/usr/bin/env python
#
# frafra-display-levenshtein.py
#
# Copyright (C) 2014 - Francesco Frassinelli
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
@frafra
frafra / ext4-checksum.sh
Created January 9, 2015 15:11
ext4 with checksums
#!/bin/bash
#
# By Frafra (http://frafra.eu)
#(shopt -s globstar;
# for f in **
# do
# if [ -f "$f" ]
# then
# echo -ne "$f\0"
@frafra
frafra / dnsmasq-block-ads.sh
Last active June 26, 2016 02:50
dnsmasq block ads
#!/bin/bash
curl -s "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&showintro=0&mimetype=plaintext" \
| sed 's;^\(.*\)$;address="/\1/127.0.0.1";' | sudo tee /etc/dnsmasq.d/ads >/dev/null
@frafra
frafra / email-archiver.py
Created February 7, 2015 18:04
Save your emails to file (both content and attachments)
#!/usr/bin/env python
#! coding: utf-8 -*-
#
# email-archiver.py
#
# Copyright (C) 2015 - Francesco Frassinelli
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
@frafra
frafra / nmcli-remove-manual-dns.sh
Created February 18, 2015 10:50
Remove manual DNS entries from active connections using nmcli
#!/bin/bash
for id in $(nmcli -t -f UUID c s -a)
do
dnss=$(nmcli -t -f ipv4.dns c s $id | cut -d: -f2- | tr -d ,)
for dns in $dnss
do
nmcli c m $id -ipv4.dns 0
done
done
@frafra
frafra / cisco-fwsm-parser.py
Created February 19, 2015 22:22
CISCO FWSM parser (draft)
#!/usr/bin/env python3
#
# cisco-fwsm-parser.py
#
# Copyright (C) 2015 - Francesco Frassinelli
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
@frafra
frafra / 05-batman
Last active February 10, 2023 08:44
NetworkManager integration with batman-adv
#!/bin/sh
#
# /etc/NetworkManager/dispatcher.d/05-batman
ESSID="Igloo mesh"
IFACE="wlp2s0"
ADDR="01:23:45:67:89:AB"
function current {
nmcli -t -f GENERAL.CONNECTION d show $IFACE | cut -d\: -f2