Skip to content

Instantly share code, notes, and snippets.

View yongjhih's full-sized avatar
🏠
Working from home

Andrew Chen yongjhih

🏠
Working from home
View GitHub Profile
@amowu
amowu / getAllCommits$.js
Last active October 22, 2018 08:42
GitHub API pagination with RxJS
const GitHubApi = require("github");
const Rx = require("rx");
const github = new GitHubApi();
const getCommitsAsync = (param) => github.repos.getCommits({
owner: 'amowu',
repo: 'test-semantic-release',
...param
});
@LouisCAD
LouisCAD / GooglePlayServices.kt
Created November 23, 2017 16:19
Allows using Google Play Services Task API in Kotlin Coroutines, plus Play Services availability check made easier.
import com.google.android.gms.common.GoogleApiAvailability
import com.google.android.gms.tasks.Task
import splitties.init.appCtx
import kotlin.coroutines.experimental.suspendCoroutine
val googleApiAvailability = GoogleApiAvailability.getInstance()!!
inline val playServicesAvailability get() = googleApiAvailability.isGooglePlayServicesAvailable(appCtx)
@JvmName("awaitVoid")
suspend fun Task<Void>.await() = suspendCoroutine<Unit> { continuation ->
@kassim
kassim / RxBottomSheetDialogFragment.kt
Created November 23, 2017 09:39
an addition to RxLifecycle for a BottomSheetDialogFragment
import android.os.Bundle
import android.support.annotation.CallSuper
import android.support.annotation.CheckResult
import android.support.design.widget.BottomSheetDialogFragment
import android.view.View
import com.trello.rxlifecycle2.LifecycleProvider
import com.trello.rxlifecycle2.LifecycleTransformer
import com.trello.rxlifecycle2.RxLifecycle
import com.trello.rxlifecycle2.android.FragmentEvent
import com.trello.rxlifecycle2.android.RxLifecycleAndroid
package NearbyWords
import java.util.LinkedList
import kotlin.collections.HashSet
typealias CharSet = MutableFifthly<Set<Char>, Iterator<Char>, Char?, Long, Long>
class MutableFifthly<A, B, C, D, E>(
var first: A,
var second: B,
@atonamy
atonamy / NearbyWordsAlt.kt
Last active October 30, 2017 01:56
Alternative solution for https://www.facebook.com/Engineering/videos/10152735777427200/ which give complexity O(n^3)
package NearbyWordsAlt
import kotlin.collections.HashSet
fun main(args : Array<String>) {
println(nearbyWords("gi"))
}
fun getAllWordPermutations(word: String): Set<String> {
import requests
session = requests.AsyncSession()
async def _main():
rs = []
for _ in range(100):
rs.append(await session.get('http://httpbin.org/get'))
print(rs)
@msangel
msangel / ApiModule.java
Last active October 10, 2022 14:45 — forked from koesie10/ApiModule.java
Retrofit 1 error handling behaviour in Retrofit 2.3.0
// Dagger 1 example
@Module(
complete = false,
library = true
)
public final class ApiModule {
@Provides
@Singleton
Retrofit provideRetrofit(Gson gson, Application app) {
return new Retrofit.Builder()
@gleicon
gleicon / README.md
Created August 9, 2017 16:35 — forked from lucindo/README.md
Using Graphite/Grafana to gather Locust.io test data

Using Locust.io with Grafana

On your locust master server:

  • Install and configure Graphite. Follow a good tutorial
  • Install and configure Grafana: tutorial

Use logra.py on your locust test file. See locustfile.py.

@tejpratap46
tejpratap46 / ImageUtil.java
Created July 5, 2017 07:15
Generate Bitmap from view in android
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.util.Log;
import android.view.View;
import java.util.ArrayList;
public class ImageUtil {
/**
@fluidsonic
fluidsonic / NestedScrollView.kt
Last active October 21, 2023 09:32
A RecyclerView subclass for Android which makes descendent NestedScrollViews scrollable
package com.github.fluidsonic.nestedrecyclerview
import android.content.Context
import android.support.v4.view.NestedScrollingParent
import android.support.v7.widget.RecyclerView
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View