Skip to content

Instantly share code, notes, and snippets.

View richardgill's full-sized avatar

Richard Gill richardgill

View GitHub Profile
@richardgill
richardgill / apphubWithRnws.sh
Created February 19, 2016 23:45
Attempt to make apphub build.zip with rnws instead of default react-native bundle.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR=$DIR/..
PLIST_FILE="$ROOT_DIR/iOS/Info.plist"
TMP_DIR="/tmp/apphub/$(uuidgen)/"
BUNDLE_DIR_NAME="ios.bundle"
BUNDLE_DIR="$TMP_DIR$BUNDLE_DIR_NAME"
ZIP_NAME="build.zip"
OUTPUT_ZIP="$TMP_DIR$ZIP_NAME"
BUNDLE_NAME="main.jsbundle"
@richardgill
richardgill / spreading.js
Last active March 8, 2016 22:46
Spreading examples
var hash = {a: 1, b: 2}
{...hash} // => {a: 1, b: 2} <- this hash is like a '_.cloned hash'
// All these hashes are 'cloned'. Nothing every gets mutated
{c: 3, ...hash} // => {a: 1, b: 2, c: 3}
{...hash, c: 3} // => {a: 1, b: 2, c: 3}
{...hash, b: 3} // => {a: 1, b: 3}
{b: 3, ...hash} // => {a: 1, b: 2}
@richardgill
richardgill / gist:25fd908503e77d966892
Created March 23, 2016 10:51
custom navigation animations
//in main app
configureScene(route, navigator) {
if (route.sceneConfig) {
return route.sceneConfig;
}
return CustomNavigatorSceneConfigs.HorizontalJump;
},
//customNavigatorSceneConfigs.js
import React from 'react-native'
@richardgill
richardgill / normalizeRNStyles.js
Last active May 3, 2016 08:14
Normalize RN styles - Code for iPhone 6s and it should work across all devices.
import _ from 'lodash'
import { Dimensions } from 'react-native'
const { height } = Dimensions.get('window')
const iphone6Height = 667
const fieldsToNormalize = [
'fontSize',
'width',
'height',
'margin',
@richardgill
richardgill / JWT Example.md
Last active July 7, 2017 10:05
JWT Example (Java)

#Login via HTTP JSON api to get JWT token

##Client does login request

POST https://myapplication.com/login, body: {username: 'richardgill', password: 'password'}

Server receives request. Takes credentials and checks they are correct.

Server uses secret key: "secretkey123!" to generate a jwt token. (Using jwt library)

@richardgill
richardgill / normalizeStyle.js
Created December 2, 2016 16:31
Makes React Native components look more consistent on different device sizes. The base size is an iPhone 6.
import _ from 'lodash'
import { Dimensions, PixelRatio } from 'react-native'
import { platformIsIos } from 'expresso-common/common/platform'
const { height } = Dimensions.get('window')
const iphone6Height = 667
const pixelRatio = PixelRatio.get()
const fieldsToNormalize = [
'fontSize',
'lineHeight',
@richardgill
richardgill / navigator.js
Created December 2, 2016 16:35
Gives you an idea of the sorts of things we needed from a general purpose navigator
import React, { Component } from 'react'
import { Navigator, StatusBar, View } from 'react-native'
import customNavigatorScenes from '../../common/customNavigatorScenes'
import style from './style'
import ErrorListener from './errorListener'
import NetworkConnectivity from '../networkConnectivity'
import _ from 'lodash'
import { brandPrimary } from '../../styleVariables'
import { reduxComponentName } from '../../common/reduxComponentName'
@richardgill
richardgill / routes.js
Created December 2, 2016 16:38
How to define all your routes in one place to avoid things getting messy
import { Navigator } from 'react-native'
export default {
component1: (order = null) => ({
component: require('./components/component1').default,
}),
component2: (prop1) => ({
component: require('./components/component2').default,
passProps: { prop1: prop1 },
sceneConfig: Navigator.SceneConfigs.FloatFromRight,
import React from 'react'
export default (props) => <Text {…props} style={[myCustomStyle, props.style]} />
#!/bin/bash
node_modules/.bin/nodemon -w ../my-common-module --exec "rsync -av --progress --exclude=node_modules --exclude .git ../my-common-module/ ./node_modules/my-common-module/"