Skip to content

Instantly share code, notes, and snippets.

View j5ik2o's full-sized avatar

Junichi Kato j5ik2o

View GitHub Profile
@j5ik2o
j5ik2o / gist:1066876
Created July 6, 2011 09:05
hadoop 0.20.2のためのFormula
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 August 20, 2011 07:36
cscopeの設定ファイルを作る方法
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 August 20, 2011 08:02
homebrew mysqlをインストールした時のログ
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 August 20, 2011 08:02
mysql install_dbのログ
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 August 23, 2011 19:32
最新版のPlayのFormula
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 October 19, 2011 10:44
Scala - val/var
$ 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 October 19, 2011 10:47
Scala - 型推論
$ scala
// 代入される値の型により変数の型が決定する
scala> val num1 = 1
num1: Int = 1
scala> val num2 = 1.5
num2: Double = 1.5
// 型を明示的に指定するなら、:型で指定する。型アノテーションという。
@j5ik2o
j5ik2o / gist:1297960
Created October 19, 2011 10:51
Scala - クラス
package money
import java.util.Currency
class Money(amnt : BigDecimal, creny : Currency){
val amount = amnt // フィールド宣言
val currency = creny // フィールド宣言
// フィールド宣言でありながら、コンストラクタのボディとなっているので、処理も書けます。
}
// 上記は下記のように省略して記述できる。
@j5ik2o
j5ik2o / gist:1297966
Created October 19, 2011 10:55
Scala - メソッド
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 October 19, 2011 10:58
Scala - 補助コンストラクタ
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))
// ...
}