Skip to content

Instantly share code, notes, and snippets.

@doubleedesign
doubleedesign / YearbookClasses.jsx
Last active November 23, 2022 15:49
InDesign Image Catalog for multiple folders at once (and multiple folders per page). Created for school yearbook projects (one folder per class, two classes per page) but could be adapted for other use cases where you want to lay out contact sheets of multiple folders automatically.
/**
* Custom Image Catalog script that runs for all subfolders in a selected folder.
* Lays out each folder of images in the specified number of rows and columns, 2 folders per page, shows an alert if there's more images than allowed for,
* labels each group with the folder name, creates paragraph styles for the captions and group headings, and saves the file.
*
* Based on the built-in Image Catalog script but modified and simplified (e.g. hard-coding the settings) for my use case.
* Could be modified to suit different numbers of folders per page, different image quantities etc by changing the settings at the top
* and making tweaks to other code as needed.
*
* Could also be extended to show one dialog for settings prior to the loop,
@xthezealot
xthezealot / README.md
Last active August 3, 2023 14:07
Normalize unicode file names (converts UTF-8 NFD to NFC). Required by macOS clients through AFP/NFS/SMB. Tested on Synology DSM 6.2 with built-in Python 2.7.12.

NFCFN.py

Normalize unicode file names (converts UTF-8 NFD to NFC).
Required by macOS clients through AFP/NFS/SMB.

Tested on Synology DSM 6.2 with built-in Python 2.7.12.

Usage

var randomNumbers = [42, 12, 88, 62, 63, 56, 1, 77, 88, 97, 97, 20, 45, 91, 62, 2, 15, 31, 59, 5]
func partition(v: Int[], left: Int, right: Int) -> Int {
var i = left
for j in (left + 1)..(right + 1) {
if v[j] < v[left] {
i += 1
(v[i], v[j]) = (v[j], v[i])
}
}
@NickBarreto
NickBarreto / iBooks popups which degrade nicely in other devices
Last active February 2, 2019 16:33
How to create popup footnotes in iBooks which degrade well for other EPUB3 readers
The only requirements for popup footnotes in iBooks are:
* Ebook has to be an EPUB3
* epub:type "noteref" and "footnote"
So you can link to a totally separate document, as you normally would for endnotes,
but include the attributes so the <a> link behaves differently in iBooks, instead triggering the popup.
Original reference link would look something like this (in a file called ch001.html):
<a epub:type="noteref" href="footnote.html#note1">1</a></div>
@pkuczynski
pkuczynski / parse_yaml.sh
Last active April 9, 2024 18:36
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
@gabalese
gabalese / html_splitter.py
Last active December 26, 2015 11:49
Splits a HTML file into several smaller files, given a tag and a (optional) class name. Also fixes links in the same document.
#! /usr/bin/env python
try:
import lxml.etree as ET
except ImportError:
from xml.etree import ElementTree as ET
from StringIO import StringIO
import sys
pub_id = "-//W3C//DTD XHTML 1.1//EN"
@rwest
rwest / README
Created January 9, 2012 16:42 — forked from symposion/README
Convert OS X Keychain exported entries into logins for 1Password import
These two files should help you to import passwords from mac OS X keychains to 1password.
Assumptions:
1) You have some experience with scripting/are a power-user. These scripts worked for me
but they haven't been extensively tested and if they don't work, you're on your own!
Please read this whole document before starting this process. If any of it seems
incomprehensible/frightening/over your head please do not use these scripts. You will
probably do something Very Bad and I wouldn't want that.
2) You have ruby 1.9.2 installed on your machine. This comes as standard with Lion, previous
versions of OS X may have earlier versions of ruby, which *may* work, but then again, they
@kch
kch / yaml-to-plist.rb
Created August 4, 2010 14:50
Writes ruby object structures to plists. When called directly, takes a YAML file.
#!/usr/bin/env ruby
# encoding: UTF-8
require 'yaml'
require 'rexml/document'
class PlistWriter
PLIST_STUB_DOC = %q[
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"></plist>]