Skip to content

Instantly share code, notes, and snippets.

@ronshapiro
ronshapiro / maven-deploy.md
Last active June 1, 2016 12:29
Getting a jar on Maven Central: An Epic
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 {
{
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"],
@ronshapiro
ronshapiro / RxApiClient.java
Last active August 8, 2016 04:38
An API client shell that abstracts it's mechanism of executing network calls and provides a simple interface to making the calls using RxJava and Java 8.
package me.ronshapiro.rxjavatest.app;
import java.util.concurrent.Executors;
import rx.Observable;
import rx.Observable.OnSubscribe;
import rx.Scheduler;
import rx.Subscriber;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
@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 / 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 / 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