Skip to content

Instantly share code, notes, and snippets.

View AdamMc331's full-sized avatar

Adam McNeilly AdamMc331

View GitHub Profile
@jonfhancock
jonfhancock / KotlinShared.xml
Last active December 10, 2020 01:35
Android Studio live templates. Apply them following directions here: https://www.jetbrains.com/help/idea/sharing-live-templates.html
<templateSet group="KotlinShared">
<template name="krequire" value="requireNotNull($VAR$) {&#10; &quot;Required value '$VAR$' in $CLASS_NAME$.$FUNCTION_NAME$() was null.&quot;&#10;}&#10;$END$" description="Require Not Null with a helpful print statement" toReformat="true" toShortenFQNames="true">
<variable name="VAR" expression="kotlinVariable()" defaultValue="" alwaysStopAt="true" />
<variable name="CLASS_NAME" expression="kotlinClassName()" defaultValue="" alwaysStopAt="false" />
<variable name="FUNCTION_NAME" expression="kotlinFunctionName()" defaultValue="" alwaysStopAt="false" />
<context>
<option name="KOTLIN" value="true" />
</context>
</template>
</templateSet>
@vlio20
vlio20 / StatusCode.kt
Last active June 19, 2023 23:56
Kotlin Http Status Codes enum
package oogaday.commons.enums
enum class StatusCode(val code: Int) {
Continue(100),
SwitchingProtocols(101),
Processing(102),
OK(200),
Created(201),
Accepted(202),
@adavis
adavis / CommonExtensions.kt
Last active April 2, 2024 20:51
Common Android Extensions in Kotlin
fun View.visible() {
visibility = View.VISIBLE
}
fun View.invisible() {
visibility = View.INVISIBLE
}
fun View.gone() {
visibility = View.GONE
@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);
@JakeWharton
JakeWharton / ShampooRule.java
Last active August 31, 2023 15:47
Got flaky tests? Shampoo them away with a quick JUnit rule. Apache 2.
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
/** Got flaky tests? Shampoo them away. */
public final class ShampooRule implements TestRule {
private final int iterations;
public ShampooRule(int iterations) {
if (iterations < 1) throw new IllegalArgumentException("iterations < 1: " + iterations);
@yqritc
yqritc / gist:ccca77dc42f2364777e1
Last active March 29, 2024 10:25
Equal column spacing for Android RecyclerView GridLayoutManager by using custom ItemDecoration

ItemOffsetDecoration

public class ItemOffsetDecoration extends RecyclerView.ItemDecoration {

    private int mItemOffset;

    public ItemOffsetDecoration(int itemOffset) {
        mItemOffset = itemOffset;
    }
@rogerallen
rogerallen / us_state_abbrev.py
Last active April 3, 2024 15:24
A Python Dictionary to translate US States to Two letter codes
# United States of America Python Dictionary to translate States,
# Districts & Territories to Two-Letter codes and vice versa.
#
# Canonical URL: https://gist.github.com/rogerallen/1583593
#
# Dedicated to the public domain. To the extent possible under law,
# Roger Allen has waived all copyright and related or neighboring
# rights to this code. Data originally from Wikipedia at the url:
# https://en.wikipedia.org/wiki/ISO_3166-2:US
#