Skip to content

Instantly share code, notes, and snippets.

@uemuraj
uemuraj / jstack-tomcat.bat
Created September 30, 2013 07:20
Windows 環境で Apache Tomcat のスタックトレースをダンプするバッチファイル。すごく適当。
@echo off
setLocal EnableDelayedExpansion
set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_25
set PATH=%JAVA_HOME%\bin;%PATH%
for /F "usebackq tokens=1,2" %%i in (`jps`) do (
if "%%j" == "Bootstrap" jstack %%i > jstack-%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt
)
@uemuraj
uemuraj / change-log.groovy
Created November 7, 2013 05:34
SubVersion のコミットログの中にあるチケット番号だけを変更する、とてもニッチなスクリプト。
#!/usr/bin/groovy
def pattern = ~/#([0-9]+)/
def offset = Integer.decode(args[0])
def target = args[1]
def username = args[2]
def password = args[3]
def logs = "svn log --xml --username=${username} --password=${password} ${target}".execute()
@uemuraj
uemuraj / change-bugs.groovy
Last active December 27, 2015 15:59
Review Board のレビューリクエストの中にあるチケット番号だけを変更する、とてもニッチなスクリプト。
#!/usr/bin/groovy
@Grab('postgresql:postgresql')
@GrabConfig(systemClassLoader=true)
import groovy.sql.*
import java.sql.*
def pattern = ~/([0-9]+)/
def offset = Integer.decode(args[0])
def target = args[1]
@uemuraj
uemuraj / jmardb-import.groovy
Last active December 28, 2015 13:59
気象庁防災情報XMLデータのインポート。XMLをまるごと入れるだけで、実は中身は見ていない...
#!/usr/bin/env groovy
@Grab('postgresql:postgresql')
@GrabConfig(systemClassLoader=true)
import java.sql.*
import java.text.*
import java.util.zip.*
import javax.xml.*
import javax.xml.transform.*
import javax.xml.transform.stream.*
@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%')"