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 models | |
import play.api.db._ | |
import play.api.Play.current | |
import anorm._ | |
import anorm.SqlParser._ | |
case class User(email: String, name: String, password: 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
require "optparse" | |
require "date" | |
OptionParser.accept(Date) do |s,| | |
begin | |
Date.parse(s) if s | |
rescue | |
raise OptionParser::InvalidArgument, s | |
end | |
end |
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.util.Random | |
object Main { | |
def main(args:Array[String]) = { | |
findSTAP() | |
} | |
def findSTAP():Unit = | |
randomString(4) match { |
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.util.Random | |
object Main { | |
val random = new scala.util.Random | |
def main(args:Array[String]):Unit = { | |
Iterator.continually(findSTAP).takeWhile(_ != "STAP").toList | |
println("見つかったよ!") |
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 sample(strOpt:Option[String]) = strOpt match { | |
case Some(str) if str == "hoge" => Some(str) | |
case _ => None | |
} |
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 java.util.Scanner; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class Main { | |
private static final Pattern pattern = Pattern.compile("([a-z])\\1*"); | |
public static void main(String[] args) { | |
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 java.util.Arrays; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
public class Main { | |
public static void main(String[] args) throws Exception { | |
List<Integer> before = Arrays.asList(1,2,3,4,5); | |
List<Integer> after = Arrays.asList(1,4,5,6); | |
System.out.print("removed:"); |
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
scalaVersion := "2.11.8" | |
lazy val FunTest = config("fun") extend Test | |
lazy val root = (project in file(".")). | |
configs(FunTest). | |
// important see http://www.scala-sbt.org/0.13/docs/Testing.html#Additional+test+configurations+with+shared+sources | |
settings(inConfig(FunTest)(Defaults.testTasks): _*). | |
settings( | |
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test", |
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
### Keybase proof | |
I hereby claim: | |
* I am takashima0411 on github. | |
* I am takashima0411 (https://keybase.io/takashima0411) on keybase. | |
* I have a public key ASDnNwTJsqXtJDXkRpREyya6rAyCHPmfUPFXu2vGpCxRvgo | |
To claim this, I am signing this object: |
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
private val bucket = new NanoTimeTokenBucket(1, 1250.milliseconds.toNanos) | |
def of = synchronized(bucket.offer(1).nanos.toMillis) | |
def req[T](uri: Uri, opWhenSuccess: HttpResponse => Source[T, NotUsed]): Future[Source[T, NotUsed]] = Future { | |
RestartSource.withBackoff(200.millis, 30.seconds, 2.0, 3) { () => | |
Source.fromFutureSource { | |
Thread.sleep(of) | |
Http().singleRequest(HttpRequest(uri = uri)).map { res => | |
if (res.status.intValue() == 200) { | |
res.headers.find(_.is("retry-after")).foreach(h => logger.debug(h.toString())) |
OlderNewer