Skip to content

Instantly share code, notes, and snippets.

@shspage
shspage / sketch_dec-06-2020_20-44-19.glisp.glisp
Last active December 17, 2020 12:32
gilsp( https://github.com/baku89/glisp ) 用スクリプトです。多角形をUIとして使う習作
; controllers
(def G0 (ngon [1 1.8125] 137 11))
(def G1 (ngon [3 0.8125] 106 7))
(def G2 (ngon [9 -4.1875] 74 8))
(def G3 (ngon [8 -1.1875] 46 5))
; coordinates of the nth vertex
(defn fv [s n] (nth s (inc n)))
; number of vertices
(defn fc [s] (dec (count s)))
@monokano
monokano / inddver.py
Last active December 13, 2022 13:07
InDesignファイル(ドキュメント、ブック、ライブラリ、テンプレート)の作成アプリバージョンを検出する
#!/usr/bin/python
#
# Usage: python inddver.py indesign-file(indd,indb,indl,indt)
#
# This script will detect the app version written in the indesign file.
#
import sys, os, re
def getAppName(verDec):
@shspage
shspage / vscode_shiftjis.md
Last active November 18, 2019 21:44
vscode の ShiftJIS 自動判定を矯正するためにソースからビルドする

vscode の ShiftJIS 自動判定を矯正するためにソースからビルドする

基本は utf-8 だけど shiftjis のファイルを開くこともよくある、という状況にあります。
vscodeで "files.autoGuessEncoding": true の設定にしていても、shiftjis なファイルを開くとちょくちょく誤判定するので困っていました。

機能拡張のAPIでファイルが表示される前の処理に介入するのも無理そうなので(※1)、ソースコードに手を入れることにしました、という話です。
※1: 調べたのは ver.1.19 くらいの頃。それ以降APIも変わっているかもしれません。

アップデートのたびにビルドし直すのも手間なので、極力少ない変更で済むようにしました。
言い換えれば、日本語文字コード判定の改善のみを目的とした大雑把な変更となっていますが、

/*
パスを延長 Copyright (c) koji sakai
https://gist.github.com/S4K4K0/62896e92287b40fded0d7f1614082d22
プレビュー部分やUIは以下のサンプルを元にしています
https://qiita.com/shspage/items/441ccf61394d9c504beb
* HOW TO USE
選択して実行するとスライダーが表示され、始端か終端のセグメントに対して指定した比率でBezier曲線のパラメータが延長されます
(サイズや長さがそのままk倍になるわけではありません)
@uchcode
uchcode / nodejs_stdio_example.js
Last active August 30, 2017 01:47
node.js stdio example
const STDIN = {
DEFAULT : Symbol(),
ALL : Symbol(),
BEFORE_ALL : Symbol(),
AFTER_ALL : Symbol(),
}
class ProcessStdio {
constructor(encoding='utf8') {
this.encoding = encoding
@uchcode
uchcode / electron-asar-launcher.js
Created August 9, 2017 11:29
electron-asar-launcher.js
app = Application.currentApplication()
app.includeStandardAdditions = true
se = Application('System Events')
function sh(script, opt={}) {
return app.doShellScript(script, {
administratorPrivileges: !!opt.withPrompt,
withPrompt: opt.withPrompt || '',
alteringLineEndings: opt.alteringLineEndings || false
}).replace(/\n$/,'')
@uchcode
uchcode / pyobjc_scriptingbridge.md
Last active June 19, 2022 14:44
PythonでMacスクリプティング

PythonでMacスクリプティングの例

現在、iTunesで再生している曲名を取得。

#!/usr/bin/python
# -*- coding: utf-8 -*-

from ScriptingBridge import *
@ten-A
ten-A / cep_cmp.js
Created June 29, 2016 05:46
Integrated CSInterface and Vulcan libraries.
function CSInterface(){}function CSXSWindowType(){}CSXSWindowType._PANEL="Panel";CSXSWindowType._MODELESS="Modeless";CSXSWindowType._MODAL_DIALOG="ModalDialog";EvalScript_ErrMessage="EvalScript error.";function Version(a,b,c,d){this.major=a;this.minor=b;this.micro=c;this.special=d}Version.MAX_NUM=999999999;function VersionBound(a,b){this.version=a;this.inclusive=b}function VersionRange(a,b){this.lowerBound=a;this.upperBound=b}function Runtime(a,b){this.name=a;this.versionRange=b}
function Extension(a,b,c,d,e,f,g,h,k,l,n,p,q,r,t,u){this.id=a;this.name=b;this.mainPath=c;this.basePath=d;this.windowType=e;this.width=f;this.height=g;this.minWidth=h;this.minHeight=k;this.maxWidth=l;this.maxHeight=n;this.defaultExtensionDataXml=p;this.specialExtensionDataXml=q;this.requiredRuntimeList=r;this.isAutoVisible=t;this.isPluginExtension=u}function CSEvent(a,b,c,d){this.type=a;this.scope=b;this.appId=c;this.extensionId=d}function SystemPath(){}SystemPath.USER_DATA="userData";
SystemPath.COMMON_FILES="commonFiles";SystemPath
@shspage
shspage / voronoi-example.jsx
Last active October 18, 2016 09:30
Adobe Illustrator script that draws voronoi diagrams - example (commented in Japanese)
//@include "~/ailib/rhill-voronoi-core.js"
// Adobe Illustrator script
// 選択した各オブジェクトの中心の座標を元にボロノイ図を描画します。
// 描画範囲は選択オブジェクト中で面積が最大のものを使用します。
// (このため、外枠となるオブジェクトも選択範囲に含めてください。
// 外枠はボロノイ計算の対象外です。)
// 描画した線はグループ化されています。
// 塗りのある面を描画しない場合は、スクリプト冒頭の
// DRAW_POLYGONS を false にしてください。
@konn
konn / dupe-pages.js
Created August 5, 2015 10:57
Duplicate each pages thru JXS + Acrobat Pro
var app = Application("Adobe Acrobat Pro")
doc = app.documents[0];
app.includeStandardAdditions = true;
app.pdfWindows[0].pages().reverse().forEach(function(page){
var n = page.pageNumber();
doc.insertPages({after: n,
from: doc,
startingWith: n,
numberOfPages: 1});