Skip to content

Instantly share code, notes, and snippets.

View amitshekhariitbhu's full-sized avatar
🎯
Helping developers in getting high-paying tech jobs

AMIT SHEKHAR amitshekhariitbhu

🎯
Helping developers in getting high-paying tech jobs
View GitHub Profile
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@interface Status {
public enum Priority {LOW, MEDIUM, HIGH}
Priority priority() default Priority.LOW;
String author() default “Amit”;
int completion() default 0;
}
Class foo = Foo.class;
for(Method method : foo.getMethods()) {
Status statusAnnotation = (Status)method.getAnnotation(Status.class);
if(statusAnnotation != null) {
System.out.println(" Method Name : " + method.getName());
System.out.println(" Author : " + statusAnnotation.author());
System.out.println(" Priority : " + statusAnnotation.priority());
System.out.println(" Completion Status : " + statusAnnotation.completion());
}
}
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)
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;
}
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();
public void onCreate() {
if (DEVELOPER_MODE) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
/* Here first of all, we get the list of users from server.
* Then for each userId from user, it makes the network call to get the detail
* of that user.
* Finally, we get the userDetail for the corresponding user one by one
*/
/*
* This observable return the list of users.
*/
private Observable<List<User>> getUserListObservable() {
/*
* First of all we are getting my friends list from
* server, then by using flatMap we are emitting users
* one by one and then after applying filter we are
* returning only those who are following me one by one.
*/
/*
* This observable return the list of User who are my friends
*/
/*
* This observable return the list of User who loves cricket
*/
private Observable<List<User>> getCricketFansObservable() {
return RxAndroidNetworking.get("https://fierce-cove-29863.herokuapp.com/getAllCricketFans")
.build()
.getObjectListObservable(User.class);
}
/*
RxAndroidNetworking.get("https://fierce-cove-29863.herokuapp.com/getAnUser/{userId}")
.addPathParameter("userId", "1")
.build()
.getObjectObservable(ApiUser.class) // This returns you an Observable
.subscribeOn(Schedulers.io()) // do the network call on another thread
.observeOn(AndroidSchedulers.mainThread()) // return the result in mainThread
.map(new Func1<ApiUser, User>() {
@Override
public User call(ApiUser apiUser) {
// here we get ApiUser from server