Skip to content

Instantly share code, notes, and snippets.

View Kreijstal's full-sized avatar
↗️

Kreijstal Kreijstal

↗️
View GitHub Profile
@Kreijstal
Kreijstal / sha-256.js
Last active November 15, 2024 12:28 — forked from rumkin/sha-256.js
/*
* Bitwise rotate a 32-bit number to the left.
*/
function ROTL(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* These functions implement the basic operation for each round of the
@Kreijstal
Kreijstal / Makefile
Last active August 8, 2024 17:42
verilator windows bug iverilog cosimulation
VERILATOR = verilator
IVERILOG = iverilog
VVP = vvp
# Detect operating system
ifeq ($(OS),Windows_NT)
DETECTED_OS := Windows
else
DETECTED_OS := $(shell uname -s)
endif
@Kreijstal
Kreijstal / dm_pkg.sv
Last active July 8, 2024 14:12
verilator
/* Copyright 2018 ETH Zurich and University of Bologna.
* Copyright and related rights are licensed under the Solderpad Hardware
* License, Version 0.51 (the “License”); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
* or agreed to in writing, software, hardware and materials distributed under
* this License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
@Kreijstal
Kreijstal / pi_calculus_excerpt.md
Created July 5, 2024 11:19
I need to read this on phone

Introduction to Part III

A type system is, roughly, a mechanism for classifying the expressions of a language. Type systems for programming languages, sequential and concurrent, are useful for several reasons, most notably:

(1) to detect programming errors statically (2) to extract information that is useful for reasoning about the behaviour of programs (3) to improve the efficiency of code generated by a compiler (4) to make programs easier to understand.

Types are an important part of the theory and of the pragmatics of the $\pi$-calculus, and they are one of the most important differences between $\pi$-calculus and CCS-like languages. Many of the type systems that have been studied for the $\pi$-calculus were suggested by well-known type systems for sequential languages, especially $\lambda$-calculi. In addition, however, type systems specific to processes have been proposed, for instance for preventing certain forms of interference among processes or certain forms of deadlock.

@Kreijstal
Kreijstal / binaryparsercombinator.js
Last active September 3, 2024 12:49
binary parser combinator js
function Result(tag, value) {
this.tag = tag;
this.value = value;
}
Result.ok = function(value) {
return new Result("ok", value);
};
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function (global){(function (){
'use strict';
var possibleNames = require('possible-typed-array-names');
var g = typeof globalThis === 'undefined' ? global : globalThis;
/** @type {import('.')} */
module.exports = function availableTypedArrays() {
@Kreijstal
Kreijstal / parsercombinator.py
Created April 10, 2024 11:15
something minimal I took ir from another website and expanded from there
import typing as tp
import operator
# Defining the basic parser structure
ParserP = tp.Callable[[str], tp.Tuple[tp.Any, str]]
# Defining the ParserError for exception handling
class ParserError(Exception):
def __init__(self, msg, content):
super().__init__(f"{msg}: {content}")
@Kreijstal
Kreijstal / canlink.py
Last active March 10, 2024 23:56
can link
@Kreijstal
Kreijstal / llmbenchmarks.txt
Created March 4, 2024 15:43
trying to make my own test set to check how good llms are
q:
```
The motion of a robot with a single prismatic joint can be modeled as: mq̈ + bq̇ + kq = f,
which depends on mass m = 2, stiffness k = 4, and friction b = 4.
We want to set the control force f = -kpx - kvẋ so that the controlled system is critically damped and has a closed-loop stiffness of k' = 8.
(Hint: a natural system is critically damped when b = 2√(mk.))
@Kreijstal
Kreijstal / NDTapeTuringMachine.py
Last active January 27, 2024 15:15
State Machine and automata, enjoy
class NDTreeNode:
def __init__(self, state, tapes, head_positions, parent=None):
self.state = state
self.tapes = tapes
self.head_positions = head_positions
self.parent = parent
self.children = []
class NDTapeTuringMachine:
def __init__(self, states, transitions, start_state, accept_state, blank_symbol, num_tapes):