Skip to content

Instantly share code, notes, and snippets.

@joemerante
joemerante / pdf_metadata.py
Last active May 30, 2023 03:48
Modify PDF metadata with Python
# some more explanation at https://joemerante.blogspot.com/2020/01/changing-pdf-metadata-with-python.html
import datetime
import fitz # install PyMuPDF
doc = fitz.open("existing_document.pdf")
for idx, page in enumerate(doc):
try:
while (next(page.annots())):
annot = next(page.annots())
page.deleteAnnot(annot)
@joemerante
joemerante / gist:93df2dd368a9ed56545a
Created July 16, 2015 15:27
Sublime Text binding.pry keyboard shortcut
For quick reference if you're not in your usual environment, add to Preferences -> Key Bindings-User:
[
{ "keys": ["alt+super+p"], "command": "insert", "args": {"characters": "binding.pry"} }
]
@joemerante
joemerante / gist:ab83d7bde85a682b9608
Created July 22, 2014 17:54
Example of a simple use of eval()
# Goes with http://joemerante.blogspot.com/2014/07/may-tmil-touch-of-eval.html
# app/models/subscription.rb
class Subscription < ActiveRecord::Base
belongs_to :plan
after_create :set_expiration
# ...
def expired?
self.expiration < DateTime.now
@joemerante
joemerante / gist:7852259
Last active December 30, 2015 15:59
Javascript and qunit test, then the qunit html for the recipe cards I made on drpescatore.com/2013-holiday-recipes - stacks of cards, when you click on one, it comes to the top. MIT licensed code, recipes not mine and reprinted w/ permission, have fun!
// recipe_cards.js
$('.cards-wrapper').on('click', '.card', function() {
var new_top = this;
var cards_length = $(this).closest('.cards-wrapper').find('.card').length;
var l = cards_length - 1;
$(this).closest('.cards-wrapper').find('.card').each(function() {
if (this == new_top) {
// highest card always top css class - card 3 in 3-card layout, card 4 in 4-card layout
$(this).attr("class", "card card-" + cards_length + "-" + cards_length);
}