Skip to content

Instantly share code, notes, and snippets.

Avatar

Marcel Rodrigues lecram

View GitHub Profile
View explode.c
/* Compiling:
* $ gcc -O2 -o explode gifdec.c explode.c
* Comparing gifdec with ImageMagick's GIF decoder:
* $ ./explode foo.gif # generates gd_%03d.ppm files
* $ convert -coalesce foo.gif im_%03d.ppm
* $ # comparing entire animation:
* $ cat gd_*.ppm | md5sum
* $ cat im_*.ppm | md5sum
* $ # comparing each frame:
* $ md5sum gd_*.ppm
@lecram
lecram / rndfmt.c
Last active Aug 14, 2020
Automatic random testing for printf() with regard to %-formatting.
View rndfmt.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
char rand_chr()
{
char c;
do {
@lecram
lecram / brlife.c
Last active Dec 16, 2016
Game of Life in terminal using braille.
View brlife.c
#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <assert.h>
#include <locale.h>
#include <time.h>
#include <poll.h>
View dvtm-open
#! /bin/sh
cmd="$(match "$(realpath "$1")")"
printf "create '%s'\\n" "$cmd" | nc -U /tmp/dvtm-sock
View txt2mid.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <ctype.h>
#include <sys/types.h>
#include <unistd.h>
#define write16(fd, n) write((fd), (uint8_t []) {(n) >> 8, (n) & 0xFF}, 2)
#define write32(fd, n) do { \
@lecram
lecram / profilight.py
Created Feb 24, 2015
Minimal Python profiler implemented in pure Python.
View profilight.py
import sys
import os
import linecache
class Profiler:
def __init__(self, instrument):
self.instrument = instrument
def run(self, func, *args, **kwargs):
@lecram
lecram / alt.lua
Last active Aug 29, 2015
AltScript Prototype
View alt.lua
local ffi = require "ffi"
ffi.cdef[[
double hypot(double x, double y);
double copysign(double x, double y);
]]
local mathx = ffi.C
function round(x)
local i, f = math.modf(x + mathx.copysign(0.5, x))
return i
@lecram
lecram / keyp.cpp
Created Feb 21, 2014
Detecção e casamento de features com OpenCV.
View keyp.cpp
/* g++ -o keyp `pkg-config --libs opencv` keyp.cpp */
#include <iostream>
#include <vector>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
@lecram
lecram / exrect.cpp
Created Feb 18, 2014
Exemplo de utilização da classe cv::Rect para extrair uma região de interesse (ROI) de uma imagem.
View exrect.cpp
/* g++ -o exrect `pkg-config --libs opencv` exrect.cpp */
#include <iostream>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
@lecram
lecram / disasm
Last active Jan 2, 2016
A wrapper to use objdump for raw i8086 disassembling with intel syntax.
View disasm
#! /bin/bash
if [ $# -lt 1 ] || [ $# -gt 3 ]
then
printf 'usage:\n %s <file> [offset [limit|(+|-)length]]\n' `basename $0`
exit 1
fi
IN="$1"
START=0
You can’t perform that action at this time.