Skip to content

Instantly share code, notes, and snippets.

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
sudo update-alternatives --config java
sudo update-alternatives --config javac
@vinoct6
vinoct6 / mongodb_find_inside_list.kt
Created August 3, 2018 03:35
Spring Data Mongo search inside list
package com.docker.kubetest
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.ApplicationArguments
import org.springframework.boot.ApplicationRunner
import org.springframework.data.mongodb.core.mapping.Document
import org.springframework.data.mongodb.repository.MongoRepository
import org.springframework.stereotype.Component
@Document
@vinoct6
vinoct6 / jsonread.kt
Last active July 20, 2018 09:59
Klaxon: Read and bind a json array in Spring application
implementation ('com.beust:klaxon:3.0.1')
[{
"name" : "Vinoth",
"age" : "25",
"languages" : [
"Tamil",
"English",
"Spanish"
]
@vinoct6
vinoct6 / ExceptionHandling.kt
Last active July 21, 2018 11:45
ExceptionHandling in Spring boot
import org.springframework.hateoas.VndErrors
import org.springframework.http.HttpStatus
import org.springframework.http.HttpStatus.*
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.ResponseStatus
import java.util.*
@vinoct6
vinoct6 / aopAndAnnotations.kt
Created July 11, 2018 11:01
Spring AOP and Kotlin annotation
package com.docker.kubetest
import org.aspectj.lang.JoinPoint
import org.aspectj.lang.annotation.Aspect
import org.aspectj.lang.annotation.Before
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.stereotype.Component
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
@vinoct6
vinoct6 / Kotlin let operator
Last active July 5, 2018 11:26
Interesting bits in Kotlin
val person: Person? = getTheBestPersonInTheWorld()
if (person != null) sendEmailTo(person.email)
can be replaced by
getTheBestPersonInTheWorld()?.let { sendEmailTo(it.email) }
//Use Extension functions defined on null
$ cat .vimrc
filetype on
filetype indent on
filetype plugin on
syntax enable
set showmatch
set smartcase
set number
set incsearch
set hlsearch
function mySetTimeOut(fn,delay){
fn();
}
function myFunc(){
console.log('This is my function');
console.log(this);
}
var obj = {
@vinoct6
vinoct6 / simpleClosure.js
Created April 18, 2016 11:35
A simple closure
/*function bar() has a closure over the scope of foo() (and
indeed, even over the rest of the scopes it has access to, such as the
global scope in our case). Put slightly differently, it’s said that bar()
closes over the scope of foo().*/
function foo() {
var a = 2;
function bar() {
console.log( a ); // 2
}
@vinoct6
vinoct6 / Module.js
Created April 18, 2016 11:11
classic module pattern
var foo = (function MyModule(){
var stmt = "Hello World";
var b = "another thing";
function saySomething(){
console.log(stmt);
}