Skip to content

Instantly share code, notes, and snippets.

@kingargyle
kingargyle / FocusableLinearLayoutManager.kt
Created October 31, 2018 01:48
Focusable Linear Smooth Scrolling for use with Android TV and Recycler View
/**
* The MIT License (MIT)
* Copyright (c) 2018 David Carver
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@kingargyle
kingargyle / AbstractSupportFragmentAssert
Created September 7, 2018 18:44
DialogSupportFragment Assertions
package com.abercrombie.abercrombie.assertions;
import android.annotation.TargetApi;
import android.support.v4.app.Fragment;
import org.assertj.core.api.AbstractAssert;
import static android.os.Build.VERSION_CODES.HONEYCOMB;
import static android.os.Build.VERSION_CODES.HONEYCOMB_MR2;
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1;
import static org.assertj.core.api.Assertions.assertThat;
@kingargyle
kingargyle / git-completion.bash
Created February 7, 2018 15:39 — forked from tomykaira/git-completion.bash
Show completion candidates for git-add, git-checkout --, and git-reset HEAD --
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
@kingargyle
kingargyle / openconnect.md
Created February 6, 2018 14:46 — forked from moklett/openconnect.md
OpenConnect VPN on Mac OS X

Unfortunately, the Cisco AnyConnect client for Mac conflicts with Pow. And by "conflicts", I mean it causes a grey-screen-of-death kernel panic anytime you connect to the VPN and Pow is installed.

As an alternative, there is OpenConnect, a command-line client for Cisco's AnyConnect SSL VPN.

Here's how to get it set up on Mac OS X:

  1. OpenConnect can be installed via homebrew:

     brew update
    

brew install openconnect

@kingargyle
kingargyle / proguard.pro
Created November 30, 2017 19:22
Toothpick Reflection Free Proguard Rules
# Note that if we could use kapt to generate registries, possible to get rid of this
-keepattributes Annotation
# Do not obfuscate classes with Injected Constructors
-keepclasseswithmembernames class * {
@javax.inject.Inject (...);
}
# Do not obfuscate classes with Injected Fields
-keepclasseswithmembernames class * {
@javax.inject.Inject ;
}
@kingargyle
kingargyle / gdc.py
Created November 14, 2017 18:22
Python 3 script to download github download stats for releases
#!/usr/bin/env python
import os
import sys
if (len(sys.argv) < 2):
print ("Usage: " + sys.argv[0] + " github-user [github-project]")
exit(1)
try:
@kingargyle
kingargyle / gist:6d9354d50ccbf6b4d681bb5c7ab6666b
Created November 9, 2017 15:58
Batch Convert Images with ImageMagic
Command line option for converting a batch of images from jpeg to png, adding a transparent background and resizing the images to 30%
of their original file size.
FOR /R %a IN (*.jpg) DO "C:\Program Files\ImageMagick-7.0.7-Q16\magick.exe" "%~a" -transparent black -adaptive-resize 28x29%\! "C:\Work\temp\%~na.png"
@kingargyle
kingargyle / CSSStyleRuleAssert.java
Created November 7, 2017 19:30
Verifying CSS rules, properties and values with AssertJ and Java. This leverages the cssparser.sourceforge.net project and the SAC w3c lib.
package us.nineworlds.xstreamer.templates.css.asserts;
import org.assertj.core.api.AbstractAssert;
import org.w3c.dom.css.CSSStyleRule;
import org.w3c.dom.css.CSSValue;
public class CSSStyleRuleAssert extends AbstractAssert<CSSStyleRuleAssert, CSSStyleRule> {
protected CSSStyleRuleAssert(CSSStyleRule actual) {
super(actual, CSSStyleRuleAssert.class);
@kingargyle
kingargyle / ShadowSubtitleView.java
Last active September 4, 2017 23:04
A ShadowSubtitleView for use with Exoplayer Simple View and Robolectric.
// A shadow for the ExoPlayer Subtitle View for use with Robolectric. Allows the view to inflate on any API level
// Add it to the config annotation (shadows = ShadowSubtitleView.class).
import com.google.android.exoplayer2.text.CaptionStyleCompat;
import com.google.android.exoplayer2.ui.SubtitleView;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.RealObject;
import org.robolectric.shadows.ShadowView;
@kingargyle
kingargyle / MvpFrameLayout.java
Created August 17, 2017 12:54
Moxy MVP FrameLayout View example
package us.nineworlds.serenity.ui.views.mvp;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.os.Parcelable;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;