Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Boyko brianboyko

View GitHub Profile
@brianboyko
brianboyko / .eslintrc.js
Created Oct 6, 2020
Current Build Process - looking for advice
View .eslintrc.js
// https://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint',
sourceType: 'module',
allowImportExportEverywhere: false
},
env: {
@brianboyko
brianboyko / shadenfreude.md
Created Oct 3, 2020
On the Morality of Shadenfreude
View shadenfreude.md

Some thoughts on Trump having COVID.

We have no way of knowing whether or not Trump really has COVID.

One of the frustrating things about the news is that while Donald Trump and the White House says Trump has COVID, we cannot believe them on their words alone. This administration has lied about everything from day one (including the President's health) and we have long learned not to take anything they have said at face value.

Because of four years of lies, misdirection, and long cons, we just don't have any reason at all to believe it - and the only evidence we have either way is coming from the White House. All we can say for sure is that the White House is claiming that Donald Trump has COVID, and that isn't worth a damn thing.

One can think of many reasons that Donald Trump might be faking the disease if he doesn't have it: to downplay how deadly it is by a "miraculous recovery" right before the election, to get out of the October 15th debates. Already the Biden campaign has pulled negativ

@brianboyko
brianboyko / new-reducer.ts
Created Sep 21, 2020
You can save a heck of a lot of boilerplate by switching to Redux Toolkit
View new-reducer.ts
import Api from "../../ajax/api";
import {createSlice} from '@reduxjs/toolkit';
import get from 'lodash/get';
export interface IPhotosState {
query: string;
totalHits: number;
hits: any[];
total: number;
}
View pepper2020.txt
extended from /u/irepostoldmemes on imgur, and with apologies to the Butthole Surfers.
---
Mark infected Sharon.
Sharon got Sharice.
They were sharin' Sharon's Covids
'Cause it's such a quick disease.
Mikey has Pneumonia scars,
Bobby got shot by the racists,
@brianboyko
brianboyko / Match.spec.ts
Created Jul 11, 2020
A Simple Match Class.
View Match.spec.ts
import Match from "./Match";
const simpleMatch = new Match(
[
["reverse", (input: string) => input.split("").reverse().join("")],
["scream", (input: string) => input.toUpperCase()],
],
(input: string) => `default output: ${input}`
);
@brianboyko
brianboyko / Movie.cpp
Last active Jun 20, 2020
Am I creating a memory leak here?
View Movie.cpp
#include "Movie.h"
#include <iostream>
#include <string>
Movie::Movie(string name, string rating, int init_watched) : name{name}, rating{rating}, watched{init_watched} {
std::cout << "Creating: " << name << " " << rating << "\n";
};
Movie::Movie() : Movie{"UNNAMED MOVIE", "UNNAMED RATING", 0} {};
View The_Supermarket_Notes.md

The Supermarket Notes

Here are some notes Brian Boyko is using to swot up for the interview with a supermarket client, but I'm saving it to Github Gist so that maybe others can use it. This is mostly stuff I already knew, but it's been a while since I had to get back-to-basics and remember these as concepts, so I did a bit of swotting up, and took these notes.

The Event Loop

Javascript has a call stack; like any LIFO stack, it only pushes and pops; when a function is called, it pushes onto the stack, when the function is returned, it pops that function off of the stack. This is how the program "keeps track" of where it is; when you see an error message, you'll almost always see a printout of the current call stack.

Javascript was designed as a single-threaded language; it does one thing at a time. This makes it great for simplicity but when you have "slow" functions, like a database call or a network request (which may never resolve), then the entire execution will wait for your slow functions. The b

@brianboyko
brianboyko / eslintrc.yml
Created Mar 18, 2020
eslint isn't working
View eslintrc.yml
extends:
- 'prettier'
- 'prettier/react'
- 'plugin:react/recommended'
- 'plugin:import/errors'
- 'plugin:import/warnings'
- 'plugin:jsx-a11y/recommended'
- 'plugin:@typescript-eslint/recommended'
- 'prettier/@typescript-eslint'
overrides: [{ files: ['*.js', '*.jsx'], rules: { '@typescript-eslint/*': "off" } }]
@brianboyko
brianboyko / example.ts
Created Feb 17, 2020
makeReduxStrategy
View example.ts
import makeReduxStrategy, {ReduxAction, ReduxReducer} from './makeReduxAction';
interface CounterAction extends ReduxAction {
payload: number;
}
const counterStrategy = makeReduxStrategy<number>({
ADD: (state: number, {payload}: CounterAction) => state + payload,
SUBTRACT: (state: number, {payload}: CounterAction) => state - payload,
})
View ifTruthyThen.ts
// *REALLY* hate Ternary syntax or && in your JSX rendering? Try this handy function.
const ifTruthyThen = <T>(predicate: any, value: T): T | null => {
if(!predicate){
return null;
}
return value;
}
// usage
You can’t perform that action at this time.