Skip to content

Instantly share code, notes, and snippets.

View senderle's full-sized avatar

Jonathan Scott Enderle senderle

View GitHub Profile
@senderle
senderle / hand-modify-pdf.md
Created September 23, 2020 15:03
So you want to modify the text of a PDF by hand

So you want to modify the text of a PDF by hand...

If you, like me, resent every dollar spent on commercial PDF tools, you might want to know how to change the text content of a PDF without having to pay for Adobe Acrobat or another PDF tool. I didn't see an obvious open-source tool that lets you dig into PDF internals, but I did discover a few useful facts about how PDFs are structured that I think may prove useful to others (or myself) in the future. They are recorded here. They are surely not universally applicable --
the PDF standard is truly Byzantine -- but they worked for my case.

@senderle
senderle / sample-test.txt
Created January 16, 2020 14:59
A demo implementation of a faster 3CosAdd test
album albums
application applications
area areas
car cars
college colleges
council councils
customer customers
day days
death deaths
department departments
FROM senderle/pystgis:django-base
# Requirements are installed here to ensure they will be cached.
COPY ./requirements /requirements
RUN pip install -r /requirements/local.txt
COPY ./compose/production/django/entrypoint /entrypoint
RUN sed -i 's/\r$//g' /entrypoint
RUN chmod +x /entrypoint
{"nodes":[{"name":"Python"},
{"name":"JavaScript"},
{"name":"PHP"},
{"name":"Django"},
{"name":"Omeka"},
{"name":"Dev 1"},
{"name":"Dev 2"}],
"links":[{"source":3,"target":0,"value":60},
{"source":3,"target":1,"value":40},
{"source":4,"target":2,"value":80},
@senderle
senderle / simplex-projection-2.py
Created July 28, 2018 19:32
Projecting the 3-simplex onto the sphere, with planes of projection.
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(figsize=(21, 18))
ax = fig.add_subplot(111, projection='3d')
u_c = np.linspace(0, np.pi / 2, 100)
v_c = np.linspace(0, np.pi / 2, 100)
x_c = 1 * np.outer(np.cos(u_c),
@senderle
senderle / simplex-projection.py
Created July 28, 2018 12:12
Projecting the 3-simplex onto the sphere.
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(figsize=(21, 18))
ax = fig.add_subplot(111, projection='3d')
u_c = np.linspace(0, np.pi / 2, 100)
v_c = np.linspace(0, np.pi / 2, 100)
x_c = 1 * np.outer(np.cos(u_c),
@senderle
senderle / textanalysis.md
Last active October 31, 2017 16:08
Links to text analysis materials.
@senderle
senderle / plato-perseus-english.txt
Last active October 31, 2017 15:45
All English translations of works by Plato available from the Perseus Project (http://www.perseus.tufts.edu/hopper/opensource/download).
An Athenian Stranger Clinias of Crete Megillus of Lacedaemon
Athenian To whom do you ascribe the authorship of your legal arrangements, Strangers? To a god or to some man? Clinias To a god, Stranger, most rightfully to a god. We Cretans call Zeus our lawgiver; while in Lacedaemon , where our friend here has his home, I believe they claim Apollo as theirs. Is not that so, Megillus? Megillus Yes. Athenian Do you then, like Homer, Cp. Hom. Od. 19.178 . say that
Minos used to go every ninth year to hold converse with his father Zeus, and that he was guided by his divine oracles in laying down the laws for your cities? Clinias So our people say. And they say also that his brother Rhadamanthys,—no doubt you have heard the name,—was exceedingly just. And certainly we Cretans
would maintain that he won this title owing to his righteous administration of justice in those days. Athenian Yes, his renown is indeed glorious and well befitting a son of Zeus. And, since you and our friend Megillus were bo
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@senderle
senderle / mem.py
Created November 6, 2015 19:40
An extremely simple object-size checker that can handle anything returned by JSON.
from collections import Sequence, Mapping
from sys import getsizeof
def traverse(obj):
if isinstance(obj, basestring):
yield obj
elif isinstance(obj, Sequence):
yield obj
for o in obj:
for inner_o in traverse(o):