Skip to content

Instantly share code, notes, and snippets.

Avatar
🐈‍⬛
Codes with cats

Paul Armstrong paularmstrong

🐈‍⬛
Codes with cats
View GitHub Profile
View Ripple.tsx
/**
* Copyright (c) 2019 Paul Armstrong
*/
import * as Theme from '../theme';
import React from 'react';
import { StyleProp, StyleSheet, TouchableOpacity, TouchableOpacityProps, View, ViewStyle } from 'react-native';
interface Props {
children: React.ReactElement;
disabled?: boolean;
View gist:8046f925665df347bc42f92ba68ab6c5
export default function(target) {
const originalMethods = {
UNSAFE_componentWillMount: target.prototype.UNSAFE_componentWillMount || noop,
componentDidMount: target.prototype.componentDidMount || noop,
UNSAFE_componentWillUpdate: target.prototype.UNSAFE_componentWillUpdate || noop,
componentDidUpdate: target.prototype.componentDidUpdate || noop,
componentWillUnmount: target.prototype.componentWillUnmount || noop
};
target.prototype.UNSAFE_componentWillMount = function(...args) {
@paularmstrong
paularmstrong / foo.test.js
Last active Mar 29, 2018
Mocha test runner with Require.js
View foo.test.js
define(['modules/foo'], function (foo) {
describe('test foo', function () {
// ...
});
});
View README.md

Convert Mocha and Chai to Jest

$ jscodeshift <path> -t assert-to-expect.js
$ jscodeshift <path> -t mocha-to-jest.js
View HeartIcon-old.jsx
const HeartIcon = (props) => React.createElement('svg', {
...props,
dangerouslySetInnerHTML: { __html: '<g><path d="M38.723 12c-7.187 0-11.16 7.306-11.723 8.131C26.437 19.306 22.504 12 15.277 12 8.791 12 3.533 18.163 3.533 24.647 3.533 39.964 21.891 55.907 27 56c5.109-.093 23.467-16.036 23.467-31.353C50.467 18.163 45.209 12 38.723 12z"></path></g>' },
viewBox: '0 0 54 72'
});
@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'
]
}