Skip to content

Instantly share code, notes, and snippets.

@floreo
floreo / index.php
Last active August 16, 2018 19:36
Philips HUE reverse proxy
<?php
/*
* Activate proxy_module and proxy_http_module
*/
ignore_user_abort(true);
$mac_address = [ '<mac address of the real bridge>', '<your fake Philips HUE mac address>' ];
$ip_hue = [ '<ip of the real bridge>', '<ip of your PI>' ];
$bridge_id = [ '<the real bridge id>', '<faked id bridge>' ];
@floreo
floreo / xbox360.sh
Last active April 12, 2018 15:31
xbox360 controllers with xboxdrv
#!/usr/bin/env bash
# apt install xboxdrv
# added at session opening
# visudo -f /etc/sudoers.d/xbox360
# floreo ALL = (root) NOPASSWD: /usr/bin/xboxdrv
sudo xboxdrv --daemon --dbus session \
-i 0 --wid 0 --detach-kernel-driver --mimic-xpad \
--next-controller -i 0 --wid 1 --detach-kernel-driver --mimic-xpad \
@floreo
floreo / LE_ocsp.sh
Created February 28, 2018 21:25
Bash script to generate OCSP for HAProy
#!/usr/bin/env bash
# Generate OCSP file for every pem
# http://www.jinnko.org/2015/03/ocsp-stapling-with-haproxy.html
# Set a cron every few hours or dayli
## CONFIGURATION ##
_LE_ROOT_DIR="/root/LE/"
_LE_CONF_DIR="${_LE_ROOT_DIR}conf/"
@floreo
floreo / backup.sh
Last active January 7, 2018 18:04
Server backup script using Duplicity and GnuPG
#!/usr/bin/env bash
_FTP_PASSWORD=""
_FTP_USER=""
_FTP_HOST=""
_FTP_DIRECTORY=""
_GPG_KEY=""
_BACKUP_OUTPUT="$( mktemp )"
_BACKUP_EMAIL=""
_BACKUP_TYPE="incremental"
@floreo
floreo / alert.sh
Created September 24, 2017 20:38
Philips HUE alert for GMAIL // make blink a lamp when finding emails
#!/usr/bin/env bash
_mail="" # without the @gmail.com
_password=""
_mailcount="$( curl -u ${_mail}:${_password} --silent "https://mail.google.com/mail/feed/atom" | sed -re 's@.*<fullcount>([0-9]+)</fullcount>.*@\1@' )"
if [ -n "${_mailcount}" ] && [ "${_mailcount}" -gt 0 ] ; then
curl -X PUT -d '{ "alert": "select" }' http://<hub IP>/api/<api key>/lights/<light number>/state &>/dev/null
fi
@floreo
floreo / calendar_astreinte.sh
Created July 12, 2017 20:26
Bash script to import ICS into Radicale
#!/usr/bin/env bash
# This script import an ics calendar into Radicale
#TODO: check if the current calendar is up to date before to import it, I tried downloading it and comparing checksums but events ain't in the same order :(
declare -r _RADICALE_CALENDAR_URL="<URL of you Radicale calendar"
declare -r _ICS_CALENDAR_URL="<URL of your ICS calendar>"
declare -r _USERPASSWD="<user>:<password>"
_TEMPORARY_ICS="$(mktemp)"
@floreo
floreo / network-graphviz.sh
Created July 6, 2017 21:08
Funny script to make a graph of the current connections
#!/usr/bin/env bash
# requires graphviz
dot -Tpng -o network-$(date +%Y-%m-%d-%H-%M-%S).png < <(sudo netstat -ntu | awk 'BEGIN \
{
print "digraph network {\n\tsize=\"35\" node [shape = circle, style=filled];\n\tratio = fill;\n\trankdir=LR;"; \
} \
/^(ud|tc)p.+/ \
{
@floreo
floreo / pid.sh
Created May 2, 2017 19:24
Simple pid script
#!/usr/bin/env bash
_pid="$HOME/$0.pid"
while :
do
if [ ! -s "${_pid}" ] ; then
echo $$ >"${_pid}"
echo "Doing real stuff"
rm "${_pid}"
@floreo
floreo / LE.sh
Last active March 12, 2017 20:11
bash script to generate Let's Encrypt certificates through Acme Tiny
#!/usr/bin/env bash
## README ##
#
# * Whats does it require ?
# To download or clone https://github.com/diafygi/acme-tiny inside _LE_ACME_DIR
#
# * How to write a correct conf file ?
# Write a file named myname.conf inside _LE_CONF_DIR
# hHre's the content:
@floreo
floreo / spoof.php
Last active March 10, 2017 22:06
Mail Spoofing Gmail like
<?php
// howto: php -c <(echo "mail.add_x_header=0") mail.php
$to = "";
$from = "User <real from>";
$spoof="fake mail";
$headers = "Reply-To: $spoof\r\n" .
"Content-type: text/plain; charset=utf-8\r\n".