This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def c = { x, y -> println("${x}, ${y}!") } | |
c.call("Hello", "kanemu") //Hello kanemu! | |
c("Hello", "kanemu") //Hello kanemu! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//splitを使った場合 | |
assert '0.8'.split('.') == [] | |
//こういう場合はtokenizeを使う | |
assert '0.8'.tokenize('.') == ['0', '8'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hoge = 'test.pdf' | |
switch(true){ | |
case (hoge=~/\.pdf$/) as Boolean: | |
println "pdfです" | |
break | |
case (hoge=~/\.xls$/) as Boolean: | |
println "えくせるです" | |
break | |
default: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alert('できるよ!'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def map = [ | |
test:"これはテストです", | |
include:[ | |
a:"あれ", | |
b:"これ", | |
c:"それ" | |
], | |
name:[ | |
firstName:"SHIGEO", | |
lastName:"NAGASHIMA" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
osascript -e "tell application \"iTerm\" | |
activate | |
if (count current terminal) is 0 then | |
set myterm to (make new terminal) | |
tell myterm | |
launch session \"Default\" | |
end tell | |
end if | |
tell the current session of the current terminal | |
write text \"groovy \" & \"'${TM_FILEPATH}'\" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
osascript -e "tell application \"Terminal\" | |
activate | |
do script \"groovy \" & \"'${TM_FILEPATH}'\" | |
end tell" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def inputCharCode = "UTF8" //入力側文字コード | |
def outputCharCode = "UTF8" //出力側文字コード | |
//変換マップ | |
def replaceTable=[ | |
/^/:"<p>", | |
/$/:"</p>", | |
/\n/:"</p><p>", | |
/|{0,1}([一-龠]+?)《([ぁ-ん]+?)》/:{ m0, m1, m2 -> "<ruby><rb>$m1</rb><rt>$m2</rt></ruby>" }, | |
"。":"んぬ。" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//InDesign そのアイテムを持つドキュメントを取る | |
function parentDoc(obj){ | |
var sp=obj.toSpecifier().split('/'); | |
if(sp.length<2||!/^document/.test(sp[1]))return; | |
return resolve(sp.slice(0,2).join('/')); | |
}; | |
var obj=app.activeDocument.selection[0]; | |
var doc = parentDoc(obj); | |
$.writeln(doc); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//apache oro でデリミタを含んだsplit。 | |
import org.apache.oro.text.perl.Perl5Util; | |
@Grab(group='oro', module='oro', version='2.0.8') | |
def perl = new Perl5Util() | |
def list = [] | |
perl.split(list, '/(<.+?>)/', 'わたしは<b>野球賭博</b>で捕まった人たちとは<b>関係がありません</b>。') | |
assert list==["わたしは","<b>","野球賭博","</b>","で捕まった人たちとは","<b>","関係がありません","</b>","。"] |