Skip to content

Instantly share code, notes, and snippets.

View scottyab's full-sized avatar

Scott Alexander-Bown scottyab

View GitHub Profile
@chrisbanes
chrisbanes / CoroutineLifecycleObserver.kt
Last active September 9, 2022 14:07
LifecycleObserver which allows easy cancelling of coroutines
/*
* 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 July 3, 2022 11:47
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
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 January 18, 2018 15:53
Android ViewPager allowing for horizontally scrolling of each View without trigger onPageChanged
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 July 25, 2017 09:17
Proguard setting for Android Architecture Components
## 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
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 April 26, 2022 08:13
Ignoring Expired TLS Certificates in 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 June 20, 2022 02:50
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
amulyakhare / icon-gen.sh
Created August 27, 2015 10:53
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.
#!/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 October 13, 2021 13:42
Google Apps Script to post a message to Slack when someone responds to a Google Form.
/**
* 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 February 12, 2023 07:44
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) {
super(context);