Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Sushant Kumar baldraider

🎯
Focusing
  • India
View GitHub Profile
View UtilsDateTime.java
public static String getDate(String time) {
DateFormat utcFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH);
utcFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
Date date = utcFormat.parse(time);
long timeDiff = System.currentTimeMillis() - date.getTime();
if (timeDiff < 86400000) {
if (timeDiff < 60) {
return "Just now";
View AsyncSubject.kt
//In this example no values will be published as the sequence never completes. No values will be written to the console.
fun asyncSubjectExample1(){
var subject = new AsyncSubject<string>()
subject.onNext("a")
subject.onNext("b")
subject.onNext("c")
subject.subscribe(println(it))
}
//In this example we invoke the OnCompleted method so the last value 'c' is written to the console:
View BehaviorSubject.kt
//In this example the value 'a' is written to the console:
fun BehaviorSubjectExample(){
//Need to provide a default value.
var subject = new BehaviorSubject<string>("a")
subject.Subscribe(println(it))
}
//In this example the value 'b' is written to the console, but not 'a'.
fun BehaviorSubjectExample2(){
var subject = new BehaviorSubject<string>("a")
View manifest_deep_link.xml
@baldraider
baldraider / RelaySubjectExampleBuffer.kt
Last active Mar 24, 2019
Relay Subject Example with buffer size
View RelaySubjectExampleBuffer.kt
class RelaySubjectExampleBuffer {
fun main(args : Array<String>){
val bufferSize = 2
val subject = RelaySubject<String>(bufferSize)
val myObserver = MyObserver()
subject.onNext("a")
subject.onNext("b")
subject.onNext("c")
subject.subscribe(myObserver)
subject.onNext("d")
@baldraider
baldraider / RelaySubjectExample1.kt
Last active Mar 24, 2019
Relay Subject Example
View RelaySubjectExample1.kt
class RelaySubjectExample1 {
fun main(args : Array<String>){
val subject = RelaySubject<String>()
val myObserver = MyObserver()
subject.onNext("a")
subject.subscribe(myObserver)
subject.onNext("b")
subject.onNext("c")
subject.onComplete()
}
@baldraider
baldraider / RxSubjectExample2.kt
Last active Mar 24, 2019
Subject example with late subscription
View RxSubjectExample2.kt
class RxSubjectExample2 {
fun main(args : Array<String>){
val subject = Subject<String>()
val myObserver = MyObserver()
subject.onNext("a")
subject.subscribe(myObserver)
subject.onNext("b")
subject.onNext("c")
subject.onComplete()
@baldraider
baldraider / RxSubjectExample.kt
Last active Mar 24, 2019
Standard Subject Example
View RxSubjectExample.kt
class RxSubjectExample {
fun main(args : Array<String>){
val subject = Subject<String>()
val myObserver = MyObserver()
subject.subscribe(myObserver)
subject.onNext("a")
subject.onNext("b")
subject.onNext("c")
subject.onComplete()
@baldraider
baldraider / rxexample1.kt
Last active Mar 24, 2019
Implementing Observer<T> and Observable<T>
View rxexample1.kt
class ObservableObserverExample {
fun main(args : Array<String>){
val myObserver = MyObserver()
val myObservable = MyObservable()
myObservable.subscribe(myObserver)
}
class MyObserver : Observer<String>{
override fun onComplete() {
View patch.json
{
"org.moire.opensudoku.gui.inputmethod.IMControlPanel$1":{
"onCellTapped":{
"action": "LOG"
}
},
"org.moire.opensudoku.gui.inputmethod.IMControlPanel":{
"easterEgg":{
"action": "TRY_CATCH"
}