Skip to content

Instantly share code, notes, and snippets.

View gmazzo's full-sized avatar
🐾
let's get it done...

Guillermo Mazzola gmazzo

🐾
let's get it done...
  • Glovo
  • Barcelona
  • 00:31 (UTC +02:00)
  • Instagram gmazzo65
View GitHub Profile
@gmazzo
gmazzo / logger.kt
Last active February 2, 2018 15:20
A lightweight Kotlin extension for java.util.logging.Logger simple support
/**
* A lightweight Kotlin extension for java.util.logging.Logger simple support
*
* Usage:
*
* At top level add:
* private val log = logger<MyClass>()
*
* Then on class body:
* log.info "Some log"
@gmazzo
gmazzo / JsoupConverterFactory.kt
Created February 2, 2018 15:19
A Jsoup body converter for Retrofit
/**
* A Jsoup body converter for Retrofit
*
* Sample usage (with Rx):
* Retrofit.Builder()
* .addCallAdapterFactory(RxJava2CallAdapterFactory.createAsync())
* .addConverterFactory(JsoupConverterFactory)
* .build()
*
* Then you can declare in you Retrofit interface return type:
@gmazzo
gmazzo / RxUtils.java
Last active February 9, 2018 04:42
A util class for RxJava which provides Observable sources for Cursor, LocalBroadcastManager and SparseArray
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.util.LongSparseArray;
import android.util.SparseArray;
import io.reactivex.Observable;
@gmazzo
gmazzo / integrationTests.gradle
Created April 3, 2018 13:31
Integration tests sourceSet script for a Gradle Java project
sourceSets {
integrationTest {
compileClasspath += sourceSets.main.output + configurations.testRuntime
runtimeClasspath += output + compileClasspath
}
}
configurations {
integrationTestCompile {
extendsFrom configurations.testCompile
@gmazzo
gmazzo / wsdl2java.gradle
Last active June 29, 2018 02:05
WSDL SOAP JAX-WB client generation with Gradle
import org.gradle.process.internal.ExecActionFactory
import org.gradle.process.internal.JavaExecAction
import javax.inject.Inject
configurations {
jaxws
}
dependencies.add('jaxws', 'com.sun.xml.ws:jaxws-tools:2.2.10')
@gmazzo
gmazzo / jacoco.gradle
Created December 16, 2018 17:09
Jacoco script for Android unit and instrumentation tests coverage report, supporting Kotlin
apply plugin: 'jacoco'
jacoco {
toolVersion = '0.8.2'
}
android {
buildTypes {
debug {
@gmazzo
gmazzo / CompletableSemaphore.kt
Last active March 6, 2020 08:47
A `Completable` class implementing a `Semaphore` behavior
import io.reactivex.Completable
import io.reactivex.Completable.defer
import io.reactivex.CompletableObserver
import java.util.concurrent.atomic.AtomicReference
class CompletableSemaphore(
private val hasPermission: () -> Boolean,
private val acquirePermission: Completable
) : Completable() {
private val complete = complete()
@gmazzo
gmazzo / NativeCollections.kt
Last active November 26, 2022 18:41
A Kotlin/Native thread-safe `List`, `Set` and `Map` implementations
package kotlin.native.concurrent
fun <T> AtomicReference<T>.computeAndSet(transform: T.() -> T) = with(value) {
@Suppress("ControlFlowWithEmptyBody")
while (!compareAndSet(this, transform().freeze()));
this
}
@gmazzo
gmazzo / build.gradle.kts
Created September 7, 2021 09:58
Android Library Maven Publication
plugins {
id("com.android.library")
`maven-publish`
}
publishing {
repositories {
// TODO define your publish repos here
}
publications {
@gmazzo
gmazzo / build.gradle.kts
Created September 7, 2021 10:25
Android Library Maven Publication (with sources)
plugins {
id("com.android.library")
`maven-publish`
}
publishing {
repositories {
// TODO define your publish repos here
}
publications {