Skip to content

Instantly share code, notes, and snippets.

👨‍💻
contributing to open-source

AMIT SHEKHAR amitshekhariitbhu

👨‍💻
contributing to open-source
Block or report user

Report or block amitshekhariitbhu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View RxPS.md

Using RxPS - RxJavaPriorityScheduler Library in your Android application

Add this in your build.gradle

implementation 'com.mindorks.scheduler:rxps:0.1.0'

Setting low level priority for a task - use RxPS.low()

getObservable()
View PaginationActivity.java
public class PaginationActivity extends AppCompatActivity {
// removed for brevity..
private PublishProcessor<Integer> paginator = PublishProcessor.create();
private ProgressBar progressBar;
private boolean loading = false;
private int pageNumber = 1;
private final int VISIBLE_THRESHOLD = 1;
private int lastVisibleItem, totalItemCount;
View PaginationAdapter.java
public class PaginationAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
List<String> items = new ArrayList<>();
public PaginationAdapter() {
}
void addItems(List<String> items) {
this.items.addAll(items);
View PaginationDataSource.java
public class PaginationActivity extends AppCompatActivity {
/**
* Simulation of network data
*/
private Single<List<String>> dataFromNetwork(final int page) {
return Single.just(true)
.delay(2, TimeUnit.SECONDS)
.map(value -> {
List<String> items = new ArrayList<>();
for (int i = 1; i <= 10; i++) {
View FlatMap.java
getUserObservable()
.flatMap(new Function<ApiUser, ObservableSource<UserDetail>>() {
@Override
public ObservableSource<UserDetail> apply(ApiUser apiUser) throws Exception {
return getUserDetailObservable(apiUser);
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getObserver());
View Map.java
getUserObservable()
.map(new Function<ApiUser, User>() {
@Override
public User apply(ApiUser apiUser) throws Exception {
// here we get the ApiUser from the server
User user = new User(apiUser);
// then by converting it into the user, we are returning
return user;
}
})
View PRDownloader.md

Using PRDownloader Library in your Android application

Add this in your build.gradle

compile 'com.mindorks.android:prdownloader:0.3.0'

Do not forget to add internet permission in manifest if already not present

<uses-permission android:name="android.permission.INTERNET" />
View SearchImplementation.java
RxSearchObservable.fromView(searchView)
.debounce(300, TimeUnit.MILLISECONDS)
.filter(new Predicate<String>() {
@Override
public boolean test(String text) throws Exception {
if (text.isEmpty()) {
return false;
} else {
return true;
}
View RxSearchObservable.java
public class RxSearchObservable {
public static Observable<String> fromView(SearchView searchView) {
final PublishSubject<String> subject = PublishSubject.create();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
subject.onComplete();
View mnist.py
from __future__ import print_function
import shutil
import os.path
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
EXPORT_DIR = './model'
if os.path.exists(EXPORT_DIR):
shutil.rmtree(EXPORT_DIR)
You can’t perform that action at this time.