Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/
sudo amazon-linux-extras install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
class RgbConversion(val rs: RenderScript, private val feedSize: Size, private val hasRotate: Boolean = true) { | |
private var mInputAllocation: Allocation? = null | |
private var mOutputAllocation: Allocation? = null | |
private var mRotatedAllocation: Allocation? = null | |
private val yuvToRgb = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs)) | |
private val rotator = ScriptC_rotator(rs) | |
var bufferCallback: ((ByteBuffer) -> Unit)? = null | |
val inputSurface: Surface | |
get() = mInputAllocation!!.surface |
// | |
// ViewController.swift | |
// CameraFilter | |
// | |
import UIKit | |
import AVFoundation | |
class ViewController: UIViewController, AVCaptureVideoDataOutputSampleBufferDelegate { | |
Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/
sudo amazon-linux-extras install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?
There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.
Here I present a composable pattern for pure state machiness with effects,
import Foundation | |
import UIKit | |
public class Checkmark: UIView { | |
// MARK: Public variables | |
public var initialLayerColor: UIColor = UIColor.blue { | |
didSet { | |
initialLayer.strokeColor = initialLayerColor.cgColor | |
} |
import Foundation | |
import UIKit | |
public class Checkmark: UIView { | |
// MARK: Public variables | |
public var initialLayerColor: UIColor = UIColor.blue { | |
didSet { | |
initialLayer.strokeColor = initialLayerColor.cgColor | |
} |
A non-exhaustive list of WebGL frameworks and libraries. It is mostly for learning purposes as some of the libraries listed are outdated/not maintained anymore.
/** | |
* An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has | |
* already been handled. | |
* | |
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled. | |
*/ | |
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> { | |
override fun onChanged(event: Event<T>?) { | |
event?.getContentIfNotHandled()?.let { value -> | |
onEventUnhandledContent(value) |
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.graphics.Canvas; | |
import android.graphics.Rect; | |
import android.graphics.drawable.Drawable; | |
import android.support.v4.view.ViewCompat; | |
import android.util.AttributeSet; | |
import android.widget.FrameLayout; | |
/** |
import android.os.SystemClock; | |
import android.view.View; | |
import java.util.Map; | |
import java.util.WeakHashMap; | |
/** | |
* A Debounced OnClickListener | |
* Rejects clicks that are too close together in time. | |
* This class is safe to use as an OnClickListener for multiple views, and will debounce each one separately. |