Skip to content

Instantly share code, notes, and snippets.

View mcavalcantib's full-sized avatar

Moisés Cavalcanti Bezerril Filho mcavalcantib

  • Vsoft
  • Paraíba, Brasil
View GitHub Profile
@mcavalcantib
mcavalcantib / state_machine.c
Created March 21, 2024 15:32
State machine using function pointers
#include <stdio.h>
long stateStart = 0;
// fun_ptr is a pointer to function fun()
void (*UpdateFunction)(void);
void ManualMode(){
//Acoes de exibir e controlar o modo manual
if(selectButton && option == 2){ //opção 2 cancelar
@mcavalcantib
mcavalcantib / humidityCalculation.cpp
Last active May 5, 2025 00:01
Absolute humidity calculation
#include "math.h"
#define e 2.718281828459045235360287471352
float calculateAbsoluteHumidity(float hum, float temp)
{
float UA = ((6.112 * (pow(e, ((17.67 * temp) / (temp + 243.5)))) * hum * 2.1674) / (273.15 + temp));
return UA;
}
@mcavalcantib
mcavalcantib / main.dart
Last active September 5, 2023 01:30
Spatial Hash Study
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class Client {
late List<int> position = List<int>.empty(), dimentions = List<int>.empty();
@mcavalcantib
mcavalcantib / c_cpp_properties .json
Last active August 28, 2023 11:09
ESP-IDF c_cpp_properties VScode configuration file
{
"configurations": [
{
"name": "ESP-IDF",
"cStandard": "c11",
"cppStandard": "c++17",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"includePath": [
"${workspaceFolder}/build/config",
"${config:idf.espIdfPath}/components/**",
@mcavalcantib
mcavalcantib / front.tsx
Last active February 1, 2023 23:16
Nodejs example using fastify and prisma
import React, { useState } from 'react';
interface FormData {
name: string;
address: string;
}
const UserForm: React.FC = () => {
const [formData, setFormData] = useState<FormData>({ name: '', address: '' });
@mcavalcantib
mcavalcantib / AWS_Policy_example.js
Created September 19, 2019 00:17
Example of how to setup a Amazon Web Services Iot Core policy to allow only two topics (inTopic and outTopic)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iot:Publish",
"iot:Connect",
"iot:Subscribe",
"iot:Receive"