Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Mobile Engineer at LaHaus.com

Daniel Gomez danielgomezrico

🏠
Mobile Engineer at LaHaus.com
View GitHub Profile
@danielgomezrico
danielgomezrico / provider_generic_extensions.dart
Last active Nov 28, 2020
Dart/Flutter - Extensions to emit ChangeNotifier changes as a Stream, very useful for unit testing
View provider_generic_extensions.dart
/// Function to get the changed value everytime
typedef GetChangeFunction<T> = T Function();
extension AsStream<T> on ChangeNotifier {
Stream<T> statusAsStream(GetChangeFunction<T> getChange) {
final controller = StreamController<T>();
// Redirect status changes into the Stream
@danielgomezrico
danielgomezrico / example.dart
Last active Aug 15, 2020
Flutter - Android - extensions to mock more easy on testing with mockito
View example.dart
// The abstractions
abstract class Result<T> {
}
class Success<T> extends Result<T> {
final T body;
Success(this.body);
}
@danielgomezrico
danielgomezrico / generics_failure.dart
Created Aug 15, 2020
Generics failure example with dart
View generics_failure.dart
abstract class Result<T> { }
class Success<T> extends Result<T> {
final T body;
Success(this.body);
}
class Failure<T> extends Result<T> {
@danielgomezrico
danielgomezrico / jacoco.gradle
Last active Jun 18, 2020
Jacoco setup to merge coverage for android when you run unit tests + integration tests and get a mixed result
View jacoco.gradle
// Merge of
// https://github.com/mgouline/android-samples/blob/master/jacoco/app/build.gradle
// and https://github.com/pushtorefresh/storio/blob/master/gradle/jacoco-android.gradle
// Requires Jacoco plugin in build classpath.
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.8.3"
}
@danielgomezrico
danielgomezrico / gist:cbd98365a840a93c4e6a04e25b2b1671
Last active Oct 9, 2019
Android - How to transform from List<T> to Observable<PageList<T>> for androidx paging library
View gist:cbd98365a840a93c4e6a04e25b2b1671
package com.lahaus.utils.extensions
import androidx.paging.DataSource
import androidx.paging.PagedList
import androidx.paging.PositionalDataSource
import androidx.paging.RxPagedListBuilder
import io.reactivex.Observable
fun <T> List<T>.toObservablePagedList(): Observable<PagedList<T>> {
val defaultConfig = PagedList.Config.Builder()
@danielgomezrico
danielgomezrico / jacoco.gradle
Created May 16, 2019
Android / Gradle - Jacoco gradle setup to join instrumentation and unit test coverage
View jacoco.gradle
// Merge of
// https://github.com/mgouline/android-samples/blob/master/jacoco/app/build.gradle
// and https://github.com/pushtorefresh/storio/blob/master/gradle/jacoco-android.gradle
// Requires Jacoco plugin in build classpath.
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.8.3"
}
@danielgomezrico
danielgomezrico / add-spaces.sh
Created May 3, 2019
Add empty space recursively on each file for current folder
View add-spaces.sh
for f in $(find . -name '*.kt')
do
echo "" >> "$f"
done
@danielgomezrico
danielgomezrico / find_replace_all.sh
Created Dec 10, 2018
Bash - Replace all with find
View find_replace_all.sh
#!/bin/bash
find $1 -type f -exec sed -i "s/$2/$3/g" '{}' \;
You can’t perform that action at this time.