Skip to content

Instantly share code, notes, and snippets.

@misterhay
misterhay / extract-minecraft-portfolio-images.py
Last active December 13, 2021 18:17
A Python script to extract images from Minecraft Education Edition portfolio exports
# python -m pip install PyMuPDF Pillow
import os # for files and directories
import io # for bytes
import fitz #PyMuPDF
from PIL import Image #Pillow
for root, dirs, files in os.walk("."):
for filename in files:
if filename.endswith('.pdf'):
@misterhay
misterhay / update-youtube-privacy.gs
Last active December 11, 2021 17:04
Google Apps Script function to change a YouTube video's privacy status
// schedule this Google Apps Script function to run at a certain time to change a YouTube video's privacy status
function updateVideoPrivacy() { // enable the YouTube Data API under "Services"
var channels = YouTube.Channels.list('contentDetails', {mine: true});
for (var i=0; i<channels.items.length; i++) {
var uploadsPlaylistId = channels.items[i].contentDetails.relatedPlaylists.uploads;
var playlistResponse = YouTube.PlaylistItems.list('snippet', {playlistId: uploadsPlaylistId, maxResults: 1}); // or more than 1 if needed
var video = playlistResponse.items[0]; // the first video in the list we retrieved
var metadata = {
status: {'privacyStatus': 'private'}, // public, unlisted, private
id: video.snippet.resourceId.videoId}; // we need to include the video ID from the playlist response
@misterhay
misterhay / testing.js
Created April 1, 2021 05:05
A quick test for loading external JavaScript files
function test() {
return "this works";
}
@misterhay
misterhay / SWEETVIZ_REPORT.html
Last active March 13, 2021 17:10
A quick demo of Sweetviz for exploratory data analysis in a Jupyter notebook
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEACABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAPD4/AC0vMADd3+AAWFpbAFlaWwC8vb0AOjw9AERHRwCSlJUAk5SVAJ6fnwD39/cAW1xeAGVnaAC0t7YAgYOEAI2OjgDk5uYA9fX1AFhaXABzdHUA5ubmAG5wcAA6PD4Ax8jIAEVHSAA2ODkAqaqqAPLz8wB7fX0AQ0VGADQ2NwB6e3sAs7W1AJqbnAAjJSYAi4yNAP7+/gDu7+8A7+/vAHZ5eQDf4OAAtbe4ANHR0QBPUFEAwsLCAKioqQCjpKQA/Pz8AO3t7QBrbG0AvcDAAExOTwDJy8oAlpeYAC4wMQDe4OEAkZOTAPr6+gBoamsAWVtcANzc3ABkZmYAKy4vAK6vrwAsLi8A/fz9AJCRkQDe3t8AZmhpANna2gDa2toAYmRkAJGTlADr6+wA9vb2AH6AgABlZmcAYGJiAMjJyQBGSEkAr6+wAIGCgwC3uLgAqKmpANTU1ABSU1QAqqusAEJERQC1trYAlpiYAC8xMQD///8AfX5/AH5+fwBtb3AA8PDwAODh4QB6enoAuLi5ALO0tAA8Pj4A/f39AHt8fQDu7u4Ad3h4AExPUADFxcYA0NDQAMDBwQBOT1AAPkBBAPn7+wDq7OwAeXp7ANvd3QDc3d0AdHZ2AEtNTgBMTU4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@misterhay
misterhay / videoconference_controller.ino
Last active February 14, 2021 19:52
Videoconference controller with arcade buttons and Teensy microcontroller (Arduino)
// Teensy 2 Videoconference Buttons Controller
// Choose Keyboard from the "Tools > USB Type" menu
// buttons connected to 6 pins, and a switch for different programs
#include <Bounce.h>
Bounce button0 = Bounce(2, 50);
Bounce button1 = Bounce(1, 100); // this button was too sensitive
Bounce button2 = Bounce(0, 50);
Bounce button3 = Bounce(3, 50);
Bounce button4 = Bounce(14, 50);
@misterhay
misterhay / rps.py
Created January 29, 2021 08:10
Animating a "Rock Paper Scissors" tournament
number_of_rounds = 50
player1 = 'Steven'
player2 = 'Edward'
choices = {
'Steven':['Rock','Paper','Scissors'],
'Bart':['Rock'],
'Edward':['Scissors','Scissors','Scissors','Scissors','Paper','Paper'],
'Freddie':['Paper','Paper','Rock','Paper','Paper','Rock']}
# create a dataframe of rock beats scissors etc.
@misterhay
misterhay / marking.py
Last active January 23, 2021 21:01
Parsing Brighspace assignment downloads and marking spelling and other conventions
import os
import pdfplumber
from spellchecker import SpellChecker
spell = SpellChecker()
for path, directories, files in os.walk('.'):
for filename in files:
if filename.endswith('.pdf'):
filepath = path + os.sep + filename
student = path.split('- ')[1].strip() # get the student name from the directory name
import pandas as pd
import folium
from folium.plugins import MarkerCluster
df = pd.read_csv('https://drive.google.com/u/0/uc?id=1ptQoyoGhAv81R4A7VzupiYBhbBSD5uEy&export=download', low_memory=False)
m = folium.Map(location=[53.5,-114],zoom_start=5,prefer_canvas=True)
mc = MarkerCluster()
for row in df.itertuples():
mc.add_child(folium.Marker(location=[row.Latitude,row.Longitude]))#, tooltip=row.Well_ID))
m.add_child(mc)
m.save('water-well-map-alberta.html')
@misterhay
misterhay / NeoPixel_Ring_Light_testing.ino
Created December 6, 2020 22:16
testing NeoPixel with Adafruit library and code samples
#include <Adafruit_NeoPixel.h>
#define N_PIXELS 12 // Number of pixels you are using
#define LED_PIN 0 // NeoPixel LED strand is connected to GPIO #0 / D0
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_PIXELS, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.setBrightness(150);
white();
}
@misterhay
misterhay / google-drive-make-copy.js
Created September 19, 2020 13:46
Bookmarklet for generating a "Make Copy" link for a Google Doc, Sheet, Slides, or Drawing
javascript:(function(){var url=location.href;if(url.includes('docs.google.com')){var urlc=url.substring(0,url.lastIndexOf('/'))+'/copy';window.prompt('Copy this URL',urlc);}else{window.alert('Run this on a Google Doc, Sheet, Slides, or Drawing');}})();