Skip to content

Instantly share code, notes, and snippets.

View edubart's full-sized avatar

Eduardo Bart edubart

View GitHub Profile
##[[
cflags '-I/usr/include/tensorflow'
linklib 'tensorflow'
cinclude '<tensorflow/c/c_api.h>'
]]
global TF_AttrType: type <cimport, nodecl, using> = @enum(cint){
TF_ATTR_STRING = 0,
TF_ATTR_INT = 1,
TF_ATTR_FLOAT = 2,
TF_ATTR_BOOL = 3,
@edubart
edubart / mdb.lua
Created December 14, 2018 22:05
Multiple MySQL connections with Lapis
local mdbs = {}
return function(config_name)
local mdb = mdbs[config_name]
if mdb then return mdb end
local type, tostring, pairs, select
do
local _obj_0 = _G
type, tostring, pairs, select = _obj_0.type, _obj_0.tostring, _obj_0.pairs, _obj_0.select
end
local concat
@edubart
edubart / main.nelua
Last active December 26, 2021 12:25
WASM4 Nelua template
require "wasm4"
local smiley: []uint8 = {
0b11000011,
0b10000001,
0b00100100,
0b00100100,
0b00000000,
0b00100100,
0b10011001,
@edubart
edubart / gfxtoy.nelua
Last active December 17, 2021 23:04
gfxtoy test
-- THIS whole framework is hacky and just a PROOF OF CONCEPT!
##[[
primtypes.number = primtypes.float32
primtypes.integer = primtypes.int32
primtypes.uinteger = primtypes.uint32
if OPENMP then
cflags '-fopenmp'
end
local function parallel_for()
@edubart
edubart / arduino-gameoflife.lua
Created September 17, 2020 22:31
Arduino Game of Life in Nelua
require 'arduino'
-- user configurable defines
local CELL_SIZE: cint <comptime> = 4 -- the height and width of each cell
local DELAY: cint <comptime> = 50 -- number of milliseconds delay between the display of each generation
-- end of user configurable defines
local ROWS: cint <comptime> = (DISPLAY_HEIGHT // CELL_SIZE)
local COLUMNS: cint <comptime> = (DISPLAY_WIDTH // CELL_SIZE)
@edubart
edubart / nene_microui.lua
Created September 22, 2021 01:13
Micro ui nene
require 'microui'
require 'hashmap'
require 'nene.core'
require 'nene.colors'
require 'nene.math'
require 'nene.font'
require 'nene.text_texture'
local mu: mu_Context
local nene: Nene
##[=[
linklib 'lua'
cinclude '<lua.h>'
cinclude '<lauxlib.h>'
cinclude '<lualib.h>'
local ccdefs = require 'nelua.ccompiler'.get_cc_defines('<lua.h>')
static_assert(ccdefs.LUA_VERSION_NUM == 504, 'unsupported Lua version')
local c2nelua = {
['double'] = float64,
@edubart
edubart / nimbenchmark.md
Last active August 18, 2021 13:55
Nim/Node benchmarks

Environment:

  • Ubuntu 16.04 LTS
  • Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz
  • Nim Compiler Version 0.14.3 (2016-06-17) [Linux: amd64]
  • node v5.10.1

Nim code:

import asynchttpserver, asyncdispatch
@edubart
edubart / nelua-opencv-example.cpp
Last active August 7, 2021 18:33
Example using OpenCV with Nelua
/* Generated by Nelua 0.2.0-dev */
/* Compile command: g++ -x c++ "/home/bart/projects/nelua/nelua-lang/nelua_cache/play/draft.c" -o "/home/bart/projects/nelua/nelua-lang/nelua_cache/play/draft" -fwrapv -g -Wall -Wextra -I/usr/include/opencv4 -DWITH_OPENEXR=OFF -lopencv_core -lopencv_imgcodecs -lopencv_highgui -lm */
/* Compile hash: 2oc8quwtnUC8s47mULrq1Bsh5u2U */
/* ------------------------------ DIRECTIVES -------------------------------- */
/* Disable some warnings that the generated code can trigger. */
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wtype-limits"
#pragma clang diagnostic ignored "-Wwrite-strings"
#pragma clang diagnostic ignored "-Wunused"
#pragma clang diagnostic ignored "-Wunused-parameter"
@edubart
edubart / blueplanet.c
Last active July 27, 2021 22:05
Blue Planet in C
/* Generated by Nelua 0.2.0-dev */
/* Compile command: c2m "/home/bart/projects/nelua/nelua-lang/nelua_cache/demos/planet.c" -o "/home/bart/projects/nelua/nelua-lang/nelua_cache/demos/planet" -w -lSDL2 */
/* Compile hash: 2oufrcKZe8TBnJwdhtW2c9mqSzEe */
/* ------------------------------ DIRECTIVES -------------------------------- */
#include <math.h>
#include <stdint.h>
#define SDL_MAIN_HANDLED
#define SDL_DISABLE_MMINTRIN_H
#define SDL_DISABLE_IMMINTRIN_H
#define SDL_DISABLE_XMMINTRIN_H