Skip to content

Instantly share code, notes, and snippets.

public class ElapsedTimeIdlingResource implements IdlingResource {
private static ElapsedTimeIdlingResource DEFAULT_RESOURCE;
private final long startTime;
private final long waitingTime;
private ResourceCallback resourceCallback;
public ElapsedTimeIdlingResource(long waitingTime) {
this.startTime = System.currentTimeMillis();
this.waitingTime = waitingTime;
}
@mykola-dev
mykola-dev / KotlinPrefs.kt
Created October 18, 2015 09:42
Shared prefs via Kotlin delegates
package ds.wifimagicswitcher.prefs
import android.content.Context
import android.content.SharedPreferences
import ds.wifimagicswitcher.utils.T
import kotlin.properties.ReadWriteProperty
object KotlinPrefsSetup {
@Volatile var isBatching = false
@mykola-dev
mykola-dev / Ternary Operators
Created September 20, 2015 10:22
Kotlin Ternary Operator implementations
package ds.features.kotlin
fun ternaryTest() {
val rand = Math.random()
val logged = isLoggedIn()
// ternary
val a = (rand > 0.5)(1, 0)
@mykola-dev
mykola-dev / Things.kt
Created September 20, 2015 10:05
Kotlin Ternary Operator implementations
package ds.features.kotlin
fun ternaryTest() {
val rand = Math.random()
// ternary
val a = (rand > 0.5)(1, 0)
val b = isLoggedIn()["logged", "screwed"]
@mykola-dev
mykola-dev / Things.kt
Created September 20, 2015 09:54
Kotlin Ternary Operator implementations
package ds.features.kotlin
fun ternaryTest() {
val rand = Math.random()
// ternary
val a = (rand > 0.5)(1, 0)
val b = isLoggedIn()["logged", "screwed"]
@mykola-dev
mykola-dev / gist:77983977b4127ec417f3
Created September 16, 2015 08:17
gradle log with timestamps
gradle.useLogger(new TimestampEventLogger())
class TimestampEventLogger extends BuildAdapter implements TaskExecutionListener {
def timestamp = 0L
public void beforeExecute(Task task) {
print "> $task.project.name:$task.name "
timestamp = System.currentTimeMillis()
}
@mykola-dev
mykola-dev / example.js
Created September 18, 2013 12:58
Welcome to your first Gist! Gists are simple code reminders. Whenever you come across a piece of code you think might be useful later on, save it as a Gist. With GistBox, you can also tag the Gist with a label. This is especially useful for keeping them organized by language, project or purpose. For more info about GistBox, visit: http://www.gi…
// log an object to the browser console
console.log({ text: "foobar" });