Predictable Random Number Generation in TypeScript

Lehmer

August 25, 2020 typescript, rng, lehmer

I got the idea for using this type of RNG from the javidx9 video Procedural Generation: Programming The Universe. It's a really good video as are most of the videos he produces so I recommend you give it a watch. The algorithm he talks about in the video is the Lehmer random number generator.

I'm implementing a simple match the blocks game in TypeScript and I wanted to implement the algorithm mentioned there in TypeScript.

Read More

Creating a tsexec command

August 21, 2020 typscript, batch

I want to use TypeScript as a scripting language for my machine and so I want to be able just to execute TypeScript files directly. There are npm packages like ts-node that do this already but I wanted to have a crack at implementing it myself. So this is the batch file I've come up with so far.

Read More

Checking for uncommited git changes in a batch program

July 22, 2020 batch, git

Sometimes it's helpful to exit out of a batch script if there are pending changes to a repo. This is done in batch script in a non intuitive way.

@ECHO OFF
PUSHD %~dp0

SET __HAS_CHANGES=0

REM The loop won't be executed if 'git status -s' doesn't produce any output.
FOR /f "tokens=*" %%i IN ('git status -s') DO ( SET __HAS_CHANGES=1 )

REM Check if the loop was executed and goto EXIT if it was.
IF "%__HAS_CHANGES%" NEQ "0" (
    ECHO There are currently uncommitted changes.
    GOTO EXIT
)

REM Do the work you want to do here.

:EXIT
POPD

Enum Extension Methods

July 17, 2020 c#, enum, extension

Did you know you can create extension methods for enums?

Read More

Disable C# null checks for a field or property

January 02, 2020 c#, nrt, nullable

The new nullable reference types in C# are great but sometimes you might need to disable it for a single field or property. You can do that by assigning the value to null and using the ! operator.

Read More