Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Nizamutdinov Adel adelnizamutdinov

View GitHub Profile
@adelnizamutdinov
adelnizamutdinov / EmptyRecyclerView.java
Created Nov 1, 2014
RecyclerView doesn't have an emptyView support, we gotta fix that
View EmptyRecyclerView.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class EmptyRecyclerView extends RecyclerView {
@Nullable View emptyView;
@adelnizamutdinov
adelnizamutdinov / client.kt
Last active Sep 29, 2018
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)
View RxMediaPlayer.java
/*
MIT License
Copyright (c) 2015 Adel Nizamutdinov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
View RxMediaRecorder.java
import android.media.MediaRecorder;
import android.support.annotation.NonNull;
import com.f2prateek.rx.android.schedulers.AndroidSchedulers;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.subscriptions.Subscriptions;
public class RxMediaRecorder {
View googles.kt
import android.os.Bundle
sealed class GoogleApiAlgebra
data class Connected(val bundle: Bundle?) : GoogleApiAlgebra()
data class Suspended(val suspended: Int) : GoogleApiAlgebra()
data class Failed(val result: ConnectionResult) : GoogleApiAlgebra()
suspend fun connect(client: GoogleApiClient): GoogleApiAlgebra =
suspendCancellableCoroutine { cont ->
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,
@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"
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,
You can’t perform that action at this time.