Skip to content

Instantly share code, notes, and snippets.

View nuboat's full-sized avatar

Peerapat CC nuboat

View GitHub Profile
@nuboat
nuboat / Hangman.scala
Last active September 22, 2018 15:11
def f(w: String, l: List[String]) = l.foldLeft(w)((x,y) => x.replace(y,"")).isEmpty
f("bigbears", List("b", "i", "g", "e", "a", "r", "s"))
print(100*(1-readLine.split(' ').map(_.toFloat).reduceLeft(_/_)))
@TableSchema(pk = "id", name = "accounts")
case class AccountEntity(id: Long
, clientId: Long
, isActive: Boolean
, isVerify: Boolean
, accountRole: Int
, username: String
, passwordHash: String = ""
, email: String = ""
, firstname: String = ""
@nuboat
nuboat / README.txt
Last active August 19, 2016 10:30
Print A n^n
n = 3
2,2,2
2,2,1
2,2,0
2,1,2
2,1,1
2,1,0
2,0,2
2,0,1
2,0,0
@nuboat
nuboat / pom.xml
Last active July 1, 2016 03:19
OA-Training
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>thjug</groupId>
<artifactId>Trainging</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
// scalastyle:off
package services.slick
import javax.inject.Singleton
import define.JobLevel
import intercept.Logging
import models.{GroupJobLevel, Subscriber}
import org.postgresql.util.PSQLException
import play.api.Logger
@nuboat
nuboat / application.properties
Last active August 29, 2015 14:27
SpringJdbc
server.port = 9090
spring.thymeleaf.cache = false
spring.datasource.url=jdbc:oracle:thin://@10.202.100.151:1521/AAAA
spring.datasource.username=xxx
spring.datasource.password=xxx
spring.datasource.driverClassName=oracle.jdbc.OracleDriver
spring.datasource.url=jdbc:postgresql://localhost/training
spring.datasource.username=postgres
spring.datasource.password=
spring.datasource.driverClassName=org.postgresql.Driver
@nuboat
nuboat / ApiSpec.scala
Last active August 29, 2015 14:23
Spec of Section in Parsley
import org.scalatest.{FlatSpec, Matchers}
import play.api.test.Helpers._
import play.api.test._
class ApiSpec extends FlatSpec with Matchers {
"GET /api/get/:username" should
"return json result" in new WithApplication {
val home = route(FakeRequest(GET, "/api/get/nb")).get
...
def groupJobLevel(): List[GroupJobLevel] = {
val cache = Cache.get("GROUPJOBLEVEL")
if (cache.isDefined) {
return cache.get.asInstanceOf[List[GroupJobLevel]]
}
val result = queryGroupJobLevel()
if (result != null) {
Cache.set("GROUPJOBLEVEL", result)