Skip to content

Instantly share code, notes, and snippets.

View danielgomezrico's full-sized avatar

Daniel Gomez danielgomezrico

View GitHub Profile
@danielgomezrico
danielgomezrico / result.dart
Created March 20, 2024 19:59
Example - Study: check if typedef works for type checks
import 'dart:async';
typedef FutureResult<T> = Future<Result<T>>;
typedef FutureOrResult<T> = FutureOr<Result<T>>;
typedef ConcatResult<F, S> = ({F first, S second});
abstract class Result<T> {
const Result();
@danielgomezrico
danielgomezrico / jacoco.gradle
Last active June 18, 2024 13:23
Jacoco setup to merge coverage for android when you run unit tests + integration tests and get a mixed result
// 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 / pubspec.yaml
Created May 2, 2024 21:20
Flutter - Built Value - Build Runner: script to update pubscpec with the files to autogenerate
targets:
$default:
builders:
built_value_generator:built_value:generate_for:
generate_for:
- HERE
@danielgomezrico
danielgomezrico / Function.java
Created May 9, 2015 16:05
Android - check if running on main thread
public boolean runningOnMainThread() {
return Looper.getMainLooper().getThread() == Thread.currentThread();
}
@danielgomezrico
danielgomezrico / readme.md
Created January 5, 2024 17:21
i18n performance test using i18n.Of, temporal variables and i18n.current

Results are:

With Current

  • direclty access to i18n(RunTime): 55185442.5 us.
  • indireclty access to i18n(RunTime): 55758307.0 us.
  • indireclty outside access to i18n(RunTime): 56177293.5 us.

With BuildContext

  • direclty access to i18n(RunTime): 92459941.0 us.
  • indireclty access to i18n(RunTime): 83667963.5 us.
@danielgomezrico
danielgomezrico / result_monad_2.dart
Last active December 15, 2023 15:06
Result Monad Example 2
///
/// The Result Monad
///
abstract class Result<T> {
bool isSuccess() {
return this is Success;
}
Success<T> asSuccess() {
return this as Success<T>;
@danielgomezrico
danielgomezrico / Manifest.xml
Created December 13, 2023 21:47
Flutter · Dart: web server to start a local webserver
<!-- Attribute to add on android -->
<app
....
android:usesCleartextTraffic="true">
...
</app>
@danielgomezrico
danielgomezrico / Checkbox.xml
Created September 14, 2015 03:21
Android - Checkbox as star/favorite view.
<CheckBox
android:id="@+id/item_card_check_favorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:padding="@dimen/activity_margin"
style="?android:attr/starStyle"/>
@danielgomezrico
danielgomezrico / provider_generic_extensions.dart
Last active October 19, 2023 16:07
Dart/Flutter - Extensions to emit ChangeNotifier changes as a Stream, very useful for unit testing
/// 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 / Dangerfile.rb
Created January 8, 2022 18:10
DangerFile - Danger System - script to check conventional commits titles and size of the PR
# https://www.regextester.com/109925
CONVENTIONS_URL = "your link"
def validate_title_format
def valid_title_format?(title)
conventional_commit_regex = /^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?: .*$/
result = title =~ conventional_commit_regex
result != nil
end