Skip to content

Instantly share code, notes, and snippets.

View fabiovila's full-sized avatar

Fabio fabiovila

View GitHub Profile
@fabiovila
fabiovila / Makefile
Last active October 1, 2023 21:28
Makefile that find any *.c *.s and folders with *.h. Target is ARM Devices. For use with VSCode or command line.
#Part two of two files that recursivaly find and compile *.c *.s files
# and automatically adds folders with *.h files to gcc include option.
# Made for STM32F103 ARM devices and for use with VSCode
# with few changes these files will work in any toolchain
include Makefile.inc
.SECONDEXPANSION:
DEFINES = -DSTM32F207xx -DARM_MATH_CM3
OUTOFCOMPILER = "./nocompile"
@fabiovila
fabiovila / fs2hex.cpp
Last active December 12, 2017 16:50
Embeddeds files in a folder -recursively- into C/C++ H files with name and size. The files are stored at array fsFiles with stFile struct type that has .name , .data and size fields. I'm using this in order to serve files from a ARM board running a web server with FreeRTOS , Lwip and Mongoose. #stm32 #embedded #c #filesystem #mongoose
#include <iostream>
#include "boost/filesystem.hpp"
#include <fstream>
#include <map>
#include <cstring>
#include <string>
// Turn all files from a folder into hex char with name and size.
// Fabio Vila
@fabiovila
fabiovila / ev_handler.c
Last active January 8, 2018 23:29
How send large files with Mongoose with low memory? Send in parts.
static void ev_handler(struct mg_connection *nc, int ev, void *p) {
if (ev == MG_EV_ACCEPT){
nc->user_data = Alloc(3 * sizeof(int)); // My malloc implementation
print("ACCEPT\n",7);
}
if (ev == MG_EV_CLOSE){
AFree(nc->user_data); // Free of malloc implementation
print("CLOSE\n",6);
}
@fabiovila
fabiovila / iris-armadillo.cpp
Last active December 23, 2017 16:42
A feedforward neural network trainned with Stochastic Gradient Descent in Iris dataset. C++ program with Armadillo as dependency only.
#include <iostream>
#include <unordered_map>
#include "armadillo"
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <string>
@fabiovila
fabiovila / nn-iris.cpp
Last active January 26, 2018 14:41
Another neural network for iris dataset. Simplified version with fixed layers, although you can change the size.
#include <iostream>
#include <unordered_map>
#include "armadillo"
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <string>
@fabiovila
fabiovila / opencl-list.c
Last active April 11, 2018 20:35
C OpenCL example wich lists platforms and devices
#include <stdio.h>
#include <CL/cl.h>
#define BUFFERSIZE 1024
#define MAX_PLATFORMS 8
#define MAX_DEVICES 8
//gcc -o opencl opencl-list.c -lOpenCL && ./opencl
int main(int argc, char** argv)
@fabiovila
fabiovila / send-nextion.c
Created May 30, 2018 00:33
Send and set object values in Nextion LCDs on Arduino or general Serials
// Usage:
// setObj ("OBJECT.PROPS", "VALUE");
// obj - name and propertie of object
// txt - value
// example:
// setObj("t0.txt", "Test");
// Warning: Your IDE (as Arduino) is very likely that be UTF-8 wich causes the LCD don't renders the exact string that you pass to setObj
void setObj( char *obj, char *txt ){
Serial.write(0xFF); Serial.write(0xFF); Serial.write(0xFF); // Usefull when Serial connected to LCD is the same of Debug (my case in NODEMCU)
for (;*obj != 0; obj++) Serial.write(*obj);
@fabiovila
fabiovila / GRU.pdf
Last active October 20, 2021 23:39
RNN Neural Math Operations Circuit Flow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fabiovila
fabiovila / present-min.js
Last active June 26, 2020 01:57
PRESENT block cipher in JavaScript version converted from original https://github.com/bozhu/PRESENT-C
function present_rounds(n,r,e){var t=1,i=new Uint8Array(8),a=new Uint8Array(10),w=new Uint8Array(8),y=new Uint8Array([192,80,96,176,144,0,160,208,48,224,240,128,64,112,16,32]),A=new Uint8Array([240,177,180,229,225,160,228,241,165,244,245,224,176,181,161,164,114,51,54,103,99,34,102,115,39,118,119,98,50,55,35,38,120,57,60,109,105,40,108,121,45,124,125,104,56,61,41,44,218,155,158,207,203,138,206,219,143,222,223,202,154,159,139,142,210,147,150,199,195,130,198,211,135,214,215,194,146,151,131,134,80,17,20,69,65,0,68,81,5,84,85,64,16,21,1,4,216,153,156,205,201,136,204,217,141,220,221,200,152,157,137,140,242,179,182,231,227,162,230,243,167,246,247,226,178,183,163,166,90,27,30,79,75,10,78,91,15,94,95,74,26,31,11,14,248,185,188,237,233,168,236,249,173,252,253,232,184,189,169,172,250,187,190,239,235,170,238,251,175,254,255,234,186,191,171,174,208,145,148,197,193,128,196,209,133,212,213,192,144,149,129,132,112,49,52,101,97,32,100,113,37,116,117,96,48,53,33,36,122,59,62,111,107,42,110,123,47,126,127,106,58,63,43,46,82,19,
@fabiovila
fabiovila / chat-messengers.txt
Last active November 5, 2018 20:53
Caracteres vetorizados ( char embedded word2vec ) com textos pt-BR de várias fontes ( buraco/salto provavelmente é o \n char)
2688 10
0.72392964 0.9034598 -3.1053286 1.6628352 4.606822 -4.2186584 2.6728196 0.62137556 5.511255 -2.8755682
a 1.3624585 0.60253286 -1.5524583 0.88856983 4.968735 -1.7671169 3.5605307 -0.3082881 3.7583148 -2.6784832
e 1.1331266 0.5756745 -2.0350173 0.73212385 5.0197186 -2.6343026 2.7539384 0.054416236 4.786159 -2.6855483
o 0.88468146 0.03247761 -2.0605369 1.327316 3.469333 -2.1021678 2.515343 -0.16603582 4.0222235 -2.978561
-0.35866624 1.5428417 -1.6936072 3.9759834 -1.4769026 -2.3522007 1.7862277 1.4861828 -0.61132175 -1.4573966
s 0.83326066 -0.07631706 -2.2592058 0.75190574 2.9966874 -3.2900043 2.324823 0.2764609 4.438978 -2.6081195
i 0.64005244 0.23788546 -2.2205324 1.2171555 3.7016447 -2.1727207 2.5417576 -0.24611953 3.561207 -2.5914588
r 1.0300969 -0.35019848 -1.8081845 0.8226696 3.7755477 -2.4118001 2.88959 -0.61905456 4.430355 -2.8297737