Skip to content

Instantly share code, notes, and snippets.

View andrewmunn's full-sized avatar

Andrew Munn andrewmunn

  • Lindy
  • San Francisco
View GitHub Profile
// fetch and display trending gifs from giphy using the giphy api via axios
import React, { useEffect, useState } from 'react';
import axios from 'axios';
interface Trending {
id: string;
title: string;
images: {
fixed_height: {
url: string;
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mymodule:testDebugUnitTest'.
> No tests found for given includes: [TestClassNames](--tests filter)
@andrewmunn
andrewmunn / build.gradle
Last active September 10, 2019 21:55
Configuring the root build.gradle to allow parallel test runs on CircleCi
subprojects {
afterEvaluate { project ->
if (project.plugins.findPlugin('android') ?: project.plugins.findPlugin('android-library')) {
android {
... // other config
testOptions {
unitTests.all {
@andrewmunn
andrewmunn / config.yml
Last active September 10, 2019 21:05
Split Gradle
...
- run:
command: |
TESTFILES=$(circleci tests glob "**/src/test/java/your/app/package/**/*Test.*" | circleci tests split --split-by=timings | tr ' ' $'\n' | sed -e 's/.*\//--tests /g' | sed -e 's/.kt//g' | sed -e 's/.java//g' | tr '\n' $' ')
echo ./gradlew testDebug ${TESTFILES}
./gradlew testDebug ${TESTFILES}
;;
...
@andrewmunn
andrewmunn / joinTo.kt
Last active February 28, 2018 07:36
Iterable.JoinTo
/**
* Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.
*
* If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
* elements will be appended, followed by the [truncated] string (which defaults to "...").
*/
public fun <T, A : Appendable> Iterable<T>.joinTo(
buffer: A,
separator: CharSequence = ", ",
prefix: CharSequence = "",
@andrewmunn
andrewmunn / joinToString.kt
Created February 28, 2018 07:33
JoinToString
/**
* Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.
*
* If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
* elements will be appended, followed by the [truncated] string (which defaults to "...").
*/
public fun <T> Iterable<T>.joinToString(
separator: CharSequence = ", ",
prefix: CharSequence = "",
postfix: CharSequence = "",
@andrewmunn
andrewmunn / toSingleLineStringForDisplayV4.kt
Last active February 28, 2018 07:44
toSingleLineStringForDisplay V4
fun toSingleLineStringForDisplay() =
listOfNotNull(street1, street2, street3, street4, city, "$state $postalCode")
.joinToString()
@andrewmunn
andrewmunn / toSingleLineStringForDisplayV3.kt
Created February 28, 2018 07:22
toSingleLineStringForDisplay V3
fun toSingleLineStringForDisplay() = buildString {
append(street1, ", ")
street2?.let { append(it, ", ") }
street3?.let { append(it, ", ") }
street4?.let { append(it, ", ") }
append("$city, $state $postalCode")
}
@andrewmunn
andrewmunn / toSingleLineStringForDisplayV0.kt
Created February 28, 2018 07:11
toSingleLineStringForDisplay V0
fun toSingleLineStringForDisplay(): String {
val sb = StringBuilder()
sb.append(street1).append(", ")
if (street2 != null) {
sb.append(street2).append(", ")
}
if (street3 != null) {
sb.append(street3).append(", ")
}
if (street4 != null) {
@andrewmunn
andrewmunn / BuildString.kt
Created February 28, 2018 06:57
BuildString
/**
* Builds new string by populating newly created [StringBuilder] using provided [builderAction]
* and then converting it to [String].
*/
public inline fun buildString(builderAction: StringBuilder.() -> Unit): String =
StringBuilder().apply(builderAction).toString()