Skip to content

Instantly share code, notes, and snippets.

View alessandroiori's full-sized avatar

Alessandro Iori alessandroiori

View GitHub Profile
@alessandroiori
alessandroiori / google_app_script_post_json_to_sheet.js
Last active May 29, 2020 13:11
How to popolate a Google Sheet CSV from JSON POST response with a Google App Script.
function myFunction() {
/*
source 1: //https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app
source 2: //https://developers.google.com/apps-script/reference/spreadsheet/sheet#getlastrow
*/
var data = {'AAAAA': 'BBBBB', 'CCCCCC': 'DDDDD'};
var headers = {'x-api-key': 'AAAAAA'}
var options = {
'method' : 'post',
@alessandroiori
alessandroiori / sniffer_wifi.py
Last active October 2, 2018 15:44
Simple Linux Sniffer WiFi with Scapy
# Simple Linux Sniffer WiFi
#
# $ python3 sniffer_wifi.py -h
#
# Based on https://github.com/0x90/wifi-scripts/blob/master/sniff/iSniff.py
from scapy.all import *
from datetime import datetime
from time import time
from pprint import pprint
@alessandroiori
alessandroiori / test_argparse.py
Created October 2, 2018 15:14
argparse example
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
'''
$ python3 test_argparse.py -h
'''
if __name__ == '__main__':
parser = ArgumentParser('TestARGPARSE', description='Easy script for testing ARGPARSE',
formatter_class=ArgumentDefaultsHelpFormatter)
parser.add_argument('-i', '--interface', default='wlan1', required=False, help='Interface to used')
@alessandroiori
alessandroiori / udp_server.py
Created May 8, 2018 14:59 — forked from majek/udp_server.py
Simple python udp server
import logging
import socket
log = logging.getLogger('udp_server')
def udp_server(host='127.0.0.1', port=1234):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
import serial
import time
import sys
default_port = '/dev/tty.usbserial-FT9UE01T'
default_baudrate = 9600
EXIT_CMD = 'exit'
COMMANDS = {
'reboot': 'AT+NRB',
@alessandroiori
alessandroiori / remove_attrs.py
Created April 17, 2018 11:05 — forked from revotu/remove_attrs.py
remove all HTML attributes with BeautifulSoup except some tags(<a> <img>...)
from bs4 import BeautifulSoup
# remove all attributes
def _remove_all_attrs(soup):
for tag in soup.find_all(True):
tag.attrs = {}
return soup
# remove all attributes except some tags
def _remove_all_attrs_except(soup):
@alessandroiori
alessandroiori / kitchenTimer.cpp
Created April 3, 2018 21:54
Arduino timer library
/*
* kitchenTimer.cpp
*
* version 0.1.2
*
* created by Alessandro Iori
*
*/
#include "KitchenTimer.h"
@alessandroiori
alessandroiori / docker-install-rpi3.md
Created March 29, 2018 12:38 — forked from tyrell/docker-install-rpi3.md
Installing latest Docker on a Raspberry Pi 3

Introduction

I wrote this gist to record the steps I followed to get docker running in my Raspberry Pi 3. The ARM ported debian version (Jessie) comes with an old version of docker. It is so old that the docker hub it tries to interact with doesn't work anymore :)

Hopefully this gist will help someone else to get docker running in their Raspberry Pi 3.

Installation

From original instructions at http://blog.hypriot.com/post/run-docker-rpi3-with-wifi/

"""
im_online.py (0.0.0)
Send email with ip to [email protected].
Run:
$ pyhon3 im_online.py [email protected]
Run script on wakeup:
- Raspberry. Add before "exit(0)" in file "/etc/rc.local": $ python3 /path/to/file/im_online.py [email protected] &
# source: https://github.com/thisbejim/Pyrebase
import pyrebase
config = {
"apiKey": "apiKey",
"authDomain": "projectId.firebaseapp.com",
"databaseURL": "https://databaseName.firebaseio.com",
"storageBucket": "projectId.appspot.com",
"serviceAccount": "path/to/serviceAccountCredentials.json"
}