This file contains 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 android.app.Activity | |
import android.content.Intent | |
import android.os.Bundle | |
import kotlinx.coroutines.experimental.suspendCancellableCoroutine | |
typealias RequestCode = Int | |
typealias ResultCode = Int | |
data class ActivityResult( | |
val requestCode: RequestCode, |
This file contains 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 android.app.Activity; | |
import android.os.Bundle; | |
import android.support.annotation.Nullable; | |
import org.opencv.android.CameraBridgeViewBase; | |
import org.opencv.android.JavaCameraView; | |
import org.opencv.android.OpenCVLoader; | |
import org.opencv.core.Mat; | |
import org.opencv.core.MatOfRect; |
This file contains 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/env python3 | |
import sys | |
from urllib.parse import quote | |
from lxml import html | |
if len(sys.argv) > 1: | |
word = sys.argv[1] |
This file contains 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/env python3 | |
import pylast | |
# get the keys https://www.last.fm/api/account/create | |
last_fm = pylast.LastFMNetwork( | |
api_key=API_KEY, | |
api_secret=API_SECRET, | |
username=USERNAME, |
This file contains 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
package chat | |
import org.zeromq.ZMQ | |
import kotlin.concurrent.thread | |
fun main(args: Array<String>): Unit = | |
ZMQ.context(1).use { ctx -> | |
thread { | |
ctx.socket(ZMQ.SUB).use { stream -> | |
stream.connect(MESSAGE_STREAM) |
This file contains 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
inline fun <T> Cursor.fold(zero: T, f: (Cursor, T) -> T): T = | |
if (moveToFirst()) { | |
moveToPrevious() | |
var accum = zero | |
while (moveToNext()) { | |
accum = f(this, accum) | |
} | |
accum | |
} else zero |
This file contains 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
[package] | |
name = "hello" | |
version = "0.1.0" | |
authors = ["adelnizamutdinov"] | |
[lib] | |
crate-type = ["dylib"] | |
[dependencies] | |
jni-sys = "0.1.0" |
This file contains 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 rx.Observable | |
import rx.Subscriber | |
import rx.schedulers.Schedulers | |
import java.lang.ref.PhantomReference | |
import java.lang.ref.ReferenceQueue | |
fun gcTriggers(): Observable<Unit> = | |
Observable.create(triggerLoop()) | |
.subscribeOn(Schedulers.newThread()) |
This file contains 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
data class Lens<S, A>(val get: (S) -> A, val set: (A, S) -> S) | |
fun <A, B, C> Lens<A, B>.compose(that: Lens<C, A>): Lens<C, B> = | |
Lens({ this.get(that.get(it)) }, { c, a -> that.set(this.set(c, that.get(a)), a) }) | |
fun <A, B> Lens<A, B>.traverse(): Lens<List<A>, List<B>> = | |
Lens({ it.map { get(it) } }, { bs, aas -> bs.zip(aas).map { this.set(it.first, it.second) } }) | |
object Play { | |
data class Point(val x: Double, val y: Double) { |
This file contains 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
#!/bin/sh | |
set -e | |
appId=$1 | |
dst=/sdcard/container-${appId} | |
tar=/sdcard/container-${appId}.tar.gz | |
backup_file=${appId}.ab | |
rm -f $backup_file |