Skip to content

Instantly share code, notes, and snippets.

View oakley808's full-sized avatar
🌮

Michael Oakley oakley808

🌮
View GitHub Profile
@oakley808
oakley808 / loading_messages.js
Created February 5, 2021 18:55 — forked from meain/loading_messages.js
Funny loading messages
export default [
"Reticulating splines...",
"Generating witty dialog...",
"Swapping time and space...",
"Spinning violently around the y-axis...",
"Tokenizing real life...",
"Bending the spoon...",
"Filtering morale...",
"Don't think of purple hippos...",
"We need a new fuse...",
@oakley808
oakley808 / stripe-credit-card-numbers.md
Created September 24, 2020 18:22 — forked from rymawby/stripe-credit-card-numbers.md
Stripe test credit card numbers for use in development

#Test credit card numbers to use when developing with Stripe

4242424242424242 Visa

4012888888881881 Visa

4000056655665556 Visa (debit)

@oakley808
oakley808 / README-Template.md
Created April 17, 2018 18:06 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@oakley808
oakley808 / users.json
Last active February 23, 2018 19:44
Sample data for user-manager
[
{
"id": "a2bab180-17da-11e8-8d5b-2936574e8713",
"first": "Michael",
"last": "Oakley",
"address": "123 Maple St. Anytown, CO"
},
{
"id": "aabab190-11e9-18da-8d5b-1136474f7711",
"first": "John",
@oakley808
oakley808 / MyFitnessPal-Highcharts.js
Created February 5, 2018 05:22
Draw a line for the average value on MyFitnessPal charts. (Paste into browser console.)
chartNum = Highcharts.charts.length - 1 // grab the last (current) chart
data = Highcharts.charts[chartNum].series[0].yData.filter(d => d > 0) // remove the nulls/zero values
avg = Math.round(data.reduce((a, b) => a + b) / data.length) // calc the average
Highcharts.charts[chartNum].yAxis[0].addPlotLine({ // draw the plotline
color: avg > 2000 ? '#FF00FF' : 'green',
dashStyle: 'longdashdot',
value: avg,
width: '2',
zIndex: 2 // To not get stuck below the regular plot lines
});
@oakley808
oakley808 / Multipoll.js
Last active July 20, 2017 22:02
Redux-saga polling recipe with concurrency and canceling
// runs on load
export function* main() {
const pollingInstance = yield fork(pollingWatcher);
// fork other watchers ...
// if location changes, kill the watcher(s)
yield take(LOCATION_CHANGE);
yield cancel(pollingInstance);
// cancel other watchers ...
}
let groupBy = 'date';
let apiData = [{date: 3, count: 5},{date: 2, count: 3},{date: 1, count: 1},{date: 1, count: 2},{date: 2, count: 4},{date: 3, count: 6}];
let sortedApiData = apiData.sort((a, b) => (a[groupBy] > b[groupBy]) ? 1 : ((b[groupBy] > a[groupBy]) ? -1 : 0 ))
let dateArray = sortedApiData.map((el, idx) => el[groupBy]).filter((el, i, a) => el !== a[i-1]);
result = dateArray
.map((dayNumber, idx) =>
sortedApiData
.filter((apiDataPoint, i) =>
@oakley808
oakley808 / saga-polling.js
Created October 6, 2016 15:47
A recipe for polling an API in redux-saga
export function* main() {
const { payload } = yield take(SOME_START_SIGNAL);
const watcherInstance = yield fork(updateResource, payload);
// cancel task instance on location change
yield take(LOCATION_CHANGE);
yield cancel(watcherInstance);
}
function* updateResource(id) {
@oakley808
oakley808 / WatcherGeneratorStrategy.js
Created September 14, 2016 20:17
Generator functions post data and to watch for location change
function* main() {
// create variable for watcher
const watcherInstance = yield fork(watcher);
// if location changes, continuation
yield take(LOCATION_CHANGE);
yield cancel(watcherInstance); // cancel task instance
}
{
"itemPool": ["Item pool 1 from server", "Item pool 2 from server"]
}