Skip to content

Instantly share code, notes, and snippets.

{
message: "There was an error.", //top level, localized
errors: [
{
hierarchy: ["card", "address"], // list of categories; hierarchy.length > 0
code: 456,
message: "Your billing address is invalid."
},
{
hierarchy: ["card", "expiration"],
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
public class OneTime {
private final Semaphore mSemaphore = new Semaphore(1);
private final AtomicBoolean mWasCalled = new AtomicBoolean(false);
public void callbackOption1() {
try {
@ronshapiro
ronshapiro / VenmoTestRunner.java
Last active August 29, 2015 14:04
An adapted version of https://code.google.com/p/android-test-kit/wiki/DisablingAnimations configured as a InstrumentationTestRunner
package com.venmo.tests;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner;
package com.venmo.views;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
@ronshapiro
ronshapiro / build.gradle
Created June 29, 2015 16:25
GIT_SHA in crashlytics version
def VERSION_NAME = "1.0.0"
def GIT_SHA = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
android {
defaultConfig {
versionName VERSION_NAME
}
buildTypes {
debug {
@ronshapiro
ronshapiro / bash-git-warning.sh
Created June 26, 2012 05:14
Git command line branch warning
# Add this to your .bash_profile
# Use this to highlight the current git branch name in your bash prompt - very useful for warning you about git branches that you should not be editing locally
# to add a warning for a branch, do `git config --local --add branch.BRANCHNAME.editwarning true` and unset with `git config --local --unset branch.BRANCHNAME.editwarning
# Colors can be found at https://wiki.archlinux.org/index.php/Color_Bash_Prompt
# thanks to @shreyansb - https://github.com/shreyansb/dotfiles/blob/master/bash/bash_profile for the idea
# and https://gist.github.com/31967 for PROMPT_COMMAND
#PROMPT_COMMAND tells bash to call format_PS1 every time prompt is requested,
#which will set PS1
PROMPT_COMMAND=format_PS1
@ronshapiro
ronshapiro / android_local_variables.xml
Created November 22, 2015 02:41
Sometimes I wish you could define inline resource values in Android XML that are scoped within their XML subtree.
<LinearLayout
android:variable:dimen:textSize="18sp">
<TextView
android:variable:dimen:paddingStartEnd="16dp"
android:variable:dimen:paddingTopBottom="16dp"
android:paddingStart="@local/paddingStartEnd"
android:paddingEnd="@local/paddingStartEnd"
android:paddingTop="@local/paddingTopBottom"
android:paddingBottom="@local/paddingTopBottom"
@ronshapiro
ronshapiro / semper-tmux.sh
Created December 19, 2012 01:06
A snippet to make sure you are always running a tmux session in your terminal. If you have an detached session, this will attach to it, otherwise, if there are no sessions or only ones which are attached, a new session will be started. Insert into your .bashrc or .bash_profile at the top to call every time you open a terminal session.
#############################################
# Attach tmux to the first detached session
#############################################
if [[ -z $TMUX ]]; then
TMUX_SESSIONS=`tmux list-sessions -F "#{session_name}ABC#{?session_attached,attached,not_attached}" 2>&1`
TMUX_FOUND=0
for i in $TMUX_SESSIONS
do
IS_ATTACHED=`echo $i | awk '{split($0,array,"ABC"); print array[2]}'`
@ronshapiro
ronshapiro / android-aliases.sh
Last active December 22, 2015 00:49
Some convenience aliases/functions for interfacing with adb
# easily parse Logcat output
alog () {
parser=ack
if [[ -e `which ack` ]]; then
parser=grep
fi
if (( $# == 0 )); then
adb logcat -v time
elif [[ $1 == "runtime" ]]; then
pattern='E/AndroidRuntime'
@ronshapiro
ronshapiro / maven-deploy.md
Last active June 1, 2016 12:29
Getting a jar on Maven Central: An Epic