Skip to content

Instantly share code, notes, and snippets.

View christopherperry's full-sized avatar

Christopher Perry christopherperry

View GitHub Profile
sebaslogen / LiveObservable.kt
Created July 9, 2017 21:15
LiveObservable: Android lifecycle aware wrapper for an RxJava Observable
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
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':
JakeWharton /
Last active April 17, 2023 14:07
A JUnit @rule which launches an activity when your test starts. Stop extending gross ActivityInstrumentationBarfCase2!
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
granoeste /
Last active April 4, 2024 22:32
[Android] How to get the each directory path.

System directories

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

External storage directories

Gimmie teh R00by

$ rvm install ruby-2.0.0 


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;
rkistner / myapp_pom.xml
Created December 6, 2012 12:32
Android library project + lightweight application using it with Maven
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
romannurik /
Last active May 16, 2023 13:42
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
pplante /
Created August 28, 2012 20:23
Robolectric does not support loading resources from an Android Library project such as ActionBarSherlock of FlyInMenu, so this patch allows you to specify a library project to load resources in tests.
// In I added the following method:
public void loadLibraryProjectResources(File libraryProjectRoot) throws Exception {
File systemResourceDir = getSystemResourceDir(getPathToAndroidResources());
File localValueResourceDir = getValueResourceDir(libraryProjectRoot);
File systemValueResourceDir = getValueResourceDir(systemResourceDir);
loadStringResources(localValueResourceDir, systemValueResourceDir);
loadPluralsResources(localValueResourceDir, systemValueResourceDir);
loadValueResources(localValueResourceDir, systemValueResourceDir);