Skip to content

Instantly share code, notes, and snippets.

View jdsingh's full-sized avatar
🎯
Focusing

Jagdeep Singh jdsingh

🎯
Focusing
View GitHub Profile
@objcode
objcode / ConcurrencyHelpers.kt
Last active May 2, 2024 08:05
Helpers to control concurrency for one shot requests using Kotlin coroutines.
/* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@Takhion
Takhion / RxFilterIsInstance.kt
Last active June 29, 2020 17:04 — forked from rock3r/RxFilterIsInstance.kt
Port Kotlin's awesome filterIsInstance() to RxJava — one call to filter by type and map-cast to that type
package me.seebrock3r.extensions.reactivex
import io.reactivex.Flowable
import io.reactivex.Maybe
import io.reactivex.Observable
import io.reactivex.Single
@Suppress("UNCHECKED_CAST") // The cast happens after we filter by type so it's safe
inline fun <reified R> Flowable<*>.filterIsInstance(): Flowable<R> =
filter { it is R }
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
@Pulimet
Pulimet / AdbCommands
Last active May 22, 2024 09:34
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
task incrementVersion << {
def propsFile = file("../gradle.properties")
def propsText = propsFile.getText()
def patternVersionNumber = Pattern.compile("app_version=(\\d+)\\.(\\d+)\\.(\\d+)")
def matcherVersionNumber = patternVersionNumber.matcher(propsText)
matcherVersionNumber.find()
def majorVersion = Integer.parseInt(matcherVersionNumber.group(1))
def minorVersion = Integer.parseInt(matcherVersionNumber.group(2))
machine:
environment:
TERM: "dumb"
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx5120m -XX:+HeapDumpOnOutOfMemoryError"'
ANDROID_HOME: /usr/local/android-sdk-linux
java:
version:
oraclejdk8
dependencies:
pre:
@paolorotolo
paolorotolo / RealmBackupRestore.java
Last active June 17, 2018 17:31
Class to easily backup/restore data from Realm.
package org.glucosio.android.tools;
import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.widget.Toast;
@joar
joar / jq-insert-var.sh
Last active May 3, 2024 13:41
Add a field to an object with JQ
# Add field
echo '{"hello": "world"}' | jq --arg foo bar '. + {foo: $foo}'
# {
# "hello": "world",
# "foo": "bar"
# }
# Override field value
echo '{"hello": "world"}' | jq --arg foo bar '. + {hello: $foo}'
{
@koesie10
koesie10 / ApiModule.java
Created October 3, 2015 07:40
Retrofit 1 error handling behaviour in Retrofit 2
// Dagger 1 example
@Module(
complete = false,
library = true
)
public final class ApiModule {
@Provides
@Singleton
Retrofit provideRetrofit(Gson gson, Application app) {
return new Retrofit.Builder()
@nesquena
nesquena / ItemClickSupport.java
Last active April 29, 2024 16:23
Click handling for RecyclerView
/*
Source: http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/
USAGE:
ItemClickSupport.addTo(mRecyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
@Override
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
// do it
}
});