Skip to content

Instantly share code, notes, and snippets.

View irof's full-sized avatar
🏠
Working from home

irof irof

🏠
Working from home
View GitHub Profile
public class DiamondProblem implements IHoge, IPiyo {
public static void main(String[] args) {
System.out.println(new DiamondProblem().hoge());
}
}
@irof
irof / hoge.sh
Last active August 29, 2015 14:07
-cpに~つかえねーとか @backpaper0 とやらがいうので https://twitter.com/backpaper0/status/522727485293596672
mkdir ~/hoge
mkdir work
cd work
echo "class Hoge { public static void main(String... args) { System.out.println(1); } }" > Hoge.java
echo "class Fuga { public static void main(String... args) { System.out.println(2); } }" > Fuga.java
javac Hoge.java Fuga.java
jar cvf Hoge.jar Hoge.class
jar cvf Fuga.jar Fuga.class
mv ./*.jar ~/hoge
@irof
irof / JerseyTestを使うときのGradleの依存解決
Last active August 29, 2015 14:20
JerseyTestを動かすのに要るjarを眺めてみる(2.17)
(https://github.com/irof/sandbox/tree/blog/20150501/jaxrs/jersey をちょっと削ったの)
% gradle dependencies --configuration testCompile :jersey:dependencies
------------------------------------------------------------
Project :jersey
------------------------------------------------------------
testCompile - Compile classpath for source set 'test'.
+--- org.glassfish.jersey.core:jersey-server:2.17
import java.time.LocalDateTime;
import java.util.Date;
import static org.junit.Assert.assertFalse;
/**
* @author irof
*/
public class DateAndDateTimeTest {
@org.junit.Test
package tddbc;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
@irof
irof / 処理の差し替え.groovy
Created March 26, 2011 15:44
処理の差し替え
class Hello {void hello(){println "1"}}
def a = new Hello()
def b = new Hello()
b.metaClass.hello = { println "2" }
a.hello()
b.hello()
a.metaClass.hello = {b.metaClass.hello}
a.hello()
@irof
irof / 処理の差し替えと戻し.groovy
Created March 27, 2011 03:22
差し替えた後元に戻す
class Hello {void hello(){println "1"}}
def a = new Hello()
a.hello()
a.metaClass.hello = { println "2" }
a.hello()
a.metaClass.hello = { a.&hello() }
a.hello()
class C {int m(){1}}
C.metaClass.m = {9}
def a = new C()
assert 9 == a.m()
a.metaClass.m = {2}
assert 2 == a.m()
C.metaClass.m = {8}
@irof
irof / replace.groovy
Created May 16, 2011 04:24 — forked from kyonmm/replace.groovy
指定ディレクトリ配下のファイルの改行コードを変換する
new File("src").eachFileRecurse(groovy.io.FileType.FILES) {
def s = it.text.replaceAll(/\r\n?/,'\n')
it.withWriter("UTF-8") {it << s}
}
@irof
irof / gist:1019573
Created June 10, 2011 19:19
リスト名から直近のTweetを取得する
@Grab("org.twitter4j:twitter4j-core:2.2.3")
import twitter4j.*
def twitter = new TwitterFactory().instance
twitter.getUserListStatuses(
twitter.getAllUserLists('kyon_mm').find{it.name == 'groovy'}.id, new Paging()
).each { println "<@${it.user.screenName}> $it.text" }