Skip to content

Instantly share code, notes, and snippets.

View bencooper222's full-sized avatar
👋

Benjamin Cooper bencooper222

👋
View GitHub Profile
@bencooper222
bencooper222 / .gitignore
Last active January 25, 2022 02:01
Get description of book from GoodReads link
node_modules/
out.txt
@bencooper222
bencooper222 / openCircleWorkflow.sh
Created December 14, 2021 21:40
Opens the circleci (assuming github) workflow for the repo/branch your working directory is in
inside_git_repo="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
if [ ! "$inside_git_repo" ]; then
echo "not in git repo"
exit
fi
BRANCH="$(git rev-parse --abbrev-ref HEAD | tr -d '\n' | xargs | jq -sRr @uri | sed -e "s/%0A$//")"
# if your origin isn't ssh, this probably won't work
REMOTE="$(git config --get remote.origin.url | xargs | cut -d ":" -f2 | sed -e "s/.git$//")"
@bencooper222
bencooper222 / expect-errors.mjs
Created November 5, 2021 06:47
Reads a set of ts compiler errors and inserts ts-expect-error before all of them (has known off by one flaws)
import { readFileSync, writeFileSync } from 'fs';
const errors = readFileSync('./out.txt', 'utf-8')
.split('\n')
.filter(el => !el.startsWith(' '));
const parsedErrors = [];
for (const err of errors) {
@bencooper222
bencooper222 / ilTax.js
Created October 11, 2020 04:08
Calculate tax burden of IL joint filers in JS under the Fair Tax Amendment
// gonna refer to this as bracket0, bracket1 etc
//| Income | Marginal Tax Rate |
//|------------------------|-------------------|
//| $0 – $10,000 | 4.75% |
//| $10,001 – $100,000 | 4.90% |
//| $100,001 – $250,000 | 4.95% |
//| $250,001 – $500,000 | 7.75% |
//| $500,001 – $1,000,000 | 7.85% |
//| $1,000,001 and above | 7.95% on net |
@bencooper222
bencooper222 / inequality.json
Created February 7, 2020 17:22
Global income distribution by region with deciles.
[
{
"region": "eu & oecd",
"decile1": 8388929.281,
"decile2": 7038948.781,
"decile3": 11950912.07,
"decile4": 19841097.99,
"decile5": 33950521.39,
"decile6": 58059009.92,
"decile7": 94884323.46,
@bencooper222
bencooper222 / getter.js
Created July 12, 2019 20:52
This pulls comic starting from a user-defined day and getting a user-defined number of days after that. See early comments for licensing information.
// MIT License Copyright (c) 2019 Benjamin Cooper
// I take no responsibility for your use of this code.
// you'll have to install these modules with npm/yarn
const download = require('image-downloader');
const fetch = require('node-fetch');
const cheerio = require('cheerio');
Date.prototype.addDays = function(days) {
var date = new Date(this.valueOf());

Keybase proof

I hereby claim:

  • I am bencooper222 on github.
  • I am benc222 (https://keybase.io/benc222) on keybase.
  • I have a public key whose fingerprint is 8BB5 3BD1 4C1C DF2F EAEE 4928 B9BD 15E1 CCA2 B985

To claim this, I am signing this object:

const swipes = [];
require('readline')
.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false,
})
.on('line', line => {
console.log('\007'); // beep beep
@bencooper222
bencooper222 / graph.txt
Last active January 27, 2021 07:34
Runs thousands of trials to evaluate whether putting the seat down or up or not changing it is best
https://shared.benc.io/screencaps/2018/09/Oropendula/24704094-46c0-4af6-afdb-56f7747625bc.png
That graph shows the default code's (seen above) results. Lower on the graph means better. This graph indicates that the best approach is to leave the seat where you had it except in the niche case where there is less than 2% biological males using that toilet. My guess is that would only apply to biological males who have undergone a gender change and now use the women's restroom.
@bencooper222
bencooper222 / getChampPower.js
Last active July 2, 2018 16:54
Run this code on champion.gg's "current patch statistics" page to get the top champions by win and play rate rn (i.e. the best champs to ban). See example: https://www.useloom.com/share/a7f0773a37004827adacc264d80521d0
console.log("Go to https://raw.githubusercontent.com/bencooper222/championgg-power-parser/master/main.prod.js for the latest version")