This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jmhSettings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Callback{ | |
def onSet(s:Set[String]):Unit | |
def onList(l:List[String]):Unit | |
} | |
def funcWithCallback(s:String,callback:Callback):Unit = ??? | |
def funcAsFuture(s:String):Future[Traversable[String]] = { | |
val p = Promise[Traversable[String]]() | |
val f = p.future | |
funcWithCallback(s,new Callback{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streams._ | |
import util._ | |
implicit val s = Strategy.fromExecutionContext(scala.concurrent.ExecutionContext.Implicits.global) | |
val t = Task(println(Thread.currentThread.getName)) | |
// Exiting paste mode, now interpreting. | |
import streams._ | |
import util._ | |
s: streams.util.Strategy = streams.util.Strategy$$anon$1@60d8175 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val ndArray = (1d to 8d by 1).mkNDArray(Array(2,2,2),NDOrdering.C) | |
ndArray: org.nd4j.linalg.api.ndarray.INDArray = | |
[[[1.00,2.00] | |
[3.00,4.00]] | |
[[5.00,6.00] | |
[7.00,8.00]]] | |
scala> ndArray.sliceP.map(s => s.rowP.map(r => r*r)) | |
res12: org.nd4j.linalg.api.ndarray.INDArray = | |
[[[1.00,2.00] |
OlderNewer