Skip to content

Instantly share code, notes, and snippets.

View DavidMetcalfe's full-sized avatar

David Metcalfe DavidMetcalfe

  • Canada
  • 16:27 (UTC -07:00)
View GitHub Profile
@DavidMetcalfe
DavidMetcalfe / nvidia-x-server-settings.txt
Last active April 12, 2024 15:31
Documents the PowerMizer CLI for potential cron jobs, etc.
Because PowerMizer settings in NVIDIA X Server Settings doesn't persist across sessions,
attempts to overclock can become a nuisance.
The following documents the three CLI settings to modify the Preferred Mode as desired:
# Auto:
nvidia-settings -a [gpu:0]/GPUPowerMizerMode=2
# Adaptive:
nvidia-settings -a [gpu:0]/GPUPowerMizerMode=0
@DavidMetcalfe
DavidMetcalfe / Google OnHub API URLs.txt
Created January 27, 2017 21:31
List of known Google OnHub API URLs
http://onhub.here/api/v1/status
http://onhub.here/api/v1/diagnostic-report
http://onhub.here/api/v1/welcome-mat
http://onhub.here/api/v1/connected-devices
http://onhub.here/api/v1/get-attestation-information
http://onhub.here/api/v1/get-endorsement-information
@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 / Minecraft hold Rightclick.ahk
Last active August 29, 2021 05:04
Minecraft Right and Mouse button (held down) loops
/* Ctrl+Right Mouse button loops holding down Right Mouse button until either W or S are pressed.
Useful with certain boring Minecraft activities that have a person standing still and holding Right Mouse
for extended periods. Moving forward or backwards (W or S respectively) will stop the loop.
Replacing "RButton" with "LButton" will change Right Mouse held down with Left Mouse.
*/
^RButton::
@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'))