Skip to content

Instantly share code, notes, and snippets.

View frafra's full-sized avatar

Francesco Frassinelli frafra

View GitHub Profile
@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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import xml.etree.ElementTree as ET
def getProperties(entry, ns):
for app_property in entry.findall('apps:property', ns):
name = app_property.attrib['name']
if name in ('forwardTo', 'shouldTrash'):
yield name
@frafra
frafra / fedora-itwiki.md
Last active July 21, 2016 23:59
Stato delle pagine della categoria Italiano sul wiki di Fedora Project
#!/usr/bin/python3
#
# Copyright (C) 2016 - 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.
#
# This program is distributed in the hope that it will be useful,
@frafra
frafra / giochino_matematico.py
Created November 16, 2016 22:32
Giochino matematico
#!/usr/bin/python3
import itertools
import operator
seq = [8, 8, 7, 6]
target = 10
ops = [
operator.add,
operator.sub,
@frafra
frafra / select-default-sink.sh
Last active December 28, 2016 18:09
Select default sink for PulseAudio
#!/bin/bash
# select-default-subj.sh
# Description: Select default sink for PulseAudio
# Author: FraFra (Francesco Frassinelli - frafra.eu)
# License: GPLv3
SINKS=($(LC_ALL=C pactl list sinks | grep -P '^\tName: ' | cut -d ' ' -f 2))
DEFAULT=$(LC_ALL=C pactl info | grep '^Default Sink: ' | cut -d ' ' -f 3)
echo "Sinks:"
@frafra
frafra / musica-dal-tubo.sh
Last active April 16, 2017 15:45
Minimalistic graphical interface for extracting audio tracks using youtube-dl
#!/bin/bash -e
title="Estrai traccia audio"
url=$(zenity --entry --title "$title" --text "Inserisci l'indirizzo:")
cd $(xdg-user-dir MUSIC)
youtube-dl --extract-audio --audio-format mp3 $url | zenity --progress --pulsate --title "$title" --text "Stato dello scaricamento"
@frafra
frafra / polimappers-changesets.py
Created May 30, 2017 22:44
Extract OpenStreetMap changesets tagged with #polimappers
#!/usr/bin/env python3
#
# https://github.com/osmcode/pyosmium/issues/39
import osmium
import json
class PolimappersHandler(osmium.SimpleHandler):
def __init__(self):
osmium.SimpleHandler.__init__(self)
@frafra
frafra / poi2coordinates.py
Created June 1, 2017 19:42
Simple script which converts address to coordinates
#!/usr/bin/env python3
import argparse
import json
import urllib.parse
import urllib.request
BASE = 'http://dev.virtualearth.net/REST/v1/Locations?'
parser = argparse.ArgumentParser()