Skip to content

Instantly share code, notes, and snippets.

View kamatama41's full-sized avatar
😀
Hello

Shinichi Ishimura kamatama41

😀
Hello
View GitHub Profile
@kamatama41
kamatama41 / GetAllInterfacesTest.java
Created June 4, 2012 13:06
Compare Class#getInterfaces() with org.springframework.util.ClassUtils#getAllInterfaces()
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.util.ClassUtils;
public class GetAllInterfacesTest {
@Test
public void getInterfaceTest() throws Exception {
Class<?>[] interfaces = new ConcreteClass1().getClass().getInterfaces();
assertEquals(0, interfaces.length);
@kamatama41
kamatama41 / todays_fortune_app.html
Created June 4, 2012 13:07
facebook application sample
<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<h1>きょうのうらない</h1>
<div id="account-info"></div>
<p id="result_button" style="display: none;"><button onclick="javascript:show_result()">うらなってみる</button></p>
<p id="result_area"></p>
<p id="post_button" style="display: none;"><button onclick="javascript:post_result('result_area')">ウォールに投稿する</button></p>
<script type="text/javascript">
@kamatama41
kamatama41 / move_dat_files.sh
Created June 5, 2012 09:00
引数で指定したディレクトリ内にある".dat"ファイルを指定したディレクトリ配下に移動する
#!/bin/sh
for file in `find $1 -name "*.dat"`;do
echo "move: $file"
mv $file $1
done
@kamatama41
kamatama41 / OrverrideConstructorTest.java
Created July 29, 2012 14:43
OrverrideConstructorTest
package com.kamatama41.sandbox4j;
import org.junit.Test;
public class OrverrideConstructorTest {
@Test(expected=NullPointerException.class)
public void test_Aの初期化時にBのsomeMethodが呼ばれてぬるぽ発生() throws Exception {
new OrverrideConstructorTest().new B();
}
@kamatama41
kamatama41 / ForLoopBySetAndList.java
Created August 25, 2012 09:27
Forループをsetとlistで展開した時の速度を調べる
package com.kamatama41.sandbox4j;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@kamatama41
kamatama41 / DangerousCopyTest.java
Created October 6, 2012 13:11
オブジェクトの値の書き換えで副作用が発生するのを観察する
package com.kamatama41.sandbox4j;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test;
public class DangerousCopyTest {
@Test
@kamatama41
kamatama41 / SafetyCopyTest.java
Created October 6, 2012 14:13
オブジェクトの値の書き換え副作用が発生しないことを観察する
package com.kamatama41.sandbox4j;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import org.junit.Test;
public class SafetyCopyTest {
@kamatama41
kamatama41 / ArrayListCompareToLinkedList.java
Created October 24, 2012 18:23
ArrayListとLinkedListのいろいろなパターンでの速度比較
package com.kamatama41.sandbox4j;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
public class ArrayListCompareToLinkedList {
@kamatama41
kamatama41 / DistributedCache.java
Created November 25, 2012 15:42
DistributedCache using ConsistentHash
package com.kamatama41.sandbox4j;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
package com.kamatama41.sandbox4j;
import java.util.Collection;
import java.util.SortedMap;
import java.util.TreeMap;
public class ConsistentHash<T> {
private final HashFunction hashFunction;
private final int numberOfReplicas;