Skip to content

Instantly share code, notes, and snippets.

✈️
Exploring Seattle

Benjamin Cooper bencooper222

✈️
Exploring Seattle
Block or report user

Report or block bencooper222

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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
Created Sep 3, 2018
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 men who have undergone a gender change and now use restrooms designated for females.
@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);
@bencooper222
bencooper222 / GetJot.cs
Created Mar 18, 2017
Checks if IHSA JOT semi-finals change. Makes synchronous GET requests and checks if it ever changes.
View GetJot.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Media;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace GetJot
@bencooper222
bencooper222 / code.js
Created Dec 12, 2016
Easy Google Apps Script Secret Santa code given a spreadsheet with names in the B column and emails in the C column
View code.js
var ss = SpreadsheetApp.getActiveSpreadsheet(); // this is meant to run inline google appsscript - you'll have to use a different get method if you don't want that
var sheet = ss.getSheets()[0]; // assumes sheet 1
var names = sheet.getRange(2,2,sheet.getLastRow()-1,2).getValues();
Logger.log(names);
if (names.length % 2 != 0) {
//alert("You must have an even number of names. You currently have " + names.length + " names.");
} else {
You can’t perform that action at this time.