Skip to content

Instantly share code, notes, and snippets.

@freretuc
freretuc / make-mosquitto-mysql-auth.sh
Created May 12, 2018 18:56
build mosquitto auth mysql plugin Ubuntu
#root else sudo
apt-get update && apt-get -y upgrade
apt-get -y install mosquitto libmosquitto-dev unzip make libssl-dev libmysqlclient-dev gcc build-essential
wget https://github.com/jpmens/mosquitto-auth-plug/archive/master.zip
wget http://mosquitto.org/files/source/mosquitto-1.4.15.tar.gz
unzip master.zip
tar -zxvf mosquitto-1.4.15.tar.gz
cd mosquitto-auth-plug-master/
cp config.mk.in config.mk
nano config.mk
@freretuc
freretuc / ovh-sms.php
Created April 1, 2018 11:45
Simple OVH API SMS
<?php
// include https://gist.github.com/freretuc/bb98f3339ccae5ac91aaea04473df4db
function sendSMS($phone, $message) {
$url = "/sms/sms-xxxxxxxx-y/jobs";
$destinataires = array();
$destinataires[] = $phone;
<?php
$ovh = array();
$ovh['api_url'] = "eu.api.ovh.com";
$ovh['app_key'] = "__APP_KEY__";
$ovh['app_secret'] = "__APP_SECRET__";
$ovh['consumer_key'] = "__CONSUMER_KEY__";
function ovh_time(){
global $ovh;
@freretuc
freretuc / keybase.md
Created January 13, 2018 12:06
keybase.md

Keybase proof

I hereby claim:

  • I am freretuc on github.
  • I am freretuc (https://keybase.io/freretuc) on keybase.
  • I have a public key whose fingerprint is 3C4A 5F80 4E56 A7F7 13C0 9685 0278 3FA6 4AA1 E582

To claim this, I am signing this object:

@freretuc
freretuc / install-snap7.py
Created December 10, 2017 15:05
Check last version, download, extract, compile snap7 on Raspberry PI (need 7zip)
#!/usr/bin/env python3
import glob
import os
import platform
import urllib.request
import re
import shutil
import sys
@freretuc
freretuc / backup.sh
Created August 11, 2017 16:35
mysqldump + duplicity on swift container
#!/bin/sh
# Delete old dumps
find /var/www/.backup/ -type f -exec rm -v {} \;
#####
DATE=`date +"%y%m%d_%Hh%M"`
DB_FILE=/var/www/.backup/dump.${DATE}.sql
@freretuc
freretuc / modPLCFunctions.vb
Created June 11, 2017 10:53
Functions to convert byte to object or objects to byte (Snap7 VB.NET)
Module modPLCFunctions
' Converti depuis C#
' https://github.com/mesta1/Sharp7-example/blob/master/Sharp7Library/Sharp7.cs
' "decimicros" between 0001-01-01 00:00:00 and 1970-01-01 00:00:00
Private bias As Int64 = 621355968000000000
Public Function ConvertBCDtoByte(ByVal B As Byte) As Integer
@freretuc
freretuc / isHoliday.php
Created April 29, 2017 06:39
Vérifie qu'une date est fériée en France (incluant l'Alsace Moselle)
<?php
// $day doit être en format timestamp
function isHoliday($day) {
$paques = easter_date(date("Y", $day));
$ferie = array('01-01', '01-05', '08-05', '14-07', '15-08', '01-11', '11-11', '25-12');
$ferie[] = '26-12'; // Lendemain de Noël - Alsace Moselle
$ferie[] = date("d-m", $paques - (2 * 24 * 3600)); // Vendredi Saint - Alsace Moselle
@freretuc
freretuc / setup.sh
Last active April 17, 2017 12:26
Overpass API setup
# http://wiki.openstreetmap.org/wiki/Overpass_API/Installation
# Ubuntu 16.04
# Intel(R) Xeon(R) CPU W3520 @ 2.67GHz
# 16GB RAM
# 2To
# update && upgrade
apt-get update && apt-get -y upgrade
@freretuc
freretuc / modSQL.vb
Created August 31, 2016 08:55
vb.net MySQL
Imports MySql.Data.MySqlClient
Public SQLServer As New MySqlConnection
Public Sub SQLOpen()
Try
If Not SQLServer Is Nothing Then SQLServer.Close()
Catch ex As Exception
End Try