Skip to content

Instantly share code, notes, and snippets.

View seriousManual's full-sized avatar
🐷
stuff

Manuel Ernst seriousManual

🐷
stuff
View GitHub Profile
server.get('/api/push', async (req, res, next) => {
const Data = require('./lib/Data');
const subscriptions = await new Data('data/subscriptions.json').load();
subscriptions.each((address) => {
bot.send(
(new builder.Message())
.text(req.body)
.address(address)
);
const lunchpad = require('lunchpad')
const initializeLP = lunchpad.initialize
const Color = lunchpad.Color
const fivetwelve = require('fivetwelve/es5')
const EnttecUsbProMk2Driver = require('fivetwelve-driver-usbpro/es5')
const SerialPort = require('serialport')
let fivetwelveInit = fivetwelve.default
let DmxDevice = fivetwelve.DmxDevice
i know this might be mitigated with react >=15 but I'm bound to 0.14.8 due to IE8 support.
var example1 = <div>{amount} <SomeComponent/></div>
would render to:
<div>
<span><<myAmount>>
<span> </span> //<---- a new span just for the blank is added
<span>output of SomeComponent</span>
</div>
@seriousManual
seriousManual / README.md
Created March 15, 2016 07:27
Coverage report via mocha on windows

coverage reports with mocha on windows

in my memory coverage reports have been always a big PITA. as I looked into it today after some fiddeling it turns out it is actually really easy!

(assumes that your tests live under tests/unit, modify as you like)

(dont forget to do npm i istanbul --save-dev before)

@seriousManual
seriousManual / fib.erl
Created September 2, 2015 07:32
Tail recursive Fibonacci generator in Erlang
fib(N) -> fib(N, 0, 0, 1).
fib(N, N, X, Y) -> X + Y;
fib(N, 0, _, _) -> fib(N, 1, 0, 1);
fib(N, 1, _, _) -> fib(N, 2, 1, 1);
fib(N, Current, X, Y) -> fib(N, Current + 1, Y, X+Y).
@seriousManual
seriousManual / StateWrapper.js
Last active August 29, 2015 14:27
wrapper the altitude state
var Emitter = require('events').EventEmitter;
var util = require('util');
function StateWrapper(client) {
Emitter.call(this);
this._state = {
altitude: 0
};
@seriousManual
seriousManual / fizzBuzzMantainanceNightmare.js
Last active September 20, 2017 14:04
Minimal Fizzbuzz
for(var i=0;i<30;i++)console.log(i%5==0&&i%3==0?'fizzbuzz':i%5==0?'buzz':i%3==0?'fizz':i)
@seriousManual
seriousManual / fizzbuzzLazy.js
Last active June 30, 2021 08:44
Infinite Lazy Fizzbuzz Generation
function* fizzbuzz() {
for (let i = 0; ; i++) {
if (i % 15 === 0) {
yield 'FizzBuzz'
continue
}
if (i % 5 !== 0) {
yield 'Fizz'
continue
@seriousManual
seriousManual / fizzbuzz.js
Last active March 25, 2022 11:10
Fizzbuzz without a loop in Javascript
Array.from(new Array(30), (value, index) => {
index++
if (index % 5 === 0 || index % 3 === 0) {
if (index % 5 !== 0) return 'Fizz'
if (index % 3 !== 0) return 'Buzz'
return 'FizzBuzz'
}
return index
@seriousManual
seriousManual / packstations.php
Last active February 1, 2021 15:14
Minimal code example for a SOAP call to the DHL API (Packstations search)
<?php
$userName = 'fooUser';
$password = 'fooPassword';
$endpoint = 'https://cig.dhl.de/services/sandbox/soap';
$client = new SoapClient("https://cig.dhl.de/cig-wsdls/com/dpdhl/wsdl/standortsuche-api/1.0/standortsuche-api-1.0.wsdl", [
'login' => $userName,
'password' => $password,
'location' => $endpoint,