Skip to content

Instantly share code, notes, and snippets.

David Hay misterhay

Block or report user

Report or block misterhay

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
misterhay / colab-gitpuller.js
Last active Nov 4, 2019
Create a Colab link for notebook from GitHub
View colab-gitpuller.js
javascript:(function(){var url=location.href;var res=url.split("");var site=res[1];colabGitUrl=""+site;window.prompt("Colab gitpuller link",colabGitUrl);})();
misterhay /
Created Oct 16, 2019
Construct a graph of net income (Alberta) versus hourly wage
def calculateFederalTax(income):
taxBrackets = [47630, 95259, 147667, 210371]
taxRates = [.15, .205, .26, .29, .33]
taxes = []
for i in range(0, len(taxBrackets)):
taxes.append(taxBrackets[i] * taxRates[i])
if income < taxBrackets[0]:
tax = income * taxRates[0]
elif income < taxBrackets[1]:
tax = taxes[0] + (income - taxBrackets[0]) * taxRates[1]
misterhay /
Created Sep 11, 2019
Generate a frequency (equal tempered) of musical notes chart using Pandas
import pandas as pd
noteList = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
def generateOctave(note, startingFrequency):
frequencyList = [startingFrequency]
for x in range(1,9):
frequencyList.append(startingFrequency * 2**x) # each octave up is twice the previous frequency
frequencyDf = pd.DataFrame({note:frequencyList})
return frequencyDf
misterhay / callysto-nbgitpuller-bookmarklet.js
Last active Oct 29, 2019
Javascript bookmarklet to generate nbgitpuller links from GitHub repositories. Create a bookmark and replace the URL of the new bookmark with the code below.
View callysto-nbgitpuller-bookmarklet.js
javascript:(function(){var url=location.href;var res=url.split("/");var site=res[2];var user=res[3];var repo=res[4];var treeBlob=res[5];var branch=res[6];var nbgitpullerUrl="";if(site==""){if(treeBlob){var urlpath="notebooks/"+repo+url.substring(url.indexOf(branch)+branch.length);nbgitpullerUrl+=""+user+"/"+repo+"&branch="+branch+"&urlpath="+urlpath;}else{nbgitpullerUrl+=url;}}window.prompt("Callysto nbgitpuller link",nbgitpullerUrl);})();
misterhay /
Created Oct 8, 2018
Video Announcements Teleprompter Formatting Script (Google Apps Script)
// remember to add an on-open trigger for addMenu
function addMenu() {
var ui = DocumentApp.getUi();
ui.createMenu('WBO Announcements')
.addItem('Format Announcements', 'formatAnnouncements')
function formatAnnouncements() {
numberOfRolls = 10
numberOfSides = 6
from random import randint # a module for random integers
resultsList = [] # create an empty list
for x in range(0,numberOfRolls): # loop through this a number of times
number1 = randint(1, numberOfSides) # pick a number between 1 and 6
number2 = randint(1, numberOfSides) # pick another number between 1 and 6
total = number1 + number2 # add those two values
resultsList += [total] # append the sum to the resultsList
misterhay /
Last active Feb 14, 2018
experimenting with Panada and Plotly offline in Jupyter for visualizing open data
import pandas as pd
import plotly
from plotly.graph_objs import Scatter, Layout
plo = plotly.offline.iplot
results = pd.read_excel('')
years = []
for value in results.columns.values:
misterhay /
Created Jan 7, 2017
Starting from a Google Spreadsheet containing links to student response documents, this creates a single document containing all of their responses.
function addMenu() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Student Responses').addItem('Concatenate all responses', 'concatenateResponses').addToUi();
function concatenateResponses() {
var responsesDoc = DocumentApp.create('Student Responses');
var responsesDocID = responsesDoc.getId();
var sheet = SpreadsheetApp.getActiveSheet();
var columnContainingLinksToDocuments = 6;
misterhay /
Last active Dec 30, 2016
Generates a subject, verb, and location for a drawing game (in Google Sheets with Google Apps Script)
// in a Google Sheet that has two sheets: Cards and Drawn
// The 'Cards' sheet should have three columns: subject, verb, and location
// This code is public domain, but let me know if there are any copyright concerns.
function addMenu() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Game').addItem('Draw Something', 'drawSomething').addToUi();
// Create a Google spreadsheet with a list of student email addresses in column A starting at row 2.
// Rename the sheet Achievements or change line 17 of this code.
// Under the Tools menu choose Script editor and paste in this code.
// Follow the directions at to authorize your script.
// Set up a trigger to run countClassroomAssignments() every morning or every week.
function listCourses() {
// Run this then check the execution logs to find the courseId for your desired course
var courses = Classroom.Courses.list().courses;
You can’t perform that action at this time.