Skip to content

Instantly share code, notes, and snippets.

Avatar
Taking some time off personal open source work

Leandro A. F. Pereira lpereira

Taking some time off personal open source work
View GitHub Profile
View minifinf.c
#include <stdio.h>
#include <string.h>
typedef void (*NativeFunction)(int *ip);
typedef struct _Instruction Instruction;
struct _Instruction {
unsigned int opcode;
unsigned long parameter;
};
@lpereira
lpereira / scdq5541.pde
Created Jun 12, 2011
Interfacing Osram SCDQ5541 dot-matrix display with an Arduino
View scdq5541.pde
class SCDQ5541 {
private:
int m_clock, m_data, m_load;
void bitbang(unsigned char code)
{
digitalWrite(m_load, LOW);
for (int i = 0; i < 8; i++) {
digitalWrite(m_clock, LOW);
digitalWrite(m_data, code & 0x01);
@lpereira
lpereira / gist:1324915
Created Oct 29, 2011
Arduino Charlieplexing
View gist:1324915
static const byte charlie_pins[] = {5, 6, 7};
static const byte charlie_led[][2] = {
{ 0, 1 },
{ 1, 0 },
{ 0, 2 },
{ 2, 0 },
{ 1, 2 },
{ 2, 1 }
};
View gist:1636774
// Ebay RFID decoder by Aaron Christiansen
// Original article: http://thetransistor.com/2011/10/hacking-cheap-rfid-readers/
// Optimizations by Leandro Pereira
// NOTE: this uses the NewSoftwareSerial beta 11
// by Mikal Hart, available here:
// http://arduiniana.org/2011/01/newsoftserial-11-beta/
#include <SoftwareSerial.h>
@lpereira
lpereira / coro.c
Created Mar 22, 2012
Simple coroutine implementation in C
View coro.c
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <ucontext.h>
typedef struct coro_t_ coro_t;
typedef struct thread_t_ thread_t;
typedef int (*coro_function_t)(coro_t *coro);
typedef enum {
CORO_NEW,
@lpereira
lpereira / gist:3267085
Created Aug 5, 2012
Pinball Display Driver
View gist:3267085
/*
* Pinball Display Driver
* Arudino version by Leandro Pereira
*
* Based on code by Daniel Quadros, available at
* http://dqsoft.blogspot.com.br/2011/06/projeto-epoch-parte4-software-cont.html
*/
#define DISP_S0 8
#define DISP_S1 9
@lpereira
lpereira / partial.c
Last active Nov 27, 2020
Partial functions in C This program illustrates a hack to create partial functions in C. The way it works is that it generates a template function (partial_template_function) with known pointers, that is later copied to a region of memory obtained with mmap(), patched up with the address and data to be passed to the real function, and then made …
View partial.c
/*
* Partial applied functions in C
* Leandro Pereira <leandro@tia.mat.br>
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
@lpereira
lpereira / Chamada de Participação para a Tosconf[1]
Created Mar 6, 2013
Chamada de Participação para a Tosconf[1]
View Chamada de Participação para a Tosconf[1]
┌───┬───┬───┬───┬───┬───┬───┐
└─┐ │ │ ─┤ │ │ │ ─┤
│ │ │ ├─ │ ─┤ │ │ │ │ ┌─┘
└─┴───┴───┴───┴───┴─┴─┴─┘
2013-06-01 LHC, Campinas - São Paulo
A Tosconf é uma desconferência anual organizada pelo Laboratório
Hacker de Campinas (LHC). Em sua primeira edição, em 2012, atraiu
desenvolvedores, pesquisadores de segurança da informação e
figuras míticas da computação.
@lpereira
lpereira / gist:6694015
Last active Jan 26, 2016
How to use sequences with lwan template
View gist:6694015
#include <assert.h>
#include <sys/types.h>
#include <dirent.h>
#include "lwan-status.h"
#include "lwan-template.h"
#include "strbuf.h"
struct file_list {
const char *path;
@lpereira
lpereira / arduino-7seg.cc
Created Oct 20, 2013
Arduino 7-segment display driver
View arduino-7seg.cc
namespace {
const char segment_pin[7] = {
[0] = 0,
[1] = 0,
[2] = 0,
[3] = 0,
[4] = 0,
[5] = 0,
[6] = 0,