Skip to content

Instantly share code, notes, and snippets.

View antarikshc's full-sized avatar
:shipit:
Shipping stupid things

Antariksh Chavan antarikshc

:shipit:
Shipping stupid things
View GitHub Profile
@antarikshc
antarikshc / gcp-storage.js
Last active June 26, 2023 17:24
Code sample to upload files in Google Cloud Storage bucket for Node.js
// Install GCP Client library
// npm install --save @google-cloud/storage
// To run the client library, you must first set up authentication by creating a service account
// and setting an environment variable. Ask your DevOps person to provide you with service account key
// For example:
// export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/[FILE_NAME].json"
// Imports the Google Cloud client library
const { Storage } = require('@google-cloud/storage');
@antarikshc
antarikshc / get-contacts-android.kt
Last active May 19, 2019 08:05
Snippet for fetching contacts in Android
// Declare the data class in Contact.kt
data class Contact(
val id: String,
val name: String,
val thumbnailUri: String?
)
// Following code goes into Fragment or Activity file
// This snippet is used in Android Fragments. Change it accordingly for using it in Activities
@antarikshc
antarikshc / DemoWorker.kt
Created August 27, 2019 20:19
Synchronized Apollo Requests with Coroutines inside WorkManager
class DemoWorker(appContext: Context, workerParams: WorkerParameters) :
Worker(appContext, workerParams) {
override fun doWork(): Result {
....
// Synchronous Apollo request
val result = runBlocking {
try {
@antarikshc
antarikshc / CustomRequestBody.java
Last active October 5, 2019 18:00
OkHttp Multipart Request with custom RequestBody
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import okhttp3.Headers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.internal.Util;
import okio.Buffer;