Skip to content

Instantly share code, notes, and snippets.

View oliverspryn's full-sized avatar
☀️
Everyday is a great day!

Oliver Spryn oliverspryn

☀️
Everyday is a great day!
View GitHub Profile
@oliverspryn
oliverspryn / app.gradle
Last active October 18, 2018 19:01
Common Android Gradle Plugins
apply plugin: 'com.android.application'
apply plugin: 'jacoco'
apply plugin: 'kotlin-android'
@oliverspryn
oliverspryn / dynatrace.gradle
Created October 18, 2018 19:04
Dynatrace Gradle Configuation Stub
apply plugin: 'com.dynatrace.tools.android'
dynatrace {
defaultConfig {
...
}
productFlavors {
dynatraceDev {
...
@oliverspryn
oliverspryn / build.sh
Last active October 18, 2018 20:20
Build an Android project in debug mode
./gradlew --build-file build.gradle assembleNoDynatraceDebug
@oliverspryn
oliverspryn / app.gradle
Last active October 19, 2018 20:34
A Gradle script which conditionally exclude a plugin based on the build variant
// Run with: ./gradlew --build-file build.gradle assembleNoDynatraceDebug
def task = gradle.startParameter.taskNames[0] ?: "" // Get "assembleNoDyntraceDebug"
if (!task.toLowerCase().contains("nodynatrace")) {
apply plugin: 'com.dynatrace.tools.android'
dynatrace {
defaultConfig {
...
}
@oliverspryn
oliverspryn / README.md
Created April 30, 2019 16:21
Manually Squash a Commit

Even though GitHub and many other Git management platforms can squash commits, they do not always sign the squashed commit with a GPG key. However, if you manually squash all of your commits into one, and then sign that commit before merging the pull request, you can keep your signed commit as you merge it another branch.

This code sample assumes that your target merge branch is develop. Notice the -S on the commit, which signs it.

@oliverspryn
oliverspryn / Maze.cpp
Created April 30, 2019 16:22
Maze Generation and Solving Algorithm
#include "Maze.h"
Maze::Maze() : alreadyInit(false), solvedCounter(1), startSet(false) { }
Maze::~Maze() {
delete root;
//Deallocate the maze resolution matrix
for(int i = 0; i < this->dim.x; ++i) {
delete [] solved[i];
@oliverspryn
oliverspryn / ChromeCustomTabsNavigator.kt
Last active June 14, 2019 19:40
Interface for the Chrome Custom Tab Navigation Component destination type
@Navigator.Name("chrome")
class ChromeCustomTabsNavigator(private val context: Context) : Navigator<ChromeCustomTabsNavigator.Destination>() {
override fun createDestination(): Destination {
TODO("not implemented")
}
override fun navigate(destination: Destination, args: Bundle?, navOptions: NavOptions?, navigatorExtras: Extras?): NavDestination? {
TODO("not implemented")
}
@oliverspryn
oliverspryn / attrs.xml
Last active June 14, 2019 20:07
Custom attributes for the Android Navigation Component's custom destination type
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="ChromeCustomTabsNavigator">
<attr name="toolbarColor" format="reference" />
<attr name="secondaryToolbarColor" format="reference" />
</declare-styleable>
</resources>
@oliverspryn
oliverspryn / Destination.kt
Created June 14, 2019 20:16
Android Navigation Component custom destination with support for two parameters
@NavDestination.ClassType(Activity::class)
class Destination(navigator: Navigator<out NavDestination>) : NavDestination(navigator) {
@ColorRes
var toolbarColor: Int = 0
@ColorRes
var secondaryToolbarColor: Int = 0
}
@oliverspryn
oliverspryn / Destination.kt
Created June 14, 2019 20:19
Fetches properties from a definition in an XML file and applies them to the properties on a class
@NavDestination.ClassType(Activity::class)
class Destination(navigator: Navigator<out NavDestination>) : NavDestination(navigator) {
@ColorRes
var toolbarColor: Int = 0
@ColorRes
var secondaryToolbarColor: Int = 0
override fun onInflate(context: Context, attrs: AttributeSet) {