On Mac, Homebrew is the de-facto package manager, and Homebrew Cask is the app manager. I’m going to use Cask to install Java 7 and 8.
Install Homebrew Cask first if you haven’t:
brew update
brew tap caskroom/cask
package datasizeformatter | |
import kotlin.math.abs | |
import kotlin.math.pow | |
import kotlin.math.roundToLong | |
/** | |
* Format a human-readable representation of data size, in binary base form. | |
* e.g. 1024 -> 1 KiB | |
* @param byteCount The number of bytes to represent in human-readable form. `Long.MIN_VALUE` is unsupported. |
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,
/** | |
* = Recursive descent parser = | |
* | |
* MIT Style License | |
* By Dmitry Soshnikov <[email protected]> | |
* | |
* In this short lecture we'll cover the basic (non-predictive, backtracking) | |
* recursive descent parsing algorithm. | |
* | |
* Recursive descent is an LL parser: scan from left to right, doing |
public class CustomView extends View { | |
private final Bus bus; | |
public CustomView(Bus bus, ....) { | |
super(....); | |
this.bus = bus; | |
} | |
@Override protected void onAttachedToWindow() { |
import android.os.SystemClock; | |
import android.support.v4.util.LruCache; | |
import java.util.HashMap; | |
import java.util.Map; | |
/** | |
* An Lru Cache that allows entries to expire after | |
* a period of time. Items are evicted based on a combination | |
* of time, and usage. Adding items past the {@code maxSize} |
<?php | |
/** | |
* Super-simple AWS CloudFront Invalidation Script | |
* | |
* Steps: | |
* 1. Set your AWS access_key | |
* 2. Set your AWS secret_key | |
* 3. Set your CloudFront Distribution ID | |
* 4. Define the batch of paths to invalidate | |
* 5. Run it on the command-line with: php cf-invalidate.php |