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 / stripDuplicates.js
Created Nov 5, 2020
How to Strip Duplicate Items from a JavaScript Array
View stripDuplicates.js
// Duplicates: Bob, Aaron, Frank
const arrayWithDuplicates = ["Aaron", "Bob", "Chris", "Dave", "Edward", "Bob", "Aaron", "Frank", "George", "Frank", "Henry", "Bob", "Bob", "Aaron", "Aaron", "Frank"];
function stripDuplicates(arrayWithDuplicates) {
let uniques = [];
arrayWithDuplicates.forEach( (value, index) => {
const indexWhereValueFirstAppears = arrayWithDuplicates.findIndex( (value_) => {
return value_ === value;
});
if (index === indexWhereValueFirstAppears) {
@topherPedersen
topherPedersen / findDuplicates.js
Created Nov 5, 2020
How to Find Duplicate Items in a JavaScript Array
View findDuplicates.js
// 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 Nov 2, 2020
TypeScript Union Type Demo
View unionTypes.ts
// 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 Aug 31, 2020
React-Native TypeScript Class Component Template
View App.tsx
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
@topherPedersen
topherPedersen / HelloDjango.txt
Created Jul 25, 2020
Django Hello, World / Quickstart / Cheatsheet for Windows
View HelloDjango.txt
$ cd Desktop
$ mkdir HelloDjango
$ cd HelloDjango
// Create Virtual Environment with Python's venv
$ python -m venv env
@topherPedersen
topherPedersen / build.gradle
Created Jul 2, 2020
Working build.grade (Sign in with Google Blog Post)
View build.gradle
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
@topherPedersen
topherPedersen / build.gradle
Created Jul 2, 2020
Broken build.grade (Sign in with Google Blog Post)
View build.gradle
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 Jun 11, 2020
Basic Line Chart in React-Native with VictoryCharts
View basicLineChart.js
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
View ReactNativeHyperlink.js
@topherPedersen
topherPedersen / simpleDotMap.js
Created May 24, 2020
Simple JavaScript .map() Method Example
View simpleDotMap.js
let oldArray = ["foo", "bar", "baz"];
let newArray = oldArray.map( (item) => {
if (item === "baz") {
return "B@Z!";
} else {
return item;
}
});
You can’t perform that action at this time.