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
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("github.com/");var site=res[1];colabGitUrl="https://colab.research.google.com/github/"+site;window.prompt("Colab gitpuller link",colabGitUrl);})();
@misterhay
misterhay / graphing_income_tax.py
Created Oct 16, 2019
Construct a graph of net income (Alberta) versus hourly wage
View graphing_income_tax.py
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
misterhay / note-frequency-table.py
Created Sep 11, 2019
Generate a frequency (equal tempered) of musical notes chart using Pandas
View note-frequency-table.py
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
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="https://hub.callysto.ca/jupyter/hub/user-redirect/git-pull?repo=";if(site=="github.com"){if(treeBlob){var urlpath="notebooks/"+repo+url.substring(url.indexOf(branch)+branch.length);nbgitpullerUrl+="https://github.com/"+user+"/"+repo+"&branch="+branch+"&urlpath="+urlpath;}else{nbgitpullerUrl+=url;}}window.prompt("Callysto nbgitpuller link",nbgitpullerUrl);})();
@misterhay
misterhay / TeleprompterFormatter.gs
Created Oct 8, 2018
Video Announcements Teleprompter Formatting Script (Google Apps Script)
View TeleprompterFormatter.gs
// remember to add an on-open trigger for addMenu
function addMenu() {
var ui = DocumentApp.getUi();
ui.createMenu('WBO Announcements')
.addItem('Format Announcements', 'formatAnnouncements')
.addToUi();
}
function formatAnnouncements() {
View barGraphTwoDice.py
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
#print(total)
resultsList += [total] # append the sum to the resultsList
@misterhay
misterhay / PandasPlotlyJupyter.py
Last active Feb 14, 2018
experimenting with Panada and Plotly offline in Jupyter for visualizing open data
View PandasPlotlyJupyter.py
import pandas as pd
import plotly
from plotly.graph_objs import Scatter, Layout
plotly.offline.init_notebook_mode(connected=True)
plo = plotly.offline.iplot
results = pd.read_excel('https://education.alberta.ca/media/3680582/diploma-multiyear-auth-list-annual.xlsx')
years = []
for value in results.columns.values:
@misterhay
misterhay / concatenateStudentResponses.gs
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.
View concatenateStudentResponses.gs
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
misterhay / drawSomething.gs
Last active Dec 30, 2016
Generates a subject, verb, and location for a drawing game (in Google Sheets with Google Apps Script)
View drawSomething.gs
// 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.
// https://developers.google.com/apps-script/guides/sheets
// https://docs.google.com/spreadsheets/d/1mrnsKUCSkum-ZmAvGtK10uAf1eypdxsoFP7tbjWynsQ
function addMenu() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Game').addItem('Draw Something', 'drawSomething').addToUi();
}
View countClassroomAssignments.gs
// 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 https://developers.google.com/classroom/quickstart/apps-script to authorize your script.
// Set up a trigger to run countClassroomAssignments() every morning or every week.
// https://developers.google.com/apps-script/reference/spreadsheet/sheet
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.