Skip to content

Instantly share code, notes, and snippets.

View AndreasHassing's full-sized avatar
🤓

Andreas Bjørn Hassing AndreasHassing

🤓
View GitHub Profile
@AndreasHassing
AndreasHassing / PowerShellContextMenu.reg
Created March 29, 2017 07:57
Get a "Open PowerShell In This Directory" context menu in Windows Explorer directories - only works for Windows 10+, for older versions of Windows: Google it.
Windows Registry Editor Version 5.00
; Download and run this .reg file to install the context menu
[HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShell]
@="&Open PowerShell Here"
"Icon"="powershell.exe"
"Position"="Top"
[HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShell\command]
@AndreasHassing
AndreasHassing / charcount.sh
Created July 10, 2017 13:07
Requires texcount, generates wordcount, charcount without spaces, charcount with spaces and pagecount based on charcount w/spaces (2400/page). Count characters in latex. Count words in latex.
#!/bin/bash
wordcount=$(texcount Main.tex | sed -n 3p | sed 's/[^0-9]*//g')
charcount=$(texcount -char Main.tex | sed -n 3p | sed 's/[^0-9]*//g')
charcountws=$(($charcount + $wordcount))
pages=$(echo "$charcountws 2400" | awk '{printf "%.2f", $1/$2}')
echo 'Wordcount:' $wordcount
echo 'Charcount no spaces:' $charcount
echo 'Charcount w/spaces:' $charcountws
@AndreasHassing
AndreasHassing / output.txt
Created August 1, 2017 10:15 — forked from jpoehls/output.txt
PowerShell benchmarking function. Or, the Windows equivalent of Unix's `time` command.
PS> time { ping -n 1 google.com } -Samples 10 -Silent
..........
Avg: 62.1674ms
Min: 56.9945ms
Max: 87.9602ms
PS> time { ping -n 1 google.com } -Samples 10 -Silent -Long
..........
Avg: 00:00:00.0612480
Min: 00:00:00.0572167
@AndreasHassing
AndreasHassing / hackerrank.fsx
Created April 28, 2019 06:58
Solve HackerRank problems with F# (FSharp)
/// Read all lines from stdin into an array of lines.
let lines = stdin.ReadToEnd().Split('\n')
// Now, all(?) problems on HackerRank can be solved using the `lines` binding.
// If you perform `stdin.ReadLine()` before the call to `stdin.ReadToEnd()` (to get a N or X variable, for instance),
// it will not be picked up by `stdin.ReadToEnd()`, yielding the expected behavior.
let (|UpperCase|) (str: string) = str.ToUpper()
// This blows my mind!
// thanks: https://youtu.be/yE88l29NOZw?t=151
let usedInAFunctionSignature (UpperCase(upper)) =
printfn "%s" upper
let usedLikeAMethod str =
let upper = (|UpperCase|) str
printfn "%s" upper
param (
$DriveToPunch = 'C',
$PathToBlackHoleFile = 'DiskPunchBlackHole.file',
$FreeSpaceToLeave = 5MB
)
$bytesToPunchOutOfTheDrive = (Get-WmiObject Win32_LogicalDisk -Filter "DeviceID='${DriveToPunch}:'").FreeSpace - $FreeSpaceToLeave
$blackHoleFile = [IO.File]::Create("${DriveToPunch}:\$PathToBlackHoleFile")
$blackHoleFile.SetLength($bytesToPunchOutOfTheDrive)
@AndreasHassing
AndreasHassing / README.md
Last active March 23, 2024 22:52
Skills for Thistle Gulch, extracted from Metaterra.Managers.NarrativeManager.Skills() in thistlegulch-windows-1.45.1-beta\ThistleGulch_Data\Managed\Metaterra.dll

Extracted from Metaterra.Managers.NarrativeManager.Skills() in thistlegulch-windows-1.45.1-beta\ThistleGulch_Data\Managed\Metaterra.dll, using ILSpy.

Had to do a few substitutions with https://regex101.com to clean the data as it came as a set of CIL-friendly strings in calls to Blackboard.FromJson.