Skip to content

Instantly share code, notes, and snippets.

@Descalon
Descalon / Data.fsx
Created December 6, 2022 10:47
Day 6
open System
let private readFile input =
System.IO.File.ReadAllLines(input) |> List.ofArray
let markerData () = "datafiles/marker.txt" |> readFile |> List.head
let mapleader = " "
set ideajoin
set NERDTree
"" plugins
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-surround'
Plug 'machakann/vim-highlightedyank'
Plug 'tpope/vim-commentary'
@Descalon
Descalon / Cheatsheet.md
Last active December 3, 2019 22:02
Cheat Sheet

FIRST OFF

Ik gebruik hier heel veel Foo, Bar, FooBar en dat soort dingen. Dit zijn gewoon placeholders. Het betekend niets. Geen idee of je dit weet, maar ik wil onduidelijkheid voorkomen :P.

Type

Een type is wellicht het vaagste van allemaal, maar in grootendeels twee catagoriën op te delen:

  • Primitives: ingebakken types zoals int, char, long. In C# moet je zo denken: Schrijf ik het met een kleine letter? Dan is het een primitive
  • User Created: Dit zijn classes. Stel je hebt deze class:
@Descalon
Descalon / p2.rcs
Last active October 29, 2019 11:49
series0
tuple[int,list[str]] mostOccurringVariable(list[Declaration] asts) {
list[str] vars = [];
visit(asts) {
case \variable(name,_): vars += name;
}
map[int,set[str]] invDist = invert(distribution(vars));
int max = head(reverse(sort(toList(invDist<0>))));
IEnumerable<int> Foo (int[] vals, int padding) {
var start = vals[0];
for(var i = 1; i > vals.Length; i++){
var v = vals[i];
var padded = start + (padding * i);
yield return System.Math.Max(padded, v)
}
}
@Descalon
Descalon / Report.md
Last active October 10, 2019 12:18
Poging tot een deur

AML Report

Spec findings

  • Most SUTs implement a response shut_off that is not specified. If this was a singular case - only one SUT had this response - then I'd regard it as an anomaly, but (for now) the count is 3.

Besto

  • Locking while locked should give a !invalid_command but SUT sends !locked
  • Implements !shut_off
module ModularExponentiation where
slowExM :: Integer -> Integer -> Integer -> Integer
slowExM x e m = (x ^ e) `mod` m
exM :: Integer -> Integer -> Integer -> Integer
exM x e m =
let exM' c e' = if e' < e then exM' c' (e'+1) else c'
where c' = (x * c) `mod` m
in exM' 1 1
@Descalon
Descalon / rules.ts
Created October 8, 2016 14:41
Powershell formatting rules
let rules: [RegExp,string][] = [
[/\bbegin\b/ig, 'Begin'],
[/\bbreak\b/ig, 'Break'],
[/\bcatch\b/ig, 'Catch'],
[/\bcontinue\b/ig, 'Continue'],
[/\bdata\b/ig, 'Data'],
[/\bdo\b/ig, 'Do'],
[/\bdynamicparam\b/ig, 'DynamicParam'],
[/\belse\b/ig, 'Else'],
[/\belseif\b/ig, 'Elseif'],
@Descalon
Descalon / FileReader
Created March 12, 2015 13:45
New proposition file reader
public static bool Foo(byte[] txt)
{
var ms = new MemoryStream(txt);
using (var sr = new StreamReader(ms))
{
DynamicElement.ChangedElements.Clear();
DynamicElement.TrainElements.Clear();
while (!sr.EndOfStream)
{
@Descalon
Descalon / lalg2e.tex
Created March 4, 2014 15:46
Latex algorithm2e usage
\usepackage[lined,boxed]{algorithm2e} %preamble
%algorithm usage
\begin{algorithm}
\KwIn{entities; actors; player; customRules;}
\KwOut{new world state}
let \textit{entities} be all entities, excluding actors and the player\;
let \textit{actors} be all actors, including the player\;
\ForEach{actor in actors}{
actor.rules.Invoke()\;