Skip to content

Instantly share code, notes, and snippets.

View riggaroo's full-sized avatar
🌍

Rebecca Franks riggaroo

🌍
View GitHub Profile
@riggaroo
riggaroo / CustomView-Snippet1.kt
Last active March 21, 2019 15:25
Drawing to Canvas without KTX
canvas.save()
canvas.translate(200f, 300f)
canvas.drawCircle(...) // drawn on the translated canvas
canvas.restore()
@riggaroo
riggaroo / PULL_REQUEST_TEMPLATE
Created February 3, 2019 14:34
Pull request template format. Add this file to your .github folder
<!--- 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 / ProjectEditorViewModel.kt
Created February 2, 2019 19:08
ProjectEditorViewModel using AndroidViewModel, exposing UI state
class ProjectEditorViewModel : ViewModel() {
private val _state = MutableLiveData<EditorState>()
val state: LiveData<EditorState>
get() = _state
}
@riggaroo
riggaroo / ProjectEditorFragment.kt
Last active February 3, 2019 10:15
ProjectEditorFragment showing how to use ViewModels to restore state.
class ProjectEditorFragment : Fragment {
@Inject
lateinit var viewModelFactory: ViewModelProvider.Factory
private lateinit var viewModel: ProjectEditorViewModel
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_editor_initial, container, false)
@riggaroo
riggaroo / MotionSensorMainActivity.kt
Created October 21, 2017 10:33
Motion sensing camera
package za.co.riggaroo.motionsense
import android.app.Activity
import android.graphics.Bitmap
import android.os.Bundle
import android.os.Handler
import android.util.Log
import android.widget.ImageView
import com.google.android.things.pio.Gpio
import com.google.android.things.pio.GpioCallback
import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.ImageFormat
import android.graphics.Matrix
import android.hardware.camera2.*
import android.hardware.camera2.CameraAccessException.CAMERA_ERROR
import android.media.ImageReader
import android.os.Handler
import android.util.Log
@riggaroo
riggaroo / create_bookdashbook.sh
Last active January 8, 2017 18:57
Script for creating book dash books from PDF for android app.
#/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 November 23, 2016 17:26
Firebase Staged Rollout Features - Sample Gist showing how to use Firebase Remote Config for stage rollout of features.
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 July 15, 2020 12:30
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.
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);

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: