Skip to content

Instantly share code, notes, and snippets.

View danielsanfr's full-sized avatar
🏠
Working from home

Daniel San Ferreira da Rocha danielsanfr

🏠
Working from home
View GitHub Profile
@danielsanfr
danielsanfr / apk-better-name.gradle
Created November 23, 2016 05:07
Producing better named Android APKs with 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
}
@danielsanfr
danielsanfr / apk-better-name.gradle
Last active July 12, 2017 03:49
Producing better named Android APKs with Gradle (Android Plugin 3.0)
// 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 / load-env-files.gradle
Created October 13, 2018 04:02
Load all .env files in the project's root directory on project property
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 / Log.swift
Last active February 4, 2020 21:26
A simple struct for printing logs in a more "Android" way. Print time, file, line and function name, plus desired message.
/**
* 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 / custom-git-describe.gradle
Last active June 6, 2022 03:26
Use Grgit to generate a "git describe" that considers the tags of all branches.
/**
* Copyright (c) 2020-present Daniel San
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@danielsanfr
danielsanfr / fix-wm-class-on-linux.sh
Created May 11, 2019 14:31
Adjust WM_CLASS of Android Studio Beta version on GNU/Linux (and X.org) so you can have 2 different icons on docks
#!/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