Skip to content

Instantly share code, notes, and snippets.

View shuji's full-sized avatar

Shuji Watanabe shuji

View GitHub Profile
@shuji
shuji / SeleniumFailedCapture.java
Created November 18, 2013 13:14
SeleniumFailedCapture
public class SeleniumFailedCapture implements TestRule {
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
try {
base.evaluate();
1. 書籍クラスを作り、toJsonメソッドのユニットテストを作成する
書籍データ
isdn: 477415377X
title: JUnit実践入門
author: 渡辺修司
toJson
{"isdn":"477415377X","title":"JUnit実践入門","author":"渡辺修司"}
2.外部APIを利用し、書籍情報を取得するメソッド(findByIsbn)を作成し、ユニットテストを作成する
@shuji
shuji / tojson
Created May 27, 2013 09:19
CDATA付きのJSONをparseする
var jsonWithCDATA = $('#data').text();
var xml = $.parseXML('<data>' + jsonWithCDATA + '</data>');
var json = $.parseJSON($(xml).find('data').text());
@shuji
shuji / pom.xml
Created December 12, 2012 06:12
Maven snipet - assembly with dependencies
<!-- mvn assembly:assembly -->
<!-- http://maven.apache.org/plugins/maven-assembly-plugin/ -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
@shuji
shuji / pom.xml
Created December 12, 2012 04:52
Maven pom snipet - using JDK 7
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
def from = 10
def to = 20
(from..to).each { println it }
@shuji
shuji / gist:2333358
Created April 8, 2012 01:08
example - "10,12-14,15-".split
import java.util.regex.Matcher
"10,12-14,15-".split(',').each {
switch(it) {
case ~/(\d+)\-(\d+)/:
def from = Matcher.lastMatcher[0][1].toInteger()
def to = Matcher.lastMatcher[0][2].toInteger()
println "from=${from}, to=${to}"
break
case ~/(\d+)\-/:
def from = Matcher.lastMatcher[0][1].toInteger()
@shuji
shuji / unique.groovy
Created February 8, 2012 01:56
重複の排除
assert [1, 2, 3, 3].unique() == [1, 2, 3]
@shuji
shuji / execute_ls.groovy
Created February 8, 2012 01:53
Process execute from Groovy
def process = "ls -la".execute()
process.waitFor()
class Foo {
def foo(String name) {
def _ = {
"Hello ${name}"
}
def __ = _.call()
return __
}
}
println new Foo().foo("World")