Skip to content

Instantly share code, notes, and snippets.

View i-e-b's full-sized avatar
🤔
Thinking

Iain Ballard i-e-b

🤔
Thinking
View GitHub Profile
@i-e-b
i-e-b / test.js
Created December 21, 2022 15:11
basic RS encode / decode in Javascript
'strict';
function log(msg){document.getElementById('outp').innerText+= msg+"\r\n";}
log("Reed solomon octal coding for short messages\r\n");
const extraCodes = 2;
let orig = [46,219,120,55];
let int32Val = (orig[0] << 24) + (orig[1] << 16) + (orig[2] << 8) + orig[3];
log("tag value="+int32Val);
@i-e-b
i-e-b / MemoryMap.cs
Created December 1, 2022 09:43
Quick demo of mmap in dotnet
using System.IO.MemoryMappedFiles;
using System.Runtime.InteropServices;
namespace MemMapTests;
internal static class Program
{
private const long Megabyte = 1048576;
private const long Kilobyte = 1024;
@i-e-b
i-e-b / caller_id.md
Created October 21, 2022 10:44
Which process is calling out to a given IP

On Linux: lsof -PniTCP -r 1 | grep 1.2.3.4 On Windows: netstat -tabn 10 | find "1.2.3.4"

@i-e-b
i-e-b / BeltAndBraces.md
Created October 19, 2022 11:52
A forth-like language with weird semantics

Take a normal forth-like

25 4 * 100 =    // true

Add parenthesis as a re-write rule, and move one symbol from the left to the right

write(2 4 *) becomes 2 4 * write

@i-e-b
i-e-b / low_bias_hash.cs
Created October 6, 2022 09:36
Low bias 32 bit hash in C#
public static uint DataHash(byte[] data, uint len)
{
var hash = len;
for (uint i = 0; i < len; i++)
{
hash += data[i];
hash ^= hash >> 16;
hash *= 0x7feb352d;
hash ^= hash >> 15;
hash *= 0x846ca68b;
[Test]
public void tiny_crypto()
{
var key = new byte[] { 55, 167, 44, 86, 217 };
var secretMessage = "This is the input text";
var input = Encoding.UTF8.GetBytes(secretMessage);
var encrypted = Encode(input, key);
@i-e-b
i-e-b / dwt97.c
Created March 5, 2019 09:57
Fast discrete biorthogonal CDF 9/7 wavelet forward and inverse transform (lifting implementation)
/**
* dwt97.c - Fast discrete biorthogonal CDF 9/7 wavelet forward and inverse transform (lifting implementation)
*
* This code is provided "as is" and is given for educational purposes.
* 2006 - Gregoire Pau - gregoire.pau@ebi.ac.uk
*/
#include <stdio.h>
#include <stdlib.h>
@i-e-b
i-e-b / time.md
Created September 12, 2022 09:28
time

maybe the wavefunction oscilates through time, taking alternate paths, until it gets stuck somewhere. Maybe this getting stuck loses information locally. That would seem to give a mechanism for collapse and directionality of time.

@i-e-b
i-e-b / Lisp and Forth?.md
Created September 12, 2022 08:22
Stalisp

Forth and List based on a 'fundamental container type'. Forth -> stack, Lisp -> linked-list. We take as the fundamental container type a list/stack hybrid. Anything in a list is data. Anything outside is a function call.

Motivational example

  (4) (1 2) + *    # 12
  (4 1 2) + *      # same
 
@i-e-b
i-e-b / wordless.txt
Last active August 24, 2022 08:37
Thinking out loud
// No keywords?
my.thing { // a namespace
// proc head
procname =>
inParam1 <- (u8) // a byte list
inParam2 <- "" // a string
{
// proc body