Skip to content

Instantly share code, notes, and snippets.


Rogério Brito rbrito

View GitHub Profile
rbrito / gist:8e17e6bbc93bc2999d92b979d080c9c3
Created Jul 7, 2020 — forked from bazub/gist:3877971
Grayscale/Binary images using PIL
View gist:8e17e6bbc93bc2999d92b979d080c9c3"1.jpg")
threshold = 100
im = im2.point(lambda p: p > threshold and 255)"d.jpg")
result = tesseract.ProcessPagesWrapper(img,api)
rbrito / mathology.html
Created Mar 30, 2020 — forked from rosinality/mathology.html
Very simple latex sketchpad
View mathology.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
body {
font-family: Arial, Helvetica, sans-serif;
rbrito / galois.c
Created May 23, 2019 — forked from meagtan/galois.c
Quick implementation of Galois fields
View galois.c
* The following is an implementation of the finite field GF(2^8) as bit vectors of length 8, where the nth bit represents the
* coefficient of the nth power of the generator in each element, and the generator satisfies the minimal polynomial
* x^8 + x^4 + x ^3 + x^2 + 1 in the prime field Z_2, in which addition is equivalent to XOR and multiplication to AND.
* The elements of GF(2^8) thus represent polynomials of degree < 8 in the generator x. Addition in this field is simply
* bitwise XOR, but multiplication requires the elimination of powers of x <= 8.
#include <stdio.h>
#include <stdint.h>
rbrito /
Created Dec 7, 2018 — forked from Iunius118/
Auto save plug-in for GIMP [2.8, 2.9]
#!/usr/bin/env python
# Original (by yahvuu):
import tempfile, os
from time import *
from gimpfu import *
def autosave(image, layer):
backupInterval = 10 * 60
rbrito /
Created Jul 20, 2018 — forked from agentcooper/
Telegram chat backup/export

How to use

  1. Login to
  2. Copy-paste contents of telegram-scripts.js into JS console
  3. Run showContacts() to get the list of contacts with ids
  4. Run saveChat(userId) where userId is the id from step 3

Process can take a while, check console for progress. Occasionall FLOOD_WAIT errors are expected. Once done, browser will download the JSON file.


rbrito / spectre.c
Created Jan 5, 2018 — forked from ErikAugust/spectre.c
Spectre example code
View spectre.c
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#include <x86intrin.h> /* for rdtscp and clflush */
rbrito / remove-duplicate-subs
Created Jun 24, 2017 — forked from otsaloma/remove-duplicate-subs
Remove duplicate subtitles with aeidon
View remove-duplicate-subs
#!/usr/bin/env python3
import aeidon, sys, time
if len(sys.argv) < 2:
print("Usage: {} SUBTITLE_FILE...".format(__file__))
raise SystemExit(1)
for fname in sys.argv[1:]:
project = aeidon.Project()
project.open_main(fname, "utf_8")
before = len(project.subtitles)
rbrito /
Last active Nov 2, 2015 — forked from hubgit/
Remove metadata from a PDF file, using exiftool and qpdf. Note that embedded objects may still contain metadata.

Anonymising PDFs

PDF metadata

Metadata in PDF files can be stored in at least two places:

  • the Info Dictionary, a limited set of key/value pairs
  • XMP packets, which contain RDF statements expressed as XML

PDF files

rbrito / gist:59736ed280e569619e84
Created Jun 4, 2015
Output from tox on edx-downloader
View gist:59736ed280e569619e84
$ tox
GLOB sdist-make: /home/rbrito/Desktop/cursos/edx-downloader/
py27 inst-nodeps: /home/rbrito/Desktop/cursos/edx-downloader/.tox/dist/
py27 runtests: PYTHONHASHSEED='3787261654'
py27 runtests: commands[0] | py.test -v --junitxml=/home/rbrito/Desktop/cursos/edx-downloader/.tox/py27/log/result.xml .
======================================================= test session starts ========================================================
platform linux2 -- Python 2.7.10 -- py-1.4.28 -- pytest-2.7.1 -- /home/rbrito/Desktop/cursos/edx-downloader/.tox/py27/bin/python2.7
rootdir: /home/rbrito/Desktop/cursos/edx-downloader, inifile:
collected 7 items
You can’t perform that action at this time.