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 / findDuplicates.js
Created November 5, 2020 21:48
How to Find Duplicate Items in a JavaScript Array
// Duplicates: Bob, Aaron, Frank
const arrayWithDuplicates = ["Aaron", "Bob", "Chris", "Dave", "Edward", "Bob", "Aaron", "Frank", "George", "Frank", "Henry", "Bob", "Bob", "Aaron", "Aaron", "Frank"];
function findDuplicates(arrayWithDuplicates) {
let duplicates = [];
arrayWithDuplicates.forEach( (value, index) => {
const indexWhereValueFirstAppears = arrayWithDuplicates.findIndex( (value_) => {
return value_ === value;
});
const indexWhereValueLastAppears = arrayWithDuplicates.lastIndexOf(value);
@topherPedersen
topherPedersen / unionTypes.ts
Created November 2, 2020 00:49
TypeScript Union Type Demo
// DEMO: Using Union-Types in TypeScript
// Question: What are Union Types???
// Answer: Union Types are TypeScript types which can be equal to many different types which often share 'union' properties amongst the various different types. For example, an Athlete Union-Type could be used to represent FootballPlayer, BasketballPlayer, and BaseballPlayer types
type FootballPlayer = {
firstName: string,
lastName: string,
jerseyNumber: number,
@topherPedersen
topherPedersen / App.tsx
Created August 31, 2020 16:28
React-Native TypeScript Class Component Template
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
@topherPedersen
topherPedersen / HelloDjango.txt
Created July 25, 2020 05:18
Django Hello, World / Quickstart / Cheatsheet for Windows
$ cd Desktop
$ mkdir HelloDjango
$ cd HelloDjango
// Create Virtual Environment with Python's venv
$ python -m venv env
@topherPedersen
topherPedersen / build.gradle
Created July 2, 2020 08:27
Working build.grade (Sign in with Google Blog Post)
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
@topherPedersen
topherPedersen / build.gradle
Created July 2, 2020 08:26
Broken build.grade (Sign in with Google Blog Post)
signingConfigs {
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
@topherPedersen
topherPedersen / basicLineChart.js
Created June 11, 2020 18:01
Basic Line Chart in React-Native with VictoryCharts
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
@topherPedersen
topherPedersen / ReactNativeHyperlink.js
Created June 9, 2020 12:56
React Native Hyperlink
@topherPedersen
topherPedersen / simpleDotMap.js
Created May 24, 2020 21:20
Simple JavaScript .map() Method Example
let oldArray = ["foo", "bar", "baz"];
let newArray = oldArray.map( (item) => {
if (item === "baz") {
return "B@Z!";
} else {
return item;
}
});
@topherPedersen
topherPedersen / autoFocusTextInputModal.jsx
Last active May 24, 2020 01:45
TextInput autoFocus work-around for use in React-Native Modals
<Modal
visible={true}
onShow={ () => { this.textInput.focus(); }}>
{/* Adapted From: https://stackoverflow.com/questions/42730400/focus-input-on-load-of-modal-in-react-native */}
<KeyboardAvoidingView style={{}}>
<TextInput
style={{}}