Skip to content

Instantly share code, notes, and snippets.

View pyrou's full-sized avatar

⭐️ Michael pyrou

View GitHub Profile
@pyrou
pyrou / docker-compose.yml
Last active April 18, 2024 05:20
Use https://traefik.me SSL certificates for local HTTPS without having to touch your /etc/hosts or your certificate CA.
version: '3'
services:
traefik:
restart: unless-stopped
image: traefik:v2.0.2
ports:
- "80:80"
- "443:443"
labels:
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
@pyrou
pyrou / rfxcom2mqtt.js
Created January 26, 2024 21:31
Super simple rfxcom mqtt bridge that support Somfy RTS (RFY) and lighting2
const mqtt = require("mqtt");
const rfxcom = require('rfxcom')
const rfxtrx = new rfxcom.RfxCom("/dev/serial/by-id/usb-RFXCOM_RFXtrx433_A1YVC00T-if00-port0", {debug: true});
const lighting2 = new rfxcom.Lighting2(rfxtrx, rfxcom.lighting2.HOMEEASY_EU);
const rfy = new rfxcom.Rfy(rfxtrx, rfxcom.rfy.RFY, {venetianBlindsMode: "EU"});
const onJsonMessage = (topic, payload) => {
const path = topic.split('/')
@pyrou
pyrou / BindableStore.swift
Last active July 3, 2019 22:42
SwiftUI Todo list prototype using ReSwift
//
// BindableStore.swift
// SwiftUIExperiment
//
// Created by Michael Hurni on 06/06/2019.
// Copyright © 2019 SwitchKit. All rights reserved.
//
import Combine
import SwiftUI
@pyrou
pyrou / ViewController.m
Last active October 20, 2018 16:51
App Store Today tile touch effect
//
// ViewController.m
// tile
//
// Created by Michael Hurni on 20/10/2018.
// Copyright © 2018 Michael Hurni. All rights reserved.
//
#import "ViewController.h"
// modified version to read DS18B20 in bit banging
//
// 24 May 2014
// Daniel Perron
//
// Use At your own risk
@pyrou
pyrou / Context.php
Last active April 20, 2018 07:55
PHP Candidate Test
<?php
/**
* Context objects aims to be used as a small bucket of mixed data.
* This class provide methods to define and retrieve these data
* identified by a Key.
*/
class Context {
/* @var array internal storage of Context variables */
@pyrou
pyrou / random.php
Created August 25, 2017 08:14
Generate a random number without uses of deterministic rand / mt_rand php function
<?php
/**
* Generate a random number without uses of deterministic rand / mt_rand php function
* based on https://codeascraft.com/2012/07/19/better-random-numbers-in-php-using-devurandom
* - Add 64 bit support
* - Removed mcrypt dependency (PHP7 required)
*/
function devurandom_rand($min = 0, $max = PHP_INT_MAX) {
# RFX protocols
# -------------------------------------------------------------------
# # Protocol State
# -------------------------------------------------------------------
# 0 Undecoded Disabled
# 1 RFU Disabled
# 2 Byrox SX Disabled
# 3 RSL Disabled
# 4 Lightning4 Enabled
# 5 FineOffset/Viking Disabled
#ifndef __CGRECT_MACROS__
#define __CGRECT_MACROS__
#define CGRectX(rect) rect.origin.x
#define CGRectY(rect) rect.origin.y
#define CGRectWidth(rect) rect.size.width
#define CGRectHeight(rect) rect.size.height
#define CGRectSetSize(rect, w, h) CGRectMake(CGRectX(rect), CGRectY(rect), w, h)
#define CGRectSetOrigin(rect, x, y) CGRectMake(x, y, CGRectWidth(rect), CGRectHeight(rect))
#define CGRectSetWidth(rect, w) CGRectSetSize(rect, w, CGRectHeight(rect))
@pyrou
pyrou / xhprof.sh
Last active August 29, 2015 14:22
Install xhprof
# apt-get install php5-dev make gcc
composer --dev require facebook/xhprof dev-master
pushd vendor/facebook/xhprof/extension
phpize
./configure
make
make install
popd
echo extension=xhprof.so > /etc/php5/mods-available/xhprof.ini
php5enmod xhprof