Skip to content

Instantly share code, notes, and snippets.

View danielgomezrico's full-sized avatar

Daniel Gomez danielgomezrico

View GitHub Profile
@danielgomezrico
danielgomezrico / EditText.xml
Created April 23, 2015 04:30
Android - EditText disabled but clickable
<EditText ...
android:clickable="true"
android:cursorVisible="false"
android:focusable="false"/>
@danielgomezrico
danielgomezrico / markdown-details-collapsible.md
Created August 12, 2021 16:12 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@danielgomezrico
danielgomezrico / cp-env-to-properties.sh
Last active July 27, 2021 12:37
Gradle / Bash - copy all env variables to app/gradle.properties (used to copy secret env vars from travis or circle CI to build android projects)
#!/usr/bin/env bash
#
# Copy env variables to app module gradle properties file
#
set +x // dont print the next lines on run script
printenv | tr ' ' '\n' > app/gradle.properties
set -x
@danielgomezrico
danielgomezrico / blogspot_to_jekyll.rb
Last active July 5, 2021 05:47 — forked from kennym/blogspot_to_jekyll.rb
Updated to get `post.published` date instead of `post.updated` for created_datetime, update `feedjira` name and remove Config include.
#!/usr/bin/env ruby
#
# Convert blogger (blogspot) posts to jekyll posts
#
# Basic Usage
# -----------
#
# ./blogger_to_jekyll.rb feed_url
#
# where `feed_url` can have the following format:
@danielgomezrico
danielgomezrico / update_list.dart
Created March 5, 2021 18:26
Example showing how to update a list
class Person {
Person(this.name);
final String name;
String toString() => name;
}
void main() {
final items = [Person("juan"), Person("pedro"), Person("coso")];
@danielgomezrico
danielgomezrico / yield.dart
Created February 5, 2021 19:56
Dart - simple yield and yield* example
Stream<String> otherNumbers() {
return Stream.fromIterable(["2", "3"]);
}
Stream<String> allNumbers() async* {
yield "1";
yield* otherNumbers();
}
@danielgomezrico
danielgomezrico / DistanceCalculator.java
Last active January 6, 2021 00:37
Java / Android - calculate the distance between two coordinates with great circle formula.
import static java.lang.Math.acos;
import static java.lang.Math.cos;
import static java.lang.Math.sin;
/**
* Calculate distance between coordinates.
*/
public class DistanceCalculator {
static double PI_RAD = Math.PI / 180.0;
@danielgomezrico
danielgomezrico / check-format.sh
Created December 27, 2020 16:36
Flutter - Check code format and fail if does not work, useful for CI flows
#!/usr/bin/env bash
#
# Runs dartfmt from dart_style to check if all of the source files are well formatted
# Requires you to have dartfmt already in your path with 'pub global activate dart_style'
#
echo "-> Running 'flutter format' to check project dart style 🤓"
RESULT=$(flutter format -n lib/main.dart lib/src/ test/)
@danielgomezrico
danielgomezrico / String+IsBlank
Created March 26, 2015 22:01
Blank string in Swift
extension String {
var isBlank: Bool {
get {
let trimmed = stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
return trimmed.isEmpty
}
}
@danielgomezrico
danielgomezrico / jacoco.gradle
Last active October 5, 2020 13:15
Gradle - jacoco gradle file that is setup to run tests and create test coverage reports for Android (junit tests or connectedTests...). apply to your project and check "reporting" in gradle tasks. Thanks to https://github.com/artem-zinnatullin/qualitymatters for it.
project.afterEvaluate {
// Grab all build types and product flavors
def buildTypes = android.buildTypes.collect { type -> type.name }
def productFlavors = android.productFlavors.collect { flavor -> flavor.name }
// When no product flavors defined, use empty
if (!productFlavors) productFlavors.add('')
productFlavors.each { productFlavorName ->
buildTypes.each { buildTypeName ->