Skip to content

Instantly share code, notes, and snippets.

View curiousercreative's full-sized avatar

Winston Hoy curiousercreative

View GitHub Profile
class Bag {
constructor (capacity) {
this.capacity = capacity;
this.cakes = [];
this.weight = 0;
this.value = 0;
}
addCake (cake) {
this.cakes.push(cake);
@curiousercreative
curiousercreative / itunes.py
Created May 8, 2016 17:27
Script to load an iTunes Media Library.xml, find duplicate tracks, remove the track with a larger file size and ensure that the remaining track inherits the older track_id
import json
import os
import re
from xml.etree import ElementTree
def get_track_attr (track, attr_name):
# iterate over each attr to find the filename
attributes = list(track)
for a in range(len(attributes)):
attr = attributes[a]
// Vanilla solution
let format = require('util').format;
const COLORS = [
{ stop: 0, rgb: [35, 198, 161] },
{ stop: 6, rgb: [245, 235, 73] },
{ stop: 48, rgb: [245, 51, 0] },
];
function getRGBColor (hours) {
@curiousercreative
curiousercreative / nys-vehicle-inspection.js
Created November 27, 2016 18:44
A web console script for searching over all NYS Vehicle Inspection search results
// This script is intended to be run from a web console. It must be run from the correct webpage.
// Step 1: Fill out this and search https://process.dmv.ny.gov/FacilityLookup/
// Step 2: Select your vehicle type, etc until you receive results
// Step 3: Edit the countResults variable below to the actual number
// Step 4: Inject jQuery into the webpage by copying the commented code below into the web console
// var jq = document.createElement('script');jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";document.getElementsByTagName('head')[0].appendChild(jq);
// Step 5: Copy and paste the below into your web console and run it. When the searching is finished, you should receive an array of matches logged to console.
// modify this value to be the total # of results
@curiousercreative
curiousercreative / netflix-random.js
Created November 27, 2016 18:47
This script will select a random movie from your Netflix list and play it
// Navigate to your "My List" page before running this in your web console
// Get a list of all titles
var movies = document.querySelectorAll(".slider-item");
// pick a random number between 0 and length
var random = Math.floor(Math.random() * movies.length);
// this is our movie
var movie = movies[random];
@curiousercreative
curiousercreative / git-rename-ts-files.js
Created March 6, 2018 17:35
Node script for renaming files with .ts or .tsx file extensions to .js or .jsx
const glob = require("glob");
const { execSync } = require('child_process');
console.log('building list of files');
const opts = { absolute: true };
var files = glob.sync("**/*.ts", opts).concat(glob.sync("**/*.tsx", opts)).filter(f => f.indexOf('node_modules') < 0);
console.log(`found ${files.length} files`);
@curiousercreative
curiousercreative / arm64-bionic-zfs
Last active December 22, 2019 14:50
Configuration for a fresh Ubuntu 18.04 Rock64 install. Adds a user, sets timezone, installs zfs, samba, configures disk power management, etc
#!/bin/bash
#
# Read this script and modify it before running. It's not tested as is and is not
# meant to be run unsupervised.
#
hostname='YOUR_DESIRED_HOSTNAME'
user='YOUR_USERNAME'
hdd_spindown_timeout=1800
@curiousercreative
curiousercreative / darktable.log
Last active March 31, 2021 13:55
darktable macOS startup output
$ rm -Rf ~/.config/darktable ~/.cache/darktable
$ /Applications/darktable.app/Contents/MacOS/darktable -d all
0.000898 application_directory: /Applications/darktable.app/Contents/MacOS
0.001040 darktable.datadir: /Applications/darktable.app/Contents/Resources/share/darktable
0.001123 darktable.plugindir: /Applications/darktable.app/Contents/Resources/lib/darktable
0.001196 darktable.localedir: /Applications/darktable.app/Contents/Resources/share/locale
0.001392 darktable.configdir: /Users/curiouser/.config/darktable
0.001539 darktable.cachedir: /Users/curiouser/.cache/darktable
0.001617 darktable.sharedir: /Applications/darktable.app/Contents/Resources/share
0.001709 darktable.tmpdir: /private/var/folders/jg/8sl7jff55y7dh77tfpztd4pr0000gn/T
@curiousercreative
curiousercreative / dockify.sh
Last active December 6, 2023 17:34
Profiles for running System76 Galago Pro (galp5) docked vs undocked
#!/bin/bash
# default text size
#gsettings set org.gnome.desktop.interface text-scaling-factor 1.0
#echo 'disablig auto-suspend on AC power'
#gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
echo 'disabling hibernation'
test -h /etc/systemd/system/systemd-suspend.service && sudo rm /etc/systemd/system/systemd-suspend.service