Skip to content

Instantly share code, notes, and snippets.

Avatar
🌈

Rebecca Franks riggaroo

🌈
View GitHub Profile
@riggaroo
riggaroo / create_bookdashbook.sh
Last active Jan 8, 2017
Script for creating book dash books from PDF for android app.
View create_bookdashbook.sh
#/usr/local/bin/bash
# Prerequistes: You need to install imagemagick and pdfimages for this script to work
# Usage - ./convert_book.sh pdf_name.pdf
# output - zip file with images and bookdetails.json file
# This script assumes the normal structure of a book dash book and wont work for bigger books or books with different formatting to the standard book dash book
# it is always advised to check the output zipped file to ensure its correct
folderName=$(basename "$1")
folderName="${folderName%.*}"
@riggaroo
riggaroo / FriendsActivity.java
Last active Nov 23, 2016
Firebase Staged Rollout Features - Sample Gist showing how to use Firebase Remote Config for stage rollout of features.
View FriendsActivity.java
public class FriendsActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
public static final String FEATURE_FLAG_ADD_FRIENDS = "feature_add_friends";
private FirebaseRemoteConfig remoteConfig;
private Button buttonAddFriend;
@Override
protected void onCreate(Bundle savedInstanceState) {
@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);
View keybase.md

Keybase proof

I hereby claim:

  • I am riggaroo on github.
  • I am riggaroo (https://keybase.io/riggaroo) on keybase.
  • I have a public key ASBwdwxxd9GeCz_wXXJYp-hWBxALsHCP9wZLUxYZpcx2cAo

To claim this, I am signing this object:

@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 / 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 / BaseResponse.java
Created Apr 13, 2016
Retrofit 2.0 - Parsing Error Responses
View BaseResponse.java
public static BaseResponseDto parseError(Response<?> response) {
Converter<ResponseBody, BaseResponseDto> converter =
Injection.getRetrofitInstance()
.responseBodyConverter(BaseResponseDto.class, new Annotation[0]);
BaseResponseDto error;
try {
error = converter.convert(response.errorBody());
} catch (IOException e) {
@riggaroo
riggaroo / tools_namespace_example.xml
Last active Nov 2, 2015
Example usage of the tools namespace for creating a meaningful Design View
View tools_namespace_example.xml
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
tools:visibility="visible"
tools:text="Rebecca Franks" />
@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();