Skip to content

Instantly share code, notes, and snippets.

View mauricedb's full-sized avatar

Maurice de Beijer mauricedb

View GitHub Profile
import React from "react";
import { Link } from "react-router-dom";
export function createResource(getPromise) {
let cache = {};
let inflight = {};
let errors = {};
function load(key) {
inflight[key] = getPromise(key)
import hoistStatics from 'hoist-non-react-statics';
import React from 'react';
/**
* Allows two animation frames to complete to allow other components to update
* and re-render before mounting and rendering an expensive `WrappedComponent`.
*/
export default function deferComponentRender(WrappedComponent) {
class DeferredRenderWrapper extends React.Component {
constructor(props, context) {
@richlander
richlander / getting-started-core.md
Last active December 14, 2016 16:00
Getting Started Writing a .NET Core app and Class Library

Getting Started Writing a .NET Core app and Class Library

These instructions are basic and a work in progress. They will be improving a lot over time.

Once you've followed the steps in this document, use the following sample to see the changes you need to make to your project: https://github.com/dotnet/corefxlab/tree/master/samples/ClassLib.

Installing the tools

@yreynhout
yreynhout / AggregateReader.cs
Last active August 29, 2015 14:14
Goodbye repository, Hello aggregate reader!
public class AggregateReader
{
private readonly Func<IAggregateRootEntity> _rootFactory;
private readonly IEventStoreConnection _connection;
private readonly EventStoreReaderConfiguration _configuration;
public AggregateReader(
Func<IAggregateRootEntity> rootFactory,
IEventStoreConnection connection,
EventStoreReaderConfiguration configuration)
@staltz
staltz / introrx.md
Last active July 25, 2024 13:33
The introduction to Reactive Programming you've been missing
@philcleveland
philcleveland / GetEventStoreEventDispatcher.cs
Last active December 16, 2015 05:19
GetEventStore Event Dispatcher EventStore.ClientAPI compatable v1.1.0
//Special thanks to Andrii Nakryiko and James Nugent
//for their help with this code.
namespace Infrastructure.EventStorage
{
using System;
using System.Collections.Concurrent;
using System.Net;
using System.Text;
using System.Threading;
using EventStore.ClientAPI;
@glennblock
glennblock / ApiControllerExtensions.cs
Last active December 14, 2015 10:39
So you don't hate yourself when you try to test a controller.
public static void ConfigureForTesting(this ApiController controller, HttpRequestMessage request, string routeName = null, HttpRoute route = null)
{
var config = new HttpConfiguration();
controller.Configuration = config;
if (routeName != null && route !=null)
config.Routes.Add(routeName, route);
else
route = config.Routes.MapHttpRoute("DefaultApi", "{controller}/{id}", new { id = RouteParameter.Optional });
var controllerTypeName = controller.GetType().Name;
@philcleveland
philcleveland / GetEventStoreEventDispatcher.cs
Last active June 8, 2016 23:04
Event dispatcher which receives events from the GetEventStore after they are saved. It takes the saved events and publishes them to the passed in Event Bus. This ensures that events are not published until they are saved in the GetEventStore. Big thanks to Andrii for all the reviews and coding help to get this thing working.
public class GetEventStoreEventDispatcher
{
private const int RECONNECT_TIMEOUT_MILLISEC = 5000;
private const int THREAD_KILL_TIMEOUT_MILLISEC = 5000;
private const int READ_PAGE_SIZE = 500;
private const int LIVE_QUEUE_SIZE_LIMIT = 10000;
private readonly IEventBus _eventBus;
private readonly EventStoreConnection _store;
@aaronshaf
aaronshaf / bookmarklet-expanded.js
Last active May 13, 2024 14:35
Copy text from Amazon's Cloud Reader. Helpful for students that need block quotes.
javascript: (function () {
new_window = window.open();
new_window.document.body.innerHTML = $("iframe")
.contents()
.find("iframe")
.contents()
.find("body")
.get(1).innerHTML;
new_window.document.body.querySelector("#content-overlays").remove();
})();
@janx
janx / analog_clock.html
Created September 2, 2011 13:04
html5 svg analog clock
<!DOCTYPE HTML>
<html>
<head>
<title>Analog Clock</title>
<script>
function updateTime() { // Update the SVG clock
var now = new Date();
var sec = now.getSeconds();
var min = now.getMinutes();
var hour = (now.getHours() % 12) + min/60;