Skip to content

Instantly share code, notes, and snippets.

Avatar
👋

Benjamin Cooper bencooper222

👋
View GitHub Profile
@bencooper222
bencooper222 / ilTax.js
Created Oct 11, 2020
Calculate tax burden of IL joint filers in JS under the Fair Tax Amendment
View ilTax.js
// 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 Feb 7, 2020
Global income distribution by region with deciles.
View inequality.json
[
{
"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 Jul 12, 2019
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.
View getter.js
// 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());
View keybase.md

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:

View swipe.js
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 Jan 27, 2021
Runs thousands of trials to evaluate whether putting the seat down or up or not changing it is best
View graph.txt
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 Jul 2, 2018
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
View getChampPower.js
console.log("Go to https://raw.githubusercontent.com/bencooper222/championgg-power-parser/master/main.prod.js for the latest version")
@bencooper222
bencooper222 / sumdigits.js
Created Oct 8, 2017
Counting the number of occurrences of each parity among a range of adjacent integers
View sumdigits.js
let start = 1;
let end = 123456789;
let evenCount = 0;
let oddCount = 0;
for (let i = start; i <= end; i++) {
if (isEven(sumDigits(i))) {
evenCount++;
@bencooper222
bencooper222 / geocode.gs
Last active Apr 4, 2017
Google Sheets Geocoding Custom Function
View geocode.gs
// returns latlng from Google API
function GEOCODE(input){
var data = JSON.parse(queryGoogle(input));
var location = data.results[0].geometry.location;
return location.lat + ", " + location.lng;
}
@bencooper222
bencooper222 / google_sheets_geocode.gs
Last active Apr 4, 2017
This script calls the Google Maps geocoding API, gives locations and returns their "locality, province/state" strings. It's a bit glitchy on certain addresses but should meet the bulk of your needs
View google_sheets_geocode.gs
// this is designed for a 2 columns, n rows range with the addresses in column with index 0
var addresses = SpreadsheetApp.openByUrl("YOUR URL HERE").
getSheetByName("Assignments").getRange("YOUR RANGE HERE").getValues(); // there are several formats for range - your choice
//Logger.log(addresses[0][1])
function searchJson(data){
data = JSON.parse(data);