Skip to content

Instantly share code, notes, and snippets.

View douglasmiranda's full-sized avatar
👽

Douglas Miranda douglasmiranda

👽
  • Earth, Brazil
View GitHub Profile
@douglasmiranda
douglasmiranda / pdf-to-svg.md
Last active November 20, 2025 13:53
About PDF to SVG converters

Update in 2024

In 2024 I'm actually having a good time using mupdf.

About my experience with mupdf:

It's written in C, but you can use it in many ways. Command line, python lib (pymupdf), js, and others.

I still coundn't find issues that I had with other tools and weird broken PDFs, so I'd say pretty good.

@douglasmiranda
douglasmiranda / gist:e5bd76d0b85a95f74b38b94528c52910
Created July 24, 2017 06:21
Fix: dpkg: error: cannot remove architecture X currently in use by the database
# You try:
sudo dpkg --remove-architecture armhf
# and get:
# dpkg: error: cannot remove architecture 'armhf' currently in use by the database
# So you have to remove the armhf packages installed to be able to `dpkg --remove-architecture armhf`
apt-get remove --purge `dpkg --get-selections | grep armhf | awk '{print $1}'`
# Then:
sudo dpkg --remove-architecture armhf
# SUCCESS!!!
@douglasmiranda
douglasmiranda / instructions.md
Created July 19, 2018 05:51
Add email to Keybase.io PGP Key (Public Key)

Export your public key:

keybase pgp export > keybase-public.key

Export your private key:

keybase pgp export --secret > keybase-private.key
@douglasmiranda
douglasmiranda / calculate.py
Created October 1, 2024 03:55
PyMuPDF - Calculate the percentage of the page height filled with text blocks.
from dataclasses import dataclass
import pymupdf
@dataclass
class Margin:
"""Margin in points
1 inch = 72 points
1 cm = 28.35 points
@douglasmiranda
douglasmiranda / b.sh
Last active July 29, 2025 21:33
Leave command running in background inside container
nohup $COMMAND > logs.log 2>&1 &
@douglasmiranda
douglasmiranda / dates.py
Created July 25, 2025 01:04
Django - Date converter for url.
class DateConverter:
"""
For urls in urls.py.
A Django URL converter for dates in the format yyyy-mm-dd.
This converter will parse a date string in the format yyyy-mm-dd and convert it to a Python date object.
It can also convert a date object back to a string in the same format for URL reversing.
Example usage in urls.py:
from django.urls import path, register_converter

Understanding PDF Format

We have been working with PDF files since 1999 and developed complex software to display PDF files. We have learnt a lot about the PDF file format in that time and share our knowledge in the articles below.

There are also a large number of technical terms used with PDF so we have created a Glossary of Terms with all the keywords.

If you are interested in using our software to display your PDF documents (we can rasterize them, convert them to HTML5 or SVG, or provide a complete Java PDF Viewer) pdf why not setup a call with us and see if we can help?

Here is an overview of the topics covered in this article:

@douglasmiranda
douglasmiranda / tinymce.md
Created December 5, 2024 01:38
TinyMCE can break your searches

TinyMCE will convert accents to HTML entities like:

à becomes á

So you see the problem there, you search in your database for "á" or even "a" (in case you are using unaccent), and you get nothing.

In my case, I was using full text search in Postgres, using the dictionary portuguese_unaccent (custom dictionary check here).

So keep in mind you can always make TinyMCE not convert stuff:

𝐀 A
𝗔 A
𝐴 A
𝘈 A
𝑨 A
𝘼 A
𝒜 A
𝙰 A
𝐁 B
𝗕 B