Skip to content

Instantly share code, notes, and snippets.

View JakeGinnivan's full-sized avatar
:shipit:

Jake Ginnivan JakeGinnivan

:shipit:
View GitHub Profile
function dispatch(action) {
// Promise tracker middleware
const nextAction = reduxThunkMiddleware(action)
// Because react-thunk returns the result of the
// thunk, our async function returns a promise
// Which means this statement will be true
if (Promise.resolve(nextAction) === nextAction) {
// Tracking a promise is a side effect of our middleware
track(nextAction)
export class PromiseTracker {
promises = []
track(promise) {
this.promises.push(promise)
}
middleware() {
return () => next => (action) => {
const result = next(action)
ReactDOM.hydrate(<MyApp />, document.getElementById('root'))
const wrapper = fixture.mountUrl('/business')
await fixture.processEvents()
const allLimas = wrapper.update().find(Lima)
expect(allLimas.length).toBeGreaterThan(0)
const bullsNBears = allLimas.filterWhere(limas => {
const props = limas.props()
if (!props.sectionHeader) {
return false
}
@JakeGinnivan
JakeGinnivan / App.js
Last active January 16, 2018 09:26
NDC London
import React, { Component } from "react";
import "./App.css";
import { fetchAgenda, talkShape } from "./fetch-agenda";
import { groupBy, formatTime } from "./utils";
import { Talk } from "./components/talk";
class App extends Component {
state = {
talks: []
};
@JakeGinnivan
JakeGinnivan / App.js
Last active August 14, 2017 05:49
Workshop gists
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { fetchAgenda } from './agenda'
import _ from 'lodash'
const Talk = ({ startTime, title }) => (
<div>{title}</div>
import cheerio from 'cheerio'
export const fetchAgenda = () => {
return fetch('http://ndcsydney.com/agenda')
.then(r => r.text())
.then(body => {
const talks = []
const $ = cheerio.load(body)
$('section.day').map((i, el) => {
import * as cheerio from 'cheerio'
export type Time = {
hour: number
minutes: number
}
export type Talk = {
startTime: Time
endTime: Time
@JakeGinnivan
JakeGinnivan / LogHelper.cs
Last active June 20, 2016 16:31
Helpers for xunit 2 to enable logging through Serilogs static Log type
public static class LogHelper
{
static readonly ConcurrentDictionary<Guid, ITestOutputHelper> LoggerLookup = new ConcurrentDictionary<Guid, ITestOutputHelper>();
public static void Log(string log)
{
var currentCorrelationId = (Guid?)CallContext.LogicalGetData("TestCorrelationId");
if (currentCorrelationId == null)
return;
var Col = require('react-bootstrap/lib/Col')
var PageHeader = require('react-bootstrap/lib/PageHeader')
var React = require('react')
var Row = require('react-bootstrap/lib/Row')
var {connect} = require('react-redux')
var {reduxForm} = require('redux-form')
var DateInput = require('./DateInput')
var FormField = require('./FormField')
var LoadingButton = require('./LoadingButton')