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 / 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.

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)
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
@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.
@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 / 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 / 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 / link_playground.sh
Last active January 16, 2017 20:59
Slap nu af Anders, vi har den [en super formel guide til Hard- og Symlinks]
using System;
using System.IO;
using System.Text;
class Solution {
static void Main(String[] args) {
var t = Convert.ToInt32(Console.ReadLine());
for(var a0 = 0; a0 < t; a0++) {
var expression = Console.ReadLine();
@AndreasHassing
AndreasHassing / InstallingFsYaccFsLexOSX.md
Last active August 8, 2022 06:47
How to get FsYacc and FsLex (FsLexYacc) on OS X

Installing FsYacc and FsLex (FsLexYacc) on OS X

Step by step guide to getting FsYacc and FsLex for development on OS X.

Changes

  • 2017-01-09: Updated guide to reflect latest version of FsLexYacc (7.0.3)
  • 2016: Created

1. Install Mono

By doing one of these: