Skip to content

Instantly share code, notes, and snippets.

View hatobi's full-sized avatar

Tobias hatobi

  • Germany
  • 04:06 (UTC +02:00)
View GitHub Profile
@hatobi
hatobi / releaseAnchoredObjectsCurrentPage.jsx
Created May 5, 2025 10:39
InDesign Script that releases all anchored objects on the current page at once
var a = app.activeWindow.activePage.pageItems.everyItem().getElements(), t;
while (t = a.pop()) {
t.isValid &&
t.hasOwnProperty('anchoredObjectSettings') &&
(t.parent instanceof Character) &&
(t = t.anchoredObjectSettings).isValid &&
t.releaseAnchoredObject();
}
@hatobi
hatobi / mergeTextFramesTopToBottom.jsx
Created May 5, 2025 09:53
InDesign Script that merges text frames from top to bottom
if (app.documents.length > 0 && app.selection.length > 0) {
var selection = app.selection;
var selectedTextFrames = [];
// Collect text frames only
for (var i = 0; i < selection.length; i++) {
if (selection[i] instanceof TextFrame) {
selectedTextFrames.push(selection[i]);
}
}
@hatobi
hatobi / compare_headers.py
Created November 7, 2024 22:00
Compare headers in two csv files with python
import csv
file1 = "file1.csv"
file2 = "file2.csv"
def sort_lowercase_headers(csvfile):
csvreader = csv.reader(csvfile, delimiter=',', quotechar='|')
header = next(csvreader)
header.sort()
header = [x.lower() for x in header]
return header
@hatobi
hatobi / calculate_photo_time.py
Last active August 12, 2024 10:54
Processes all images in a folder and its subfolders, reads their exif-creation-time and calculates the timeframe, the pictures have been taken in, while subtracting breaks in picture-taking of a user-defined minimum length.
import os
import subprocess
import datetime
import sqlite3
def get_exif_date_taken(file_path):
"""Extract the date taken from an image's EXIF data using exiftool."""
result = subprocess.run(['exiftool', '-DateTimeOriginal', '-s3', file_path], stdout=subprocess.PIPE, text=True)
date_taken_str = result.stdout.strip()
if date_taken_str:
@hatobi
hatobi / email-extract.py
Created April 5, 2024 11:13
extract email addresses from text file
import re
# Function to extract and save email addresses from a text file
def extract_emails(input_file_path, output_file_path):
# Regex pattern to find emails
pattern = r"(\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b)"
# Reading the input from the file
with open(input_file_path, "r") as file:
text = file.read()