Skip to content

Instantly share code, notes, and snippets.

View frafra's full-sized avatar

Francesco Frassinelli frafra

View GitHub Profile
@frafra
frafra / ydlredirect-bookmarklet.js
Created August 29, 2014 09:04
(youtube-dl) + web service + bookmarklet = play just the video/no Flash
javascript:(function(){window.location='http://localhost:8080?url='+window.btoa(unescape(encodeURIComponent(window.location)));})()
@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 / 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 / disable-video-output.sh
Last active August 29, 2015 14:18
Disable ghosts video outputs on Linux
#!/bin/bash -e
#
# How to run this script:
# $ (source <(curl https://gist.githubusercontent.com/frafra/babfe4c32478923687ea/raw))
DIR=/sys/class/drm
REGEX="(card[0-9]+-(.+))"
OUTPUTS=($(for f in $DIR/*
do [[ $f =~ $REGEX ]] && echo ${BASH_REMATCH[1]} || true
done))