Skip to content

Instantly share code, notes, and snippets.

Peerapat A nuboat

Block or report user

Report or block nuboat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Expecte.rb
{1=>[1,1],
3=>[1,1,1,1],
5=>[1,1,1]
7=>[1,1],
2=>[1,1,1]}
View InstallCert.java
package com.thjug.tools.sslcert;
import javax.net.ssl.*;
import java.io.*;
import java.security.KeyStore;
import java.security.MessageDigest;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
/**
@nuboat
nuboat / HIndex.scala
Last active Aug 29, 2015
Thailandoi Programming Contest #2, March
View HIndex.scala
case class HIndex(publishs: List[Int]) {
val checklist = 0.to(publishs.max).sortWith(_ > _)
def calc(): Int = checklist.find(c => rule1(c) && rule2(c)).get
private def refer(c: Int): List[Int] = publishs.filter(_ >= c).toList
private def rule1(c: Int): Boolean = refer(c).size >= c
@nuboat
nuboat / TwoSum.scala
Last active Aug 29, 2015
ปัญหา 2-SUM
View TwoSum.scala
object TwoSum {
def sum(n: Int, sorted: ArrayBuffer[Int]): Boolean = sorted.par.find(x => isMatch(x, n, sorted)).isDefined
def isMatch(x: Int, n: Int, sorted: ArrayBuffer[Int]): Boolean = sorted.find( y => (x + y) == n).isDefined
}
View Currency.java
/*
* (c) nuboat.net 2012
*/
package net.nuboat.currency;
/**
*
* @author nuboat
*/
import java.util.StringTokenizer;
View LocalCache.java
package intercept;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface LocalCache {
View SlickSubscriberService.scala
...
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)
@nuboat
nuboat / ApiSpec.scala
Last active Aug 29, 2015
Spec of Section in Parsley
View ApiSpec.scala
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
View application.properties
spring.datasource.url=jdbc:postgresql://localhost/training
spring.datasource.username=postgres
spring.datasource.password=
spring.datasource.driverClassName=org.postgresql.Driver
View application.properties
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
You can’t perform that action at this time.