Skip to content

Instantly share code, notes, and snippets.

@0187773933
0187773933 / PrintFileSignature.bat
Last active May 23, 2023 15:12
Windows Command to Print the File Signature Bytes
powershell -Command "& {$file = Get-Content -Path $args[0] -Encoding Byte -TotalCount 16; $hex = ($file | % { $_.ToString('X2') }) -join ' '; $ascii = [System.Text.Encoding]::ASCII.GetString($file); Write-Host 'Hex: ' $hex; Write-Host 'ASCII: ' $ascii}" Other_2
@0187773933
0187773933 / ImagesToPowerPoint.py
Last active May 5, 2023 03:48
Converts Images in Directory to PowerPoint Slides
#!/usr/bin/env python3
import os
import glob
import collections # cause of yew python 3.10
import collections.abc # cause of yew python 3.10
# import pptx # pip install python-pptx
from pptx import Presentation
from pptx.util import Inches
from pptx.dml.color import RGBColor
from PIL import Image
@0187773933
0187773933 / GetSpikeProperties.py
Created April 11, 2023 02:03
Get Spike Properties
def get_percent_error( value , target ):
return ( ( abs( value - target ) / target ) * 100.0 )
def get_spike_properties( voltages , times ):
threshold = -70.2 # mV
voltage_recordings_np = voltages.as_numpy()
time_recordings_np = times.as_numpy()
peak_voltage = np.max( voltage_recordings_np )
@0187773933
0187773933 / WaitOnElement.js
Last active March 9, 2023 22:35
Vanilla JS ES6 Wait on Element
function wait_on_element( query_selector , check_interval=500 , timeout=20000 ) {
return new Promise( function( resolve , reject ) {
try {
let READY_CHECK_INTERVAL = setInterval( function () {
let element = document.querySelectorAll( query_selector );
if ( element ) {
if ( element[ 0 ] ) {
clearInterval( READY_CHECK_INTERVAL );
resolve( element[ 0 ] );
return;
@0187773933
0187773933 / FixAPTSourcesList.sh
Created March 4, 2023 15:12
Fix APT Sources List File
#!/bin/bash
# https://launchpad.net/ubuntu/+cdmirrors
SourcesFilePath="/etc/apt/sources.list"
MirrorURL="https://mirrors.cat.pdx.edu/ubuntu"
DistName="jammy"
EndPoints=(
" main restricted"
"-updates main restricted"
" universe"
@0187773933
0187773933 / MakeMKVFFmpegCombineToMP4.ps1
Created February 14, 2023 00:09
MakeMKV FFmpeg Combine DVD Tracks to MP4
Get-ChildItem -Path . -Filter *.mkv | Sort-Object { [int]($_.Name -replace '.*_t(\d{2}).mkv', '$1') } | foreach { $_.FullName } | foreach { "file '$_'" } | Out-File -Encoding ascii -FilePath output.txt; Get-Content .\output.txt; ffmpeg -y -safe 0 -f concat -i output.txt -c copy combined.mp4; Remove-Item .\output.txt
@0187773933
0187773933 / PowerPointExtractSlideTitles.py
Last active February 8, 2023 14:04
Prints Slide Titles from a PPTX PowerPoint
#!/usr/bin/env python3
import sys
import collections # cause of yew python 3.10
import collections.abc # cause of yew python 3.10
import pptx # python-pptx
def get_highest_shape_object( slide ):
potentials = []
for index , shape in enumerate( slide.shapes ):
potentials.append( [ shape.top , shape ] )
@0187773933
0187773933 / GithubTurnOffIssues.py
Created January 5, 2023 16:03
Turns Off Issues on All Repositories in a Github Account
#!/usr/bin/env python3
import requests
from pprint import pprint
TOKEN = "API_TOKEN"
USERNAME = "GITHUB_USERNAME"
API_BASE_URL = "https://api.github.com"
# https://docs.github.com/en/rest/repos/repos#update-a-repository
if __name__ == "__main__":
@0187773933
0187773933 / Handbell_Midi_Transposer.py
Created January 5, 2023 15:19
Tries to Find All Possible Transpositions for a Set of Handbells
#!/usr/bin/env python3
import sys
import json
import inspect
# pprint( inspect.getmembers( midi ) )
from pathlib import Path
from pprint import pprint
import music21
from music21 import *
@0187773933
0187773933 / MIDI_Transpose_To_All_Keys.py
Last active December 31, 2022 23:22
Transpose MIDI To All Key Variations
#!/usr/bin/env python3
import sys
from music21 import *
from pathlib import Path
keys = [ "A" , "B" , "C" , "D" , "E" , "F" , "G" ]
key_modifiers = [ '####' , '###' , '##' , '#~' , '#' , '~' , '----' , '---' , '--' , '-`' , '-' , '`' , '' ]
key_modifier_names = [ 'quadruple-sharp' , 'triple-sharp' , 'double-sharp' , 'one-and-a-half-sharp' , 'sharp' , 'half-sharp' , 'quadruple-flat' , 'double-flat' , 'one-and-a-half-flat' , 'flat' , 'half-flat' , 'natural' ]
if __name__ == "__main__":