Skip to content

Instantly share code, notes, and snippets.

Junichi Kato j5ik2o

Block or report user

Report or block j5ik2o

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@j5ik2o
j5ik2o / gist:1066876
Created Jul 6, 2011
hadoop 0.20.2のためのFormula
View gist:1066876
require 'formula'
class Hadoop0202 < Formula
url 'http://www.gtlib.gatech.edu/pub/apache/hadoop/core/hadoop-0.20.2/hadoop-0.20.2.tar.gz'
homepage 'http://hadoop.apache.org/common/'
md5 '8f40198ed18bef28aeea1401ec536cb9'
def shim_script target
<<-EOS.undent
#!/bin/bash
@j5ik2o
j5ik2o / gist:1158810
Created Aug 20, 2011
cscopeの設定ファイルを作る方法
View gist:1158810
OPEN_JDK_HOME=/Developer/SDKs/openjdk-6-src-b23-05_jul_2011/
find $OPEN_JDK_HOME -name "*.cpp*" -print > cscope.files
find $OPEN_JDK_HOME -name "*.hpp*" -print >> cscope.files
cscope -bqk
@j5ik2o
j5ik2o / gist:1158828
Created Aug 20, 2011
homebrew mysqlをインストールした時のログ
View gist:1158828
Set up databases to run AS YOUR USER ACCOUNT with:
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
To set up base tables in another folder, or use a different user to run
mysqld, view the help for mysqld_install_db:
mysql_install_db --help
and view the MySQL documentation:
* http://dev.mysql.com/doc/refman/5.5/en/mysql-install-db.html
@j5ik2o
j5ik2o / gist:1158830
Created Aug 20, 2011
mysql install_dbのログ
View gist:1158830
junichi-macbook-pro:~ junichi$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
@j5ik2o
j5ik2o / play.rb
Created Aug 23, 2011
最新版のPlayのFormula
View play.rb
require 'formula'
class Play < Formula
url 'http://download.playframework.org/releases/play-1.2.3.zip'
homepage 'http://www.playframework.org/'
md5 '75822b1ec443239a4467147a94882442'
def install
rm_rf 'python' # we don't need the bundled Python for windows
rm Dir['*.bat']
@j5ik2o
j5ik2o / gist:1297952
Created Oct 19, 2011
Scala - val/var
View gist:1297952
$ scala
scala> val name = "Junichi Kato"
name: java.lang.String = Junichi Kato
// 定数なので初期化できない
scala> name = "HOGE"
<console>:8: error: reassignment to val
name = "HOGE"
^
@j5ik2o
j5ik2o / gist:1297955
Created Oct 19, 2011
Scala - 型推論
View gist:1297955
$ scala
// 代入される値の型により変数の型が決定する
scala> val num1 = 1
num1: Int = 1
scala> val num2 = 1.5
num2: Double = 1.5
// 型を明示的に指定するなら、:型で指定する。型アノテーションという。
@j5ik2o
j5ik2o / gist:1297960
Created Oct 19, 2011
Scala - クラス
View gist:1297960
package money
import java.util.Currency
class Money(amnt : BigDecimal, creny : Currency){
val amount = amnt // フィールド宣言
val currency = creny // フィールド宣言
// フィールド宣言でありながら、コンストラクタのボディとなっているので、処理も書けます。
}
// 上記は下記のように省略して記述できる。
@j5ik2o
j5ik2o / gist:1297966
Created Oct 19, 2011
Scala - メソッド
View gist:1297966
class Money(val amount: BigDecimal, val currency: Currency){
def plus(other: Money) = {
require(other.currency == currency) // falseだとIllegalArgumentException
new Money(amount + other.amount, currency) // 最後の式で評価された値が戻り値
}
override def equals(obj: Any) = obj match { // 該当したcaseの=>の右側の式が評価され、その結果がmatch式の戻り値
case that: Money => amount == that.amount && currency == other.currency
case _ => false // defaultケースのようなもの
@j5ik2o
j5ik2o / gist:1297971
Created Oct 19, 2011
Scala - 補助コンストラクタ
View gist:1297971
package money
import java.util.Currency
import java.util.Locale
class Money(val amount : BigDecimal, val currency: Currency) {
// 補助コンストラクタ
def this(amount : BigDecimal) = this(amount, Currency.getInstance(Locale.getDefault))
// ...
}
You can’t perform that action at this time.