This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # -*- coding:utf-8 -*- | |
| import sys | |
| import os | |
| picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') | |
| libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') | |
| if os.path.exists(libdir): | |
| sys.path.append(libdir) | |
| import logging |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| import os | |
| import subprocess | |
| import time | |
| from io import StringIO | |
| from typing import List, Dict | |
| from datadog import initialize, statsd | |
| from kubernetes import client, config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tailrec fun fib(count: Long, seq: List<Int> = listOf(1,1)): List<Int> = | |
| if (seq.size >= count) seq else fib(count, seq + (seq.last() + seq[seq.lastIndex - 1])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Person(val name: String, val city: String) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ComposedObject(textDelegate: EditTextDelegate){ | |
| var text: String? by textDelegate | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class EditTextDelegate { | |
| // represents some editable text view | |
| var editText: EditText = EditText(); | |
| operator fun getValue(thisRef: Any?, property: KProperty<*>): String? { | |
| return editText.text | |
| } | |
| operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String?) { | |
| editText.text = value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var isChecked: Boolean by object { | |
| operator fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { | |
| return checkbox.checked | |
| } | |
| operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) { | |
| checkbox.checked = value | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (1..100000).map { it * it }.find { it.toString().contains(Regex(".*123.*")) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| listOf("This", "is","a", "sentence").reduce { accumulator, s -> accumulator +" " + s } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val listener: (View) -> Unit = { println(“clicked!”) } | |
| some_view.setOnClickListener (listener) | |
| // Or you can use closures | |
| some_view.setOnClickListener {doSomething()} |
NewerOlder