Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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;
{
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 / maven-deploy.md
Last active June 1, 2016 12:29
Getting a jar on Maven Central: An Epic
@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 / iOS_Android_Vocab_Cheat_Sheet.md
Last active February 1, 2023 07:54
iOS <> Android Vocab Cheat Sheet

iOS <> Android Vocab Cheat Sheet

A couple months ago while at Venmo, @chrismaddern and I discussed the lack of a bidirectional dictionary/vocab list of parallel terms in Android and iOS. It's important to know what your teammates are refering when they talk about code, even if you're not engaged with it every day. This is a beginning attempt to finally break down that knowledge gap. The goal is to allow developers of one framework to understand the basics of the other and should someone want to make the switch, this can be a resource in helping learn the new framework.

If there's a topic that you think would be interesting to discuss, tweet at me and we'll get include it in this list. I'll be updating this post with links to all future posts.

Disclaimer: I'm an Android developer and have done minimal iOS/Objective-C programming. If there is anything incorrect, reach out and I'll fix it as soon as possible. I'm assuming iOS developer are