Skip to content

Instantly share code, notes, and snippets.

@vsajip
vsajip / overlay_pdf.py
Created April 11, 2020 15:19 — forked from dwayneblew/overlay_pdf.py
Overlay text on a PDF template using fpdf and PyPDF2
import fpdf
from PyPDF2 import PdfFileWriter, PdfFileReader
overlay_pdf_file_name = 'overlay_PDF.pdf'
pdf_template_file_name = 'base_PDF_template.pdf'
result_pdf_file_name = 'final_PDF.pdf'
# This section creates a PDF containing the information you want to enter in the fields
# on your base PDF.
@dfm
dfm / betterstep.py
Last active March 1, 2023 18:49
A 'better' step function for matplotlib
import matplotlib.pyplot as plt
def betterstep(bins, y, **kwargs):
"""A 'better' version of matplotlib's step function
Given a set of bin edges and bin heights, this plots the thing
that I wish matplotlib's ``step`` command plotted. All extra
arguments are passed directly to matplotlib's ``plot`` command.
Args:
@tonywangcn
tonywangcn / gevent_sqlalchemy_example.py
Last active September 16, 2018 03:29
gevent and sqlalchemy usage example
# coding:utf-8
from gevent import monkey, sleep, spawn, joinall
monkey.patch_all()
import datetime
from sqlalchemy import Column, Integer, String, DateTime, Numeric, create_engine, VARCHAR, UniqueConstraint
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
import sqlalchemy
import time
@jepio
jepio / pyroot-numpy.py
Last active April 14, 2018 22:20
Copy TGraph data to numpy array and back.
"""
Example of interfacing numpy to pyroot. Additionally, the great package
root_numpy implements interfaces between various pyroot objects and numpy
through a cython extension module.
"""
import numpy as np
import ROOT
data = ROOT.TGraph("filename")
# Create buffers
@mtmtcode
mtmtcode / auto-rsync.el
Last active September 2, 2022 00:30
auto-rsync.el - Emacs minor mode to execute rsync automaticlly
;;; auto-rsync-mode -- minor mode for auto rsync
;;
;; Author: @l3msh0
;;
;;; Example
;;
;; (require 'auto-rsync)
;; (auto-rsync-mode t)
;; (setq auto-rsync-dir-alist