Skip to content

Instantly share code, notes, and snippets.

View sneakers-the-rat's full-sized avatar

Jonny Saunders sneakers-the-rat

View GitHub Profile
@sneakers-the-rat
sneakers-the-rat / clean_pdf.sh
Last active February 14, 2024 16:52
Strip PDF Metadata
# --------------------------------------------------------------------
# Recursively find pdfs from the directory given as the first argument,
# otherwise search the current directory.
# Use exiftool and qpdf (both must be installed and locatable on $PATH)
# to strip all top-level metadata from PDFs.
#
# Note - This only removes file-level metadata, not any metadata
# in embedded images, etc.
#
# Code is provided as-is, I take no responsibility for its use,
@sneakers-the-rat
sneakers-the-rat / gate_input.js
Last active January 5, 2022 09:12
gate mouse events
// define key that toggles class
const ctrlKeys = ['CapsLock', 'ControlRight'];
// make element to block pointer events
let blockStyle = document.createElement('style')
blockStyle.type = "text/css"
blockStyle.innerText = "* {pointer-events: none !important;}"
// register callback to detect keydown events to gate
document.addEventListener('keydown', (e) => {
@sneakers-the-rat
sneakers-the-rat / hypothesis_sidebar.js
Created October 14, 2021 06:23
change color of hypothes.is bucket sidebar
window.onload = function() {
let style = document.createElement('style');
style.textContent = `
.Buckets__list {
background-color: transparent !important;
}
`
let container = document.getElementsByTagName("hypothesis-sidebar")[0];
container.shadowRoot.appendChild(style);
@sneakers-the-rat
sneakers-the-rat / _profile_jekyll.rb
Created October 5, 2021 20:59
Profile Jekyll Build with ruby-prof
require "jekyll"
require "ruby-prof"
result = RubyProf.profile do
# you can set any of the --options you'd pass to build here
# it will automatically pick up the _config.yml file in source
options = {
"source" => './',
"destination" => './_site',
protocol = [
{
"allow_repeat": False,
"graduation": {
"type": "n_trials",
"value": {
"current_trial": "0",
"n_trials": "200",
"type": "n_trials"
}
@sneakers-the-rat
sneakers-the-rat / grid_search_ssm.ipynb
Created March 12, 2021 00:01
grid_search_ssm.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sneakers-the-rat
sneakers-the-rat / remove_meta.sh
Last active January 9, 2021 00:16
remove pdf metadata
####
# 1) install exiftool and qpdf
# https://exiftool.org/
# http://qpdf.sourceforge.net/
# (can be installed with homebrew: brew install exiftool qpdf )
####
# 2) remove metadata - this step is reversible, so we will need to recreate the PDF afterwards
exiftool -all:all= /location/of/some/file.pdf
@sneakers-the-rat
sneakers-the-rat / yt-dl.sh
Created January 6, 2021 23:24
using youtube dl
###########
# Mac
# (copy and paste these into your Terminal (Open Terminal from Applications > Utilities > Terminal)
# 1. install homebrew if you haven't already
# https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# 2. install youtube-dl
brew install youtube-dl
@sneakers-the-rat
sneakers-the-rat / gist:0d17da7c9297ca1d33b23fa33086c3a4
Created January 2, 2021 05:14
use acme to issue and maintain a cert on cpanel
# curl https://get.acme.sh | sh
./.acme.sh/acme.sh --force --issue -d website.com -d www.website.com -w /home/nod3bp3usey4/public_html/website_path
./.acme.sh/acme.sh --deploy -d website.com -d www.website.com --deploy-hook cpanel_uapi
@sneakers-the-rat
sneakers-the-rat / scrape_courses.py
Last active July 24, 2020 07:19
scrape uo course catalogue
import requests
from bs4 import BeautifulSoup as bs
import pandas as pd
import tqdm
import datetime
import os
import pickle
def scrape_crn(crn, page_dir):
url = f"https://classes.uoregon.edu/duckweb/hwskdhnt.p_viewdetl?term=202001&crn={crn}"