Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Bild MikeBild

View GitHub Profile
@MikeBild
MikeBild / aws_iot.ino
Created Nov 6, 2019
ESP8622 AWS IoT Client
View aws_iot.ino
#define ESP8622
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <AmazonIOTClient.h>
#include "Esp8266AWSImplementations.h"
#include <Wire.h>
#include <MechaQMC5883.h>
@MikeBild
MikeBild / website-deploy.js
Created Apr 8, 2019
AWS-CDK CloudFront CDN + S3 WebSite deployment with automatic cache invalidation
View website-deploy.js
const { join } = require('path');
const { Stack, RemovalPolicy, ScopedAws, CfnOutput } = require('@aws-cdk/cdk');
const { Bucket } = require('@aws-cdk/aws-s3');
const { BucketDeployment, Source } = require('@aws-cdk/aws-s3-deployment');
const {
CloudFrontWebDistribution,
ViewerProtocolPolicy,
PriceClass,
OriginProtocolPolicy,
} = require('@aws-cdk/aws-cloudfront');
View Demo
import React, { useState } from 'react';
import { render } from 'react-dom';
const todosStore = {
todos: {
'1': {
id: '1',
text: '',
},
},
@MikeBild
MikeBild / async-either-with-promise.js
Last active Nov 10, 2018
Async Railway Oriented Programming in JS
View async-either-with-promise.js
#!/bin/env node
//thx to http://fsprojects.github.io/Chessie/a-tale-of-3-nightclubs.html
Promise.all([
suitablePersonEnterGayBar(),
unsuitablePersonEnterGayBar(),
])
.then(result => result.map((person, i) => `Person ${i+1}: ${person.cost || ''}${person.reasons.join(' ')}`))
.then(result => console.log(`Person entries\n${result.join('\n')}`));
@MikeBild
MikeBild / async-await-promise-all-error-handling.js
Last active May 10, 2018
Avoid async/await on integration level
View async-await-promise-all-error-handling.js
const defaultFirst = 'A`'
const defaultSecond = 'B`'
const defaultThird = 'C`'
async function doFirst() {
// throw new Error('Error A')
return await 'A'
}
async function doSecond() {
@MikeBild
MikeBild / compose-graphql-queries.js
Last active Sep 12, 2017
API Prototype - compose React components to Higher-Order-Components with GraphQL Fragment / Query composer
View compose-graphql-queries.js
export const Gists = props =>
<div>
{
props.viewer.gists &&
props.viewer.gists.map(x => <p>{x.description}</p>)
}
</div>
export const GistsWithGraphQL = compose(
withGraphQL(variables => Fragment`fragment gists on Gist {
@MikeBild
MikeBild / bank-account-system-poc.js
Last active Apr 10, 2017
Proof of Concept (recompose) - Bank-Account-System composition with higher-order functions (NodeJS6)
View bank-account-system-poc.js
const account = openBankAccount({name: 'Max Muster'})({})
account.deposit(1000)
account.withdraw(800)
account.withdraw(800)
// use compose(...) building block
const { calculateBalance, name, transactions, save} = compose(withBalanceCalculation({}), withStore())(account)
console.log(`${name}: ${calculateBalance()} [${transactions.map(x => x.deposit || 0 - x.withdraw)}]`)
console.log(save())
// same stuff, but use the handy way
@MikeBild
MikeBild / demonstration.js
Created Nov 10, 2016
Q&A - I wanna understand TypeScript - Part TypeScript Union Types as Redux Action Tags
View demonstration.js
// demonstrate
const simulateActions = [
addTodo({text: 'todo 1'}),
addTodo({text: 'todo 2'}),
toggleTodo({index: 0}),
toggleTodo({index: 1}),
];
const actual = simulateActions.reduce(todosReducer, []);
console.log(actual);
@MikeBild
MikeBild / microservice-workflows.md
Last active Nov 1, 2016
Microservice Workflows mit Consumer-Driven-Contracts
View microservice-workflows.md

Microservice Workflows mit Consumer-Driven-Contracts

Allen voran geht es mir um die Vereinfachung der Softwareentwicklung auch auf Systemebene. Ich meine die folgenden Artikel zeigen zumindest mittel- und langfristig genau das Gegenteil und sind ein gutes Beispiel ausufernder Systemlandschaften durch selbstverschuldet aufgesetzte Komplexität.

Wer Microservice richtig richtig macht, braucht keine Workflow Engine, kein BPMN, kein ESB, kein Message Broker, keine Aktor-Modelle und Frameworks, keine Enterprise Application Server, kein Event-Sourcin

@MikeBild
MikeBild / app.js
Last active Oct 30, 2016
Memoize - you never need constructor/property based dependency injection in JavaScript
View app.js
const require1 = require('./require1');
const require2 = require('./require2');
const require3 = require('./require3');
console.log(require1.getValue());
console.log(require2.getValue());
console.log(require3.getValue());