Skip to content

Instantly share code, notes, and snippets.

View aya-eiya's full-sized avatar

ayabe hidetoshi aya-eiya

View GitHub Profile
apply plugin: 'java'
apply plugin: 'groovy'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "net.saliman:gradle-cobertura-plugin:2.0.0"
}
@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
@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 / 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 / file3.txt
Created July 23, 2013 13:57
ちょっとしたことがGroovy「あっという間に死んでしまう正規表現を検証する」 ref: http://qiita.com/aya_eiya/items/5aa5aac1c00d81772dd6
(パターン+)+
@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 / regexp_faster.groovy
Created July 1, 2013 13:29
ちょっとしたことがGroovy「正規表現の部分で遅くなってたのを検証」 ref: http://qiita.com/aya_eiya/items/cd49e5a8a70149947a74
import java.util.regex.Matcher
import java.util.regex.Pattern
def stopWatch = {c->
s = System.nanoTime()
c()
"${(System.nanoTime() - s) / 1000} [microsec]"
}
Pattern slowp = Pattern.compile(/[^。「」]{30,}/)
@aya-eiya
aya-eiya / getSteps.groovy
Created June 27, 2013 09:19
ちょっとしたことがGroovy「ある値まで一定間隔のRangeのリストを作りたい」 ref: http://qiita.com/aya_eiya/items/d48541f1ca2e57c16ef2
def getSteps = {start=1,max,step=1000 ->
if(max <= start + step) return [[start..max]]
def rs = (start..max).step(step).inject([]) {a,c -> (c>start) && a << [ ((a!=[])?a.last().to[0]+1:start)..c-1];a}
(rs.last().to[0] != max) && rs << [rs.last().to[0]+1..max];rs
}
println"""
getSteps(max=10020) = ${getSteps(max=10020)}
"""
println"""
@aya-eiya
aya-eiya / quateToString()
Created June 27, 2013 07:18
ちょっとしたことがGroovy 「リストの文字列表現で要素に任意の引用符つけたい」 ref: http://qiita.com/aya_eiya/items/c9b8e0b3d417dae2a7a3
List.metaClass.toString = { squate,equate=null ->
if(equate==null) equate = squate
delegate.collect {"${squate}${it}${equate}"}
}
def l = ["a","b","c"];
println l.toString()
println l.toString("'")
@aya-eiya
aya-eiya / file0.bat
Created June 7, 2013 13:22
Windowsのパスの長さ制限に引っかかったので短くしてみた ref: http://qiita.com/items/d2677c85017a010f2772
C:\>echo %path% | perl -nle "s/;/;\n/g;print $_"
C:\Program Files (x86)\Haskell\bin;
C:\Program Files (x86)\Haskell Platform\2013.2.0.0\lib\extralibs\bin;
C:\Program Files (x86)\Haskell Platform\2013.2.0.0\bin;
C:\Program Files (x86)\Intel\iCLS Client\;
C:\Program Files\Intel\iCLS Client\;
%SystemRoot%\system32;
%SystemRoot%;
%SystemRoot%\System32\Wbem;
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;