Skip to content

Instantly share code, notes, and snippets.

View baz8080's full-sized avatar

Barry Carroll baz8080

  • Pinterest
  • Dublin
View GitHub Profile
@baz8080
baz8080 / flipFlop.sh
Last active July 26, 2016 19:06
Flipping images using ImageMagick
# This isn't a script. Just copy / paste or type along.
# Go to your downloads directory
cd ~/Downloads
# Unzip the icon set and cd into the directory
unzip -q ic_attach_file_black_24dp.zip
cd ic_attach_file_black_24dp
# At this point you'll have some lovely attach
@baz8080
baz8080 / clearGit.sh
Last active March 28, 2017 12:37
clearGit.sh
#!/bin/bash
GIT_STATUS=`git status --porcelain`
if [ ! -z "$GIT_STATUS" ] ; then
echo "This script will not run if git status --porcelain indicates that changes are present"
exit 1
fi
set -e
@baz8080
baz8080 / getConfigurationParameter.gradle
Created October 15, 2016 13:07
Gets a environment variable, or falls back to a property
/**
* Looks for the specified configuration key in this order:
*
* <ol>
* <li>system environment</li>
* <li>project properties</li>
* </ol>
*
* If it isn't found, then the empty string is returned. This stops the gradlew from failing until
* it actually needs those values.
@baz8080
baz8080 / ColorStateList.java
Created January 31, 2017 10:16
Creating ColorStateList programatically
int[][] states = new int[][] {
new int[] { android.R.attr.state_enabled },
new int[] { -android.R.attr.state_enabled }
};
int[] coloursLight = new int[] {
Color.argb(255, 255, 255, 255), // White, active, 100% opaque
Color.argb(128, 255, 255, 255) // White, inactive, 50% opaque
};
@baz8080
baz8080 / support_travis_matrix.yml
Created April 24, 2017 20:45
Support SDK travis matrix
env:
matrix:
- COMPONENT=unit
- COMPONENT=instrumentation-provider
- COMPONENT=instrumentation-sdk
- COMPONENT=sample
- COMPONENT=build
@baz8080
baz8080 / travis_before_script.sh
Created May 12, 2017 09:46
Travis before script
#!/usr/bin/env bash
set -e
# Starting emulators is very costly. We should only start them if we're building a matrix
# component which requires one. We start the travis_create_avd.sh in the background because
# we can get a small performance improvement by continuing the build, and only blocking and
# waiting for the emulator when we absolutely need it.
if [ "$COMPONENT" == "instrumentation-provider" ] || [ "$COMPONENT" == "instrumentation-sdk" ]; then
@baz8080
baz8080 / travis_create_avd.sh
Created May 12, 2017 09:55
Travis create AVD
#!/usr/bin/env bash
# Creates and starts an emulator.
# Avoid the tempation to skip the boot animation. CI scripts use that to figure out when the device is ready.
# The emulator is started in the background. This is to avoid holding up the build until we need it.
android-update-sdk --components=sys-img-armeabi-v7a-android-16 --accept-licenses='android-sdk-license-[0-9a-f]{8}'
echo no | android create avd --force -n test -t android-16 --abi armeabi-v7a --skin QVGA
emulator -avd test -no-audio -no-skin -netfast -no-window &
@baz8080
baz8080 / travis_script.sh
Created May 12, 2017 10:01
Travis dispatcher script
#!/usr/bin/env bash
set -e
if [ "$COMPONENT" == "unit" ]; then
./scripts/travis_test_unit.sh
elif [ "$COMPONENT" == "instrumentation-provider" ]; then
./scripts/travis_test_instrumentation_provider.sh
elif [ "$COMPONENT" == "instrumentation-sdk" ]; then
./scripts/travis_test_instrumentation_sdk.sh
@baz8080
baz8080 / unit_test_snippet.gradle
Created May 12, 2017 10:12
Unit test gradle snippets
// We use the --settings-file switch to ensure we are building the modules in isolated scopes
./gradlew --settings-file settings_only_providers.gradle clean :ZendeskProviders:assembleDebug :ZendeskProviders:lintDebug :ZendeskProviders:testDebug :ZendeskProviders:debugJavadoc
./gradlew --settings-file settings_only_sdk.gradle :ZendeskSDK:assembleDebug :ZendeskSDK:lintDebug :ZendeskSDK:testDebug :ZendeskSDK:debugJavadoc
@baz8080
baz8080 / travis_test_instrumentation_x.sh
Created May 12, 2017 10:21
Travis instrumentation test snippet
# We can build this part of the instrumentation tests before we need the emulator
./gradlew --settings-file settings_only_providers.gradle assembleDebug assembleDebugAndroidTest
# Now we absolutely need the emulator, so we check to see if we are on travis,
# and then we wait for it to start.
which android-wait-for-emulator > /dev/null
if [ "$?" -eq 0 ]; then
echo "Waiting for emulator..."
android-wait-for-emulator