Skip to content

Instantly share code, notes, and snippets.

View erikcox's full-sized avatar

Erik erikcox

View GitHub Profile
// One
if(BuildConfig.DEBUG) {
Toast.makeText(this, "Debug mode", Toast.LENGTH_SHORT).show();
}
// Two
try {
appInfo = pacMan.getApplicationInfo(pacName, 0);
} catch (NameNotFoundException e) {
Toast.makeText(this, "Could not find package " + pacName, Toast.LENGTH_SHORT).show();
@erikcox
erikcox / android_sdk_update.sh
Last active October 14, 2015 17:37
Android Notes
android update sdk --no-ui --all
@erikcox
erikcox / InetCheck.java
Created May 18, 2015 15:26
Check for Internet availability
public boolean canConnect() {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
@erikcox
erikcox / ADB_WiFI.sh
Created September 26, 2015 20:08
ADB over WiFi
# Plug in device via USB first
adb devices
adb tcpip 5555
# Unplug device
adb connect 192.168.1.10
adb devices
@erikcox
erikcox / androidSysSettings.java
Created November 16, 2014 20:31
Android intent to go to the system settings
/* Look into android.provider.Settings
Not all settings may be available on customized versions of Android,
so be sure to catch ActivityNotFoundException. */
try {
startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS));
} catch (ActivityNotFoundException e) {
// Unavailable
}
function fizzBuzz(n) {
for (i = 0; i <= n; i++) {
if (i % 15 === 0) {
console.log("FizzBuzz");
} else if (i % 3 === 0) {
console.log("Fizz");
} else if (i % 5 === 0) {
console.log("Buzz");
} else {
console.log(i);
@erikcox
erikcox / virtualenvwrapper.py
Created August 19, 2014 02:54
pip, virtualenv & virtualenvwrapper
mkvirtualenv [ENV_NAME] # creates and activates a fresh virtual environment
rmvirtualenv [ENV_NAME] # removes virtual environment
workon [ENV_NAME] # activates an already-created virtual environment
deactivate # deactivates the virtual environment that is currently active
# within an activated virtualenv
pip install [PACKAGE_NAME] #installs a package into the virtualenv
pip freeze # lists the packages that is installed & accessible within the virtualenv
@erikcox
erikcox / git.txt
Last active August 29, 2015 14:05
Git notes
# Setup
git config --global user.name "Erik Cox"
git config --global user.email "erikbcox@gmail.com"
git config --global color.ui auto
# Creating a new local repository
git init
# Cloning
git clone <URL>
@erikcox
erikcox / layout-debug.css
Created August 1, 2014 15:57
CSS layout debug class
.debug { border:1px dashed red; }