Skip to content

Instantly share code, notes, and snippets.


Scott Alexander-Bown scottyab

View GitHub Profile
chrisbanes / CoroutineLifecycleObserver.kt
Last active May 21, 2020
LifecycleObserver which allows easy cancelling of coroutines
View CoroutineLifecycleObserver.kt
* Copyright 2018 Google LLC
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
LouisCAD / LifecycleCoroutines.kt
Last active Aug 31, 2020
CoroutineScope and Job integration with Lifecycle for Android. Meant to be used for your coroutines in lifecycle aware components. OUTDATED. See up to date implementation here:
View LifecycleCoroutines.kt
import android.arch.lifecycle.GenericLifecycleObserver
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.Lifecycle.Event.ON_DESTROY
import android.arch.lifecycle.LifecycleOwner
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.Job
fun Lifecycle.createJob(cancelEvent: Lifecycle.Event = ON_DESTROY): Job {
airowe / AddingOnPageChangedListener
Last active Jan 18, 2018
Android ViewPager allowing for horizontally scrolling of each View without trigger onPageChanged
View AddingOnPageChangedListener
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
viewPagerAdapter = MLPagedScrollAdapter(childFragmentManager, fragments)
fragmentViewPager = viewPager!!
fragmentViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) {
viewPager.scrollState = state
brownsoo / android-architecture-components-proguard.txt
Created Jul 25, 2017
Proguard setting for Android Architecture Components
View android-architecture-components-proguard.txt
## Android architecture components: Lifecycle
# LifecycleObserver's empty constructor is considered to be unused by proguard
-keepclassmembers class * implements android.arch.lifecycle.LifecycleObserver {
# ViewModel's empty constructor is considered to be unused by proguard
-keepclassmembers class * extends android.arch.lifecycle.ViewModel {
# keep Lifecycle State and Event enums values
View gist:aa8f9d2e59c3eb727723c2d1c27b1f5e
1.Install the BEEKs app from the Play store (this is not a Google product)
2.Hold the beacon to the back of the phone (most helpful when there are >1 beacons in the room)
3.The beacon marked (NEAR) will be at the top, select that
4.When connected, a LED will glow inside the beacon
5.Scroll down to the Eddystone area
6.Two buttons, one to set the URL another to set the power/frequency
7.Suggested transmit power is -20dbm at 2 times a second
divergentdave /
Last active Aug 12, 2020
Ignoring Expired TLS Certificates in Java
polbins /
Last active May 20, 2020
Android Studio as default Git Diff Tool

Create Android Studio Command-line Launcher

  1. Open Android Studio
  2. Go to: Tools > Create Command-line Launcher
  3. Leave as default, Press OK

Configure Git to use Android Studio as default Diff Tool

  1. Add the following lines to your .gitconfig
amulyakhare /
Created Aug 27, 2015
Bash script to update the application icon of our internal release builds to include a visual marker and version number on the icon for convenience of the testers.
# $> bash <version label> <project dir> <script sub-dir>
# process_icon version_num res_sub_dir current_work_dir target_dir
image_width=`identify -format %[fx:w] $3/app/src/main/res/drawable-$2/com_garena_shopee_logo_shopee_launcher.png` && let "image_width-=4"
image_height=`identify -format %[fx:h] $3/app/src/main/res/drawable-$2/com_garena_shopee_logo_shopee_launcher.png` && let "image_height-=4"
convert $3$4/marker.png -background '#0000' -fill white -gravity south -size 137x16 caption:$1 -composite -resize $image_widthx$image_height $3$4/intermediate.png
convert -composite -gravity center $3/app/src/main/res/drawable-$2/com_garena_shopee_logo_shopee_launcher.png $3$4/intermediate.png $3$4/com_garena_shopee_logo_shopee_launcher.png
akash1810 /
Last active Oct 27, 2020
Google Apps Script to post a message to Slack when someone responds to a Google Form.
* Google Apps Script to post a message to Slack when someone responds to a Google Form.
* Uses Slack incoming webhooks -
* and FormsResponse -
* Akash A <>
rodrigohenriques /
Last active Jun 22, 2020
Used to make your EditText a better option than Spinners
public class ClickToSelectEditText<T extends Listable> extends AppCompactEditText {
List<T> mItems;
String[] mListableItems;
CharSequence mHint;
OnItemSelectedListener<T> onItemSelectedListener;
public ClickToSelectEditText(Context context) {
You can’t perform that action at this time.