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 / 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 / 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 January 7, 2024 16:40
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,
};
@topherPedersen
topherPedersen / setter.ts
Created January 14, 2022 04:58
Solana 101: Set Data on Solana Blockchain (From Figment.io's Solana 101 Course)
import {
Connection,
PublicKey,
Keypair,
TransactionInstruction,
Transaction,
sendAndConfirmTransaction,
} from '@solana/web3.js';
import type {NextApiRequest, NextApiResponse} from 'next';
import {getNodeURL} from '@figment-solana/lib';
@topherPedersen
topherPedersen / getter.ts
Created January 14, 2022 04:53
Solana 101: Get Data from Solana Blockchain (From Figment.io's Solana 101 Course)
import type {NextApiRequest, NextApiResponse} from 'next';
import {Connection, PublicKey} from '@solana/web3.js';
import {getNodeURL} from '@figment-solana/lib';
import * as borsh from 'borsh';
// The state of a greeting account managed by the hello world program
class GreetingAccount {
counter = 0;
constructor(fields: {counter: number} | undefined = undefined) {
if (fields) {