Skip to content

Instantly share code, notes, and snippets.

View milligramme's full-sized avatar

milligramme milligramme

View GitHub Profile
//@target "indesign"
$.writeln(app.version);
var doc = app.documents.add();
app.scriptPreferences.measurementUnit = MeasurementUnits.MILLIMETERS;
var tf = doc.textFrames.add({geometricBounds:[10,10,50,100]});
var tbl = tf.tables.add({bodyRowCount:4, columnCount:4});
var c = tbl.columns[0];
var i = 2;
while (i-=0.0001) {
@milligramme
milligramme / death_chime_mac.rb
Created October 31, 2016 05:22
Death Chime for Sonic Pi
live_loop :death_chime_mac do
use_synth :sine
play :g4
sleep 0.25
play :g4
play :b4
sleep 0.25
play :g4
play :b4
play :d5
@milligramme
milligramme / ind_add_color_group_swatch.jsx
Last active October 6, 2016 01:41
ColorGroupSwatch sample - InDesign CC 2014 or later
//@target "indesign-10"
var doc = app.documents.add();
var color_group = doc.colorGroups.add({name:"CG"});
var ref_swatch = doc.colors.add({
model: ColorModel.PROCESS,
space: ColorSpace.CMYK,
colorValue: [100,50,0,0],
name: "ref_swatch"}
@milligramme
milligramme / 1.html
Last active September 5, 2016 05:11
tm broken preview
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Running “hello.go”…</title>
<link rel="stylesheet" href="file:///Users/gdansk/Library/Application%20Support/TextMate/Managed/Bundles/Scott%20Web%20Preview%20Theme.tmbundle/Support/scott/style.css" type="text/css" charset="utf-8" media="screen">
<link rel="stylesheet" href="file:///Users/gdansk/Library/Application%20Support/TextMate/Managed/Bundles/Themes.tmbundle/Support/web-themes/bright/style.css" type="text/css" charset="utf-8" media="screen">
<link rel="stylesheet" href="file:///Users/gdansk/Library/Application%20Support/TextMate/Managed/Bundles/Themes.tmbundle/Support/web-themes/dark/style.css" type="text/css" charset="utf-8" media="screen">
<link rel="stylesheet" href="file:///Users/gdansk/Library/Application%20Support/TextMate/Managed/Bundles/Themes.tmbundle/Support/web-themes/default/style.css" type="text/css"
@milligramme
milligramme / tm_isdelta.rb
Created September 2, 2016 01:48
is tmbundle delta or not
require 'plist'
bundle_dir = "~/Library/Application Support/Avian/Bundles/"
Dir.glob("#{File.expand_path bundle_dir}/*.tmbundle/info.plist") do |b|
plist = Plist::parse_xml b
if plist['isDelta']
# <dict>
# <key>isDelta</key>
# <true/>
//@target "InDesign"
// [Extract Metadata with Adobe XMP \[Part 1\] \| IndiSnip \[InDesign® Snippets\]](https://indisnip.wordpress.com/2010/08/13/extract-metadata-with-adobe-xmp/)
(function () {
var XMPload = Boolean(false);
if (ExternalObject.AdobeXMPScript == undefined){
try {ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript'); XMPload = true;}
catch(ex) {alert("Unable to load the AdobeXMPScript library!");}
}
if (!XMPload) {
@milligramme
milligramme / ind_dont_overwrite_pdf.jsx
Last active July 13, 2016 04:25
sample.jsx change pdf filename if already exists
//@target "InDesign"
var increase_or_suffix = function (filename, suffix) {
if (suffix == undefined) {
var reg = new RegExp('(\\d+)(\\..+$)');
var ret = filename.replace(reg, function (m) {
var mm = m.match(reg);
if(mm) {
return (mm[1] * 1 + 1) + mm[2]
}
#targetengine "poo"
var u;
var w = new Window('window', "list item destroy", u, {closeButton:true, minimizeButton:true, maximizeButton:false, resizeable:false, borderless:false});
w.orientation = 'column';
w.margins = 5;
w.spacing = 5;
w.alignChildren = ['fill', 'fill'];
var s_panel = w.add('panel');
require 'date'
require 'fileutils'
include FileUtils
data = DATA.read
root, *paths = data.split("\n")
puts root
today_dir = File.expand_path("~/Desktop/#{Date.today.to_s}/#{File.basename(root)}")
@milligramme
milligramme / create_guide_with_uicolor_and_style_preview_color.jsx
Last active March 28, 2016 00:33
bug in InDesign XXXStyle.previewColor
var UIC = [
"BLACK",
"BLUE",
"BRICK_RED",
"BROWN",
"BURGUNDY",
"CHARCOAL",
"CUTE_TEAL",
"CYAN",
"DARK_BLUE",