This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DynamoDB } from 'aws-sdk'; | |
export interface Entity { | |
id: string; | |
} | |
export default (tableName: string) => { | |
const ddb = new DynamoDB(); | |
return (dataType: string) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define ESP8622 | |
#include <ESP8266WiFi.h> | |
#include <WiFiClient.h> | |
#include <AmazonIOTClient.h> | |
#include "Esp8266AWSImplementations.h" | |
#include <Wire.h> | |
#include <MechaQMC5883.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
import { render } from 'react-dom'; | |
const todosStore = { | |
todos: { | |
'1': { | |
id: '1', | |
text: '', | |
}, | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const defaultFirst = 'A`' | |
const defaultSecond = 'B`' | |
const defaultThird = 'C`' | |
async function doFirst() { | |
// throw new Error('Error A') | |
return await 'A' | |
} | |
async function doSecond() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const require1 = require('./require1'); | |
const require2 = require('./require2'); | |
const require3 = require('./require3'); | |
console.log(require1.getValue()); | |
console.log(require2.getValue()); | |
console.log(require3.getValue()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Rx = require('rx'); | |
// simulate transactions | |
const bookCar = id => Rx.Observable.return({sagaId: id, 'Car A': true}).delay(1000); | |
const bookHotel = id => Rx.Observable.return({sagaId: id, 'Hotel B': true}).delay(1000); | |
const bookFlight = id => Rx.Observable.return({sagaId: id, 'Flight C': true}).delay(1000); | |
// simulate error | |
//const bookFlight = id => Rx.Observable.throw({sagaId: id, 'Flight C': true}).delay(1000); | |
// transaction compensation (idempotence) |
NewerOlder