Skip to content

Instantly share code, notes, and snippets.

View leiradel's full-sized avatar

Andre Leiradella leiradel

View GitHub Profile
@leiradel
leiradel / modules.c
Created February 29, 2020 19:44
Use a package searcher to static link LuaSocket into an executable.
#include <stddef.h>
#include <string.h>
#include <lua.h>
#include <lauxlib.h>
#include "luasocket/src/ftp.lua.h"
#include "luasocket/src/headers.lua.h"
#include "luasocket/src/http.lua.h"
#include "luasocket/src/ltn12.lua.h"
-- Based off https://github.com/EmmanuelOga/easing
-- For all easing functions:
-- t = elapsed time between 0 and 1
-- b = begin
-- c = end
local pow = math.pow
local sin = math.sin
local cos = math.cos
@leiradel
leiradel / main.cpp
Created August 7, 2019 21:22
Dear ImGui docking bug
#include <imgui.h>
#include <imgui_impl_sdl.h>
#include <imgui_impl_opengl2.h>
#include <SDL.h>
#include <SDL_opengl.h>
#include <string>
class Application
@leiradel
leiradel / memory_layout.md
Last active November 4, 2024 16:31
Memory Layout for Raspberry Pi
  • User/Kernel split
    • 3 GB user, 1 GB kernel
  • User split
    • 1 MB unmapped for illegal access exceptions
    • .text, .rodata, .data, heap and stack
    • Heap is right after .data
    • Stack is at the end of the available user RAM
    • Heap and stack grow towards each other
  • Kernel split
  • 512 MB VideoCore RAM (reserved address space, actual RAM may be less)
/*
The MIT License (MIT)
Copyright (c) 2016 Andre Leiradella
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@leiradel
leiradel / roomenc.cpp
Created September 26, 2018 21:29
Generates code that fills the entire screen, with gray support
#include <stdio.h>
#include <stdint.h>
/*---------------------------------------------------------------------------*/
/* stb_image config and inclusion */
#define STBI_ASSERT( x )
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
@leiradel
leiradel / bmpenc.cpp
Created September 15, 2018 20:09
An image encoder for Gamebuino Classic bitmaps
#include <stdio.h>
#include <stdint.h>
/*---------------------------------------------------------------------------*/
/* stb_image config and inclusion */
#define STBI_ASSERT( x )
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
set title 'Graph Title'
set xlabel 'ms'
set ylabel 'Mb'
set terminal svg
set output 'graph.svg'
plot 'lua.log' title 'Lua' with lines, 'wren.log' title 'Wren' with lines
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <stdlib.h>
#include <wren.h>
#ifdef __APPLE__
#include <mach/mach_time.h>
#else
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <stdlib.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#ifdef __APPLE__