Skip to content

Instantly share code, notes, and snippets.

View frafra's full-sized avatar

Francesco Frassinelli frafra

View GitHub Profile
@frafra
frafra / seren-zeroconf.sh
Created May 15, 2015 10:47
Seren autocalling local hosts using zeroconf/avahi
#!/usr/bin/bash
service="_seren._udp"
# Select a random host
host=$(avahi-browse -d local $service -tpr | grep ";$service;" | grep -e '^=;' | sort -R | head -n1)
avahi-publish -s "Seren for $(hostname)" $service 8110 &
pid=$!
if [ -z "$service" ]
/*
* Copyright (c) 2015, Marco Motta.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@frafra
frafra / united_music_playlist.sh
Created July 10, 2013 14:05
Little project for generating United Music web radios XSPF playlist
#!/bin/bash
#
# Copyright (C) 2013 Francesco Frassinelli (FraFra - http://frafra.eu)
# License: GPLv3
#
# Special thanks to: http://blog.redaelli.eu/2010/03/lista-di-radio-su-unitedradioit.html
filename="unitedradio-it.xspf"
server="http://shoutcast.unitedradio.it"
@frafra
frafra / divide.py
Created October 3, 2013 19:35
Split every PDF page in 2 or 4 parts
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2013 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 / click_timing.sh
Last active December 26, 2015 06:29
Calculate interval between two clicks
#!/bin/bash
DEV="/dev/input/mouse0"
SEQ="ht nul nul"
function click_event {
stdbuf -oL od -w3 -t a -A n "$DEV" | grep -m1 "$SEQ" > /dev/null
}
click_event
@frafra
frafra / select-default-source.sh
Created November 13, 2013 18:56
Select default source for PulseAudio
#!/bin/bash
# select-default-source.sh
# Description: Select default source for PulseAudio
# Author: FraFra (Francesco Frassinelli - frafra.eu)
# License: GPLv3
SOURCES=($(LC_ALL=C pactl list sources | grep -P '^\tName: ' | cut -d ' ' -f 2))
DEFAULT=$(LC_ALL=C pactl info | grep '^Default Source: ' | cut -d ' ' -f 3)
echo "Sources:"
#!/bin/bash
# organize-your-files.sh
# Description: Organize your files
# Author: FraFra (Francesco Frassinelli - frafra.eu)
# License: GPLv3
#
# Idea presa da:
# http://magliettabianca.blogspot.it/2013/11/bash-guida-allautomazione-organizzare-i.html
#
# Questa versione migliora alcuni aspetti:
@frafra
frafra / bici-in-città.sh
Created November 28, 2013 21:10
Mostra lo stato delle stazioni per le biciclette di Savona
#!/bin/bash
SAVONA='http://www.bicincitta.com/citta_v3.asp?id=43&pag=2'
NAME="bici-in-città"
temp=$(mktemp --suffix=$NAME)
curl -s $SAVONA -o $temp
code=$(grep 'var sita_n' $temp | cut -d\" -f2,4 --output-delimiter=)
IFS=$'_' places=($code)
@frafra
frafra / sms-from-bash.sh
Last active January 1, 2016 18:09
Send SMS using USB dongle or smartphone
#!/bin/bash
# sms-from-bash.sh
# Description: Send SMS using USB dongle or smartphone
# Author: FraFra (Francesco Frassinelli - frafra.eu)
# License: GPLv3
MODEM=/dev/ttyACM0
T=3
if [ ! -w $MODEM ]
#!/usr/bin/python3
# https://fedoraproject.org/wiki/Packaging:Guidelines#File_and_Directory_Ownership
# Made by Frafra
import collections
import rpm
def depchain_check(pkg, pkgs):
ts = rpm.TransactionSet()
ts.addErase(pkg)