Skip to content

Instantly share code, notes, and snippets.

@irondoge
irondoge / COLLECTIONS.md
Last active March 14, 2021 14:02
C collections implementation [vector, map, string-value map (svmap), dynamic type list (dynlist)]

C Collections

C Collections is a light and short C implementation of usefull collections. It contains:

  • fixed type vector
  • string-int map
  • string-fixed type map (svmap)
  • dynamic type list (dynlist)

Code Example

#pragma once
#ifndef _EXPAND_MACRO_H_
# define _EXPAND_MACRO_H_
# define __DONOTHING(...)
# define __EXPAND(...) __VA_ARGS__
# define __COMMA(A) A,
# define __CAT(A, B) A ## B
# define CAT(A, B) __CAT(A, B)
# define __SELECT( \
[CCode (cheader_filename = "hello.h")]
namespace Go {
[CCode (cname = "hello")]
extern void hello();
}
@irondoge
irondoge / Makefile
Created August 5, 2017 09:54
GNU Make C API - hello world
CC := gcc
CFLAGS := -fpic
LD := $(CC)
LDFLAGS := -shared
LDLIBS :=
all:; @echo $(hello )
say:; @echo $(say "hello, world")
@irondoge
irondoge / ccompounds.c
Created June 10, 2017 00:55
C/C++ compound litterals
#include <stdio.h>
void dummy(float *blblbl)
{
int i;
for (i = 0; i < 2; i++)
printf("%f\n", blblbl[i]);
}
@irondoge
irondoge / ironbnf.md
Last active June 17, 2017 14:50
IronBNF Specifications

IronBNF Specifications

IronBNF is a context-sensitive derivate of the original BNF notation.

Syntax and delimiters

The BNF syntax describe a grammar by defining rules, and each rule may be a block that may contain blocks.

Blocks and precedence

@irondoge
irondoge / macro.cpp
Created December 1, 2016 17:39
Recursive variadic C/C++ macro. [compilation: gcc -std=c++11 macro.cpp]
#include <stdio.h>
#define PRINT(...) CAT(CT(__VA_ARGS__))(__VA_ARGS__)
#define CAT(N) DOG(N)
#define DOG(N) PRINT ## N
/* max supported args is 5 for now */
#define CT(...) VALS(__VA_ARGS__, 5, 4, 3, 2, 1)
#define VALS(N1, N2, N3, N4, N5, N, ...) N
@irondoge
irondoge / EPIECH_SPIDER_PROTOCOLS.md
Last active January 26, 2022 10:00
Spider Protocols.md

#Spider Protocols

###Enveloppe.proto

message Enveloppe {
    required string UUID = 1;
    required string PayloadBuffer = 2;
    required google.protobuf.Any Payload = 3;
}
@irondoge
irondoge / dims.py
Created October 15, 2016 14:12
Get python list dimensions number
def dims(lst):
ct = 1
while list in [ type(i) for i in lst ]:
lst = sum([ i for i in lst if type(i) == list ], [])
ct += 1
return ct
@irondoge
irondoge / extract.txt
Last active October 14, 2016 23:27
extract Makefile variables
$ cat Makefile
NAME := star my github repo's pliz
NAME2 = OK
get-%:; $($*)
$ make -n get-NAME
star my github repo's pliz
$ make -n get-NAME2