Skip to content

Instantly share code, notes, and snippets.

View Jthomas54's full-sized avatar

Justin Thomas Jthomas54

  • Tonal
  • United States
View GitHub Profile
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.drive.Drive;
import com.google.android.gms.drive.DriveApi;
import com.google.android.gms.drive.DriveContents;
@Jthomas54
Jthomas54 / ElasticTranscoder.cs
Created May 27, 2016 16:28
Simple Elastic Transcoder Fluent Interface
using System;
using System.Collections.Generic;
using System.Linq;
using Amazon.ElasticTranscoder.Model;
namespace AmazonHelpers
{
public sealed class ElasticTranscoder
{
@Jthomas54
Jthomas54 / build.gradle
Last active June 9, 2017 16:40
Tasks for doclava and jars
android {
configurations {
//Used to hold the doclava dependency configuration
doclava
//Used to hold the other dependency configuration
classpaths
}
dependencies {
@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();
@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 / 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 / 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 / .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 / 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 / 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