Skip to content

Instantly share code, notes, and snippets.

Avatar
🌈

Rebecca Franks riggaroo

🌈
View GitHub Profile
@riggaroo
riggaroo / tag_release.yml
Created Oct 4, 2020
Github Action workflow for tagging release on Github Release, copying release notes from CHANGELOG.md
View tag_release.yml
name: Tag Release
on:
push:
branches: [ main ]
jobs:
tag_release:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
@riggaroo
riggaroo / create_release_branch.yml
Last active May 16, 2021
Github Action workflow for creating release branch, updating versionName and versionCode, copying strings.xml to another repo, submitting PRs as per GitFlow.
View create_release_branch.yml
name: Create Release Branch
on:
workflow_dispatch:
inputs:
versionName:
description: 'Name of version (ie 5.5.0)'
required: true
versionCode:
description: 'Version number (50500)'
required: true
@riggaroo
riggaroo / RestServiceMockUtils.java
Last active May 1, 2021
Mocking API Responses using a Retrofit Client in Android
View RestServiceMockUtils.java
public class RestServiceMockUtils {
public static String convertStreamToString(InputStream is) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
reader.close();
@riggaroo
riggaroo / PULL_REQUEST_TEMPLATE
Created Feb 3, 2019
Pull request template format. Add this file to your .github folder
View PULL_REQUEST_TEMPLATE
<!--- Provide a general summary of your changes in the Title above -->
<!--- If there is no changelog entry, label this PR as trivial to bypass the Danger warning -->
## Description
<!--- Describe your changes in detail -->
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
@riggaroo
riggaroo / AndroidManifest.xml
Created Apr 13, 2016
Custom Android Espresso Test Runner - Unlocking a Device, Granting Permission to turn animations off, turning the Screen on.
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Put this file in the "debug" folder so it only gets merged into debug builds -->
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.bookdash.android">
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- Disable animations on debug builds so that the animations do not interfere with Espresso
@riggaroo
riggaroo / export_strings.yml
Last active Dec 5, 2020
Github Action workflow that copies string translations from one repo into another and creates a PR.
View export_strings.yml
name: Translation Export to Android Repo
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
push_strings_to_over:
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'Automated checkin')"
steps:
@riggaroo
riggaroo / MainActivity.java
Last active Jul 15, 2020
Online Presence with Firebase and Android based off article https://firebase.googleblog.com/2013/06/how-to-build-presence-system.html . Read the article as it explains the whole .onDisconnect().removeValue() nicely.
View MainActivity.java
private void initialiseOnlinePresence() {
final DatabaseReference onlineRef = databaseReference.child(".info/connected");
final DatabaseReference currentUserRef = databaseReference.child("/presence/" + userId);
onlineRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(final DataSnapshot dataSnapshot) {
Log.d(TAG, "DataSnapshot:" + dataSnapshot);
if (dataSnapshot.getValue(Boolean.class)){
currentUserRef.onDisconnect().removeValue();
currentUserRef.setValue(true);
@riggaroo
riggaroo / pull_screenshots.sh
Created Apr 30, 2020
pull_screenshots.sh script from Chiu-ki Chan's video on terminal tricks https://youtu.be/1N90lU1xn2w
View pull_screenshots.sh
#! /bin/bash
today=$(date +%Y%m%d)
for path in $(adb shell ls /sdcard/Pictures/Screenshots/*"${today}"*); do
name=$(basename "$path")
if [ ! -f "$name" ]; then
adb pull "$path"
fi
done
@riggaroo
riggaroo / RecyclerViewAdapterTemplate.java
Created May 2, 2016
File Template for Android Studio for creating a RecyclerViewAdapter without having to remember much of the boilerplate.
View RecyclerViewAdapterTemplate.java
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
#parse("File Header.java")
@riggaroo
riggaroo / InlineClasses.kt
Last active Mar 2, 2020
Have you heard about inline classes in Kotlin?
View InlineClasses.kt
// Why use inline classes? 🤔
// 🎯 Compile time safety
// 🎯 Less runtime overhead than a normal wrapper class as it "inlines" the data into its usages
// More info : https://kotlinlang.org/docs/reference/inline-classes.html
// Without inline classes 😞
data class Recipe(id: UUID)
data class Ingredient(id: UUID, recipeId: UUID)