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
<?php | |
$array = ['A', 'A', 'A', 'B', 'B', 'C', 'D']; | |
function selectDuplicates($array) { | |
$duplicate = array_filter(array_count_values($array), function($v) { | |
return $v > 1; | |
}); | |
return array_keys($duplicate); | |
} |
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
val (text, status) = args.headOption.collect { | |
case "new" => newCommand _ | |
case "help" => helpCommand _ | |
}.map { command => | |
command(args.drop(1)) | |
}.getOrElse { | |
(Colors.red("Error"), -1) | |
} |
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
app.configuration.getBoolean("trustxforwarded").orElse(Some(false)) |
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
<?php | |
preg_match('/^([[:alnum:]]*)([[:^alnum:]]*)$/u', 'aaaaああああ', $matches); | |
if ($matches[0] === 'aaaaああああ') { | |
echo 'MATCH!' | |
} | |
/* | |
UTF8モードだとalnumでひらがながマッチする |
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
module.exports = (time) -> | |
elapse = | |
if time instanceof Date | |
time.getTime() - Date.now() | |
else if typeof time == "number" | |
time - Date.now() | |
else | |
console.warn "Given a invalid date type(\"#{typeof time}\") arguments. expected date type is Date or Number." | |
"" | |
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
object Application extends Controller { | |
implicit val charset = Codec.javaSupported("iso-8859-1") | |
def index = Action { | |
Ok(<h1>hello</h1>).as(HTML) | |
} | |
} |
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 SlickDBSessionElement extends StackableController { | |
self: Controller => | |
import play.api.db.slick | |
type Session = slick.Session | |
case object DBSessionKey extends RequestAttributeKey[Session] | |
override def proceed[A](req: RequestWithAttributes[A])(f: RequestWithAttributes[A] => Result): Result = { | |
val session:Session = play.api.db.slick.DB.createSession() |
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
$ scaladoc -d doc/ -s src/main/scala/**/*.scala |
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
implicit def session(implicit request: RequestHeader) = request.session |
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
class ClassA(val label: String) | |
implicit val arg1:ClassA = new ClassA("ぼくは暗黙的パラメータ") // implicit def foo のための暗黙的パラメータ定義 | |
implicit def foo(implicit a: ClassA):String = { // 引数の implicit 消すと 暗黙的パラメータ見つからないってエラーになる | |
println("fooだよ") | |
a.label | |
} | |
def bar()(implicit argStr:String):String = { |
OlderNewer