Showing posts with label scala. Show all posts
Showing posts with label scala. Show all posts

Wednesday, December 21, 2016

Scala implementation of the Glicko-2 system

I did not found a Scala realization of the Glicko-2 system as a library in a repository, so I did a new one and publish it to maven. Feel free to use it:

Github

https://github.com/andriykuba/scala-glicko2

Maven

<dependency>
  <groupId>com.github.andriykuba</groupId>
  <artifactId>scala-glicko2</artifactId>
  <version>1.0.0</version>
</dependency>

sbt

libraryDependencies += "com.github.andriykuba" % "scala-glicko2" % "1.0.0" 

Precision

The original paper has an issue with precision: https://github.com/andriykuba/scala-glicko2#precision

Monday, September 26, 2016

Handlebars module for Play Framework

I wrap up all my "handlebars around" code in the module play-handlebars. You can use it as easy as
public class HomeController extends Controller { 

    @Inject
    private HandlebarsApi handlebarsApi;

    public Result index() {
        // Data. 
        final Map data = new HashMap<>();
        data.put("title", "Page Title");
        data.put("header", "Header");
        data.put("main", ImmutableMap.of("article", "Main Article"));
        data.put("footer", "Footer");

        // Fill it with the data.
        final Content page = handlebarsApi.html("page", data, Context.current().lang().code());

        // Return the page to the client. 
        return ok(page);
    }
}
Or
class HomeController @Inject() (val handlebarsApi: HandlebarsApi)extends Controller with HandlebarsSupport{
  def index = Action { implicit request =>{
    val jsonData = 
      Json.obj("users" -> Json.arr(
        Json.obj(
          "name" -> "Jhon",
          "age" -> 4,
          "role" -> "Worker"
        ),
        Json.obj(
          "name" -> "Duck",
          "age" -> 6,
          "role" -> "Administrator"
        )))
    val page = render("page", jsonData)
    Ok(page)
  }}
}