This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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); | |
} | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |