Skip to content

Instantly share code, notes, and snippets.


Benjamin Cooper bencooper222

View GitHub Profile
View hello.cs
private string doThis(){
return kek;
bencooper222 / Check_checkboxes_squirrelmail.js
Last active Aug 12, 2016
Selects all messages on Squirrelmail to allow for easy deleting on servers that have quotas (was designed to work with the student and alumni squirrelmail at IMSA)
View Check_checkboxes_squirrelmail.js
var inputs = document.getElementsByTagName("input");
var checkboxes = [];
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == "checkbox") {
checkboxes[checkboxes.length] = inputs[i];
bencooper222 /
Created Sep 1, 2016
Creates a superlative form for a set of names
function myFunction() {
var form = FormApp.create("Superlatives");
var array = // PUT YOUR NAMES HERE
for(var i = 0; i<array.length; i++){
var item = form.addParagraphTextItem();
bencooper222 / add_image_onclick.js
Created Sep 18, 2016
Adds image anywhere on a webpage at every location someone clicks.
View add_image_onclick.js
function createImage(coordinates){
var xPos = coordinates[0];
var yPos = coordinates[1];
var image = document.createElement("img");
image.src = ;// add image file reference here
// set their position = yPos + "px"; = xPos + "px";
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();
if (names.length % 2 != 0) {
//alert("You must have an even number of names. You currently have " + names.length + " names.");
} else {
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 /
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
// 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
function searchJson(data){
data = JSON.parse(data);
bencooper222 /
Last active Apr 4, 2017
Google Sheets Geocoding Custom Function
// returns latlng from Google API
function GEOCODE(input){
var data = JSON.parse(queryGoogle(input));
var location = data.results[0].geometry.location;
return + ", " + location.lng;
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))) {
bencooper222 / getChampPower.js
Last active Jul 2, 2018
Run this code on'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:
View getChampPower.js
console.log("Go to for the latest version")