Skip to content

Instantly share code, notes, and snippets.

View faceyspacey's full-sized avatar

James Gillmore faceyspacey

View GitHub Profile
var express = require(‘express’);
var app = express();
app.get(‘/’, function (req, res) {
 res.send(‘Hello World!’);
});
var server = app.listen(3000, function () {
 var host = server.address().address;
 var port = server.address().port;

Tracker.autorun(func, { subscriptionsReady: [‘posts’, ‘comments’], isTrue: () => Session.get(‘foo’) userIs: ‘admin’ templateIsVisible: ‘AllPosts’ });

import * as actions from './actions';
class MyComponent extends React.Component {
componentWillMount() {
this.props.subscribe('posts', [categoryId, limit, page});
}
render() {
<View>
{this.props.posts.map((post) => <View><Text>{post.title}</Text</View>)}
@faceyspacey
faceyspacey / meteor-accounts-twitter-auth.js
Last active June 10, 2019 17:30
meteor-accounts-twitter-auth
const Twit = Meteor.npmRequire('twit');
Accounts.registerLoginHandler('twitter', function(params) {
const data = params.twitter;
// If this isn't twitter login then we don't care about it. No need to proceed.
if (!data) {
return undefined;
}
import React, { Component } from 'react';
import {
Text,
View,
Image,
Animated,
Easing,
} from 'react-native';
const ALL_PROPERTIES = ['translateX', 'translateY', 'translateZ', 'rotateX', 'rotateY', 'rotateZ', 'scale'];
@faceyspacey
faceyspacey / ImageAlternative.js
Created October 19, 2016 21:34
RNW Image component that does not use the backgroundImage property
import React, { Component } from 'react'
import {
View,
ActivityIndicator,
StyleSheet,
} from 'react-native'
export default class Image extends Component {
@faceyspacey
faceyspacey / rnw.stylesheet.index.js
Last active November 26, 2016 04:28
RNW className transform concept
import * as css from './css';
import createReactStyleObject from './createReactStyleObject';
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
import flattenStyle from '../../modules/flattenStyle';
import React from 'react';
import ReactNativePropRegistry from '../../modules/ReactNativePropRegistry';
import StyleSheetValidation from './StyleSheetValidation';
import jss from 'jss'
import preset from 'jss-preset-default'
import React from 'react';
import isEqual from 'lodash/isEqual';
function RouteTransitionGroup() {
let {children, location} = this.props;
let {type, payload, pathname} = location;
children = React.Children.toArray(children)
.filter(child => isChildMatch(child, location));
@faceyspacey
faceyspacey / redux-middleware-test.js
Last active February 11, 2017 10:43
redux middleware test
a = next => action => { console.log('a1'); action = next(action+'A'); console.log('a2'); return action+'a' }
b = next => action => { console.log('b1'); action = next(action+'B'); console.log('b2'); return action+'b' }
c = next => action => { console.log('c1'); action = next(action+'C'); console.log('c2'); return action+'c' }
funcs = [a, b, c]
dispatch = funcs.reduce((a, b) => (...args) => a(b(...args)))(action => { console.log('BEFORE'); return action; })
dispatch('FOO')
a = next => { console.log('A ACTION'); return (action) => { console.log('a1'); action = next(action+'A'); console.log('a2'); return action+'a'; }; }
b = next => { console.log('B ACTION'); return (action) => { console.log('b1'); action = next(action+'B'); console.log('b2'); return action+'b'; }; }
@faceyspacey
faceyspacey / createLocationReducer.js
Last active May 31, 2017 06:38
createLocationReducer with unused reconcileEntries algorithm
// @flow
import { NOT_FOUND } from '../index'
import isServer from '../pure-utils/isServer'
import { nestHistory } from '../pure-utils/nestAction'
import type {
LocationState,
RoutesMap,
Action,
Payload,
History