Skip to content

Instantly share code, notes, and snippets.

View topherPedersen's full-sized avatar
💭
Rolling my katamari ball

Christopher Pedersen topherPedersen

💭
Rolling my katamari ball
View GitHub Profile
@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
#import "RNNUtility.h"
@topherPedersen
topherPedersen / AppDelegate.m
Created August 4, 2022 01:49
Register React Native Navigation External Component in Swift
//#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
#!/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)
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 / DudeWheresMyScreen.ts
Last active July 25, 2024 22:38
Dude Where's My Screen: How to Know What Screen You Are On in a React Native Navigation App
Navigation.events().registerComponentDidAppearListener(async ({ componentName, componentType }) => {
if (componentType === 'Component') {
alert(`screen: ${componentName}`);
}
});
@topherPedersen
topherPedersen / App.js
Created February 28, 2022 18:13
Blank React-Native Boilerplate for New Application
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
/*
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
function takeThreeArgs(arg1, arg2, arg3) {
console.log(arg1);
console.log(arg2);
console.log(arg3);
}
const myArgs = ["foo", "bar", "baz"];
takeThreeArgs.apply(null, myArgs);
@topherPedersen
topherPedersen / deploySolanaProgram.md
Created January 15, 2022 00:58
Solana 101: Terminal Commands to Deploy Rust Program to Solana Blockchain (from Figment.io's Solana 101 Course)

$ yarn run solana:build:program

$ solana program deploy /home/zu/project/figment/learn-web3-dapp/dist/solana/program/helloworld.so

@topherPedersen
topherPedersen / lib.rs
Last active August 27, 2024 09:49
Solana 101: Hello, World Rust/Solana Program (from Figment.io's Solana 101 Course)
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint,
entrypoint::ProgramResult,
msg,
program_error::ProgramError,
pubkey::Pubkey,
};