Skip to content

Instantly share code, notes, and snippets.

View guliash's full-sized avatar
🏠
Working from home

Artem Gilmudinov guliash

🏠
Working from home
View GitHub Profile
@guliash
guliash / Main.java
Last active September 3, 2015 20:42
154
import java.io.InputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStreamReader;
import java.io.IOException;
public ArrayDeque<PairInt> findPoints(PairInt[] points) {
ArrayDeque<PairInt> result = new ArrayDeque<>();
int n = points.length;
int val, j;
int leftBorder, rightBorder;
leftBorder = Integer.MAX_VALUE;
rightBorder = Integer.MIN_VALUE;
Arrays.sort(points, new Comparator<PairInt>() {
@Override
public int compare(PairInt o1, PairInt o2) {
@guliash
guliash / Main.java
Last active February 7, 2016 06:57
acmp191
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;
/**
public class TaskAcmpFast {
int n;
int m;
int k;
boolean[] used;
String[] tickets;
long[] wins;
public void solve(int testNumber, InputReader in, PrintWriter out) {
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
@guliash
guliash / Checker.java
Last active October 1, 2017 23:06
check whether fragment destroyed permanently
void onDestroy() {
if (getActivity.isFinishing()) {
//разрушаемся навсегда
} else if (getActivity.isChangingConfigurations()) {
//разрушаемся не навсегда
} else {
//разрушаемся навсегда
//кажется тут остаются варианты - удалили из бэк стека или вызвали remove у транзакции
//Или уничтожился процесс - тогда кеш презентеров все равно теряется
}
@guliash
guliash / Reusable.java
Created August 13, 2017 08:41
Reusable
@Component(modules = MyModule.class)
public interface ComponentA {
OkHttpClient a();
SubcomponentB subcomponentB();
SubcomponentC subcomponentC();
}
@guliash
guliash / MembersInjectExample.java
Created October 11, 2017 13:17
Dagger2 MembersInjector example
public class Main {
public static void main(String[] args) {
A a = new A();
DaggerComponentA.create().inject(a);
B b = new B();
a.injector.injectMembers(b);
System.out.println(b.string);
@guliash
guliash / RxTest.java
Created December 11, 2017 15:47
RetryWhenWithoutComposingErrors
@Test
public void retryWhenWithoutComposingErrors() {
TestSubscriber subscriber = new TestSubscriber();
Observable.just(1)
.retryWhen(errors -> Observable.never())
.subscribe(subscriber);
subscriber.assertCompleted();
}
@guliash
guliash / Main.java
Created July 14, 2018 12:38
Fake components
package com.guliash.dagger;
import dagger.Component;
import javax.inject.Scope;
public class Main {
public static void main(String[] args) {
}