Skip to content

Instantly share code, notes, and snippets.

@bennettscience
bennettscience / pity_party_scraper.py
Last active July 22, 2019 18:03
A script to scrape The Pity Part playlist from WDBM and create a spotify playlist
import re, sys
import requests
import spotipy
import spotipy.util as util
from bs4 import BeautifulSoup
# Get the ID of the track from Spotify
def get_track_id(username, title, artist):
print("Searching for {} by {}".format(title, artist))
scope = 'playlist-modify-public'
@bennettscience
bennettscience / sgstatus.user.js
Last active May 29, 2019 19:04
Update the assignment status from the speedgrader in canvas
// ==UserScript==
// @name SpeedGrader Status
// @namespace http://tampermonkey.net/
// @version 0.4
// @description Set Canvas Assignment statuses from the SpeedGrader
// @author You
// @include /^https://.*\.instructure\.com/
// @grant none
// ==/UserScript==
@bennettscience
bennettscience / script.py
Created May 10, 2019 11:45
Sample script of changing the enrollment statuses with canvasapi
from canvasapi import Canvas
# Instantiate the Canvas object
canvas = Canvas("your_url", "your_key")
# Get the course by it's ID
course = canvas.get_course(course_id)
# Get a list of Enrollment items
# Use the 'type' and 'state' kwargs to only get active students
@bennettscience
bennettscience / pool_test.py
Created May 1, 2019 13:44
First take at using multiprocessing with UCFOpen's canvasapi in Python
import multiprocessing as mp
from canvasapi import Canvas
import json
def process_submissions(assignment):
obj = {}
canvas = Canvas(url, key)
@bennettscience
bennettscience / chart.gs
Last active September 19, 2018 07:58
Code to display Google Sheets data as a web-based dashboard
// Pie Chart visualization client-side scripting
// Initialize the script and grab the data from the spreadsheet.
google.script.run.withSuccessHandler(drawChart).getSpreadsheetData();
google.load("visualization", "1", {packages:["corechart"]});
// Using the returned data from the spreadsheet, draw the chart.
// ssData is a 2D array of the candidate name and their electoral vote totals from the spreadsheet.
function drawChart(ssData) {
@bennettscience
bennettscience / helpbotBrain.gs
Last active March 22, 2018 11:46
Main files for an apps script bot and webapp pair
/**
* getLookup - Get an array of videos matching the search key request
*
* @param {Object[]} keys - Array of search terms
* @returns {Object[]} matches - Array of video objects matched to the tag
*/
function getLookup(keys) {
var sheet = ss.getSheetByName("db");
var data = sheet.getDataRange().getValues();
@bennettscience
bennettscience / config
Created March 17, 2018 18:30
git config sample
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
@bennettscience
bennettscience / outcome.py
Created February 1, 2018 16:34
Playing with the Canvas LMS python API
from canvasapi import Canvas
API_URL = 'https://my.url.com'
API_KEY = 'mySTringKEy123'
canvas = Canvas(API_URL, API_KEY)
outcome = canvas.get_outcome(5426)
class Rating:
@bennettscience
bennettscience / index.js
Created December 31, 2017 02:34
Node JS function to watch Firebase realtime database
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const nodemailer = require('nodemailer');
admin.initializeApp(functions.config().firebase);
// set up email credentials in firebase.config
// See https://github.com/firebase/functions-samples/tree/master/quickstarts/email-users for example
const gmailEmail = functions.config().gmail.email;
@bennettscience
bennettscience / code.gs
Last active November 28, 2017 19:32
Automatically create bit.ly shortlinks of Google Forms via the API
// Copyright 2017 Brian E. Bennett
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
// and associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.