Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Rolling my katamari ball

Christopher Pedersen topherPedersen

💭
Rolling my katamari ball
View GitHub Profile
@topherPedersen
topherPedersen / YourCode.swift
Created August 5, 2022 16:27
Blog Post Embed (YourCode.swift): A Working Example of React Native Navigation External Components
View YourCode.swift
let externalComponentName = "YourComponentName"
let viewController = YourViewController()
registerExternalComponent(externalComponentName, viewController)
@topherPedersen
topherPedersen / RNNUtility.m
Created August 5, 2022 16:26
Blog Post Embed (RNNUtility.m): A Working Example of React Native Navigation External Components
View RNNUtility.m
//
// RNNUtility.m
// yourapp
//
// Created by Christopher Pedersen on 8/5/22.
// Copyright © 2022 Super Sweet Co. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <ReactNativeNavigation/ReactNativeNavigation.h>
@topherPedersen
topherPedersen / RNNUtility.h
Created August 5, 2022 16:26
Blog Post Embed (RNNUtility.h): A Working Example of React Native Navigation External Components
View RNNUtility.h
//
// RNNUtility.h
// yourapp
//
// Created by Christopher Pedersen on 8/5/22.
// Copyright © 2022 Super Sweet Co. All rights reserved.
//
#ifndef RNNUtility_h
#define RNNUtility_h
@topherPedersen
topherPedersen / yourapp-Bridging-Header
Created August 5, 2022 16:25
Blog Post Embed (yourapp-Bridging-Header): A Working Example of React Native Navigation External Components
View yourapp-Bridging-Header
#import "RNNUtility.h"
@topherPedersen
topherPedersen / AppDelegate.m
Created August 4, 2022 01:49
Register React Native Navigation External Component in Swift
View AppDelegate.m
//#import "AppDelegate.h"
//#import <React/RCTBridge.h>
//#import <React/RCTBundleURLProvider.h>
//#import "RNNCustomViewController.h"
//#import <ReactNativeNavigation/ReactNativeNavigation.h>
class AppDelegate : RCTBridgeDelegate {
@topherPedersen
topherPedersen / delete_old_branches.sh
Last active October 24, 2022 15:09
Delete Old Git Branches on Mac using Zsh Shell Script
View delete_old_branches.sh
#!/bin/zsh
# Put this script in your git repo: /Users/yourusername/yourrepo/delete_old_branches.sh
# Create a text file called old_branches.txt, put this in your repo as well: /Users/yourusername/yourrepo/old_branches.txt
# In old_branches.txt, put the names of the branches you want to delete. 1 Branch name per line, no commas.
# Then run...
# cd /Users/yourusername/yourrepo
# chmod 755 delete_old_branches.sh
# git config --global --add safe.directory /Users/yourusername/yourrepo
@topherPedersen
topherPedersen / App.js
Last active July 6, 2022 14:05
Custom Side-Menu / Drawer in React-Native (Demo/Prototype)
View App.js
import React, { useState } from 'react';
import {
View,
SafeAreaView,
Dimensions,
Image,
} from 'react-native';
import { GestureDetector, Gesture } from 'react-native-gesture-handler';
import Animated, {
useSharedValue,
@topherPedersen
topherPedersen / App.js
Created February 28, 2022 18:13
Blank React-Native Boilerplate for New Application
View App.js
import React from 'react';
import {
SafeAreaView,
Text,
} from 'react-native';
class App extends React.Component {
constructor(props) {
super(props);
}
@topherPedersen
topherPedersen / uuid.js
Created February 17, 2022 04:21
Generate UUID in JavaScript
View uuid.js
/*
UUIDs (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDentifier), according to RFC 4122, are identifiers designed to provide certain uniqueness guarantees.
While it is possible to implement RFC-compliant UUIDs in a few lines of JavaScript code (e.g., see @broofa's answer, below) there are several common pitfalls:
Invalid id format (UUIDs must be of the form "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx", where x is one of [0-9, a-f] M is one of [1-5], and N is [8, 9, a, or b]
Use of a low-quality source of randomness (such as Math.random)
Thus, developers writing code for production environments are encouraged to use a rigorous, well-maintained implementation such as the uuid module.
@topherPedersen
topherPedersen / passAnArrayOfArguments.js
Created February 2, 2022 17:25
How to Pass an Array of Arguments in JavaScript
View passAnArrayOfArguments.js
function takeThreeArgs(arg1, arg2, arg3) {
console.log(arg1);
console.log(arg2);
console.log(arg3);
}
const myArgs = ["foo", "bar", "baz"];
takeThreeArgs.apply(null, myArgs);