Skip to content

Instantly share code, notes, and snippets.

View dmueller39's full-sized avatar

Daniel Mueller dmueller39

  • Facebook Inc.
  • New York, NY
View GitHub Profile
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
import React, {
AppRegistry,
Component,
StyleSheet,
Text,
@dmueller39
dmueller39 / testing_async_redux_actions.js
Created September 14, 2016 15:18
Testing Async redux actions in jest
function update(value) {
return (dispatch) => new Promise((resolve) => setImmediate(
() => {
dispatch({ type: 'UPDATE', value });
resolve();
}
));
}
@dmueller39
dmueller39 / simplereddit.py
Created February 7, 2017 11:15
A simple reddit json requester written in python
import urllib2
import json
import time
def get(o, p, d=None):
keys = p.split('.')
rv = o
for key in keys:
if isinstance(rv, dict) and key in rv:
rv = rv[key]
@dmueller39
dmueller39 / git-prettier.sh
Created March 29, 2017 21:47
A simple shell script for validating prettier has been used on the files that were changed according to git
command -v prettier >/dev/null 2>&1 || { npm install -g prettier; }
usage() {
echo "usage: git-prettier.sh (format|validate) [<commit>]"
}
must_provide_commit_error () {
echo "Must provide a known revision to compare against"
usage
exit 1
@dmueller39
dmueller39 / MainStyledComponents.js
Created May 17, 2017 17:26
Basic Working Example for styledComponents
import styled from 'styled-components/native';
const getTitleFontSize = ({sizeClass}) => {
const sizes = {
small: 20,
large: 50,
};
return sizes[sizeClass] || sizes['small'];
};
@dmueller39
dmueller39 / LazyComponent.js
Created July 27, 2017 14:04
Lazy Higher Order Component
// @flow
import React, { PureComponent } from 'react';
export default function createLazyComponent<A>(
getClass: () => Class<React.Component<void, A, void>>
) {
return class extends PureComponent {
componentWillMount() {
this.lazyComponentClass = getClass();
}
@dmueller39
dmueller39 / constant.js
Created November 7, 2017 20:40
Demonstration of bug where Flow can not decide which case to select when constant is defined in a different file
// @flow
export const Foo:'foo' = 'foo';