Skip to content

Instantly share code, notes, and snippets.

View Stephanvs's full-sized avatar

Stephan van Stekelenburg Stephanvs

View GitHub Profile
@Stephanvs
Stephanvs / sketch.ino
Created August 31, 2019 19:43
Arduino Multitasking
/* Arduino Multitasking
Author : CircuitDigest (circuitdigest.com)
*/
int led1 = 6; // led1 connected at pin 6
int led2 = 7; // led1 connected at pin 7
int toggleLed = 5; // push button controlled led connected at pin 5
int pushButton = 2; // push butoon connected at pin 2 which is also interrupt pin
int ledState1 = LOW; // to determine the states of led1 and led2
@Stephanvs
Stephanvs / piezo.ino
Created August 31, 2019 19:04
Basic Piezo sounds
/*
Melody
Plays a melody
circuit:
- 8 ohm speaker on digital pin 8
created 21 Jan 2010
modified 30 Aug 2011
@Stephanvs
Stephanvs / BLE_IMU.ino
Created August 21, 2019 15:00
BLE IMU
/*
BLE IMU sketch on projecthub
-----------------------------
Arduino MKR 1010 + IMU Shield
FOR USE WITH WEB APP DEMO AT :
https://8bitkick.github.io/ArduinoBLE-IMU.html
IMPORTANT - if required update MKR 1010 fw for bluetooth support first
@Stephanvs
Stephanvs / sketch.ino
Created August 20, 2019 08:48
BLE_IMU
/*
BLE IMU sketch on projecthub
-----------------------------
Arduino MKR 1010 + IMU Shield
FOR USE WITH WEB APP DEMO AT :
https://8bitkick.github.io/ArduinoBLE-IMU.html
IMPORTANT - if required update MKR 1010 fw for bluetooth support first
@Stephanvs
Stephanvs / sketch.ino
Created August 19, 2019 14:46
Arduino Adafruit BLE (nRF8001) sample
// This version uses call-backs on the event and RX so there's no data handling in the main loop!
#include <SPI.h>
#include "Adafruit_BLE_UART.h"
// Connect CLK/MISO/MOSI to hardware SPI
// e.g. On UNO & compatible: CLK = 13, MISO = 12, MOSI = 11
#define ADAFRUITBLE_REQ 8
#define ADAFRUITBLE_RDY 2 //interrupt pin. on Uno that's #2 or #3
@Stephanvs
Stephanvs / Arduino Song
Created August 14, 2019 07:24 — forked from eznj/star_wars.ino
Arduino Star Wars Song for Piezo
**/
const int c = 261;
const int d = 294;
const int e = 329;
const int f = 349;
const int g = 391;
const int gS = 415;
const int a = 440;
const int aS = 455;
@Stephanvs
Stephanvs / .htaccess
Last active June 19, 2018 13:10
WordPress Docker Compose
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
@Stephanvs
Stephanvs / readme.md
Created June 13, 2018 21:27
Install Docker Compose 1.14.0 on CoreOS

The first thing to do when installing a new CoreOS is to install the Docker Compose.

Install

node01 ~ # sudo su -
node01 ~ # mkdir -p /opt/bin
node01 ~ # curl -L "https://github.com/docker/compose/releases/download/1.14.0/docker-compose-$(uname -s)-$(uname -m)" -o /opt/bin/docker-compose
node01 ~ # chmod +x /opt/bin/docker-compose
@Stephanvs
Stephanvs / facebook.csx
Last active May 11, 2018 06:52
Widget to track facebook page metrics
#!/usr/bin/env ruby
require 'net/http'
require 'json'
# this job will track some metrics of a facebook page
# Config
# ------
# the fb id or username of the page you’re planning to track
facebook_graph_username = ENV['FACEBOOK_GRAPH_USERNAME'] || 'foobugs'
@Stephanvs
Stephanvs / EventMachines.md
Created February 5, 2018 11:09 — forked from eulerfx/EventMachines.md
The relationship between state machines and event sourcing

A state machine is defined as follows:

  • Input - a set of inputs
  • Output - a set of outputs
  • State - a set of states
  • S0 ∈ S - an initial state
  • T : Input * State -> Output * State - a transition function

If you model your services (aggregates, projections, process managers, sagas, whatever) as state machines, one issue to address is management of State. There must be a mechanism to provide State to the state machine, and to persist resulting State for subsequent retrieval. One way to address this is by storing State is a key-value store. Another way is to use a SQL database. Yet another way is event sourcing. The benefit of even sourcing is that you never need to store State itself. Instead, you rely on the Output of a service to reconstitute state. In order to do that, the state machine transition function needs to be factored into two functions as follows: