Skip to content

Instantly share code, notes, and snippets.

Nizamutdinov Adel adelnizamutdinov

Block or report user

Report or block adelnizamutdinov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@adelnizamutdinov
adelnizamutdinov / cli.kt
Last active Oct 28, 2019
Calling CLI tools using kotlin coroutines with cancellation support
View cli.kt
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import kotlinx.coroutines.suspendCancellableCoroutine
import java.io.StringWriter
sealed class Cli {
data class Ok(val stdout: String) : Cli()
data class Err(val stderr: String) : Cli()
View json.swift
enum ColumnType: String, Codable {
case line
case x
case area
case bar
}
typealias LineId = String
struct Columns {
@adelnizamutdinov
adelnizamutdinov / multitouch.kt
Last active Apr 5, 2019
Android multitouch helper
View multitouch.kt
import android.view.MotionEvent
typealias PxF = Float
typealias X = PxF
typealias Y = PxF
typealias PointerId = Int
inline fun MotionEvent.multiTouch(
View ActivityResult.kt
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,
View MainActivity.java
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;
@adelnizamutdinov
adelnizamutdinov / tat.py
Created Apr 22, 2017
translate between tatar and russian from CLI
View tat.py
#!/usr/bin/env python3
import sys
from urllib.parse import quote
from lxml import html
if len(sys.argv) > 1:
word = sys.argv[1]
@adelnizamutdinov
adelnizamutdinov / lastlove.py
Created Apr 14, 2017
love last.fm nowplaying from CLI
View lastlove.py
#!/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,
@adelnizamutdinov
adelnizamutdinov / client.kt
Last active Apr 14, 2019
CLI instant messenger in 60 lines with ZMQ
View client.kt
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)
@adelnizamutdinov
adelnizamutdinov / cursor.kt
Created Jul 21, 2016
folding cursors all day
View cursor.kt
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
@adelnizamutdinov
adelnizamutdinov / Cargo.toml
Created May 26, 2016
Simple JNI with Kotlin and Rust
View Cargo.toml
[package]
name = "hello"
version = "0.1.0"
authors = ["adelnizamutdinov"]
[lib]
crate-type = ["dylib"]
[dependencies]
jni-sys = "0.1.0"
You can’t perform that action at this time.