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 / parse-args.c
Created November 16, 2018 17:38
Parses a string into seprate arguments similar to those recieved by main( int argc, char **argv );
#include <stdlib.h>
#include <string.h>
// strdup isn't 'standard'.
//extern char *strdup(char*);
/*
* usage:
* function f( char *argString ) {
* int argc;
@d3x0r
d3x0r / svgToCanvas.html
Last active November 17, 2018 22:51
Draw an SVG Image on a canvas.
<HTML>
<meta charset="utf-8"/>
<BODY>
</BODY>
<SCRIPT>
function makeNode( extra ) {
var svg = document.createElementNS( "http://www.w3.org/2000/svg","svg" );
@d3x0r
d3x0r / panthers_c_preprocessor.c
Last active January 23, 2021 05:52
This is portable a C preprocessor written in low level C.
// make #if conditions spanning files a warning...
// also unbalanced #endif statements....
#ifndef __GCC__
//#include <conio.h>
#endif
#if defined( _WIN32 )
// getmodulefilename
#include <windows.h>
#include <direct.h>
#endif
@d3x0r
d3x0r / PrimesQuick-28sec-5M
Created November 24, 2018 06:16
Quick remodel of primes test
#include <stdio.h>
#include <windows.h> // GetTickCount();
struct primes {
int last;
int checkTo;
long long primes[100000];
};
struct primes * getPrimes( void ) {
@d3x0r
d3x0r / CombinationsAndPermutations.js
Last active November 29, 2018 00:12
Generalized loops to iterate all combinations and permutations
//
// call initRowPerms( [], /* number of columns to permutate */, /* number from */, /*number to */ )
//
//----------------------------------------------------------------------------
// generate combinations to a callback
//----------------------------------------------------------------------------
function getCombinations(cb, cols, from, to) {
var indexes = [];
for (var n = 0; n < cols; n++) indexes.push(from);
@d3x0r
d3x0r / HTTP.md
Last active December 2, 2018 10:01
Links to HTTP stuffs
@d3x0r
d3x0r / C Conventions.md
Last active December 4, 2018 01:32
C Notes (fixme)

know the length of things.

  • when passing arrays as pointers, include passing the length.
    • function handleBuffer( char*buffer, size_t length );

buffer/length pairing

  • conventions in C libraries typically follow
    • (destination, source) as in destination = source;
  • (state object, int arguments ) as in the state object for the function should be the first parameter.
function call
function { arg1: 3, arg2: 4 }
{
arg1: 3,
arg2: 4
}
@d3x0r
d3x0r / test_once_on.js
Created January 8, 2019 08:24
Demonstration of difference between GunDB's on and once
var Gun = require( ".." );
var gun = new Gun();
var db = gun.get( "db" );
var player1Node = gun.get( "player1" );
var player2Node = gun.get( "player2" );
var players = db.get( "players" );