Skip to content

Instantly share code, notes, and snippets.

View moimikey's full-sized avatar
:shipit:
ship it

Michael Scott Hertzberg moimikey

:shipit:
ship it
View GitHub Profile
const createStore = (initialState, reducer) => {
let state = {};
let listeners = [];
const getState = () => state;
const setState = (nextState) => {
state = nextState;
return state;
};
@mxstbr
mxstbr / idea.md
Last active February 16, 2021 18:33
Code splitting react-router routes with webpack 2

NOTE: Sokra confirmed I had a misunderstanding, Webpack is still a static build tool and the below won't work. It's still a nice concept though...

With webpack 1, code splitting react-router routes is quite tedious. It requires us to repeat the getComponent function over and over again. (See here for an explanation how it works with webpack 1)

Example:

<Router history={history}>
  <Route
    path="/"
@bcoe
bcoe / npm-top.md
Last active July 28, 2025 08:15
npm-top.md

npm Users By Downloads (git.io/npm-top)


npm users sorted by the monthly downloads of their modules, for the range May 6, 2018 until Jun 6, 2018.

Metrics are calculated using top-npm-users.

# User Downloads

Redux Chaos Monkey

This is a proof of concept which allows you to replay system events in a random order each time to make sure your UI can tolerate variable states.

I'm not sure if this is worthy of its on open source project with additional features like changing play back time, whitelisting/blacklisting actions etc but figured I'd put this out there to see if it piques anyones interest.

See a video of this in action here: [https://www.youtube.com/watch?v=wkoukONfwmA](Video on YouTube).

@bishboria
bishboria / springer-free-maths-books.md
Last active July 17, 2025 06:34
Springer made a bunch of books available for free, these were the direct links
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import assert from 'assert';
function render(jsx) {
return ReactDOMServer.renderToStaticMarkup(jsx);
}
function assertEqual(actual, expected) {
assert.equal(render(actual), render(expected));
@max-mapper
max-mapper / index.js
Last active August 1, 2018 16:17
http with require('net')
var net = require('net')
var concat = require('concat-stream')
var pump = require('pump')
var reqBody = new Buffer(`GET / HTTP/1.1
User-Agent: curl/7.37.1
Host: localhost:8080
Accept: */*
`)
@danielmahal
danielmahal / firebase-decorator-api.jsx
Last active June 7, 2017 19:47
Firebase decorator api
// Alternative 1
// One function at top-level that returns whatever it needs.
// Can be run multiple times, and return different things
@firebase(props => {
if (!props.projectIndex) {
return {
projectIndex: `users/${props.authId}/projects`,
};
}

there are two fundamental types of streams source and sink. There are two composite types of streams through (aka transform) and duplex A through stream is a sink stream that reads what goes into the source. a duplex stream is a pair of {source, sink} streams.

Source streams have two methods.

readable stream: source

A source (readable stream) is an async function that may be called repeatedly until it returns a terminal state. You must not call the read function until the previous call has returned, except for a call to abort the stream. pull-streams have back pressure, but it implicit instead of sending an explicit back pressure signal. If a source