Skip to content

Instantly share code, notes, and snippets.

View taisukeoe's full-sized avatar

Taisuke Oe taisukeoe

  • Japan Scala Association, Inc.
  • Tokyo
  • X @OE_uia
View GitHub Profile
@taisukeoe
taisukeoe / pattaernMatch.scala
Created February 21, 2015 13:36
パターンマッチの網羅性チェックとifガード節
scala> def func(s:Option[String]) = s match{case Some(x) if x.size > 0 => x}
func: (s: Option[String])String
scala> def func(s:Option[String]) = s match{case Some(x) => x}
<console>:7: warning: match may not be exhaustive.
It would fail on the following input: None
def func(s:Option[String]) = s match{case Some(x) => x}
^
func: (s: Option[String])String
@taisukeoe
taisukeoe / dna.scala
Last active August 29, 2015 14:10
for rosalind
package hemplant.rosalind.dna
sealed abstract trait Nucleotide{
def complementary:Nucleotide = Nucleotide.complementary(this)
}
case object A extends Nucleotide
case object T extends Nucleotide
case object G extends Nucleotide
case object C extends Nucleotide
@taisukeoe
taisukeoe / Calculator.scala
Created September 1, 2014 15:43
某勉強会の予定を調整さんに投げる用プロジェクト
import com.github.nscala_time.time.Imports._
import annotation.tailrec
import org.joda.time.DateTimeConstants
object Calculator extends App{
val start = nextMonday(DateTime.now.toLocalDate)
val days = start :: Stream.iterate(start + 1.day)(_ + 1.day).takeWhile(_.getDayOfWeek != DateTimeConstants.MONDAY).toList
val result = days.map {
@taisukeoe
taisukeoe / gist:052a252bcb3aeda5f853
Created June 5, 2014 06:15
Xcode 6 beta crash report in opening .sks file
Process: Xcode [742]
Path: /Applications/Xcode6-Beta.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 6.0 (6194.21)
Build Info: IDEFrameworks_KLONDIKE-6194021000000000~12
Code Type: X86-64 (Native)
Parent Process: launchd [172]
Responsible: Xcode [742]
User ID: 502
@taisukeoe
taisukeoe / UIDemoActivity.scala
Last active April 16, 2017 05:01
How to force to execute Future callback function in Android UIThread.
import scala.concurrent._
import ExecutionContext.Implicits.global
import android.util.Log
import android.widget.TextView
class UIDemoActivity extends Activity {
override def onCreate(bundle: Bundle) {
super.onCreate(bundle)
val tv = new TextView(this)
@taisukeoe
taisukeoe / gist:6343272
Last active December 21, 2015 17:49
awscala.ec2.Instanceに、単純なssh/scpをscala-ssh非依存で実行させてみるてすつ。
def process(command: String, keyPairFile: File, sshOption: String = "-o StrictHostKeyChecking=no -t -t"): Either[String, String] = {
import sys.process._
try {
Right(s"echo ${command}" #&& "echo exit" #> s"ssh ${sshOption} -i ${keyPairFile.getAbsolutePath} ec2-user@${publicDN}" !!)
} catch { case e: Exception => Left(e.toString) }
}
def scp(file: File, keyPairFile: File, scpOption: String = "-o StrictHostKeyChecking=no"): Either[String, String] = {
import sys.process._
try {