Skip to content

Instantly share code, notes, and snippets.

Working from home

Carlos M. carlosmuvi

Working from home
View GitHub Profile
ferrerojosh / AndroidWorkerInjection.kt
Created May 30, 2018
androidx workmanager injector temporary impl
View AndroidWorkerInjection.kt
object AndroidWorkerInjection {
fun inject(worker: Worker) {
checkNotNull(worker, { "worker" })
val application = worker.applicationContext
if (application !is HasWorkerInjector) {
throw RuntimeException("${application.javaClass.canonicalName} does not implement ${}")
JakeWharton /
Last active Feb 17, 2020
A comparison between non-capturing and capturing expressions across Java 6, Java 8, Java 8 with Retrolambda, Kotlin with native function expressions, and Kotlin with Java SAM expression.
import java.util.Arrays;
class NonCapturing {
public static void main(String... args) {
run(new Runnable() {
@Override public void run() {
alex-shpak /
Last active Aug 3, 2020
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON
ssinss /
Last active Jul 16, 2020
Endless RecyclerView OnScrollListener
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
jmlweb / validnif.js
Created Nov 22, 2014
Directiva Angular para validación de NIF/NIE españoles | Angular directive for spanish NIF/NIE validation
View validnif.js
'use strict';
* @ngdoc directive
* @name directive:validnif
* @description
* # validnif
.directive('validnif', function () {
samkirton / gist:0242ba81d7ca00b475b9
Last active Feb 28, 2020
Fixed a bug where images added to the MediaStore are not inserted at the front of the gallery
View gist:0242ba81d7ca00b475b9
package com.memtrip;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
MostafaGazar /
Last active Oct 24, 2017
Based on, Custom shape ImageView using PorterDuffXfermode and SVGs as masks
* Copyright 2014 Mostafa Gazar
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
wbroek / genymotionwithplay.txt
Last active Jul 26, 2020
Genymotion with Google Play Services for ARM
View genymotionwithplay.txt
NOTE: Easier way is the X86 way, described on
Download the following ZIPs:
ARM Translation Installer v1.1 (
Download the correct GApps for your Android version:
Google Apps for Android 6.0 ( -
Google Apps for Android 5.1 ( -
Google Apps for Android 5.0 ( -
You can’t perform that action at this time.