Skip to content

Instantly share code, notes, and snippets.

@uemuraj
uemuraj / w3c_validator.groovy
Created February 4, 2014 10:54
http://validator.w3.org/ で指定のURLをチェックする。
// W3C Markup Validation Service
import groovy.json.*
def slurper = new JsonSlurper()
args.each {
def uri = URLEncoder.encode(it)
def json = slurper.parseText(new URL("http://validator.w3.org/check?uri=${uri}&charset=%28detect+automatically%29&doctype=Inline&group=0&verbose=1&output=json").text)
@uemuraj
uemuraj / Another_HTML-lint.groovy
Created February 5, 2014 10:17
Another HTML-lint - http://openlab.ring.gr.jp/k16/htmllint/ で指定のURLをチェックする。
// Another HTML-lint
@Grab('org.jsoup:jsoup:1.7.+')
import org.jsoup.*
args.each {
def url = new URL("http://openlab.ring.gr.jp/k16/htmllint/htmllint.cgi")
def connection = url.openConnection()
connection.setRequestMethod("POST")
connection.doOutput = true
@uemuraj
uemuraj / dialogue-test.groovy
Last active August 29, 2015 13:56
株式会社NTTドコモ 雑談対話 API を試す簡単なスクリプト。本当に簡単。
#!/usr/bin/env groovy
import groovy.json.*
//
// 株式会社NTTドコモ 雑談対話 API を試す簡単なスクリプト
//
def apikey = '999999'
def url = new URL("https://api.apigw.smt.docomo.ne.jp/dialogue/v1/dialogue?APIKEY=${apikey}")
def slurper = new JsonSlurper()
@uemuraj
uemuraj / groovy.bat
Last active August 29, 2015 14:00
Apache Ivy を利用した Groovy 起動用のバッチファイル
@echo off
setLocal EnableDelayedExpansion
set PATH=%JAVA_HOME%\bin;%PATH%
set IVY=%TEMP:\=/%/ivy-2.3.0.jar
if not exist "%IVY%" (
jrunscript %JAVA_OPTS% -e "cp('http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar', '%IVY%')"
)
@uemuraj
uemuraj / groovy.sh
Last active August 29, 2015 14:00
Apache Ivy を利用した Groovy 起動用のシェルスクリプト
#!/bin/bash
export PATH=${JAVA_HOME}/bin:${PATH}
IVY=/tmp/ivy-2.3.0.jar
if [ ! -f "${IVY}" ]; then
jrunscript ${JAVA_OPTS} -e "cp('http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar', '${IVY}')"
fi
java ${JAVA_OPTS} -jar "${IVY}" -error -dependency org.codehaus.groovy groovy-all 2.3.+ -main groovy.lang.GroovyShell -- $@
@uemuraj
uemuraj / ant.bat
Last active August 29, 2015 14:00
Apache Ivy を利用した Apache Ant 起動用のバッチファイル
@echo off
setLocal EnableDelayedExpansion
set PATH=%JAVA_HOME%\bin;%PATH%
set LIB=%USERPROFILE:\=/%/.ant/lib
set IVY=%LIB%/ivy-2.3.0.jar
if not exist "%IVY%" (
mkdir "%LIB%"
jrunscript %JAVA_OPTS% -e "cp('http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar', '%IVY%')"
@uemuraj
uemuraj / ant.sh
Last active August 29, 2015 14:00
Apache Ivy を利用した Apache Ant 起動用のシェルスクリプト
#!/bin/bash
export PATH=${JAVA_HOME}/bin:${PATH}
LIB=${HOME}/.ant/lib
IVY=${LIB}/ivy-2.3.0.jar
if [ ! -f "${IVY}" ]; then
mkdir -p "${LIB}"
jrunscript ${JAVA_OPTS} -e "cp('http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar', '${IVY}')"
fi
@uemuraj
uemuraj / xslt.bat
Created April 21, 2014 10:43
jrunscript で XSLT 変換するバッチファイル
@echo off
rem
rem xslt.bat [xsl] [input] [output]
rem
setLocal EnableDelayedExpansion
set PATH=%JAVA_HOME%\bin;%PATH%
jrunscript %JAVA_OPTS% -e "XSLTransform('%2','%1','%3')"
@uemuraj
uemuraj / xslt.sh
Created April 21, 2014 10:44
jrunscript で XSLT 変換するシェルスクリプト
#!/bin/bash
#
# xslt.sh [xsl] [input] [output]
#
export PATH=${JAVA_HOME}/bin:${PATH}
jrunscript ${JAVA_OPTS} -e "XSLTransform('$2','$1','$3')"
@uemuraj
uemuraj / unzip.js
Created April 25, 2014 01:06
jrunscript で UNZIP する
importPackage(java.io);
importPackage(java.util.zip);
for (i = 0; i < arguments.length; i++) {
var zip = new ZipFile(new File(arguments[i]));
var entries = zip.entries();
while (entries.hasMoreElements()) {