Skip to content

Instantly share code, notes, and snippets.

View EvanBacon's full-sized avatar
🥓
Markdown developer

Evan Bacon EvanBacon

🥓
Markdown developer
View GitHub Profile
@EvanBacon
EvanBacon / scaleLongestSideToSize.js
Last active October 18, 2017 18:31
Three.js helper function for scaling the longest side of a mesh to a certain size. This is a debug method for AR development.
const scaleLongestSideToSize = (mesh, size) => {
const { x: width, y: height, z: depth } = new THREE.Box3().setFromObject(mesh).getSize();
const longest = Math.max(width, Math.max(height, depth));
const scale = size / longest;
mesh.scale.set(scale, scale, scale);
}
export default scaleLongestSideToSize;
@EvanBacon
EvanBacon / alignMesh.js
Last active October 18, 2017 18:31
Three.js helper function for aligning a mesh.
const alignMesh = (mesh, axis = { x: 0.5, y: 0.5, z: 0.5 }) => {
axis = axis || {};
const box = new THREE.Box3().setFromObject(mesh);
const size = box.getSize();
const { max } = box;
const min = { x: -box.min.x, y: -box.min.y, z: -box.min.z };
Object.keys(axis).map(key => {
const scale = axis[key];
@EvanBacon
EvanBacon / Instagram_App.js
Created July 6, 2018 00:29
Instagram Expo Clone Navigation
// Import React Navigation
import {
createBottomTabNavigator,
createStackNavigator,
} from 'react-navigation';
import tabBarIcon from './utils/tabBarIcon';
// Import the screens
import FeedScreen from './screens/FeedScreen';
import NewPostScreen from './screens/NewPostScreen';
@EvanBacon
EvanBacon / App.js
Created February 6, 2018 08:36 — forked from giautm/App.js
Sketch App
import Expo from 'expo';
import * as ExpoPixi from 'expo-pixi';
import React, { Component } from 'react';
import { Image, StyleSheet, View } from 'react-native';
export default class App extends Component {
state = {
strokeColor: Math.random() * 0xffffff,
strokeWidth: Math.random() * 30 + 10,
};
@EvanBacon
EvanBacon / output.sh
Created January 8, 2019 21:07
When expo build:ios works
GoogleAuthDemo $ exp build:ios -c
We've built a brand new CLI for Expo!
Expo CLI is a drop in replacement for exp.
Install: npm install -g expo-cli
Use: expo --help
Read more: https://blog.expo.io/expo-cli-2-0-released-a7a9c250e99c
[13:05:12] Making sure project is set up correctly...
[13:05:13] Your project looks good!
[13:05:13] Checking if current build exists...
@EvanBacon
EvanBacon / ReactNativeSimpleStyledMap.jsx
Created February 17, 2019 02:09
A custom map renderer to spice things up 🍕
import React from 'react';
// import
import { MapView } from 'expo';
export default BaseMap = ({ children, ...props }) => (
<MapView
{...props}
>
<MapView.UrlTile
/**

h1

h2

h3

h4

h5
@EvanBacon
EvanBacon / transformAssetLocation.ts
Created August 20, 2021 20:09
Emulate "public path" functionality in React Native
import { Platform } from "react-native";
import getDevServer from "react-native/Libraries/Core/Devtools/getDevServer";
const devServerInfo = getDevServer();
/**
* Transform a local "public" path location to a URL that works in React Native.
*
* When the project is not hosted from a development server, use an offline path from an embedded asset.
*
@EvanBacon
EvanBacon / AndroidManifest.xml.diff
Last active November 29, 2021 16:30
Diff between SDK 42 & SDK 43 AppDelegate.m for user reference when updating dangerous Expo config plugins
diff --git a/templates/expo-template-bare-minimum/android/app/src/main/AndroidManifest.xml b/templates/expo-template-bare-minimum/android/app/src/main/AndroidManifest.xml
index 136676d7c5..764b402b52 100644
--- a/templates/expo-template-bare-minimum/android/app/src/main/AndroidManifest.xml
+++ b/templates/expo-template-bare-minimum/android/app/src/main/AndroidManifest.xml
@@ -8,25 +8,20 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- END OPTIONAL PERMISSIONS -->
- <application
- android:name=".MainApplication"
@EvanBacon
EvanBacon / metro-transformer.js
Created December 22, 2021 20:31
Using Realm with Expo Metro config "Exotic" bundling.
const { createExoticTransformer } = require("@expo/metro-config/transformer");
module.exports = createExoticTransformer({
// Add realm packages to the list of modules to transpile locally.
transpileModules: ["@realm/", "realm"],
});