Skip to content

Instantly share code, notes, and snippets.

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

Takuya Nagasaka takungsk

🏠
Working from home
View GitHub Profile
@takungsk
takungsk / gist:2044260
Created March 15, 2012 13:43
階乗計算
// 階乗計算
def fact(n: Int): Int = {
n match {
case 0 => 1
case _ => n * (n - 1)
}
}
@takungsk
takungsk / gist:2044322
Created March 15, 2012 13:58
フィボナッチ数列
// フィボナッチ数列 単純版
def fib(n:Int):Int = {
n match {
case x if (x <= 1) => x
case _ => fib(n - 1) + fib(n - 2)
}
}
@takungsk
takungsk / gist:2049196
Created March 16, 2012 08:47
idea プラグイン用の設定 sbt
// project ディレクトリの下に plugins.sbt として
// 実行は gen-idea
resolvers += "sbt-idea-repo" at "http://mpeltonen.github.com/maven/"
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.0.0")
@takungsk
takungsk / tmux_cheat_cheet.markdown
Last active April 7, 2019 18:21
tmuxのcheat sheet(日本語)

tmux cheat sheet

コマンド

新しく開始:

tmux

セッションに名前を付けて開始:

tmux new -s myname

アタッチ:

tmux a # (or at, or attach)

再アタッチ:

tumx a -d

@takungsk
takungsk / echo.scala
Created April 5, 2012 07:24 — forked from tototoshi/echo.scala
Scalaでスクリプトとか書くときのコマンドライン引数の解析
#!/bin/sh
exec scala "$0" "$@"
!#
val helpMessage = """
Usage:
-n do not output the trailing newline
-x repeat x times
@takungsk
takungsk / CheckLog.scala
Created April 6, 2012 11:15
テキストファイルを読み込んで 指定した文字列を含む行を出力するサンプル
import scala.io.Source
object CheckLog {
case class Args(
filename: String,
exp: String
)
def main(args: Array[String]) {
@takungsk
takungsk / gist:2320002
Created April 6, 2012 13:59
java コマンドで scala のプログラムを実行

##java コマンドで scala のプログラムを実行 やりかたあっているのかわからないが とりあえず動いた方法

sbt で jar を作る

> package

target に出来たjar ファイルを使う。

後 実行には scala-library.jar も必要。 これは homebrew でインストールした場合は /usr/local/Cellar/scala/2.9.1/libexec/lib にある。

@takungsk
takungsk / gist:2338185
Created April 8, 2012 16:07
Dispatch の Request と Handler

Dispatch の Request と Handler

##Request RequestはHTTPアクセスに必要な情報を持っています。

どのような値が設定されているか確認するには、次のメソッド(変数)で確認します。

class Request {
  val body: Option[HttpEntity]

val creds: Option[Credentials]

@takungsk
takungsk / gist:2369143
Created April 12, 2012 17:00
合成関数で 最長重複文字列問題をとく
//以前の最長文字列問題を 合成関数を使うように変更したバージョン
// mississipi という文字列の中の最長重複文字を探す
package takuya71
import takuya71.ExFunction._
class ExFunction[-ARG, +RET](f: ARG => RET) {
def :>:[A](g: A => ARG): A => RET = f compose g
def :*:(arg: ARG): RET = f(arg)
@takungsk
takungsk / gist:2621809
Created May 6, 2012 11:40
テキスト読み込み2
// Scala 実践プログラミングの grep の記事を参考にしたバージョン
import scala.io.Source
object CheckLog {
case class Args(
filename: String,
exp: String
)