This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController { | |
@IBOutlet weak var sceneView: ARSCNView! | |
// declare world tracker | |
let configuration = ARWorldTrackingConfiguration() | |
override func viewDidLoad() { | |
super.viewDidLoad() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - ISO8601 to NSDate & vice-versa | |
// Convert ISO 8601 standard Zulu date+time to NSDate | |
+ (NSDate*)convertISO8601ToNSDate:(NSString*)isoString { | |
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; | |
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"]; | |
// Always use this locale when parsing fixed format date strings | |
NSLocale *posix = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; | |
[formatter setLocale:posix]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background: #d5d5d5; | |
font-family: arial; | |
color: #FAFAFA; | |
text-transform: uppercase; | |
} | |
.scoreboard { | |
background: #333; | |
width: 700px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented presentingViewController:(UIViewController *)presenting sourceViewController:(UIViewController *)source | |
{ | |
// Here, we'll provide the presentation controller to be used for the presentation | |
Class presentationControllerClass; | |
// If our presentation should be awesome, return the AAPLCoolPresentationController. We determine this based on -[AAPLRootViewController presentationShouldBeAwesome] | |
if([source isKindOfClass:[AAPLRootViewController class]] && [(AAPLRootViewController *)source presentationShouldBeAwesome]) | |
{ | |
presentationControllerClass = [AAPLCoolPresentationController class]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)postJSONToSlack { | |
NSLog(@"Post JSON to Slack"); | |
// BuiltInNM #random | |
// NSMutableURLRequest *request = [NSMutableURLRequest | |
// requestWithURL:[NSURL URLWithString:@"https://hooks.slack.com/services/"]]; | |
// This is for NMDevs to #random | |
NSMutableURLRequest *request = [NSMutableURLRequest |