Skip to content

Instantly share code, notes, and snippets.

@john-hix
john-hix / KeepToMarkdown.py
Created July 21, 2021 01:35 — forked from ThomasHineXYZ/KeepToMarkdown.py
Google Keep "Takeout" to Markdown Converter
#!/usr/bin/env python
# Google Keep "Takeout" to Markdown Converter
# This allows you to convert your Google Keep notes that are downloaded from
# Google's "Takeout" system. This works with NextCloud's Notes system.
from datetime import datetime
import base64
import json
import os
@john-hix
john-hix / approx-pi.cpp
Created August 25, 2020 03:06
Approximate Pi
// A program I made after Calculus II class because I was
// itching to apply the idea of using series to estimate certain
// mathematical constants. I use the Leibniz series knowing that
// there are better, faster-converging series out there.
//
// This program currently uses only built-in C++ data types rather
// than arbitrary precision numbers. As such, there are likely errors
// introduced to the calculation inherent to that data representation.
//
// Program output assumes Unicode for Greek/mathematical characters
@john-hix
john-hix / canvas-scraper.py
Last active May 13, 2020 16:03 — forked from Koenvh1/canvas-scraper.py
Scrape your Canvas website and download all content to a folder. Tested on 2020-05-14.
#!bin/python3
import argparse
import os
import re
from pathvalidate import sanitize_filename
from canvasapi import Canvas
from canvasapi.course import Course
from canvasapi.exceptions import Unauthorized, ResourceDoesNotExist
from canvasapi.file import File
@john-hix
john-hix / duplicate-post-titles.sql
Created March 23, 2020 23:02
Find WordPress posts with duplicate titles
SELECT wp_posts.post_title, COUNT(wp_posts.post_title) FROM wp_posts
GROUP BY wp_posts.post_title
HAVING COUNT(wp_posts.post_title) > 1
ORDER BY COUNT(wp_posts.post_title) DESC
@john-hix
john-hix / scrape-videos.js
Last active June 24, 2020 13:24
Get IMathAS popup videos: Script to quickly scrape all the video helps for an IMathAS assignment. Copy the JSON response from startassess.php and assign it to the data variable. Works for sites like Lumen OHM, etc.
var data = {};
function normalizeUrl(/*string*/ mathIasPopupUrl) {
const url = new URL(mathIasPopupUrl);
// console.log(url.search);
const searchParams = new URLSearchParams(url.search);
// console.log(searchParams.get("url"));
return searchParams.get("url");
}
@john-hix
john-hix / Code.gs
Last active July 10, 2018 17:58
Google Sheets "sheetExists" function (detect if sheet exists)
function sheetExists(sheetName) {
if (typeof sheetName !== "string") {
throw ("The sheetExists function requires string input.")
}
var allSheets = SpreadsheetApp.getActive().getSheets();
var foundSheet = false;
var len = allSheets.length;
var chkThisIndex = 0;
while (!foundSheet && chkThisIndex < len) {
if (allSheets[chkThisIndex].getName() === sheetName) {