Skip to content

Instantly share code, notes, and snippets.

View mara004's full-sized avatar

mara004

View GitHub Profile
@jrsmith3
jrsmith3 / sla2pdf.py
Created March 12, 2014 01:31
Converts every scribus document to a PDF in a specified directory.
"""
Convert every .sla to a pdf in a specified directory.
This script can only be run from within [scribus](http://http://scribus.net).
"""
import os
work_dir = #you have to explicitly tell scribus where your working directory is.
filenames = os.listdir(work_dir)
#!/usr/bin/python
# Copyright 2006 Google Inc.
# Author: [email protected] (Adam Langley)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@lattner
lattner / TaskConcurrencyManifesto.md
Last active August 19, 2025 19:22
Swift Concurrency Manifesto
@bittner
bittner / keyboard-keys.md
Created February 28, 2019 22:50
Keyboard keys markup in MarkDown

Ctrl + Alt + Space

@lebedov
lebedov / jpype_api_demo.py
Last active July 10, 2023 14:04
How to call pdfbox's API with JPype.
#!/usr/bin/env python3
"""
How to call pdfbox's API with JPype.
"""
import pathlib
import pkg_resources
import re
import urllib.request
@lebedov
lebedov / jpype_pdf_text_stripper.py
Created April 28, 2021 12:29
How to use pdfbox's PDFTextStripper class in Python.
#!/usr/bin/env python3
"""
How to use pdfbox's PDFTextStripper class in Python.
"""
import pathlib
import pkg_resources
import re
import urllib.request
@mara004
mara004 / pdfbox.py
Last active April 4, 2025 00:02
PDF rendering with PDFBox, from Python
# Four lines intentionally left blank
# SPDX-FileCopyrightText: 2025 geisserml <[email protected]>
# SPDX-License-Identifier: Apache-2.0 OR MPL-2.0
# Assuming you have an Apache PDFBox 3 jar in the same directory
@mara004
mara004 / pdfbox_version_parsing.py
Last active July 31, 2024 20:53
Parse pdfbox versions
# SPDX-FileCopyrightText: 2024 geisserml <[email protected]>
# SPDX-License-Identifier: Apache-2.0
import re
from datetime import datetime
from urllib.request import urlopen
from packaging.version import Version as PypaVersion
PB_RELEASE_URL = "https://archive.apache.org/dist/pdfbox/"
PB_DISTS_RE = r'<a href="([\d\.]+.+?)/">.+</a>\s+([\d\-]+ [\d:]+)'
@mara004
mara004 / pypdfjs.py
Last active May 13, 2025 15:38
PDF rendering with pdf.js, from Python
# Four lines intentionally left blank
# SPDX-FileCopyrightText: 2025 geisserml <[email protected]>
# SPDX-License-Identifier: Apache-2.0 OR MPL-2.0
# See also https://github.com/extremeheat/JSPyBridge/blob/master/examples/python/pdfjs.py
@mara004
mara004 / safer_tar_extract.py
Last active February 8, 2025 20:21
Safer tar extraction
# SPDX-FileCopyrightText: 2023 geisserml <[email protected]>
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause OR MPL-2.0
# Safer tar extraction (hopefully) preventing CVE-2007-4559 etc.
# Tries to use the most elegant strategy available in the caller's python version (>= 3.6)
__all__ = ["safer_tar_unpack"]
import sys
if sys.version_info >= (3, 11, 4): # PEP 706