Skip to content

Instantly share code, notes, and snippets.


Christopher Perry christopherperry

View GitHub Profile
JakeWharton /
Last active January 20, 2023 08:52
A JUnit @rule which launches an activity when your test starts. Stop extending gross ActivityInstrumentationBarfCase2!
granoeste /
Last active January 19, 2023 15:05
[Android] How to get the each directory path.

System directories

Method Result
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system

External storage directories

romannurik /
Last active July 12, 2022 10:17
Android helper class for showing cheat sheets (tooltips) for icon-only UI elements on long-press. This is already default platform behavior for icon-only action bar items and tabs. This class provides this behavior for any other such UI element.
* Copyright 2012 Google Inc.
* 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
* Unless required by applicable law or agreed to in writing, software
abhiaiyer91 /
Last active April 29, 2022 06:00
Redux Selector Pattern

Redux Selector Pattern

Imagine we have a reducer to control a list of items:

function listOfItems(state: Array<Object> = [], action: Object = {}): Array<Object> {
  switch(action.type) {
    case 'SHOW_ALL_ITEMS':
Takhion /
Last active April 11, 2022 02:29
Collection of methods to achieve better circular arc drawing, as Canvas.drawArc() is unreliable. See the related article:
* Copyright (c) 2014 BioWink GmbH.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
peter /
Created June 30, 2012 21:03
Creating and Deploying an EdgeRails (Rails 4) Application to Heroku
# 0. Make sure you have Ruby 1.9.3 installed, and optionally RVM and PostgreSQL
# 0.2 If you are on the Mac, make sure you have a c compiler by installing XCode Command Line Tools or gcc4.2 with homebrew
# 0.5 Make sure you have bundler version ~> 1.2 as Rails depends on it
gem install bundler
# 1. Get edge Rails source (master branch)
git clone
swankjesse /
Created February 8, 2013 23:27
Stream editor for Java nerds. Use Java regular expressions to break up lines, and Java format strings to put them back together again.
/*bin/mkdir /tmp/rip 2> /dev/null
javac -d /tmp/rip $0
java -cp /tmp/rip Rip "$@"
import java.util.*;
import java.util.regex.Matcher;
kimkidong / gist:3346007
Created August 14, 2012 03:10
Convert YUV420 to RGB8888
View gist:3346007
// decode Y, U, and V values on the YUV 420 buffer described as YCbCr_422_SP by Android
// David Manpearl 081201
public void decodeYUV(int[] out, byte[] fg, int width, int height)
throws NullPointerException, IllegalArgumentException {
int sz = width * height;
if (out == null)
throw new NullPointerException("buffer out is null");
if (out.length < sz)
throw new IllegalArgumentException("buffer out size " + out.length
+ " < minimum " + sz);
sebaslogen / LiveObservable.kt
Created July 9, 2017 21:15
LiveObservable: Android lifecycle aware wrapper for an RxJava Observable
View LiveObservable.kt
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.LifecycleObserver
import android.arch.lifecycle.LifecycleOwner
import android.arch.lifecycle.OnLifecycleEvent
import com.jakewharton.rxrelay.BehaviorRelay
import rx.Observable
import rx.functions.Action1
import rx.subscriptions.CompositeSubscription
arpit /
Created July 13, 2012 22:27
Stagger LayoutTransitions in Android
package com.arpit.animatortest;
import android.animation.AnimatorSet;
import android.animation.LayoutTransition;
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;