Skip to content

Instantly share code, notes, and snippets.

View hhariri's full-sized avatar

Hadi Hariri hhariri

View GitHub Profile
import javax.servlet.http.HttpServlet
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import javax.servlet.annotation.WebServlet as web
import javax.inject.Inject
import javax.enterprise.context.Dependent
web(name = "Hello", value = array("/hello"))
public class HomeController : HttpServlet() {
val appServer = AppServer()
appServer.get("/", {
response.send("Hello!")
}
appServer.start() // port 3000 default
buildscript {
ext.kotlin_version = '0.1-SNAPSHOT'
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
fun plus(number1: Int, number2: Int): Int {
if (zero(number2)) {
return number1
} else {
return (add1(plus(number2, sub1(number1))))
}
}
fun myFunc(f: T-> Any) = f
val something = myFunc {
}

You have:

package kotlin.browser

Members

Name Summary
_document   private val _document: Document
document Provides access to the current active browsers DOM for the currently visible page.
  public val document: Document
val http = EasyHttp()
http.get("http://localhost/customers", callback = {
assertEquals("joe", asJson("results.customers[10].name"))
})
fun setDate(year: Int, month: Int, day: Int): Date {
val cal = Calendar.getInstance()
cal.set(year, month - 1, day);
return cal.getTime()
}
data class Customer(val id: Int, val name: String)
val getPersons = routeHandler {
buildscript {
version = '0.1-SNAPSHOT'
repositories {
mavenCentral()
maven {
url 'http://oss.sonatype.org/content/repositories/snapshots'
}
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.1-SNAPSHOT'
public class CustomerController [Inject] (val customerRepository: CustomerRepository) {
fun list() {
customerRepository.getAll()
}
}