Skip to content

Instantly share code, notes, and snippets.

Avatar
🐈‍⬛
Codes with cats

Paul Armstrong paularmstrong

🐈‍⬛
Codes with cats
View GitHub Profile
View deferComponentRender.js
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) {
@paularmstrong
paularmstrong / memorySizeOfObject.js
Created Mar 16, 2017 — forked from zensh/memorySizeOfObject.js
calculate memory size of javascript object, it is not a accurate value!
View memorySizeOfObject.js
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
@paularmstrong
paularmstrong / memorySizeOfObject.js
Created Mar 16, 2017 — forked from zensh/memorySizeOfObject.js
calculate memory size of javascript object, it is not a accurate value!
View memorySizeOfObject.js
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
View LoadingRenderer.js
const FetchStatus = {
FAILED: 'failed',
LOADED: 'loaded',
LOADING: 'loading',
NONE: 'none'
};
class LoadingRenderer extends React.Component {
static propTypes = {
fetchStatus: React.PropTypes.oneOf(Object.values(FetchStatus)).isRequired,
View keybase.md

Keybase proof

I hereby claim:

  • I am paularmstrong on github.
  • I am paularmstrong (https://keybase.io/paularmstrong) on keybase.
  • I have a public key ASBFEf8k-OMRv7mD5wCCWTGMs7hwhdni7EO1LxPII3dnPwo

To claim this, I am signing this object:

View state.js
const state = {
timelines: {
home: {
tweets: [
'123',
'456',
'789',
'012'
]
}
View README.md

Convert Mocha and Chai to Jest

$ jscodeshift <path> -t assert-to-expect.js
$ jscodeshift <path> -t mocha-to-jest.js
View ignore.txt
.Spotlight*
.Trash*
.AppleDouble*
Thumbs.db
.DocumentRevisions*
.AppleDB*
.AppleDesktop*
.apdisk*
.TemporaryItems*
@paularmstrong
paularmstrong / rm-branch_alias.sh
Created Jul 28, 2016
Because sometimes everything you wrote was bad.
View rm-branch_alias.sh
# Completely remove the current branch from a git repo
function rm-branch() {
branch="$(git branch --no-color | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')"
git checkout master
git branch -D $branch
}
@paularmstrong
paularmstrong / tdf2016.css
Last active Jul 6, 2016
Tour de France 2016 custom stylesheet for NBC Sports streams.
View tdf2016.css
body {
background: #000 !important;
}
div#nbc-header {
display: none !important;;
}
div#player-wrapper + div,
div#player-wrapper + div + div {