Skip to content

Instantly share code, notes, and snippets.

Avatar

Scott Alexander-Bown scottyab

View GitHub Profile
@chrisbanes
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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@LouisCAD
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: https://github.com/LouisCAD/Splitties/tree/master/modules/lifecycle-coroutines
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
import kotlinx.coroutines.experimental.android.Main
fun Lifecycle.createJob(cancelEvent: Lifecycle.Event = ON_DESTROY): Job {
@airowe
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
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 {
<init>(...);
}
# ViewModel's empty constructor is considered to be unused by proguard
-keepclassmembers class * extends android.arch.lifecycle.ViewModel {
<init>(...);
}
# 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
divergentdave / Example.java
Last active Aug 12, 2020
Ignoring Expired TLS Certificates in Java
View Example.java
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
@polbins
polbins / README.md
Last active May 20, 2020
Android Studio as default Git Diff Tool
View README.md

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
amulyakhare / icon-gen.sh
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.
View icon-gen.sh
#!/bin/bash
# $> bash icon-gen.sh <version label> <project dir> <script sub-dir>
#
#
# process_icon version_num res_sub_dir current_work_dir target_dir
process_icon(){
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
akash1810 / slack-hook.gs
Last active Oct 27, 2020
Google Apps Script to post a message to Slack when someone responds to a Google Form.
View slack-hook.gs
/**
* ABOUT
* Google Apps Script to post a message to Slack when someone responds to a Google Form.
*
* Uses Slack incoming webhooks - https://api.slack.com/incoming-webhooks
* and FormsResponse - https://developers.google.com/apps-script/reference/forms/form-response
*
*
* AUTHOR
* Akash A <github.com/akash1810>
@rodrigohenriques
rodrigohenriques / ClickToSelectEditText.java
Last active Jun 22, 2020
Used to make your EditText a better option than Spinners
View ClickToSelectEditText.java
public class ClickToSelectEditText<T extends Listable> extends AppCompactEditText {
List<T> mItems;
String[] mListableItems;
CharSequence mHint;
OnItemSelectedListener<T> onItemSelectedListener;
public ClickToSelectEditText(Context context) {
super(context);
You can’t perform that action at this time.