Skip to content

Instantly share code, notes, and snippets.

View d3x0r's full-sized avatar

Jim B d3x0r

  • Las Vegas
View GitHub Profile
@d3x0r
d3x0r / liba.c
Created May 30, 2019 12:27
Simple Emscriptem dynamic link test
#include <stdlib.h>
#include <malloc.h>
char *makeThing( void ) {
return malloc( 10 );
}
void unmakeThing( char *thing ) {
free( thing );
}
@d3x0r
d3x0r / JSOX encoded data.js
Last active May 16, 2019 23:12
Example Stored Object
{
data: {
data: {
groups: [{
captain: {
children: [],
created: 2019-05-16T14:05:10-07:00,
@d3x0r
d3x0r / memops.c
Created May 9, 2019 15:15
Hacked memops with pre-post alignment checking.
void MemSet ( POINTER p, uintptr_t n, size_t sz )
{
#if defined( _MSC_VER ) && !defined( __NO_WIN32API__ ) && !defined( UNDER_CE )
# if defined( __64__ )
// quad word align...
if( ((uintptr_t)p) & 1 ) {
(*(uint8_t*)( ((uintptr_t)p) + sz - (sz&1) ) ) = (uint8_t)n;
p = (POINTER)( ((uintptr_t)p) + 1 )
sz -= 1;
}
@d3x0r
d3x0r / tensorExperiment1.js
Created May 8, 2019 14:11
My First Brain (?)
import * as tfa from '@tensorflow/tfjs';
const tf = tfa.default;
// Optional Load the binding:
// Use '@tensorflow/tfjs-node-gpu' if running with GPU.
import * as unused from '@tensorflow/tfjs-node-gpu';
import * as CRa from "./chainReact.mjs"
@d3x0r
d3x0r / Plugins.md
Last active April 27, 2019 05:12
A document describing simple a plugin pattern for C/C++

Pluggable Programs in C/C++

Extendable programs are wonderful... but how does one actually implement plugable portions of code?

Interfaces

An interface is a structure that contains function pointers. These functions are used to call into either the plugin or the main program.

@d3x0r
d3x0r / pthread_once.c
Last active June 27, 2020 00:06
pthread_once emulation...
// best version
// would like to do CreateEvent in static initializer; but that's not a constant expression.
#define PTHREAD_ONCE_INIT { 0, 0 }
struct pthread_once {
HANDLE event;
volatile LONG inited;
};
typedef struct pthread_once pthread_once_t;
@d3x0r
d3x0r / simpleHash.c
Last active April 19, 2019 23:28
Simple Hash hash storage.
like struct hashNode {
struct data {
int used;
union hndata {
struct hashNode *nextPage;
char *hash
}data;
} data[256];
};
struct hashNode root;
@d3x0r
d3x0r / sampleOut.MD
Last active April 3, 2019 04:12
test user input node script
Thing is: "�"
LINE: <Buffer f0 9f 92 a9 0d 0a>
output 1:
["�","�","\r","\n"]
output 2: 💩
 [ '�', '�', '\r', '\n' ]
💩
@d3x0r
d3x0r / os-index-notes.md
Created March 24, 2019 03:03
Object Storage Indexing; indexing for graph databases.

javascript

  1. create index object type 1a) index object types have a specific object type on the disk 2b) Indexes are assigned unique filenames (related to the source object they index as?)

  2. query for records from storage 2a) db = os.get( "root" ); 2b) db.setmap( "players", "firstName = 'bob'" ).on( handleBobs ); 2c) db.setmap( "players", "firstName = 'bob' and lastName='bob'" ).on( handleBobs ); 2d) db.setmap( "players", "firstName = 'bob' or lastName='bob'" ).on( handleBobs );

@d3x0r
d3x0r / test3-b.js
Created March 22, 2019 18:21
Test gun-db sync
var vfs = require( "sack.vfs" );
var vol = vfs.Volume( "MountName", "vfsFile.dat" );
var Gun = require('gun');
require('gun-db');
var peers = [
'http://localhost:8081/gun',
]
// Create a new gun instance