Skip to content

Instantly share code, notes, and snippets.

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

HIGUCHI Ryusuke rhiguchi

🏠
Working from home
  • Yokohama, Japan
View GitHub Profile
@rhiguchi
rhiguchi / AdminAction.scala
Created July 23, 2013 04:06
Play Framework で Basic 認証を行うアクションのミックスイン ref: http://qiita.com/flo_jack/items/257fe8b0cf93151f8a3d
package controllers
import play.api._
import play.api.mvc._
/**
* 管理者のアカウントを取り扱うモジュール
*/
trait AdminSecure {
import play.api.mvc.Results._
@rhiguchi
rhiguchi / build.xml
Created June 24, 2012 04:59
Ant で Ivy の jar をダウンロードさせて、その jar からタスクを定義する ref: http://qiita.com/items/21e5370ffa178bb19bc9
<project xmlns:ivy="antlib:org.apache.ivy.ant">
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
<property name="ivy.home" value="${user.home}/.ivy2" />
<property name="ivy.install.dir" value="${ivy.home}/lib" />
<property name="ivy.install.dest" value="${ivy.install.dir}/ivy.jar" />
<target name="-check-ivy-user-installed" description="check ivy jar file existence on user's ivy home">
<available file="${ivy.install.dest}" property="ivy.install.dest.exisits" />
@rhiguchi
rhiguchi / file1.txt
Created April 1, 2012 08:27
NHKネットラジオをVLCで録音するスクリプト ref: http://qiita.com/items/549b42c8b361807d96a2
recording.sh 10
@rhiguchi
rhiguchi / gist:2228130
Created March 28, 2012 16:49
vlc streaming
-I rc mms://a33.l12993146032.c129931.g.lm.akamaistream.net/D/33/129931/v0001/reflector:46032 :sout='#transcode{acodec=mp4a}:std{access=file,mux=mp4,dst=test.mp4}
@rhiguchi
rhiguchi / LoanPatternLock.scala
Created February 25, 2012 13:55
Scala で ReadWriteLock にローンパターンを使う ref: http://qiita.com/items/2805
object LoanPatternLock {
import java.util.concurrent.locks.{Lock, ReadWriteLock}
def lockWith[A <% Lock, B](l: A)(e: => B) = {
l.lock()
try e finally l.unlock()
}
def readLockWith[A <% ReadWriteLock, B](l: A)(e: => B) =
lockWith(l.readLock)(e)
@rhiguchi
rhiguchi / PropertyChangePublisher.scala
Created February 24, 2012 16:31
Scala で PropertyChangeEvent の発行とかを実装するミックスイン用トレイト ref: http://qiita.com/items/2791
import java.beans.{PropertyChangeListener, PropertyChangeSupport, PropertyChangeEvent}
trait PropertyChangePublisher {
private lazy val propertyChangeSupport = new PropertyChangeSupport(this)
def addPropertyChangeListener(listener: PropertyChangeListener) =
propertyChangeSupport.addPropertyChangeListener(listener)
def removePropertyChangeListener(listener: PropertyChangeListener) =
propertyChangeSupport.removePropertyChangeListener(listener)
@rhiguchi
rhiguchi / LimitValueTest.java
Created February 6, 2012 02:00
MIN_VALUEの値のテスト
public class LimitValueTest {
@Test
public void limitOfInteger() {
assertEquals(2147483647, Integer.MAX_VALUE);
assertEquals(0x7fffffff, Integer.MAX_VALUE);
assertEquals(-2147483648, Integer.MIN_VALUE);
assertEquals(-0x80000000, Integer.MIN_VALUE);
}
@Test
@rhiguchi
rhiguchi / ViewTest.java
Created February 5, 2012 01:48
Swingビューテストのテンプレート
import javax.swing.JFrame;
public class ViewTest {
ViewTest craeteView() {
return new ViewTest();
}
public static void main(String[] args) {
final ViewTest test = new ViewTest();
@rhiguchi
rhiguchi / AlphaDigitsHexNumberColorDecodingTest.java
Created February 4, 2012 14:23
アルファ値を持つ16進数文字列からColorオブジェクトを作成するテスト
import static org.junit.Assert.*;
import java.awt.Color;
import org.junit.Test;
public class AlphaDigitsHexNumberColorDecodingTest {
@Test
public void decodeHexStringToColor() {
Color color = Color.decode("#000000");
@rhiguchi
rhiguchi / MainView.java
Created January 29, 2012 13:41
Swing を MVC パターンで設計する流れの確認。
import static javax.swing.SpringLayout.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;