Skip to content

Instantly share code, notes, and snippets.

View axemorgan's full-sized avatar
🚀
Composing myself

Alex Morgan axemorgan

🚀
Composing myself
  • The Kroger Co
  • Cincinnati, Ohio
View GitHub Profile
@axemorgan
axemorgan / Tracer.java
Created January 14, 2016 15:17
A wrapper for Android's Trace utility that checks the SDK version so you don't have to before each call.
import android.os.Build;
import android.os.Trace;
import android.support.annotation.NonNull;
/**
* A wrapper for {@link Trace}, which is unavailable on SDK versions under 18 (Jelly Bean MR2).
* Using any methods of this class on versions below 18 will result in a runtime exception.
*/
public class Tracer {
private static final int REQUIRED_SDK = Build.VERSION_CODES.JELLY_BEAN_MR2;
@axemorgan
axemorgan / NonNullArrayList.java
Created January 14, 2016 15:10
An ArrayList implementation that does not accept null values. Attempts to add null to it result in an exception.
import java.util.ArrayList;
import java.util.Collection;
/**
* An {@link ArrayList} implementation that does not accept null values. Attempts to add
* <code>null</code> using any of the add methods will result in an {@link IllegalArgumentException}
* being thrown. Attempts to addAll from a Collection that contains null elements will also result
* in an exception.
* <p/>
* Here's why: <a href="https://github.com/google/guava/wiki/UsingAndAvoidingNullExplained">UsingAndAvoidingNullExplained</a>
@axemorgan
axemorgan / adb-reconnect.sh
Last active September 22, 2015 17:00
A shell script to read the IP adress of a USB connected Android device and automatically re-connect to it via wireless ADB.
# A command line utility for automatically connecting ADB (Android Debug Bridge) to a USB connected Android device
# Records the status of the wifi interface on the device
adb shell ifconfig wlan0 > line
if [ "$?" -gt 0 ]
then
echo "Couldn't read IP address from device. Is it connected via USB?"
exit 1
fi