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
// g100pon #61 FizzBuzz | |
1.upto(100) { | |
ans ="" | |
if (it%3 == 0) {ans ="Fizz"} | |
if (it%5 == 0) {ans += "Buzz"} | |
if (ans == "") {println it} else println ans | |
} | |
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
// run findEncryptedZipFile.groovy in the root directory of Encrypted zip files | |
// to find out encrypted zip files recursively. | |
// run this code at the top directory of zip files. | |
// Output directory is d:\WORK\ENCRYPTED, modify the location to meet your environmnet | |
// Using maven https://mvnrepository.com/artifact/net.lingala.zip4j/zip4j | |
@Grapes( | |
@Grab(group='net.lingala.zip4j', module='zip4j', version='1.3.2') | |
) |
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
@echo off | |
rem this batch will call some batch file "updateIt.bat" at each 10 days | |
rem one line of log.txt is like 2017012 ("2017 Jan 20thday") and so on, if the last line of log.txt | |
rem is different from now, the next batch file will ba called. | |
rem So we can invoke updateIt.bat at each 10 days | |
rem Good for some cleanup acitivity | |
FOR /F "delims=," %%a IN (log.txt) DO ( | |
IF %%a == %date:~0,4%%date:~5,2%%date:~8,1% ( | |
goto DONE |
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
// g100pon recursively grep various filetype files with one or two keywords | |
// lastly invoke Hidemaru editor | |
startDir = "." | |
filePattern = /(\.asm.*$|\ | |
\.awk$|\ | |
\.bat$|\ | |
\.BMS$|\ | |
\.c$|\ | |
\.cbl.*$|\ |
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
// 文字コード判定 | |
// ソースコードのコードページを再帰的に判定し続ける | |
import com.ibm.icu.text.CharsetDetector | |
@Grab(group='com.ibm.icu', module='icu4j', version='56.1') | |
def detector = new CharsetDetector() | |
// UTF-8, UTF-16 UTF-32, Windows-31j | |
// ISO-8859-2, windows-1252, windows-1250, ISO-8859-2, ISO-8859-1, Big5, UTF-16LE |
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
// File Space Renamer | |
// Renames any file which has %20 %40 (space) : ; | |
// %20 -> _ | |
// %40 -> @ | |
// (space) -> _ | |
// eg "Hello World.txt%40" -> "Hello_World@.txt" | |
new File(".").eachFile { file -> | |
if(file.isFile()){ | |
curName = file.getPath().replaceAll(/.\\(.*)/) {m0,m1 -> m1} | |
newFileN = URLDecoder.decode(curName, "UTF-8").replaceAll(/%20/,"_").replaceAll(/%40/,"@").replaceAll(/ /,"_").replaceAll(/:/,"_").replaceAll(/;/,"_") |
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
// PDF Renamer : Rename PDF file from the metadata Title | |
// 1: set PATH to pdftk | |
// 2: plase PDFRenamer.groovy (this file to same directory of pdftk ) | |
// 3: move to the root of target PDF directory | |
// 4: start PDFRenamer.groovy in pdftk directory | |
@Grab('net.java.dev.jna:jna:3.4.0') // since Java does not have directory moving function | |
import com.sun.jna.*; | |
import com.sun.jna.win32.*; |
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
//println "drv [ free ]G [ total ]G [free]%" | |
println "drv [ 空き ]G [ 計 ]G [Free]%" | |
allFree=0 | |
allTotal=0 | |
for (drive in "B".."Z") { | |
file = new File("${drive}:/") | |
BigDecimal free = file.getFreeSpace()/1000000000 | |
allFree=allFree+free | |
BigDecimal total= file.getTotalSpace()/1000000000 | |
allTotal=allTotal+total |
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
#!/usr/bin/groovy | |
import groovy.util.Eval | |
if (args.length ==0) { | |
println """Groovy電卓 使用例: dentaku 1+2*3 | |
第一引数に 計算式をスペース無しで指定してください""" | |
return | |
} |
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
import java.text.* | |
Timer timer = new Timer(); | |
println "Start:" | |
timer.schedule( new TimerTask() { | |
public void run() { | |
println new SimpleDateFormat("yyyyMMdd-HH:mm:ss.S").format(new Date()) | |
} | |
}, 0, 60*1000); |
NewerOlder