Skip to content

Instantly share code, notes, and snippets.

@0187773933
0187773933 / traverse_dom_node.js
Created December 11, 2022 14:12
Javascript - Traverse Down through A DOM Node
let prompt_elements = [ ...document.querySelectorAll( ".stack__answer-question" )[ 0 ].querySelectorAll( "p" ) ];
let tree_walker = document.createTreeWalker( prompt_elements[ 2 ] , NodeFilter.SHOW_ALL , {
acceptNode: function ( node ) {
return NodeFilter.FILTER_ACCEPT;
}
} , false );
let done = false;
while( done === false ) {
let next_node = tree_walker.nextNode();
if ( !next_node ) { done = true; }
@0187773933
0187773933 / javascript_quickhash_string.js
Created December 10, 2022 15:37
Javascript - Quick Hash String
function quick_hash_string( input_string ) {
// https://stackoverflow.com/a/47617289
return input_string.split('').map(v=>v.charCodeAt(0)).reduce((a,v)=>a+((a<<7)+(a<<3))^v).toString(16);
}
@0187773933
0187773933 / photoPeaApp.sh
Last active October 30, 2022 16:19
Open "App" Version of PhotoPea
#!/bin/bash
# https://peter.sh/experiments/chromium-command-line-switches/
# Load-Extension Flag CANNOT have spaces in path or even escaped spaces
# https://crxextractor.com
# https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm
open -n -a "Brave Browser" --args \
-incognito \
-app="https://photopea.com"
@0187773933
0187773933 / ConvertAllPPTXInFolderToPDF.sh
Created October 24, 2022 20:02
Apple Script to Export PPTX File to PDF
#!/bin/bash
for file in "$1"/*.pptx; do
file_path=$(readlink -f "$file")
osascript "./ExportPPTXToPDF.scpt" "$file_path"
done
@0187773933
0187773933 / CalculatePeptidePI.py
Last active October 21, 2022 20:16
Calculates the Isoelectric Point , Neutral pH , and Net Charge at Some pH of Some Peptide Sequence
#!/usr/bin/env python3
import math
import numpy as np
from decimal import Decimal
AMINO_ACIDS = {
"A": {
"name": "Alanine" ,
"3letter": "Ala",
"sc_mass": 15.0234,
@0187773933
0187773933 / GetTimeString.py
Created October 1, 2022 12:34
Get Common Time String in Python
import datetime
from pytz import timezone # pip install pytz
# print( pytz.country_timezones[ "US" ] )
def get_common_time_string( time_zone=timezone( "US/Eastern" ) ):
now = datetime.datetime.now().astimezone( self.timezone )
milliseconds = round( now.microsecond / 1000 )
milliseconds = str( milliseconds ).zfill( 3 )
now_string = now.strftime( "%d%b%Y === %H:%M:%S" ).upper()
return f"{now_string}.{milliseconds}"
@0187773933
0187773933 / crontab
Created October 1, 2022 12:14
Crontab Runas User
31 22 * * * /usr/local/bin/restartMotionServerWithDelay.sh
01 10 * * * systemctl stop motion-script.service
# @reboot /usr/local/bin/restartMotionServerWithDelay.sh
@0187773933
0187773933 / TerminalDisplayImage.sh
Created October 1, 2022 12:04
Terminal Display Image
#!/bin/bash
convert frame.jpeg frame.png
# https://github.com/radare/tiv
tiv frame.png
@0187773933
0187773933 / SpotifyPlaylistMiner.py
Created September 23, 2022 20:15
Spotify Playlist Miner - Most Used Songs Across Playlist Search
#!/usr/bin/env python3
import os
import time
import json
from pprint import pprint
from box import Box # pip install python-box
from tqdm import tqdm
from concurrent.futures import ThreadPoolExecutor
from slugify import slugify # pip install python-slugify==5.0.2
import spotipy # pip install spotipy
@0187773933
0187773933 / MacOSXToastNotification.py
Created September 13, 2022 22:47
Python Script to Trigger Mac OSX Toast Notification
#!/usr/bin/env python3
import sys
import os
import json
import subprocess
import requests
import pyperclip
def read_json( file_path ):
with open( file_path ) as f: