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
class InMemoryCounter { | |
constructor({ seconds = 1, rolling = true, max }) { | |
this.seconds = seconds; | |
this.rolling = rolling; | |
this.max = max; | |
if (!this.rolling) { | |
this.interval = setInterval(() => { | |
this.counter = 0; | |
}, this.seconds * 1000); |
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 { listen, emit } = require("rikkert"); | |
const express = require('express'); | |
const app = express(); | |
const rikkertMiddleware = (req, res, next) => { | |
emit("http.request", { req, res }).then(next); | |
}; | |
app.use(rikkertMiddleware); | |
app.listen(3000); |
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 INIT = '@redux/INIT'; | |
export const createStore = (reducer, state, enhancer) => { | |
if (enhancer) { | |
return enhancer(createStore)(reducer, state); | |
} | |
const subscribers = []; | |
dispatch({ type: INIT }); |
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 numpy as np | |
import hashlib | |
def create_block(parent_block, value, hashfunc): | |
""" ------------------------------------------------ | |
String -> Block -> (Block -> String) -> Block | |
------------------------------------------------ | |
Produce a new block from a string value and a hash | |
of its parent block. In this case, a block is also a 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
<html> | |
<body> | |
<div id="react-root"></div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-with-addons.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.5.2/redux.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.7.7/babel.min.js"></script> | |
<script id="react-app" type="text/template"> | |
const App = ({name}) => { |
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 App = ({name}) => { | |
return ( | |
<h1>Hello {name}</h1> | |
); | |
}; | |
ReactDOM.render(<App name="World" />, document.getElementById("App")); |
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
function decorate (...functions) { | |
return functions.reduce( | |
(a, b) => b(a), | |
functions.pop() // Pop wrapped function as initial value | |
); | |
}; | |
decorate( | |
(func) => (text) => func(text.toUpperCase() + "!"), // Outer-wrapper |