This file contains hidden or 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
import com.maddyhome.idea.vim.key.KeyParser | |
import com.maddyhome.idea.vim.key.Shortcut | |
import com.maddyhome.idea.vim.command.Command | |
import javax.swing.KeyStroke | |
import java.awt.event.KeyEvent | |
// Input Method制御のおまじない( windows / osx ) | |
System.properties["ideavim.imcontrol"] = "windows" |
This file contains hidden or 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
// g100pon #24 grep | |
startDir = "." | |
filePattern = /\.groovy$/ | |
pattern = /groovy/ | |
enc = "windows-31j" | |
new File(startDir).eachFileRecurse { file -> | |
if (file =~ filePattern) { | |
file.eachLine(enc) { line, count -> |
This file contains hidden or 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
// g100pon #22 正規表現:FQCNからクラス名を抜出す | |
fqcn = String.class.name | |
classname = fqcn.replaceAll(/(.*\.)(.+$)/) { full, m1, m2 -> m2 } | |
println classname |
This file contains hidden or 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
// g100pon #28 ファイル名の一括置換 | |
// | |
import groovy.io.FileType | |
// 開始ディレクトリや探索方法は適当に直して | |
new File("../").eachFileRecurse(FileType.FILES) { file -> | |
// とりあえずファイル名を置換してみる(変換パターンも適当に直して) | |
def newFileName = file.name.replaceAll(/.class$/, ".clazz") | |
if (file.name != newFileName) { | |
// 置換できてれば、実ファイルをリネームする |
This file contains hidden or 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
// g100pon #29 ファイル内の特定の文字列を一括置換 | |
def content = """ | |
雨にもまけず 風にもまけず | |
雪にも夏の暑さにもまけぬ 丈夫なからだをもち | |
慾はなく 決して瞋らず いつもしずかにわらっている | |
一日に玄米四合と 味噌と少しの野菜をたべ | |
あらゆることを じぶんをかんじょうに入れずに | |
よくみききし わかり そして わすれず | |
野原の松の林の蔭の 小さな萱ぶきの小屋にいて | |
東に病氣のこどもあれば 行って看病してやり |
This file contains hidden or 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
// g100pon #87 YAML | |
// | |
@Grab(group='net.java.dev', module='jvyaml', version='0.2.1') | |
import org.jvyaml.YAML | |
def yamlData = """ | |
- title: なんとかのテストをする | |
node: | |
- title: ほげほげ | |
node: |
This file contains hidden or 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
// g100pon #80 HTTP GET/POST | |
// HTTP GET | |
"http://www.google.com".toURL().eachLine { | |
println it | |
} | |
def qs = [] | |
qs << "q=" + URLEncoder.encode("Groovy 日本語") | |
qs << "hl=" + URLEncoder.encode("ja") |
This file contains hidden or 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
// g100pon #76 外部コマンドの起動と出力の取得等 | |
def COMMAND = "ls -l ." | |
// def COMMAND = "cmd /c dir" // Windowsだったらこう? | |
// 外部コマンドの実行 | |
def p = COMMAND.execute() | |
p.waitFor() // 終了まで待機 | |
println p.exitValue() // 終了コード |
This file contains hidden or 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
// g100pon #36 ファイルをドラッグ&ドロップできるウィンドウ | |
// | |
import groovy.swing.SwingBuilder | |
import java.awt.dnd.DropTarget | |
import java.awt.dnd.DropTargetAdapter | |
import javax.swing.DefaultListModel | |
import static java.awt.datatransfer.DataFlavor.javaFileListFlavor | |
import static java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE | |
import static javax.swing.WindowConstants.EXIT_ON_CLOSE |
This file contains hidden or 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
import org.codehaus.groovy.scriptom.* | |
import org.codehaus.groovy.scriptom.tlb.office.* | |
import org.codehaus.groovy.scriptom.tlb.office.excel.* | |
import org.codehaus.groovy.scriptom.tlb.office.word.WdSaveOptions | |
def waitTime = 10000 | |
Scriptom.inApartment { | |
def dir = new File("c:/temp") | |
def xlApp = new ActiveXObject('Excel.Application') | |
def wdApp = new ActiveXObject('Word.Application') |