Skip to content

Instantly share code, notes, and snippets.

View ThomasGHenry's full-sized avatar

Thomas G Henry ThomasGHenry

View GitHub Profile
import PropTypes from 'prop-types';
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
type Defined<T> = T extends undefined ? never : T;
/**
* Get the type that represents the props with the defaultProps included.
*
* Alternatively, we could have done something like this:
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active May 19, 2024 13:30
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@Matt-Dionis
Matt-Dionis / rootQueryExample.js
Created July 21, 2017 21:26
A sample GraphQL RootQueryType
const RootQueryType = new graphql.GraphQLObjectType({
name: 'RootQueryType',
fields: {
accounts: {
type: new graphql.GraphQLList(Account),
description: 'A list of accounts.',
args: {
accountType: {
type: AccountType
},
@spicecadet
spicecadet / 1. Codeship Deployment
Last active October 5, 2020 21:40
This is my deployment script for pushing from Github to a WP Engine WordPress install. The scripts below can be added as custom scripts to Codeship's Deployment Pipelines.
# Environment Variables
#INSTALL=
#EMAIL=
#ENVIRONMENT="production"
#SERVICE=
#ASSERTIBLE_CODE=
@ainalain
ainalain / testSetup.js
Last active February 9, 2021 17:39
Setup environment for testing React components with mocha, sinon, enzyme and jsdom
/* This file helps you to setup an environment
* for testing a React app with Mocha.
* It provides transpiling and some global variables before
* Mocha runs all the tests.
* Usage example in npm script: "test": "mocha --require tools/testSetup.js test/*.test.js"
* The major part of this file I got from Cory House pluralsight-redux-starter repo:
* https://github.com/coryhouse/pluralsight-redux-starter/blob/master/tools/testSetup.js
*/
process.env.NODE_ENV = 'test';
@Gabelbombe
Gabelbombe / README.md
Last active March 26, 2024 13:15
Yell Die Try functions for bash...

Explanation

  • yell: print the script name and all arguments to stderr:
    • $0 is the path to the script
    • $* are all arguments.
    • >&2 means > redirect stdout to & pipe 2. pipe 1 would be stdout itself.
  • die does the same as yell, but exits with a non-0 exit status, which means "fail".
  • try uses the || (boolean OR), which only evaluates the right side if the left one didn’t fail.
@moodysalem
moodysalem / PreventLeaveRoute.jsx
Created January 22, 2017 18:52
React HOC to prevent leaving a page
import React, { Component, PropTypes } from 'react';
/**
* Only ever render one of these per page
*
* TODO: improve with react-side-effect to better handle multiple instances of this being rendered at once so we can
* nest the component in forms
*/
export default class PreventLeaveRoute extends Component {
static contextTypes = {
@mknabe
mknabe / README.md
Last active September 18, 2021 09:14
React component to warn users about unsaved changes to forms when they attempt navigate away from the page using redux-form

Use with the following

  • react-router
  • redux-form

You must use this compontent on the route component where the form is shown not on the form component itself. This is because this.props.route is only added to route components, and I didn't want to pass that down through props.

Inspired by this Codepad

Feedback appreciated

@leonklingele
leonklingele / key-bindings.bash
Last active August 10, 2018 09:06
fzf key-bindings.bash: ignore duplicates
# ..
# Requires https://st.aticpan.org/source/PERLANCAR/App-nauniq-0.10/script/nauniq
# SHA256: 046d69b8b1ed74aaff38565f08acc9781e7404fa240b2d091601043a5838f9f0
# gsed -i 's?#!perl?#!/usr/bin/env perl?' nauniq
# patch -p1 nauniq < nauniq-ignore-pattern.patch
__fzf_history__() (
local line
shopt -u nocaseglob nocasematch