Skip to content

Instantly share code, notes, and snippets.

View snijsure's full-sized avatar

Subodh Nijsure snijsure

  • Self
  • Oakland, CA
View GitHub Profile
@snijsure
snijsure / ImageFileExtensionWithApply.kt
Last active May 18, 2021 19:19
ImageFileExtensionWithApply
private fun ImageFile.toAttachment(): Attachment {
return Attachment().also {
it.fileName = imageName
it.updateTime = updateTime
}
}
@snijsure
snijsure / KotlinAttachment.kt
Created May 18, 2021 19:14
KotlinAttachment
data class KotlinAttachment (
var fileName: String = "default-kotlin-file-name",
var updateTime: String = "1970/1/1"
)
fun ImageFile.toKotlinAttachment(): KotlinAttachment {
return KotlinAttachment().apply {
fileName = imageName
updateTime = updateTime // self-assignment warning
@snijsure
snijsure / ImageFileExtension.kt
Last active May 18, 2021 19:12
ImageFileExtension
fun ImageFile.toAttachment(): Attachment {
return Attachment().apply {
fileName = imageName
updateTime = updateTime // No self-assignment warning
}
}
data class ImageFile (
val imageName: String,
val imageType: Int,
val updateTime: String
)
public class Attachment {
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
@snijsure
snijsure / RxSearchObservable.java
Created August 29, 2018 17:31
Implement search using RxJava
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();
@snijsure
snijsure / ApiService.kt
Created July 18, 2018 18:45
Sample Api Service
import com.yourpackage.model.Price
import com.yourpackage.model.Ticket
import io.reactivex.Single
import retrofit2.http.GET
import retrofit2.http.Query
interface ApiService {
@GET("airline/tickets")
fun searchTickets(@Query("from") from: String, @Query("to") to: String): Single<List<Ticket>>
@snijsure
snijsure / ApiClient.kt
Last active July 18, 2018 18:50
Create API Client given BASE_URL
import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import info.androidhive.flighttickets.app.Const
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit
// Use as val apiService = ApiClient.client?.create(ApiService::class.java)
@snijsure
snijsure / gcm-high-prio.sh
Created April 29, 2017 02:12 — forked from sebastianbenz/gcm-high-prio.sh
Send high priority GCM messages via curl (Android Doze mode & App Standby testing)
curl -X POST \
-H "Authorization: key= YOUR-API-KEY" \
-H "Content-Type: application/json" \
-d '{
"registration_ids": [
"YOUR-GCM-REGISTRATION-ID"
],
"data": {
"message": "Hello Message"
},