Skip to content

Instantly share code, notes, and snippets.

@bulwinkel
bulwinkel / main.dart
Created February 8, 2022 02:02
Row with spacer
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@bulwinkel
bulwinkel / set-version-from-git.sh
Created October 9, 2018 00:42
iOS Git Versioning
#!/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 October 8, 2018 03:38
Hydric AppCenter Scripts: Post to slack for iOS

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 January 15, 2018 03:01
script that moved imageRes-mdpi.png into res/mdpi/imageRes.png
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 July 4, 2017 07:51
Utility class for checking if a Throwableis a HttpException of a specific codes.
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() {
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 January 12, 2017 01:40
Android helper functions for highlighting a search term in a given CharSequence.
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 January 7, 2017 13:35
Partial implementation of converting a `Map<String, V>` to a Bundle.
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 August 18, 2016 13:11
Android TypedValue Utilities (px -> dp)
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 August 18, 2016 13:08
Android Window Utilities
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