Skip to content

Instantly share code, notes, and snippets.

View JEuler's full-sized avatar
🍉

Ivan Terekhin JEuler

🍉
View GitHub Profile
@JEuler
JEuler / some_kind_of_store.dart
Last active December 10, 2019 07:53
MobX Store example
part 'some_kind_of_store.g.dart';
/// User Resources Store
class SomeKindOfStore = SomeKindOfStoreBase with _$SomeKindOfStore;
/// User Resources Store
abstract class SomeKindOfStoreBase with Store {
final WebService _webService;
final StorageService _storageService;
@JEuler
JEuler / flutter_app.dart
Last active December 10, 2019 07:52
FlutterAppMultiProvider
class FlutterApp extends StatelessWidget {
final WebService _webService;
final StorageService _storageService;
FlutterApp(this._webService, this._storageService);
@override
Widget build(BuildContext context) {
var localizationDelegate = LocalizedApp.of(context).delegate;
@JEuler
JEuler / reg_comments.txt
Created September 4, 2019 08:25
Regular to match comments.
"[^"\\]*(?:\\[\W\w][^"\\]*)*"|(\/\/.*)
@JEuler
JEuler / BaseActivityRx.kt
Created March 6, 2019 13:05
RxLifecycle helper
protected fun <T> subscribe(observable: Observable<T>?, observer: Observer<T>?, bind: Boolean = true) {
if (observable != null && observer != null) {
if (bind) {
observable
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread(), true)
.bindToLifecycle(this)
.subscribe(observer)
} else {
observable
@JEuler
JEuler / BaseActivityRx.java
Created March 6, 2019 13:04
RxGroups helper
protected <T> void autoResubscribe(Observable<T> observable, ResubscriptionObserver<T> resubscriptionObserver) {
if (getObservableGroup() != null && observable != null) {
observable
.compose(getObservableGroup().<T>transform((String) resubscriptionObserver.resubscriptionTag()))
.compose(applySchedulers())
.subscribe(resubscriptionObserver);
}
}
@JEuler
JEuler / SendDataJob.kt
Created February 25, 2019 17:01
Priority queue job example
class SendDataJob(private val dataInput: SomeDataClass) :
Job(Params(1).requireNetwork().persist().groupBy(“tag”)), KoinComponent {
// job is queued, need to update local storage
override fun onAdded() {
}
@Throws(Throwable::class)
override fun onRun() {
val sendService: SendService? by inject()
sendService?.sendData(dataInput)
@JEuler
JEuler / SendDataWorker.kt
Created February 25, 2019 17:02
SendData Worker example
class SendDataWorker(context: Context, params: WorkerParameters) : Worker(context, params), KoinComponent {
@SuppressLint("CheckResult")
override fun doWork(): Result {
val sendService: SendService? by inject()
val data = inputData.getString("data")
val dataInput = getGsonForJoda()?.fromJson(data, SomeDataClass::class.java)
return try {
val query = sendService?.sendData(dataInput)
?.blockingGet()
@JEuler
JEuler / build.gradle
Created February 1, 2019 08:32
Example of packing options
packagingOptions {
exclude "lib/armeabi/libsnappydb-native.so"
exclude "lib/mips/libsnappydb-native.so"
exclude "lib/mips64/libsnappydb-native.so"
}
Exclude not very useful libs
@JEuler
JEuler / circle.yml
Created January 29, 2019 16:50
Basic Circle CI setup
version: 2
jobs:
build:
working_directory: ~/code
docker:
- image: circleci/android:api-28-alpha
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
@JEuler
JEuler / ShowDebugKeyFingerprints.sh
Created May 9, 2018 06:44 — forked from j796160836/ShowDebugKeyFingerprints.sh
Show android debug key's fingerprints. (MD5 / SHA1 / SHA256)
#!/bin/bash
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android