Skip to content

Instantly share code, notes, and snippets.

View set-version-from-git.sh
#!/usr/bin/env bash
# set-version-from-git.sh
# Usage: `set-version-from-git.sh [branch]`
# Run this script after the 'Copy Bundle Resources' build phase
# Ref: http://tgoode.com/2014/06/05/sensible-way-increment-bundle-version-cfbundleversion-xcode/
# Sets the build and version numbers in the compiled app bundle so it doesn't
# modify your version controlled info.plist
branch=${1:-'master'}
@bulwinkel
bulwinkel / README_APPCENTER_SCRIPTS.md
Last active Oct 8, 2018
Hydric AppCenter Scripts: Post to slack for iOS
View README_APPCENTER_SCRIPTS.md

Hydric AppCenter Scripts for iOS

Currently these scripts post to slack when:

  • a build starts
  • a build finishes successfully

Usage Instructions

  1. Create an incoming webhook for the channel you would like these scripts to post to.
  2. Download and extract all the files from this gist into the root directory of your iOS project.
    If you have 'jq' installed (brew install jq) you can do this step with the following command from the root directory of your project:
    curl --silent "https://gist.github.com/bulwinkel/b1c371d447df071b90fe6e331d8b7d98/archive/$(http https://api.github.com/gists/b1c371d447df071b90fe6e331d8b7d98/commits | jq -r '.[0].version').zip" | tar --strip-components=1 -xf - -C .
@bulwinkel
bulwinkel / org-res.sh
Created Jan 15, 2018
script that moved imageRes-mdpi.png into res/mdpi/imageRes.png
View org-res.sh
RESOLUTIONS=('-mdpi' '-hdpi' '-xhdpi' '-xxhdpi' '-xxxhdpi')
for res in "${RESOLUTIONS[@]}"; do
echo $res
DIR="res/drawable${res}"
mkdir -p ${DIR}
for file in $(find . -type f -iname "*${res}*"); do
echo "${file}"
mv "$file" "${DIR}/${file/${res}/}"
done
@bulwinkel
bulwinkel / HttpExceptions.java
Last active Jul 4, 2017
Utility class for checking if a Throwableis a HttpException of a specific codes.
View HttpExceptions.java
package com.nm.support.okhttp;
import retrofit2.HttpException;
import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR;
import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED;
public final class HttpExceptions {
private HttpExceptions() {
View RealmListJsonAdapter.java
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.JsonReader;
import com.squareup.moshi.JsonWriter;
import com.squareup.moshi.Moshi;
import com.squareup.moshi.Types;
import io.realm.RealmList;
import io.realm.RealmModel;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@bulwinkel
bulwinkel / CharSequences.java
Created Jan 12, 2017
Android helper functions for highlighting a search term in a given CharSequence.
View CharSequences.java
import android.support.annotation.ColorInt;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jetbrains.annotations.NotNull;
import static android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE;
@bulwinkel
bulwinkel / mapToBundle.kt
Created Jan 7, 2017
Partial implementation of converting a `Map<String, V>` to a Bundle.
View mapToBundle.kt
package com.bulwinkel.android
import android.os.Bundle
import android.os.IBinder
import android.os.Parcelable
import java.io.Serializable
fun <V> Map<String, V>.toBundle(bundle: Bundle = Bundle()): Bundle = bundle.apply {
forEach {
val k = it.key
@bulwinkel
bulwinkel / TypedValues.java
Created Aug 18, 2016
Android TypedValue Utilities (px -> dp)
View TypedValues.java
import android.content.Context;
import android.util.TypedValue;
public class TypedValues {
private TypedValues() {
//no instances
}
public static int dip(Context context, float dp) {
@bulwinkel
bulwinkel / Windows.java
Created Aug 18, 2016
Android Window Utilities
View Windows.java
import android.annotation.TargetApi;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.view.Window;
import android.view.WindowManager;
public class Windows {
private Windows() {
//no instances
@bulwinkel
bulwinkel / SerializedProperty.java
Created Jul 31, 2016
Serialize Properties into Bundles and back (Experimental)
View SerializedProperty.java
import android.os.Bundle;
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import java.io.IOException;
/**
* Removes some of the boilerplate associated with Properties in android fragments by handling
* the serialization and deserialization of wrapped objects into and out of argument
* {@link Bundle}s.
*