Skip to content

Instantly share code, notes, and snippets.

View ide's full-sized avatar
📈
My life is a hackathon

James Ide ide

📈
My life is a hackathon
View GitHub Profile
@ide
ide / gist:1740856
Created February 4, 2012 22:53
Parse tree for ThrowStatement without semicolon
{
name: 'ThrowStatement',
source: 'function x() {\n throw 5\n}',
range: {
location: 17,
length: 8
},
children: [{
name: 'THROW',
source: 'function x() {\n throw 5\n}',
@ide
ide / JSDomEnvironment.js
Last active August 29, 2015 14:22
Using <script> tags to evaluate code in jest
/**
* Copyright (c) 2014, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
var FakeTimers = require('./lib/FakeTimers');
@ide
ide / index.ios.js
Last active September 1, 2015 00:39
Redux batching example with React Native
/**
* Batched updates test with Redux. You will need React 0.6.0 and a .babelrc:
{
"whitelist": [
"es6.parameters.default",
"es7.decorators"
]
}
*/
'use strict';
@ide
ide / npm-shrinkwrap.json
Created June 24, 2015 19:06
React Native npm dependencies
{
"name": "react-native",
"version": "0.6.0",
"dependencies": {
"absolute-path": {
"version": "0.0.0",
"from": "[email protected]",
"resolved": "https://registry.npmjs.org/absolute-path/-/absolute-path-0.0.0.tgz"
},
"babel": {
@ide
ide / gist:41a6530a0b606545c55f
Last active July 17, 2020 22:43
Moving Redux state mapper into a component
// Trying out a new syntax. It is:
//
// - not magical except for the DecoratedComponent bit
// - communicates that it returns props
// - ...that are computed from Redux data
// - resembles familiar functions like getInitialProps
// - nice aesthetically
@connect(data => X.DecoratedComponent.getDataProps(data))
export default class X extends React.Component {
@ide
ide / _.js
Last active August 29, 2015 14:24
Issues with decorators and higher-order components
// @connect is a decorator provided by Redux that returns a new class that wraps
// the one defined below. Somewhat unintuitively but understandably, "Example"
// refers to the wrapper component returned from the decorator, not the wrapped
// component defined below.
@connect(data => ({ }))
class Example extends React.Component {
static staticMethod() {}
instanceMethod() {}
@ide
ide / .eslintrc
Created August 17, 2015 21:01
.eslintrc
{
"parser": "babel-eslint",
"ecmaFeatures": {
"jsx": true
},
"env": {
"es6": true,
"jasmine": true,
@ide
ide / HomeRoute.js
Last active February 24, 2016 16:11
Simple example of an ExRoute object
let homeRoute = {
getSceneClass() {
return require('./HomeScreen');
},
getTitle() {
return 'Home',
},
renderLeftButton(navigator) {
@ide
ide / ExNavigatorExample.js
Created October 19, 2015 06:12
An example of setting up ExRoute
render() {
let navigationBarHeight = 64;
return (
<ExNavigator
initialRoute={homeRoute}
style={{ flex: 1 }}
sceneStyle={{ paddingTop: navigationBarHeight }}
/>
);
}
@ide
ide / ProfileRoute.js
Last active October 19, 2015 07:13
Showing how a function creates a parameterized route
function getProfileRoute(user) {
return {
renderScene(navigator) {
let ProfileScreen = require('./ProfileScreen');
return <ProfileScreen user={user} navigator={navigator} />;
},
getTitle() {
return user.fullName;
},