Skip to content

Instantly share code, notes, and snippets.

View joshparkerj's full-sized avatar
🥰

Josh Parker joshparkerj

🥰
View GitHub Profile
@joshparkerj
joshparkerj / fire.py
Created September 16, 2020 23:48
net worth over time
def fire(age, expected_death, expected_retirement, savings, income, spending, rate):
import matplotlib.pyplot as plt
age *= 10
expected_death *= 10
expected_retirement *= 10
remaining_tenths_of_a_year = int(expected_death-age)
ages = []
savingses = []
ages.append(age/10)
savingses.append(savings)
@joshparkerj
joshparkerj / ikea-brand-names.json
Last active March 4, 2021 02:55
ikea brand names
["ABSORB","ADMETE","AGAM","AGEN","AGNARYD","AGNE","AINA","AKSDAL","AKURUM","AKUT","ALARM","ALEX","ALG","ALKALISK","ALLAK","ALLAMÅLA","ALSARP","ALSEDA","ALSTER","ALSVIK","ALVE","ALVINE","ALÄNG","AMALIA","AMON","AMORF","ANDREA","ANDRUP","ANDY","ANEBODA","ANEMON","ANITA","ANJA","ANNAMOA","ANNARS","ANNO","ANNONS","ANORDNA","ANRIK","ANSLUTA","ANSSI","ANTIFONI","ANTIK","ANTILOP","ANTONIUS","APA","APELSKÄR","ARHOLMA","ARILD","ARRAK","ARV","ARVINN","ASKER","ASPEKT","ASPELUND","ASPUDDEN","ASPVIK","ASTER","ASTRAKAN","ATNA","ATTEST","ATTITYD","AUKRA","BAGGE","BAGIS","BALK","BALSER","BAND","BAREN","BARNSLIG","BAROMETER","BASISK","BASTANT","BATIST","BEATA","BEDDINGE","BEHANDLA","BEHÖVD","BEKVÄM","BELLINGE","BENJAMIN","BENNO","BERGSBO","BERIT","BERNHARD","BERTA","BERTBY","BERTIL","BERYLL","BERÄTTA","BERÖM","BESKÅDA","BESTÅ","BETA","BEVARA","BIBBI","BIBY","BIGARRÅ","BIGUM","BILD","BILDAD","BILLSTA","BILLY","BISSA","BITIG","BJURSTA","BJURÖN","BJÄRNUM","BJÖRKEFALL","BJÖRKEN","BJÖRKUDDEN","BJÖRNHOLMEN","BLAD","BLADET","BLADHUL
@joshparkerj
joshparkerj / reviews-example.txt
Created March 9, 2021 03:04
show url and sample json output
GET /api/reviews/11,22,38
[
{
"itemID": 11,
"number": 3,
"average": 4.7
},
{
"itemID": 22,
"number": 8,
@joshparkerj
joshparkerj / partition-list.js
Created April 8, 2021 03:48
This is what I came up with for partition list during the V&V session April 7
/**
* Definition for singly-linked list.
* function ListNode(val, next) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
*/
/**
* @param {ListNode} head
* @param {number} x
@joshparkerj
joshparkerj / reactjs-docs.user.js
Last active November 6, 2021 19:13
browse the reactjs docs with arrow keys
// ==UserScript==
// @name Browse the reactjs docs with arrow keys
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://reactjs.org/docs/*
// @icon https://www.google.com/s2/favicons?domain=reactjs.org
// @grant none
// ==/UserScript==
@joshparkerj
joshparkerj / page-views.js
Last active April 10, 2021 06:52
script to quickly get the number of page views for all of the wikipedia articles listed on a wikipedia category page.
const parser = new DOMParser();
Promise.all(
[...document.querySelectorAll('.mw-category-group a')]
.map(a => {
return fetch(`https://en.wikipedia.org/w/index.php?title=${a.href.split('wiki/')[1]}&action=info`)
.then(r => r.text()).then(bodyText => parser.parseFromString(bodyText, 'text/html'))
.then(doc => {
const title = doc.querySelector('#mw-pageinfo-display-title td ~ td').textContent;
const views = doc.querySelector('.mw-pvi-month').textContent;
return `Title: ${title} Views: ${views}`;
/**
* @param {character[][]} grid
* @return {number}
*/
var numIslands = function(grid) {
var visited = grid.map(array => array.map(e => false));
var counter = 0;
var visit = function(i, j) {
visited[i][j] = true;
@joshparkerj
joshparkerj / decode-variations.js
Created June 7, 2021 09:28
decode variations puzzle
/* this is the first puzzle I've ever received from pramp.
I admit, I didn't know how to approach the problem until after I'd slept on it.
Here's how the challenge works:
Each letter of the alphabet is encoded as a number
A -> 1
B -> 2
C -> 3
...
Z -> 26
@joshparkerj
joshparkerj / get-predictions.js
Created June 7, 2021 23:45
function that aggregates the win probabilities on fivethirtyeight's nba predictions page
function getPredictions(teamAbbreviation) {
// run this at https://projects.fivethirtyeight.com/2021-nba-predictions/games/
// teamAbbreviation can be one of the following:
// 'DEN' 'PHX' 'LAC' 'UTA'
return new Promise((resolve) => {
document.getElementById('js-upcoming-expander').click();
const afterTimeout = () => {
const selector = `#upcoming-days tr[data-team="${teamAbbreviation}"]`;
const toFraction = (e) => Number(e.textContent.replace('%', '')) / 100;
@joshparkerj
joshparkerj / parse-goodreads.js
Created July 1, 2021 05:14
Parse goodreads book list
// I used this at https://www.goodreads.com/series/40650-discworld
console.log(['title,author,rating,ratings,reviews,date,editions', ...[...document.querySelectorAll('.responsiveBook')].map((rb) => {
const title = rb.querySelector('.gr-h3 span[itemprop="name"]').textContent;
const author = rb.querySelector('span[itemprop="author"]').textContent;
const rating = rb.querySelector('.communityRating__starsWrapper ~ .gr-metaText').textContent;
const allTextContent = rb.textContent;
const matches = allTextContent.match(/(?<ratings>[\d,]+) Ratings[^\d\w]*((?<reviews>[\d,]+) Reviews)?[^\d\w]*(published (?<date>\d+))?[^\d\w]*((?<editions>\d+) editions)?/);
return {
title,