Skip to content

Instantly share code, notes, and snippets.

View nbergont's full-sized avatar

Bergont Nicolas nbergont

View GitHub Profile
@nbergont
nbergont / TinyMutex.h
Created December 12, 2013 16:30
Just a mutex class
#ifndef TinyMutex_h
#define TinyMutex_h
#if defined(_WIN32) || defined(__WIN32__)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <process.h>
#elif defined(__GNUC__)
#include <pthread.h>
#endif
@nbergont
nbergont / strformat.cpp
Created December 12, 2013 16:33
Formateur de chaine de caratère std::string à la manière Qt (voir QString)
#include "strformat.h"
#include <iomanip>
#include <cassert>
strformat::strformat(const std::string &str) : _str(str), _level(1)
{
}
strformat &strformat::arg(const std::string &str1)
@nbergont
nbergont / QConsoleWidget.cpp
Last active December 31, 2015 03:59
Widget console de log pour Qt. Exemple : int main() { InstallQConsoleMsgHandler(); ... }
#include "QConsoleWidget.h"
#include <QMutex>
#include <QAction>
#define HTML_CONSOLE_MODE
#if QT_VERSION >= 0x050000
static QtMessageHandler _old_handler = 0;
#else
static QtMsgHandler _old_handler = 0;
@nbergont
nbergont / RER.py
Last active January 3, 2016 06:58
Affiche les horaires du RER (comme les vieux afficheurs en gare)
import requests
from bs4 import BeautifulSoup
import pygame
from pygame.locals import *
import time
def readHtml():
payload = {'origine': 'Massy Palaiseau', 'origineCode': 'MPU', 'origineData' : '', 'destination' : '', 'destinationCode' : '', 'destinationData' : ''}
r = requests.post('http://www.transilien.mobi/train/result', data=payload)
print "STATUS CODE = " + str(r.status_code)
@nbergont
nbergont / slideshow.qml
Last active March 12, 2019 10:01
QML slideshow with KenBurns effect
import QtQuick 2.0
import Qt.labs.folderlistmodel 2.0
/**
--- QML Ken Burns slideshow ---
Work well on Raspberry Pi (resize image 1920*1600 max before ...)
call :
qmlscene slideshow.qml path="/home/img"
qmlscene.exe slideshow.qml path="/C:/test/img"
**/
Rectangle {
@nbergont
nbergont / fade.ino
Last active December 24, 2018 09:20
fastled light for stairs
#include <FastLED.h>
#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
#warning "Requires FastLED 3.1 or later; check github for latest code."
#endif
#define NUM_LEDS 150
#define DATA_PIN 3
#define BRIGHTNESS 150
#define FRAMES_PER_SECOND 60
@nbergont
nbergont / StairLed.ino
Created February 17, 2019 19:58
Stair leds animation
#include <FastLED.h>
#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
#warning "Requires FastLED 3.1 or later; check github for latest code."
#endif
#define NUM_LEDS 130
#define DATA_PIN 3
#define BRIGHTNESS 200
#define FRAMES_PER_SECOND 60
@nbergont
nbergont / configuration.yaml
Created April 28, 2019 17:13
Home Assistant configuration for Poêle Palazetti CBox
# Change with your IP !!!
sensor:
- platform: rest
resource: http://192.168.1.33/cgi-bin/sendmsg.lua?cmd=EXT+ADRD+2066+1
name: poele_nb_allumage
value_template: '{{ value_json.DATA.ADDR_2066 }}'
scan_interval: 3600
- platform: rest