Skip to content

Instantly share code, notes, and snippets.

()
()
@k-goto
k-goto / RegexMatcher.java
Created June 11, 2013 14:08
JUnit4 Matcher for assertThat
package matchers;
import java.util.regex.Pattern;
import org.hamcrest.Description;
import org.junit.internal.matchers.TypeSafeMatcher;
public class RegexMatcher extends TypeSafeMatcher<String> {
private final String criteria;
package utils;
import junit.framework.TestCase;
import org.junit.Test;
public class StringJUtilsTest extends TestCase {
@Test
public void test_fullHiraganaToFullKatakana() {
package utils;
public class StringJUtils {
private static final char[] HALF_KATAKANA = { '。', '「', '」', '、', '・',
'ヲ', 'ァ', 'ィ', 'ゥ', 'ェ', 'ォ', 'ャ', 'ュ', 'ョ', 'ッ', 'ー', 'ア', 'イ',
'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ',
'タ', 'チ', 'ツ', 'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ', 'ヒ', 'フ',
'ヘ', 'ホ', 'マ', 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル',
@k-goto
k-goto / DraggableOverlay.java
Created July 21, 2011 08:22
draggable overlay item
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
@k-goto
k-goto / gist:848601
Created March 1, 2011 04:20
PHP BentchMark
// PHP5.3以降
function bentch($count, $func) {
$start_m = microtime();
$start = time();
for ($i = 0; $i < $count; $i++) {
$func();
}
$end_m = microtime();
@k-goto
k-goto / php prime_number
Created February 8, 2011 16:58
php prime_number use Closure
<?php
print_r(
array_filter(
range(2, 100), function ($num) {
return !in_array(0, array_map(function ($n) use ($num) {
return $num % $n;
}, range(2, $num - 1)));
}
)