Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Chris Jungmann jungchris

View GitHub Profile
@jungchris
jungchris / Template.js
Created Apr 13, 2017
React Native Component Template
View Template.js
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View
} from 'react-native';
export default class Template extends Component {
render() {
@jungchris
jungchris / selector.js
Created Apr 11, 2017
A Simple Redux Selector Example
View selector.js
import { createSelector } from 'reselect'
const shopItemsSelector = state => state.shop.items
const taxPercentSelector = state => state.shop.taxPercent
const subtotalSelector = createSelector(
shopItemsSelector,
items => items.reduce((acc, item) => acc + item.value, 0)
)
@jungchris
jungchris / Template.js
Created Mar 16, 2017
React Native Template for Flexbox Layout
View Template.js
// This expands on the React Native docs
// https://facebook.github.io/react-native/docs/height-and-width.html
<View style={{flex: 1, flexDirection: 'column'}}>
<View style={{flex: 1, flexDirection: 'row'}}>
<View style={{flex: 5, backgroundColor: 'powderblue'}}>
<Text style={{ fontSize: 18, fontFamily: fonts.base}}>Box 1</Text>
</View>
<View style={{flex: 2, backgroundColor: 'skyblue'}}>
<Text>Box 2</Text>
@jungchris
jungchris / StockPriceAsync.js
Created Mar 9, 2017
Seven Lines of React Native Code to Show a Stock Price Alert
View StockPriceAsync.js
// Credit to: https://blog.expo.io/react-native-meets-async-functions-3e6f81111173#.7dvhnohnu
async function showAppleStockPriceAsync() {
let url = 'http://dev.markitondemand.com/Api/v2/Quote/json?symbol=AAPL'
let response = await fetch(url)
let body = await response.json()
let { AlertIOS } = require('react-native')
AlertIOS.alert(body.Symbol, '$' + body.LastPrice)
}
showAppleStockPriceAsync()
View ReactClassBindingExample.js
// I love this way of creating a superclass as a bind helper method,
// rather than binding in the constructor as follows:
/*
constructor() {
super();
this. _handleClick = this. _handleClick.bind(this);
this. _handleFoo = this. _handleFoo.bind(this);
}
*/
// we bind in the BaseComponent instead using forEach with a fat arrow function
@jungchris
jungchris / AppBeta.js
Last active Dec 10, 2016
Creating Random React Components
View AppBeta.js
import React from 'react';
import Child from './Child';
import Child2 from './Child2';
// const App = () => <h1>ReactDOM</h1>
// class App extends React.Component {
// render() {
// return <h1>Reactly</h1>
// }
@jungchris
jungchris / app.css
Created Dec 5, 2016
Scoreboard Application to Learn React
View app.css
body {
background: #d5d5d5;
font-family: arial;
color: #FAFAFA;
text-transform: uppercase;
}
.scoreboard {
background: #333;
width: 700px;
@jungchris
jungchris / ViewController.swift
Created Apr 15, 2016
Controller for ToDo App
View ViewController.swift
//
// ViewController.swift
// HelloToDoSwift
//
// Created by Chris Jungmann on 4/1/16.
// Copyright © 2016 Chris Jungmann. All rights reserved.
//
import UIKit
@jungchris
jungchris / SeatModel.swift
Last active Apr 15, 2016
Encode with Coder
View SeatModel.swift
func initWithCoder(aDecoder:NSCoder ) -> instancetype {
self = super.init()
self.seatUUID = aDecoder.decodeObjectForKey("seatUUID")
self.seatManuID1 = aDecoder.decodeObjectForKey("seatManuID1")
self.seatManuID2 = aDecoder.decodeObjectForKey("seatManuID2")
self.seatDataStructure = aDecoder.decodeObjectForKey("seatDataStructure")
self.seatBabyPresent = aDecoder.decodeObjectForKey("seatBabyPresent")
self.seatBatteryLevel = aDecoder.decodeObjectForKey("seatBatteryLevel")
self.seatSignalStrength = aDecoder.decodeObjectForKey("seatSignalStrength")
@jungchris
jungchris / AddItem.swift
Created Apr 15, 2016
Controller to add an item in Swift
View AddItem.swift
//
// AddStuffVC.swift
// HelloToDoSwift
//
// Created by Chris Jungmann on 4/1/16.
// Copyright © 2016 Chris Jungmann. All rights reserved.
//
import UIKit
You can’t perform that action at this time.