Skip to content

Instantly share code, notes, and snippets.

@Jarak-Jakar
Jarak-Jakar / UnsafeBoolAddition.cs
Created January 23, 2021 22:12
A short demo of using unsafe features to add bools together, for use in LINQPad or RoslynPad
/* Tested with .NET 5.0.102, using RoslynPad 15.1 and LINQPad 6.11.11.
The sample is taken from https://stackoverflow.com/a/64897013/6792709 on 24 Jan 2021
and is courtesy of StackOverflow user brandwegg */
// A very brief demonstration of using unsafe C# operations to add two bools together as if they are ints.
unsafe static int AddBools(bool* a, bool* b)
{
/*casts the bool pointer to a byte pointer and then uses the *
operator to access the value at the position as a byte, which you can
@Jarak-Jakar
Jarak-Jakar / README.md
Created May 28, 2020 09:39
A Powershell script I wrote to distribute files downloaded from Bandcamp automatically in my Music folder

Distribute Zips

A Powershell script to distribute .zip files of music to the correct locations and extract their contents, with every folder named correctly according to my personal preference.

Usage

To use this, situate it in your Music folder (or equivalent), and simply run the script at the command line, e.g. .\distribute-zips.ps1. I strongly recommend you look at the rest of the README below before doing so, in order to understand what it will and won't do.

Rationale

@Jarak-Jakar
Jarak-Jakar / Cargo.toml
Last active February 14, 2019 00:35
A (slightly obfuscated) copy of a short Rust program to test efficiency/implementation of message exchanges over channels
[package]
name = "thor_rust"
version = "0.1.0"
authors = ["Anon <anon@hidden.com>"]
edition = "2018"
[dependencies]
rayon = "1.0.3"
crossbeam-channel = "0.3"
@Jarak-Jakar
Jarak-Jakar / rollingwindow.fs
Last active January 11, 2019 08:39
A quick & dirty sequence comprehension that does windowed sequences, but starts with ones that aren't yet the full window size
let seqNums = [1.0; 1.5; 2.0; 1.5; 1.0; 1.5] |> Seq.ofList;;
let windows windowSize theSeq = seq {
for i in 1..(windowSize - 1) do
yield Seq.take i theSeq |> Array.ofSeq
yield! Seq.windowed windowSize theSeq
}
let myWindowedNums = windows 3 seqNums