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 bbmonitor
#!/usr/bin/python2
#
# Buildbot monitor
# Author: Leandro A. F. Pereira <leandro@profusion.mobi>
#
# Copyright (C) 2010 ProFUSION Embedded Systems
#
import urllib
import BeautifulSoup
@lpereira
lpereira / Non-pipelined
Created Mar 3, 2015
Pipelined vs non-pipelined strace output
View Non-pipelined
3340 accept4(15, <unfinished ...>
3341 <... nanosleep resumed> NULL) = 0
3341 nanosleep({3, 0}, NULL) = 0
3341 nanosleep({4, 0}, <unfinished ...>
3340 <... accept4 resumed> 0, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK) = 16
3340 write(14, "\20\0\0\0", 4) = 4
3345 <... epoll_wait resumed> {{EPOLLIN, {u32=0, u64=0}}}, 1024, -1) = 1
3340 accept4(15, <unfinished ...>
3345 open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 18
3345 fstat(18, {st_mode=S_IFREG|0644, st_size=2015, ...}) = 0
View pipeline-test.sh
#!/bin/sh
exec wrk -H 'Host: localhost' \
-H 'Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \
-H 'Connection: keep-alive' \
-d 10 \
-c 1000 \
--timeout 16384 \
-t 4 \
http://127.0.0.1:8080/hello \
@lpereira
lpereira / gist:ccbb99a0ed288a2e9487
Created May 14, 2015
Lwan template interpreter
View gist:ccbb99a0ed288a2e9487
New Old
movsx esi,BYTE PTR [r14+0x8] movsx esi,BYTE PTR [r13+0x8]
mov rdi,r12 mov rdi,rbp
add rbx,0x1 add r13,0x18
call 0x412fd0 <strbuf_append_char> call 0x413ed0 <strbuf_append_char>
mov rax,QWORD PTR [r15+rbx*8] mov eax,DWORD PTR [r13+0x0]
jmp QWORD PTR [rax*8+0x416440] mov rax,QWORD PTR [rax*8+0x4166a0]
jmp rax
View gist:31b2ace8acf07594e5e9
#!/usr/bin/python
import mraa
import time
import pyupm_i2clcd
import pyupm_grove
import SimpleXMLRPCServer
import netifaces as ni
import threading
import Queue
View nope-fire.c
/*
* ----------------------------------------------------------------------------
* "THE MATE-WARE LICENSE" (Revision 42): <leandro@tia.mat.br> wrote this
* file. As long as you retain this notice you can do whatever you want
* with this stuff. If we meet some day, and you think this stuff is worth
* it, you can buy me a Club-Mate in return. Leandro Pereira
* ----------------------------------------------------------------------------
*/
#include <arpa/inet.h>
@lpereira
lpereira / valuepack.py
Created Sep 9, 2015
Value packing with prime numbers
View valuepack.py
#!/usr/bin/python
import math
def pack_bits(*bits):
n = 0
max_n = 1
for value, prime_for_value in bits:
while n % prime_for_value != value:
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 / 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>