Skip to content

Instantly share code, notes, and snippets.

View aya-eiya's full-sized avatar

ayabe hidetoshi aya-eiya

View GitHub Profile
@aya-eiya
aya-eiya / fast_30.groovy
Created July 12, 2013 11:11
ちょっとしたことがGroovy「めちゃくちゃ重い正規表現をどうにかする確認」 ref: http://qiita.com/aya_eiya/items/4bae8e2dbde97ed248bb
import java.util.regex.Matcher
import java.util.regex.Pattern
def stopWatch = {c->
s = System.nanoTime()
c()
def w = System.nanoTime() - s
if(w < 1000000)
"${w / 1000} [microsec]"
else if(w < 1000000000)
@aya-eiya
aya-eiya / file3.txt
Created July 23, 2013 13:57
ちょっとしたことがGroovy「あっという間に死んでしまう正規表現を検証する」 ref: http://qiita.com/aya_eiya/items/5aa5aac1c00d81772dd6
(パターン+)+
@aya-eiya
aya-eiya / xml_data_fix.groovy
Created August 9, 2013 07:32
ちょっとしたことがGroovy「PostgreSQLのXML型のカラムのデータを修正する」 ref: http://qiita.com/aya_eiya/items/7e4d126757e684f0ff0a
@Grab(group='postgresql', module='postgresql', version='9.1-901.jdbc4')
@Grab(group='org.codehaus.gpars', module='gpars', version='1.0.0')
import org.postgresql.ds.PGSimpleDataSource;
import groovy.sql.Sql;
/* meta */
String.metaClass.queryTo = { con ->
def qry = delegate
@aya-eiya
aya-eiya / file0.txt
Created September 5, 2013 03:20
サブモジュールの状態を含めてZSHの右側に表示する ref: http://qiita.com/aya_eiya/items/3696fae450bf413eae3e
### Git
#
# Show branch name in Zsh's right prompt
#
autoload -Uz VCS_INFO_get_data_git; VCS_INFO_get_data_git 2> /dev/null
setopt prompt_subst
setopt re_match_pcre
function rprompt-git-submodule-status {
local st color subName name treeTop cdir
@aya-eiya
aya-eiya / ignoreSSLErr.groovy
Created September 30, 2013 09:13
ちょっとしたことがGroovy「エラーの出るSSL証明書を無視してHTTPSアクセスをテストする」 ref: http://qiita.com/aya_eiya/items/58ff3723a0f00574d421
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.6')
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
import javax.net.ssl.X509TrustManager
import javax.net.ssl.SSLContext
import java.security.cert.X509Certificate
import javax.net.ssl.TrustManager
apply plugin: 'java'
apply plugin: 'groovy'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "net.saliman:gradle-cobertura-plugin:2.0.0"
}
@aya-eiya
aya-eiya / file0.txt
Created November 7, 2013 11:14
Pushの前にかならずテストするGitのHookスクリプト ref: http://qiita.com/aya_eiya/items/99e2fcd770325ae5a767
#!/bin/bash
echo "prepush called"
DIR=$PWD
ROOT=$PWD/`git rev-parse --show-cdup`
ROOT=${ROOT%/}
result=0
#dryRun
@aya-eiya
aya-eiya / file0.txt
Created December 4, 2013 03:41
gitサブモジュールのHookをどこに置けばいいか ref: http://qiita.com/aya_eiya/items/dc706589c5af75cb08ef
git rev-parse --git-dir
@aya-eiya
aya-eiya / openjpa.gradle
Created December 5, 2013 14:35
GradleでOpenJPAのenhanceタスクを実装 ref: http://qiita.com/aya_eiya/items/65561d8e534c602818b6
def relativize = {file->
projectDir.toURI().relativize(file.toURI()).toString()
}
task(enhance,dependsOn:classes) << {
description 'OpenJPA enhancer task.'
ant.taskdef (
name : 'openjpac',
classpath : project.runtimeClasspath.asPath,
classname : 'org.apache.openjpa.ant.PCEnhancerTask'
@aya-eiya
aya-eiya / FieldNG.groovy
Created December 6, 2013 05:02
Groovyのちょっとしたこと「Scriptのローカル変数のスコープ」 ref: http://qiita.com/aya_eiya/items/32876e8693b77f4277f3
def myVar = 'myvar'
def callMyVar() {
println myVar
}
callMyVar()