Skip to content

Instantly share code, notes, and snippets.

Alex Lockwood alexjlockwood

Block or report user

Report or block alexjlockwood

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@alexjlockwood
alexjlockwood / PathCompat.java
Last active Nov 5, 2019
Backports Path#approximate(float) for pre-O devices.
View PathCompat.java
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.os.Build;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Size;
import java.util.ArrayList;
import java.util.List;
View androidx-class-mapping.csv
android.support.v7.widget.util.SortedListAdapterCallback androidx.recyclerview.widget.SortedListAdapterCallback
android.support.v7.widget.helper.ItemTouchUIUtilImpl androidx.recyclerview.widget.ItemTouchUIUtilImpl
android.support.v7.widget.helper.ItemTouchUIUtil androidx.recyclerview.widget.ItemTouchUIUtil
android.support.v7.widget.helper.ItemTouchHelper androidx.recyclerview.widget.ItemTouchHelper
android.support.v7.widget.WithHint androidx.appcompat.widget.WithHint
android.support.v7.widget.ViewUtils androidx.appcompat.widget.ViewUtils
android.support.v7.widget.ViewStubCompat androidx.appcompat.widget.ViewStubCompat
android.support.v7.widget.ViewInfoStore androidx.recyclerview.widget.ViewInfoStore
android.support.v7.widget.ViewBoundsCheck androidx.recyclerview.widget.ViewBoundsCheck
android.support.v7.widget.VectorEnabledTintResources androidx.appcompat.widget.VectorEnabledTintResources
@alexjlockwood
alexjlockwood / svgo.json
Last active Oct 30, 2019
A customized SVGO (github.com/svg/svgo) config for use with the Sketch SVGO Compressor plugin (github.com/BohemianCoding/svgo-compressor).
View svgo.json
{
"comment": "This is the settings file for the SVGO Compressor Plugin. For more info, please check <https://github.com/BohemianCoding/svgo-compressor>",
"pretty": true,
"indent": 2,
"floatPrecision": 3,
"plugins": [
{
"name": "removeDoctype",
"enabled": true
},
@alexjlockwood
alexjlockwood / TypedArrayUtils.kt
Created Aug 13, 2019
Kotlin helper functions for extracting ColorStateLists and Drawables from a TypedArray using AppCompatResources.
View TypedArrayUtils.kt
import android.content.Context
import android.content.res.ColorStateList
import android.content.res.TypedArray
import android.graphics.drawable.Drawable
import androidx.annotation.StyleableRes
import androidx.appcompat.content.res.AppCompatResources
/**
* Utility methods for extracting [ColorStateList]s and [Drawable]s from a [TypedArray].
@alexjlockwood
alexjlockwood / piazza.py
Last active Sep 4, 2019
Authenticating with Piazza's Internal REST API
View piazza.py
import urllib2
from cookielib import CookieJar
cj = CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# login to Piazza.
login_url = 'https://piazza.com/logic/api?method=user.login'
login_data = '{"method":"user.login","params":{"email":"alockwoo@andrew.cmu.edu","pass":"fakePassword"}}'
@alexjlockwood
alexjlockwood / MainActivity.java
Last active Aug 29, 2019
Sample usage of the "android.app.Application.ActivityLifecycleCallbacks" class.
View MainActivity.java
public class MainActivity extends Activity {
private final MyActivityLifecycleCallbacks mCallbacks = new MyActivityLifecycleCallbacks();
@Override
protected void onCreate(Bundle savedInstanceState) {
// Always register before calling into the super class.
getApplication().registerActivityLifecycleCallbacks(mCallbacks);
super.onCreate(savedInstanceState);
@alexjlockwood
alexjlockwood / RingOfCirclesView.kt
Last active Aug 27, 2019
Kotlin implementation of a Ring of Circles animation, inspired by https://twitter.com/InfinityLoopGIF/status/1101584983259533312
View RingOfCirclesView.kt
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import android.view.View
private const val N = 16
private const val PERIOD1 = -10000.0
private const val PERIOD2 = -500.0
@alexjlockwood
alexjlockwood / flatten.js
Created Dec 11, 2016 — forked from timo22345/flatten.js
Flatten.js, general SVG flattener. Flattens transformations of SVG shapes and paths. All shapes and path commands are supported.
View flatten.js
<!doctype html>
<html>
<title>Flatten.js, General SVG Flattener</title>
<head>
<script>
/*
Random path and shape generator, flattener test base: http://jsfiddle.net/xqq5w/embedded/result/
Basic usage example: http://jsfiddle.net/Nv78L/3/embedded/result/
@alexjlockwood
alexjlockwood / AppCompatViewConstructorDetector.kt
Created Aug 10, 2019
Custom lint rule that prohibits requires instantiating AppCompat views when possible.
View AppCompatViewConstructorDetector.kt
package com.lyft.android.lint.checks
import com.android.SdkConstants
import com.android.tools.lint.detector.api.*
import com.intellij.psi.PsiMethod
import org.jetbrains.uast.UCallExpression
class AppCompatViewConstructorDetector : Detector(), Detector.UastScanner {
companion object {
@alexjlockwood
alexjlockwood / WaveSquare.kt
Created Mar 11, 2019
Kotlin implementation of a wave square animation, inspired by https://twitter.com/beesandbombs/status/1101169015299420163
View WaveSquare.kt
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Path
import android.util.AttributeSet
import android.view.View
import kotlin.math.atan2
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt
You can’t perform that action at this time.