Skip to content

Instantly share code, notes, and snippets.

View bradkrane's full-sized avatar

Brad Krane bradkrane

  • Waterloo, Ontario
View GitHub Profile
@bradkrane
bradkrane / doses-remaining-estimator.html
Last active May 2, 2024 17:59
Estimates Remaining Quantity/Time of Doses using Weight
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Doses Remaining Estimator</title>
</head>
<body>
<h2>Doses Remaining Estimator</h2>
<form>
<label for="emptyWeight">Bottle weight (g):</label>
@bradkrane
bradkrane / pwd.rb
Created October 5, 2022 03:07
Quick script to select subset of password list
#!/usr/bin/ruby
# ruby this.rb <wordlist> <command> <param> [cmd]
# Ex. C:\Users\Brad Krane\Documents\src\pwd>ruby pwd.rb 10-million-password-list-top-1000000.txt letters 5 "echo Weak PWD"
#Weak password
#Weak qwerty
#Weak dragon
#Weak baseball
#Weak football
throw ArgumentError.new "Invalid aruments: #{ARGV}\nruby this.rb <wordlist> <command> <param> [cmd]" if ARGV.length > 4 || ARGV.length < 3
@bradkrane
bradkrane / Base64toFile.html
Created March 16, 2022 19:22
Paste Base64 and Save As...
<html>
<body>
<p><h2>Base64 to file</h2></p>
<p>
Get data with: <pre>cat &lt;file&gt; | gzip -c | base64</pre><br/>
Paste below and save to file:
</p>
<p>
<textarea id="content" style="width: 580px; height: 250px;"></textarea>
<br/>
@bradkrane
bradkrane / kill-quantum.ps1
Created December 31, 2021 18:37
Kills the uses way too much CPU JBL QuantumApp
$process = Get-Process -Name "QuantumApp"
if ($process -eq $null) {
exit
}
$time = New-TimeSpan -Start $process.StartTime
if ($time.Minutes -gt 5) {
Stop-Process -Force -Id $process.Id
}
module Kernel
def to_hash
new_hash = self.instance_variables.reduce({}) do |hash, instance_var|
hash[instance_var.to_s[1..-1].to_sym] = self.instance_variable_get instance_var
hash
end
end
end
@bradkrane
bradkrane / dynamic-timeanddate.js
Last active April 5, 2021 02:10
Dynamic DateTime www.timeanddate.com Bookmarklet
javascript:(() => {
const pad = (x) => { if(x < 10){ return x = '0' + x } return x };
let now = new Date();
let y = now.getFullYear();
let mo = pad(now.getMonth() +1);
let d = pad(now.getDate());
let h = pad(now.getUTCHours());
now = `${y}${mo}${d}`;
window.location.replace(`https://www.timeanddate.com/worldclock/converter.html?iso=${now}T${h}0000&p1=137&p2=55&p3=250&p4=136&p5=48&p6=56&p7=214&p8=240`);
@bradkrane
bradkrane / preventAdditionalMouseEvent.html
Created August 20, 2020 01:07 — forked from toruta39/preventAdditionalMouseEvent.html
Prevent mouseout/mouseover event triggered when moving onto/from a child element
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Prevent additional mouse event</title>
</head>
<body>
<div id="ele" style="width: 300px; height: 300px; background-color: #0FF;">
This is the parent element.
<div style="width: 200px; height: 200px; background-color: #FFF;">
REM This is to fix teams issue: MS Teams keeps randomly crashing
REM https://answers.microsoft.com/en-us/msoffice/forum/all/ms-teams-keeps-randomly-crashing/d4b3fd90-c77e-468a-82a7-8190db44f73f
taskkill /F /IM teams.exe
del /f /s /q %appdata%\Microsoft\teams\application cache\cache\*
del /f /s /q %appdata%\Microsoft\teams\blob_storage\*
del /f /s /q %appdata%\Microsoft\teams\databases\*
del /f /s /q %appdata%\Microsoft\teams\GPUcache\*
del /f /s /q %appdata%\Microsoft\teams\IndexedDB\*
del /f /s /q "%appdata%\Microsoft\teams\Local Storage\*"
@bradkrane
bradkrane / shopify-country-region.rb
Created February 19, 2020 03:42
Shopify Country Code to Region Mapping
regions = {
AF: 'Africa',
AS: 'Asia',
CA: 'Central America',
EU: 'European Union',
NA: 'North America',
OC: 'Oceania',
OT: 'Other',
SA: 'South America',
AN: 'Antarctica',
@bradkrane
bradkrane / odt2txt.cmd.md
Last active April 27, 2024 01:46
Git diff for LibreOffice ODT files for Windows Setup

Batch Script and Git Setup for text diff of ODT files with LibreOffice

git Windows will diff docx files without any additional configuration but surprisingly, this is not the case for ODT files. This simple Window shell script and git attributes configuration allows for diffing ODT files with LibreOffice

Windows Shell Script

Copy the script below locally, I use %USERPROFILE%\scripts as the reference destination in the Configure Git section below, but you can choose whatever you want replacing the path with your own throughout the document.

Waring: this script assumes that the there is no .txt file that matches the filename less extension of the ODT file being diffed. This is a temporary work around for the --cat option of soffice.exe not working as advertized. Bug 129713