Skip to content

Instantly share code, notes, and snippets.

View Jthomas54's full-sized avatar

Justin Thomas Jthomas54

  • Tonal
  • United States
View GitHub Profile
## Useful Commands
Get kubectl version
kubectl version
Get cluster info:
@Jthomas54
Jthomas54 / ColorsHelper.java
Created January 24, 2019 19:48
Determine contrasting color based on another
import android.graphics.Color;
public final class ColorsHelper {
/**
* Contrast constant as defined by W3C for the sRGB color space where white and black are used
* as the light and dark colors.
* <p>
* For more info, see https://www.w3.org/TR/WCAG20/#contrast-ratiodef
* </p>
*/
@Jthomas54
Jthomas54 / okhttp.WebviewCookieHandler.java
Created January 24, 2019 19:47
OkHttp and Webview cookie sharing
import android.webkit.CookieManager;
import java.io.IOException;
import java.net.CookieHandler;
import java.net.URI;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Jthomas54
Jthomas54 / StartLinearSnapHelper.kt
Created January 24, 2019 19:46
SnapHelper for RecyclerView to snap to the child's start instead of center
import android.support.v7.widget.LinearSnapHelper
import android.support.v7.widget.OrientationHelper
import android.support.v7.widget.RecyclerView
import android.view.View
open class StartLinearSnapHelper : LinearSnapHelper() {
protected var _verticalHelper: OrientationHelper? = null
protected var _horizontalHelper: OrientationHelper? = null
@Jthomas54
Jthomas54 / okhttp3.WebviewCookieHandler.java
Last active May 29, 2019 04:59
Cookie jar that handles syncing okhttp cookies with Webview cookie manager
import android.webkit.CookieManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
@Jthomas54
Jthomas54 / .bash_aliases
Last active October 24, 2021 03:28
files and scripts for setting up elementaryOS
cb() {
local _scs_col="\e[0;32m"; local _wrn_col='\e[1;31m'; local _trn_col='\e[0;33m'
# Check that xclip is installed.
if ! type xclip > /dev/null 2>&1; then
echo -e "$_wrn_col""You must have the 'xclip' program installed.\e[0m"
# Check user is not root (root doesn't have access to user xorg server)
elif [[ "$USER" == "root" ]]; then
echo -e "$_wrn_col""Must be regular user (not root) to copy a file to the clipboard.\e[0m"
else
# If no tty, data should be available on stdin
@Jthomas54
Jthomas54 / build.gradle
Last active January 9, 2018 18:40
Gradle helper functions for loading properties file and merging into project properties
loadExternalProperties('version.properties')
def loadExternalProperties(fileName) {
def Properties props = new Properties()
file(fileName).withInputStream { stream ->
props.load stream
props.each { prop ->
project.ext[prop.key] = prop.value
}
stream.close()
@Jthomas54
Jthomas54 / FusedLocationProvider.kt
Created December 6, 2017 15:49
Getting location updates with Android using the FusedLocationProviderClient
import android.content.Context
import android.location.Location
import com.google.android.gms.location.*
/**
* A default implementation using the fused location provider to supply the application with locations
*<p>
* You should ensure you have the correct permissions in the manifest, that the permissions have
* been granted, and location services are enabled.
@Jthomas54
Jthomas54 / Connectivity.kt
Last active December 6, 2017 15:28
Helpers for checking network connectivity on Android
import android.content.Context
import android.net.ConnectivityManager
import android.net.NetworkInfo
import android.os.Handler
import android.os.Looper
import java.net.URL
import java.net.UnknownHostException
import java.util.concurrent.Executors
import javax.net.ssl.HttpsURLConnection
@Jthomas54
Jthomas54 / VerticalTextView.java
Last active January 17, 2017 20:18
TextView that allows the text to be rendered vertically, from bottom to top
import android.content.Context
import android.graphics.Canvas
import android.graphics.Path
import android.graphics.Rect
import android.util.AttributeSet
import android.widget.TextView
public class VerticalTextView extends TextView {
private Rect _textBounds = new Rect();