Skip to content

Instantly share code, notes, and snippets.

@kingargyle
kingargyle / MediaCodecInfoUtil.kt
Created January 13, 2019 23:06
Detect Media Codecs on Device
package us.nineworlds.serenity.common.android.mediacodec
import android.media.MediaCodecList
import android.util.Log
class MediaCodecInfoUtil {
val supportedContainers = hashMapOf<String, Boolean>("video/mkv" to true, "video/mp4" to true, "video/avi" to false, "video/webm" to true, "video/ogg" to true, "video/mv4" to true)
/**
@kingargyle
kingargyle / BindingAdapter.java
Created November 29, 2018 21:16 — forked from JakeWharton/BindingAdapter.java
An adapter base class that uses a new/bind pattern for its views.
// Apache 2.0 licensed.
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/** An implementation of {@link BaseAdapter} which uses the new/bind pattern for its views. */
public abstract class BindableAdapter<T> extends BaseAdapter {
@kingargyle
kingargyle / AnimatingDialogFragment.kt
Last active November 18, 2018 03:26
A DialogFragment that support Animations useful for TV development
/**
* Dialog Fragment with hide animations
*/
class AnimatingDialogFragment : DialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.TvTheme_Dialog)
}
@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 <[email protected]>
# 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"