Skip to content

Instantly share code, notes, and snippets.

View andreacioni's full-sized avatar

Andrea Cioni andreacioni

View GitHub Profile
@andreacioni
andreacioni / Timeline.js
Created December 11, 2015 15:23
Simple canvas-based timeline to rappresent interval in day
/*var _margin = 20;
var _marg_btw_quart;
var _height;
var _width;
var _cnvElementId;*/
function init() {
//var t = new Timeline('myCanvas',document.getElementById('canvasContainer').clientHeight,document.getElementById('canvasContainer').clientWidth);
var t = new Timeline('myCanvas');
t.drawCanvas();
@andreacioni
andreacioni / openhab
Last active November 24, 2017 18:08
OpenHab 2 start on boot script
#! /bin/sh
### BEGIN INIT INFO
# Provides: openHAB
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop openHAB in screen Session
@andreacioni
andreacioni / wifichk.sh
Last active July 31, 2016 19:59
WiFi Checker - ifconfig version
#!/bin/bash
##################################################################
# A Project of TNET Services, Inc
#
# Title: WiFi_Check
# Author: Kevin Reed (Dweeber)
# dweeber.dweebs@gmail.com
# Project: Raspberry Pi Stuff
#
# Copyright: Copyright (c) 2012 Kevin Reed <kreed@tnet.com>
@andreacioni
andreacioni / wifichk.sh
Last active August 23, 2016 19:25
WiFi Checker - nm version
#!/bin/bash
##################################################################
# A Project of TNET Services, Inc
#
# Title: WiFi_Check
# Author: Kevin Reed (Dweeber)
# dweeber.dweebs@gmail.com
# Project: Raspberry Pi Stuff
#
# Copyright: Copyright (c) 2012 Kevin Reed <kreed@tnet.com>
@andreacioni
andreacioni / ohutil.sh
Last active December 31, 2017 16:12
OpenHab2 .sh script to help backup/restore and install new version
#!/bin/sh
#Usage: ./ohutil.sh <version> (e.g.: ./ohutil.sh 2.2.0)
#In order to run this script you must have installed: wget, unzip, tar
COMMAND=$1
OH_VERSION=$2
DOWNLOAD_URL=https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab%2F$OH_VERSION%2Fopenhab-$OH_VERSION.zip
HOME_PATH=/home/udooer #CHANGE ME!
OH_PATH=$HOME_PATH/openhab #CHANGE ME!
@andreacioni
andreacioni / fand.c
Last active August 2, 2019 18:22
Simple utility program for GNU/Linux systems to control a fan motor of your miniPC (UDOO,Raspberry Pi,Orange Pi,etc) through a PWM signal
/*
A Project of Andrea Cioni
Title: Fan Daemon (FanD)
Author: Andrea Cioni (andreacioni)
cioni95@gmail.com
Copyright:
Copyright (c) 2017 Andrea Cioni <cioni95@gmail.com>
@andreacioni
andreacioni / restartr8169.py
Created December 10, 2017 12:53
Restart 8169 module on startup
from subprocess import call
from time import sleep
while call(["/bin/ping","-c","1","8.8.8.8"]) == 0:
print "Network is not reachable, try restarting r8169 driver"
call(["rmmod","r8169"])
sleep(5)
call(["modprobe","r8169"])
sleep(10)
@andreacioni
andreacioni / torblock.py
Last active December 23, 2017 10:26
Block access to your site from Tor network
#!/usr/bin/env python
"""
This utility script download Tor exit node list IP from the Web and
block every one of them with a dedicated iptables rule.
"""
import logging
from subprocess import call
@andreacioni
andreacioni / install_motion.sh
Created February 15, 2018 17:27
script used to install motion on Raspberry Pi Zero
#!/bin/bash
sudo apt-get update
sudo apt-get install autoconf automake build-essential pkgconf libtool git libzip-dev libjpeg-dev checkinstall
sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libavdevice-dev
sudo apt-get install libjpeg-turbo8 libjpeg-turbo8-dev
sudo apt-get install libwebp-dev
git clone https://github.com/Motion-Project/motion.git
@andreacioni
andreacioni / checktag.sh
Created March 6, 2018 14:42
Checkout git repository to last tag
#!/bin/sh
#From: https://addhewarman.com/2015/01/23/easiest-way-how-to-get-tag-from-remote-github-repository/
LAST_TAG=$(git ls-remote --tags git@github.com:MY_REPOSITORY/"$MY_PROJECT".git | awk '{print $2}' | grep -v '{}' | awk -F"/" '{print $3}' | tail -n 1)
git checkout $LAST_TAG