Skip to content

Instantly share code, notes, and snippets.

View LeeCheneler's full-sized avatar

Lee Cheneler LeeCheneler

  • Enzyme Software
  • UK
  • 03:46 (UTC +01:00)
View GitHub Profile
/**
* Determine if the current browser is IE 11
*/
export const isIE11 = (): boolean => {
return !!window.MSInputMethodContext && !!document.documentMode;
};
@LeeCheneler
LeeCheneler / default-error-fallback.tsx
Created October 19, 2019 21:41
react error boundary example
import React from "react";
export const DefaultErrorFallback = () => {
return <span>Oops! Failed to load...</span>;
};
@LeeCheneler
LeeCheneler / testcafe-selectors.txt
Last active October 21, 2019 14:38
testcafe utils and selector functions
import { Selector, t } from "testcafe";
import { waitUntilTrue } from "./utils";
/**
* Build test id selector string
*/
export const byTestId = (testId: string) => {
return `[data-testid="${testId}"],[data-test-id="${testId}"]`;
};
@LeeCheneler
LeeCheneler / example-usage.tsx
Last active September 12, 2019 07:01
useBreakpoint hook experiment
import React from "react";
import styled from "styled-components";
import { Box } "./some-styled-system";
import { useBreakpoints } from "./use-breakpoints";
// Very contrived example
const ColoredBox = styled.div<{ isRed: Boolean; isBlue: boolean }>`
width: 100px;
height: 100px;
@LeeCheneler
LeeCheneler / wishlist.md
Created July 18, 2019 07:38
Tooling Wish List
  • Fast in browser testing

    • Hot reload app
    • Only run tests related to hot patched code
  • Simple website build platform

    • Stateful SSR
    • Set routes as static in route config to be generated at build time

Keybase proof

I hereby claim:

  • I am leecheneler on github.
  • I am lacheneler (https://keybase.io/lacheneler) on keybase.
  • I have a public key ASAyZnwZx1KKed8kGZYDRqqZKnYdxd4yHvKu5B2EY_3CxAo

To claim this, I am signing this object:

@LeeCheneler
LeeCheneler / .zshrc
Created January 31, 2019 10:19
Git Aliases got .zshrc
# git aliases
alias g="git"
alias ga="git add -A"
alias gc="git commit"
alias gcm="git commit -m"
alias gp="git push"
alias gch="git checkout"
alias gpu="git pull"
alias gb="git branch"
@LeeCheneler
LeeCheneler / free port
Created November 2, 2018 17:01
Kill process consuming a port
kill -9 $(lsof -t -i:3000)
@LeeCheneler
LeeCheneler / Consumer.jsx
Last active November 1, 2018 15:39
Flag using flex instead of table
import React from 'react'
import Flag from './Flag'
const Consumer = () => (
<Flag.Wrapper spacer="md">
<Flag.Component>Component</Flag.Component>
<Flag.Body>Body</Flag.Body>
</Flag.Wrapper>
)
@LeeCheneler
LeeCheneler / index.js
Created October 30, 2018 09:48
useLocalStorage React Hook
import { useState, useEffect } from 'react';
// Usage
function App() {
// Similar to useState but we pass in a key to value in local storage
// With useState: const [name, setName] = useState('Bob');
const [name, setName] = useLocalStorage('name', 'Bob');
return (
<div>