Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Daniel San Ferreira da Rocha danielsanfr

🏠
Working from home
View GitHub Profile
@danielsanfr
danielsanfr / custom-git-describe.gradle
Last active Nov 8, 2020
Use Grgit to generate a "git describe" that considers the tags of all branches.
View custom-git-describe.gradle
static String buildDescribeString(String tag, int commitsCount, /* org.ajoberstar.grgit.Commit */ headCommit) {
return "$tag-$commitsCount-g${headCommit.id.substring(0, 7)}"
}
String unreleasedDescribe() {
def headCommit = grgit.head()
def commitsCount = grgit.log().size()
return buildDescribeString("unreleased", commitsCount, headCommit)
}
@danielsanfr
danielsanfr / Log.swift
Last active Feb 4, 2020
A simple struct for printing logs in a more "Android" way. Print time, file, line and function name, plus desired message.
View Log.swift
/**
* Log.swift
* Copyright (c) 2020 Daniel San <daniel.samrocha@gmail.com>
* Created by Daniel San on 17/01/2020.
*/
import Foundation
struct Log {
@danielsanfr
danielsanfr / fix-wm-class-on-linux.sh
Created May 11, 2019
Adjust WM_CLASS of Android Studio Beta version on GNU/Linux (and X.org) so you can have 2 different icons on docks
View fix-wm-class-on-linux.sh
#!/bin/sh
# Update WM_CLASS
fault_tolerance=0
beta_timeout=50
while true; do
wids=$(timeout 2 xdotool search --sync --onlyvisible --class "jetbrains-studio")
if [ -z "$wids" ] ; then
if [ $fault_tolerance -eq 0 ]; then
fault_tolerance=1
@danielsanfr
danielsanfr / load-env-files.gradle
Created Oct 13, 2018
Load all .env files in the project's root directory on project property
View load-env-files.gradle
task loadEnv(dependsOn: ":app:build") {
file(rootProject.projectDir).listFiles({
it.isFile() && it.name.endsWith(".env")
} as FileFilter).each { file ->
file.withInputStream { inputStream ->
def properties = new Properties()
properties.load(inputStream)
properties.stringPropertyNames().forEach { name ->
ext.setProperty(name, properties.getProperty(name))
}
@danielsanfr
danielsanfr / apk-better-name.gradle
Last active Jul 12, 2017
Producing better named Android APKs with Gradle (Android Plugin 3.0)
View apk-better-name.gradle
// http://www.jayway.com/2015/03/13/producing-better-named-android-apks-with-gradle/
// https://stackoverflow.com/questions/44239235/android-gradle-3-0-0-alpha2-plugin-cannot-set-the-value-of-read-only-property
android.applicationVariants.all { variant ->
def appName
// Check if an applicationName property is supplied; if not use the name of the parent project.
if (project.hasProperty("applicationName")) {
appName = applicationName
} else {
appName = parent.name
}
@danielsanfr
danielsanfr / apk-better-name.gradle
Created Nov 23, 2016
Producing better named Android APKs with Gradle
View apk-better-name.gradle
// http://www.jayway.com/2015/03/13/producing-better-named-android-apks-with-gradle/
android.applicationVariants.all { variant ->
def appName
// Check if an applicationName property is supplied; if not use the name of the parent project.
if (project.hasProperty("applicationName")) {
appName = applicationName
} else {
appName = parent.name
}