Skip to content

Instantly share code, notes, and snippets.

View duplaja's full-sized avatar

Dan D. duplaja

  • Central US
View GitHub Profile
@duplaja
duplaja / wp-equipment-post-type.php
Created March 26, 2022 13:18
WordPress Equipment Post Type
<?php
if ( ! function_exists('register_equpiment_post_type') ) {
// Register Custom Post Type
function register_equpiment_post_type() {
$labels = array(
'name' => 'Equipment',
'singular_name' => 'Equpiment',
@duplaja
duplaja / weighted-spin.php
Last active March 27, 2022 17:39
Weighted "Spin the Prize Wheel" function
<?php
function lottery_spin_the_wheel() {
//Form is key (reward as string) value (frequency as int)
$rewards_master = array(
'1 bonus token'=>25,
'5-album mini themed list'=>20,
'Album on demand'=>20,
'Trade 1 token for 2 tokens of your choice'=>15,
'Top-off overload +5 on Wednesday'=>10,
@duplaja
duplaja / librarything.js
Last active April 12, 2022 18:57
Rate LibraryThing Works
window.addEventListener("load", function(event) {
const ratingtd = document.getElementById("ratingstdtitle");
const orig_rating = document.getElementById("form_rating").value;
const button = document.createElement('a');
button.setAttribute("id", "rate-button");
button.innerHTML = "<h3>Rate Book (Current Rating: "+orig_rating+")</h3>"
@duplaja
duplaja / fixdiscordspellcheck.js
Last active April 13, 2022 18:35
Fix Discord Web Browser Spellcheck
window.addEventListener("load", fixStupidDiscordSpellcheck, false);
window.addEventListener('locationchange', fixStupidDiscordSpellcheck, false);
window.addEventListener('hashchange', fixStupidDiscordSpellcheck, false);
function fixStupidDiscordSpellcheck(event){
setTimeout(function() {
var textBoxes = document.querySelectorAll('div[role="textbox"]');
@duplaja
duplaja / mullvadcheck.py
Created May 1, 2022 23:12
Mullvad VPN Check - Python
import subprocess
result = subprocess.run(['mullvad', 'status'], stdout=subprocess.PIPE)
mullvad_status = result.stdout.decode('utf-8')
if 'Disconnected' in mullvad_status:
print('Mullvad VPN is Disconnected: Connect and try again')
quit()
else:
print('Mullvad VPN is Active, continuing: ')
@duplaja
duplaja / create_privatebin.py
Last active May 30, 2022 03:56 — forked from dedunumax/create_privatebin.py
Sample program to create PrivateBin notes using Python 3. Change URL on line 41 to your desired instance of PrivateBin
"""
This script creates a PrivateBin using Python 3.
Code is based on https://github.com/r4sas/PBinCLI repository.
Thanks a lot @r4sas!
Below modules should be installed in the environment.
requests
base58
pycryptodome
"""
@duplaja
duplaja / scraperym.js
Created June 22, 2022 18:46
Scrape RYM Charts - 6-22-22
function generateDownload(filename, text, type='text/plain;charset=utf-8') {
// Create an invisible A element
const a = document.createElement('a');
a.style.display = 'none';
document.body.appendChild(a);
var BOM = new Uint8Array([0xEF,0xBB,0xBF]);
// Set the HREF to a Blob representation of the data to be downloaded
@duplaja
duplaja / rym-recs-to-txt.js
Created July 13, 2022 20:35
RYM Recs to Text Export
function generateTextDownload(filename, text, type='text/plain;charset=utf-8') {
// Create an invisible A element
const a = document.createElement('a');
a.style.display = 'none';
document.body.appendChild(a);
var BOM = new Uint8Array([0xEF,0xBB,0xBF]);
// Set the HREF to a Blob representation of the data to be downloaded
@duplaja
duplaja / all-music-scraper-new.js
Created August 3, 2022 00:55
New All Music Favorites Scraper
start_countdown();
function start_countdown() {
for (let i = 1; i <= 2; i++) {
setTimeout(function timer() {
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' })
if (i == 2) {
export_csv_favorites();
}
}, i * 4000);
@duplaja
duplaja / make-epub-folders.sh
Created October 30, 2022 07:26
Makes folders for each epub in the current directory, based on title and author tags.
#!/bin/bash
#Requires exiftool installed
#Subfolder to store results in
containingfolder="./epubs-folder/"
for i in *.epub; do
[ -f "$i" ] || break