Skip to content

Instantly share code, notes, and snippets.

Eric Chiesse echiesse

Block or report user

Report or block echiesse

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@echiesse
echiesse / sizeof_array.c
Last active May 15, 2019
C sizeof on vars, arrays and malloc
View sizeof_array.c
#include <stdio.h>
int main()
{
int a[5];
int b;
int* c = malloc(10 * sizeof(int));
printf("%i\n", sizeof(a));
printf("%i\n", sizeof(b));
@echiesse
echiesse / testLuaTableC_API.lua
Created Mar 15, 2019
Lua test script for creating a metatable from C API
View testLuaTableC_API.lua
print(getmetatable(A))
for i, v in pairs(A) do
print(i, v)
end
A.a = "banana"
A.subtable.a = "abacate"
print(A.a)
@echiesse
echiesse / lua_table_api_example.c
Created Mar 15, 2019
Setting a metatable inside a table from C API
View lua_table_api_example.c
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<lua.h>
#include<lualib.h>
#include<lauxlib.h>
int main()
@echiesse
echiesse / queue.lua
Created Oct 8, 2018
Basic queue data structure implementation in Lua
View queue.lua
function reverse(tb)
local ret = {}
for i = #tb, 1, -1 do
table.insert(ret, tb[i])
end
return ret
end
--##############################################################################
@echiesse
echiesse / maybeMonad.lua
Last active Aug 6, 2018
Lua implementation of Maybe Monad.
View maybeMonad.lua
-- The Maybe Monad:
local NOTHING = { val = nil }
maybe = {}
maybe.__index = maybe
-- Constructors:
maybe.just = function(val)
local obj = setmetatable({ val = val }, maybe)
View scrapper_desporto.py
import requests
from io import StringIO
from lxml import etree
URL = "https://observador.pt/seccao/desporto/"
def main():
response = requests.get(URL)
content = response.text
@echiesse
echiesse / appScheleton.py
Last active Mar 17, 2018
Esqueleto de aplicação com suport a plugins
View appScheleton.py
################################################################################
# mainMenu.py
mainMenu = [
'Areas',
'Volumes',
'Funcoes e, Equacoes (FE)',
'Potencias',
'Radicais',
'Trigonometria',
'Geometria',
@echiesse
echiesse / TakePhoto.html
Created Nov 30, 2017
Exemplo de tirar fotos a partir do browser
View TakePhoto.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Teste de Tirar Foto</title>
</head>
<body>
<div class="camera">
<video id="video" autoplay>Video stream not available.</video>
<button id="startbutton">Take photo</button>
@echiesse
echiesse / CommandLineInputValidation.py
Created Nov 24, 2017
Exemplo de validação de dados de input a partir do teclado em programas de linha de comando.
View CommandLineInputValidation.py
# Exemplo de validação de dados numéricos a partir da linha de comando.
# Entry Point
def main():
while True:
print("Entrada inválida. Apenas numeros são aceitos")
strNum = input("Digite um numero: ")
num = asNumber(strNum)
if num != None:
break
View ExValidacaoModular.py
class Combustivel:
def __init__(self, nome, preco, texto):
self.nome = nome
self.preco = preco
self.texto = texto
gasolina = Combustivel(
nome = "gasolina",
preco = 1,
You can’t perform that action at this time.