Skip to content

Instantly share code, notes, and snippets.

View DavidMetcalfe's full-sized avatar

David Metcalfe DavidMetcalfe

  • Canada
  • 01:34 (UTC -07:00)
View GitHub Profile
@DavidMetcalfe
DavidMetcalfe / Escape and unescape URLs in PowerShell.ps1
Created January 4, 2023 04:03
Escape and unescape URLs in PowerShell
function EscapeURL() {
# Escape the given URL and return it.
param (
[Parameter()]
[string] $URL_To_Escape
)
return [uri]::EscapeDataString($URL_To_Escape)
}
for f in *.mp4; do ffmpeg -vn -acodec copy $f.aac -i $f; done
@DavidMetcalfe
DavidMetcalfe / Prints the file count per directory for the current directory level.sh
Created July 4, 2022 23:18
Prints the file count per directory for the current directory level
# Credit for script to Sebastian Piskorski on Stack Overflow:
# https://stackoverflow.com/a/39622947/563231
du -a | cut -d/ -f2 | sort | uniq -c | sort -nr
@DavidMetcalfe
DavidMetcalfe / DebugLogger.ahk
Created February 21, 2021 05:44
AutoHotkey Logging function for debug and other uses since there's nothing native that seems to work well for this.
DebugLogger(logText, debugLevel:="DEBUG") {
; Debug logging functionality for AutoHotkey (AHK).
; Creates one log file per day, and appends date/time to each log line.
; Uses debug levels: DEBUG, INFO, WARNING, ERROR, CRITICAL.
FormatTime, CurrentDate,, yyyy-MM-dd
FormatTime, CurrentDateTime,, yyyy-MM-dd hh:mm:ss
IfNotExist, .\log\
FileCreateDir, .\log\
@DavidMetcalfe
DavidMetcalfe / Single and double quotes.vb
Created May 13, 2020 22:05
Single and double quotes in VBA strings
Public Const vbDoubleQuote As String = """" 'represents 1 double quote (")
Public Const vbSingleQuote As String = "'" 'represents 1 single quote (')
@DavidMetcalfe
DavidMetcalfe / Column letters to numbers.vb
Last active May 13, 2020 20:22
Convert between column numbers and column letters in Excel VBA
Function columnLetterToNumber(letter) As Long
' Convert a given column letter into the corresponding column number.
columnLetterToNumber = Range(letter & 1).Column
End Function
@DavidMetcalfe
DavidMetcalfe / Get script location example usage.py
Created May 5, 2020 08:25
Gets the location of the currently running Python script. Allows one to easily access files in the same directory as the script.
import os
__location__ = os.path.realpath(
os.path.join(os.getcwd(), os.path.dirname(__file__)))
f = open(os.path.join(__location__, 'example.jpg'))
javascript: (function () {
var allsongs = [];
var outText = "";
var songsToText = function (style, csv, likedonly) {
if (style === undefined) {
console.log("style is undefined.");
return;
}
var csv = csv || false; // defaults to false
var likedonly = likedonly || false; // defaults to false
@DavidMetcalfe
DavidMetcalfe / autoclicker.js
Last active May 1, 2018 01:48
Cookie Clicker Auto Clicker (Click Spammer)
// [ === Toggleable autoclicker === ]
// Activating will enable, and a second toggle will deactivate.
// ** Legit version (doesn't activate Game.autoclickerDetected)
if (window._activeClickInterval) {
clearInterval(window._activeClickInterval);
delete window._activeClickInterval;
} else {
window._activeClickInterval = setInterval(Game.ClickCookie, 250);
}
@DavidMetcalfe
DavidMetcalfe / Recursive search through files.sh
Last active April 19, 2018 23:19
Recursively search through files in chosen directory
# -r = recursive
# -n = line number within file
# -w = match whole word
grep -rnw . -e 'query' # Search current dir in bash.
grep -rnw '/path/to/directory/' -e 'query' # Search provided directory in bash.