Skip to content

Instantly share code, notes, and snippets.

View eurocat2k's full-sized avatar

eurocat2k eurocat2k

View GitHub Profile
@eurocat2k
eurocat2k / i5n.js
Last active November 23, 2023 12:11
I5N six bit encoded message decoder in JS
// An Asterix cat48 data from a PCAP file
// 0000 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
// 0010 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
// 0020 .. .. .. .. .. .. .. .. .. .. 30 00 1f fd c1 02
// 0030 16 0d 6f 4c 75 a8 45 9c 28 c3 0f 93 06 18 4d 24
// 0040 60 5d a6 b1 e3 48 20 00 fd
// in case we would like to use static code table - ignored characters replaced by hashtag
let sixbitstable = "#ABCDEFGHIJKLMNOPQRSTUVWXYZ##### ###############0123456789######";
// the 6 bit encoded aircraft ID can be found in the line
// 0040 .. 5d a6 b1 e3 48 20 .. ..
@eurocat2k
eurocat2k / ptrcheck.asm
Created October 9, 2023 14:55
C pointer check at runtime
# Assembly code of:
# clang -arch x86_64 -masm=intel -S -Wall -O3 -o - ptrcheck.c
#
.text
.intel_syntax noprefix
.file "ptrcheck.c"
.globl isValidPointer # -- Begin function isValidPointer
.p2align 4, 0x90
.type isValidPointer,@function
isValidPointer: # @isValidPointer
@eurocat2k
eurocat2k / vector.c
Last active August 9, 2023 13:24
vector data type library for C
#include "vector.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
// instance of vector_t
struct vector_instance_t {
void *data;
size_t data_size;
@eurocat2k
eurocat2k / app.js
Last active June 12, 2023 21:45
VSCROLL SELECTION MENU
$(function(){
console.log(`ready....`);
$vscroll = $('.vscroll_container');
$vscroll.vScrolled({
visible: 7 // number of visible list items in the scrolled menu
});
$(document).on('onVSelect', {selected: 0}, function (ev, fl) { ev.data.selected = fl; console.log(`FL${fl} [${$vscroll.selected()}]`, ev) });
});
@eurocat2k
eurocat2k / Vector3D.js
Last active December 15, 2022 09:35
Find shortest distance between two line segments in 3D space
class Point3D {
constructor(x = 0, y = 0, z = 0) {
this._vector = new Float32Array(3)
this._vector[0] = x
this._vector[1] = y
this._vector[2] = z
}
set(x=0, y=0, z=0) {
this._vector[0] = x
this._vector[1] = y
@eurocat2k
eurocat2k / CreateTCPSocket.c
Last active December 2, 2022 09:14
TCP non-blocking client connection using kqueue
#include "tcpsocket.h"
/**
* @brief Create a Socket object
* @name CreateSocket
* @param int domain
* @param bool keepalive
* @param bool nonblock
* @return int socket
*/
int CreateSocket(int domain, bool keepalive, bool nonblock) {