Skip to content

Instantly share code, notes, and snippets.

View derek-duncan's full-sized avatar

Derek Duncan derek-duncan

View GitHub Profile
@derek-duncan
derek-duncan / reusable-graphql-containers.jsx
Last active December 8, 2017 16:19
Typescript example on how to strongly type your Apollo graphql containers. These containers are completely reusable for any component, with full TS typings.
import * as React from "react";
import * as ReactDOM from "react-dom";
import gql from "graphql-tag";
import { graphql } from "react-apollo";
/**
* Using intersection types, we can allow our `graphql` injected props
* to be defined in our `Props` type.
*/
@derek-duncan
derek-duncan / Deferred-Rendering-HOC.js
Created April 18, 2017 13:38
Assists react in mounting/unmounting large component trees. Originally inspired by mobile twitter.
import React, { Component } from 'react';
const withDeferRender = Presentational =>
class DeferRender extends Component {
state = {
shouldRender: false,
};
componentDidMount() {
window.requestAnimationFrame(() => {
# ..just merged dev into stage
git checkout stage
# on branch stage. We have a few blockers: we don't want commits 1234-my-feature [1a613sa] and 1234-my-feature-updated [2u817n0]
git revert -n 1a613sa
git revert -n 2u817n0
git commit -m "... Except commits 1234-my-feature and 1234-my-feature-updates"
# The commits will now be excluded and can be fixed later
# Push
git push
@derek-duncan
derek-duncan / 1-suggested-branch-naming-scheme.rb
Last active May 17, 2021 00:29
Git workflow for small teams
# [pivital-story-id]-[feature-name]
# All lowercase. Spaces replaced with dashes
94198518-cs-block-bugs
@derek-duncan
derek-duncan / Project Euler Solutions
Last active December 21, 2015 01:19
ProjectEuler.net Solutions
# Project Euler Algorithems
#!/usr/bin/python3
import time
def Euler1():
numbers = [n for n in range(0, 1000) if n % 3 == 0 or n % 5 == 0]
return sum(numbers)