Skip to content

Instantly share code, notes, and snippets.

View normen's full-sized avatar

Normen Hansen normen

View GitHub Profile
@normen
normen / httpserver.js
Last active June 14, 2017 21:05
JS HTTP server
const http = require('http');
const url = require('url');
const fs = require('fs');
const path = require('path');
const port = process.argv[2] || 9000;
http.createServer(function (req, res) {
console.log(`${req.method} ${req.url}`);
// parse URL
const parsedUrl = url.parse(req.url);
// extract URL path
@normen
normen / homebridge-433-arduino.ino
Created June 15, 2017 12:30
homebridge-433-arduino code
/*
Arduino code for homebridge-433-arduino
(c) by Normen Hansen, released under MIT license
uses code from http://forum.arduino.cc/index.php?topic=396450.0
*/
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
const byte numChars = 255; // max number of received chars
char receivedChars[numChars]; // an array to store the received data
@normen
normen / Split Notes To Channels.lua
Last active March 2, 2020 14:17
Separate Notes to Channels MIDI Machine
channels = {} -- save pitch per channel#
channelNo = {} -- save channel# per pitch
function GetFreeChannel()
for i = 1, 16 do if channels[i] == nil then return i end end
Print("Error: ran out of channels")
return 1
end
function OnNote(channel, pitch, velocity)