Skip to content

Instantly share code, notes, and snippets.

View igorlukanin's full-sized avatar
🚀
All things growth @cube-js

Igor Lukanin igorlukanin

🚀
All things growth @cube-js
View GitHub Profile
@igorlukanin
igorlukanin / max.kt
Last active October 10, 2015 08:25
There's nothing wrong with nulls if you have proper types :)
fun max<T : Any>(list: List<T>, weight: (T) -> Int): T? {
return when (list.size()) {
0 -> null
1 -> list.first()
else -> list.reduce({ a, b -> if (weight(a) > weight(b)) a else b })
}
}
fun main(args: Array<String>) {
println( max(listOf("a", "bcd", "ef"), { it.length() }) )
@igorlukanin
igorlukanin / RethinkDB.kt
Last active October 29, 2015 03:35
Using RethinkDB Java driver with Kotlin
/**
* Database.kt
*/
import com.rethinkdb.RethinkDB
import com.rethinkdb.gen.ast.ReqlExpr
import com.rethinkdb.net.Connection
import com.rethinkdb.net.ConnectionInstance
object Database {
private lateinit var db: String
@igorlukanin
igorlukanin / falkeyn.js
Created June 30, 2016 12:37
FalkeynScript
// ==UserScript==
// @name FalkeynScript
// @match *
// ==/UserScript==
/* jshint multistr: true */
(function() {
var css = '\
<style>\
@igorlukanin
igorlukanin / Wtf.kt
Created August 22, 2016 05:31
wtf-kotlin
package Wtf
// Primitives
operator fun Int.plus(that: String) = "$this$that"
operator fun String.plus(that: Int) = "$this$that"
@igorlukanin
igorlukanin / Dasha.md
Last active June 15, 2017 04:24
🚀
var streamReader = new StreamReader("c:\\file.txt");
try
{
Console.Write(streamReader.ReadToEnd());
}
finally
{
if (streamReader != null)
streamReader.Dispose();
}
@RestController
class GreetingController {
val counter = AtomicLong()
@GetMapping("/greeting")
fun greeting(@RequestParam(value = "name", defaultValue = "World") name: String) =
Greeting(counter.incrementAndGet(), "Hello, $name")
}
@igorlukanin
igorlukanin / quizzes.md
Last active November 7, 2017 08:28
SKB Kontur @ HighLoad++
{
"asd": "123" }