Skip to content

Instantly share code, notes, and snippets.

View jemshit's full-sized avatar
👑
Solving Problems

Jemshit Iskanderov jemshit

👑
Solving Problems
View GitHub Profile
@jemshit
jemshit / text_colors.xml
Last active March 21, 2021 01:07
Android Text Colors according to Material Design Pattern
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Dark Text Color for Light Background -->
<color name="textDarkPrimary">#DE000000</color> <!--DE for %87 opacity-->
<color name="textDarkSecondary">#8A000000</color> <!--8A for %54 opacity-->
<color name="textDarkDisabled">#61000000</color> <!--61 for %38 opacity-->
<!-- White Text Color for Dark Background -->
<color name="textLightPrimary">#FFFFFF</color> <!--%100 opacity-->
@jemshit
jemshit / LazySingletonThreadSafe3.java
Last active November 6, 2016 19:35 — forked from oznus/LazySingletonThreadSafe3.java
Singleton: synchronized, shared across Threads
public class LazySingleton {
private LazySingleton() {
}
private static volatile LazySingleton sInstance;
public static LazySingleton getInstance() {
if (sInstance == null) {
100% — ff
99% — fc
98% — fa
97% — f7
96% — f5
95% — f2
94% — f0
93% — ed
92% — eb
91% — e8
@jemshit
jemshit / HttpStatusCodeHelper.java
Last active July 29, 2021 11:28
HTTP Status Codes, Helper Class in JAVA
public class HttpStatusCodeHelper {
/**
* Gets Http Status Code Information for given Code. No Reflection, No Enum
* @param code
* @return type + text
*/
public static String getHttpTypeAndTextByCode(final int code) {
//region 1xx
@jemshit
jemshit / RetryWithDelay.java
Last active January 13, 2021 09:25
RxJava Retry Web Service Connection incrementally if there is Network Kind of Error.
public class RetryWithDelay implements Func1<Observable<? extends Throwable>, Observable<?>> {
private int numberOfTry;
private int delay;
private int retryCount = 1;
private final TimeUnit timeUnit;
public RetryWithDelay(int numberOfTry, int delay, TimeUnit timeUnit) {
this.numberOfTry = numberOfTry;
this.delay = delay;
@jemshit
jemshit / .bash_profile
Last active May 6, 2020 08:33
Custom .bash_profile for MacOs
#### cd to the path of the front Finder window
cdf() {
target=`osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)'`
if [ "$target" != "" ]; then
cd "$target"; pwd
else
echo 'No Finder window found' >&2
fi
}
@jemshit
jemshit / proguard-rules.pro
Last active April 27, 2024 08:54
Proguard Rules for Android libraries
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}
### RxJava, RxAndroid (https://gist.github.com/kosiara/487868792fbd3214f9c9)
-keep class rx.schedulers.Schedulers {
public static <methods>;
@jemshit
jemshit / BaseFragment.java
Created December 1, 2016 12:21
Do something when Fragment is visible
public class BaseFragment extends Fragment {
private boolean fragmentResume=false;
private boolean fragmentVisible=false;
private boolean fragmentOnCreated=false;
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
import com.jakewharton.rx.ReplayingShare;
import com.jakewharton.rxrelay2.PublishRelay;
import com.jakewharton.rxrelay2.Relay;
import io.reactivex.Observable;
import java.util.concurrent.TimeUnit;
public class HotReactiveData {
// Problems to solve:
import com.jakewharton.rx.ReplayingShare;
import com.jakewharton.rxrelay2.PublishRelay;
import com.jakewharton.rxrelay2.Relay;
import io.reactivex.Observable;
import java.util.concurrent.TimeUnit;
public class HotReactiveDataExpiration {
// Problems to solve: