Skip to content

Instantly share code, notes, and snippets.


Scott Alexander-Bown scottyab

View GitHub Profile
scottyab / meetup-graphql-query-variables.txt
Last active August 14, 2023 13:52
Query all the past events a group has hosted. Meetup doesn’t great way of surfacing a meetup groups past events (paging through the calendar is PITA). This GraphQL query can be run from the MeetupAPI GraphQL playground
View meetup-graphql-query-variables.txt
{ "urlname": "YOUR URL PATH here, for the urlname is swmobile" }
scottyab / AssertExtensions.kt
Created March 20, 2023 10:31
Assert `isInstanceOf` extensions to improve readablity of JUnit test assertions. I've found this most useful when asserting sealed class result objects as you can asset it's the correct type and then via smart casting continue to assert any specifics of the result, in the sample below I assert the type and then taskId.
View AssertExtensions.kt
import org.assertj.core.api.AbstractObjectAssert
inline fun <reified R> AbstractObjectAssert<*, *>.isNotInstanceOf(): AbstractObjectAssert<*, *>? =
inline fun <reified R> AbstractObjectAssert<*, *>.isInstanceOf(): AbstractObjectAssert<*, *>? =
scottyab / KoltinUnitTestTemplate.kt
Created February 9, 2023 11:46
Jetbrains IDE code template for JUnit tests written in Kotlin.
View KoltinUnitTestTemplate.kt
package ${PACKAGE_NAME}
import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.whenever
import org.assertj.core.api.Assertions.assertThat
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.junit.MockitoJUnitRunner
scottyab / firebase-hosting-deploy.yml
Last active January 4, 2023 09:51
Github action used on to Build Jekyll and Deploy to Firebase Hosting when commits pushed to main. `GITHUB_TOKEN`, `FIREBASE_PROJECT_ID`, `FIREBASE_SERVICE_ACCOUNT` will vary for your setup and need to be configured via Githuib repo settings..
View firebase-hosting-deploy.yml
name: Build and Deploy to Firebase
- main
name: Build and deploy Jekyll site
runs-on: ubuntu-latest
scottyab / MyAppFirebaseMessagingService.kt
Last active August 17, 2020 13:32
Sample of how an app "MyApp" would intergrate and enable Beacon SDK push notifications
View MyAppFirebaseMessagingService.kt
class MyAppFirebaseMessagingService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
if( {
private fun processNewMessage(remoteMessageData: Map<String, String>) {
if (BeaconPushNotificationsProcessor.isBeaconNotification(remoteMessageData)) {
scottyab / SampleEncPrefs.kt
Created July 24, 2019 20:12
Simple example of using EncrypredSharedPreferences
View SampleEncPrefs.kt
import android.content.Context
import android.content.SharedPreferences
import com.scottyab.whatsnewplayground.BuildConfig
internal class SampleEncPrefs(context: Context) {
scottyab /
Created October 29, 2018 15:22 — forked from milosmns/
Android: Coloring (Helper Class)
package me.angrybyte.coloringdemo;
import static;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
#!/usr/bin/env bash
# exit if fails
set -o errexit
set -o pipefail
# reads the first arg as the file - expected list of file names without extension
# loops through each line
while read -r line
scottyab /
Last active May 24, 2018 09:17 — forked from rodrigosetti/
Adds Copyright Notice to a bunch of Java and Kotlin files
scottyab / Contract Killer
Created November 24, 2017 12:38 — forked from malarkey/Contract Killer
The latest version of my ‘killer contract’ for web designers and developers