specs2でテストでtagをつけて
"hugehuge" in {
//
} tag("a")
指定して実行
// SeqをMapに | |
// Seq(1,2,3) => Map(1 -> 2, 2 -> 3, 3 -> 4) | |
Seq(1, 2, 3).flatMap { i => | |
Map(i -> (i + 1)) | |
}.toMap | |
// SomeにnullいれてもNoneにはならない | |
Some(null) == None // false | |
Option(null) == None // true |
specs2でテストでtagをつけて
"hugehuge" in {
//
} tag("a")
指定して実行
val pp1 = Seq(1, 2) zip Seq(3, 4) | |
println(pp1) | |
// List((1,3), (2,4)) | |
case class Image(width: Seq[Int], height: Seq[Int]) | |
val images = Seq(Image(Seq(200, 300), Seq(210, 310)), Image(Seq(400, 500), Seq(510, 610))) | |
val pp2 = images.flatMap { b => | |
b.width zip b.height |
abstract class Interface(_id: Int) { | |
def id: Int = _id | |
} | |
trait Like { | |
self : Interface => | |
def get: Int = this.id | |
} | |
trait Param { |
var params = {b: 1, a: 5, c: 2}; | |
_.pick(params, _.keys(params).sort()); // {a: 5, b:1, c:2} |
var obj = {b: 1, a: 3, c:2}; | |
_.map(_.keys(obj).sort(), function(key) { | |
return key + '=' + obj[key]; | |
}).join('&'); | |
// a=3&b=1&c=2 |
/** | |
* $formのデータをkey:valueで取得 | |
* @param {jQuery} $form | |
* @return {Object} {name: "value", ...} | |
*/ | |
getValues: function($form) { | |
return _.chain($form.serializeArray()) | |
.map(function(obj) { return [obj.name, obj.value] }) | |
.object() | |
.value(); |
#!/bin/sh | |
# | |
# hbase - this script starts and stops the hbase-standalone daemon | |
# | |
# chkconfig: - 85 15 | |
# description: hbase-standalone daemon | |
# processname: hbase-standalone | |
# Source function library. | |
. /etc/rc.d/init.d/functions |
/** | |
* 文字列内の数値をインクリメントする | |
* ex) TextIncrementer("abc123efg456hij").++() // abc124efg457hij | |
* ex) TextIncrementer("あいう1 2 3えお").++() // あいう2 3 4えお | |
* @param t インクリメントしたい文字列 | |
* @param incrValue いくつインクリメントするか | |
* @return インクリメントした文字列 | |
*/ | |
case class TextIncrementer(t: String, incrValue: Int = 1) { | |
def ++(i: Int = 0, n: String = ""): String = { |
import java.nio.file.{ FileSystem, FileSystems, WatchKey, WatchService, StandardWatchEventKinds } | |
import java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY | |
import scala.collection.JavaConverters._ | |
import scala.concurrent._ | |
import ExecutionContext.Implicits.global | |
object Main { | |
def main(args: Array[String]) { | |
FileWatcher("/tmp/build/classes", "hoge.html").watch { | |
println("change") |