Skip to content

Instantly share code, notes, and snippets.

@willblaschko
willblaschko / ev.dart
Created December 12, 2020 17:06
Photography EV/F-Stop/ISO/Shutter Speed Calculations - Dart
import 'dart:math';
import 'package:lightmeterv2/models/shutter.dart';
class EV
{
static double luxToFC = 10.763910417;
static double calc(double f, int iso, Shutter sec)
{
double EV = (((log(f * f) / log(2.0)) - (log(sec.getValue()) / log(2.0))) - (log(iso / 100) / log(2.0)));
@willblaschko
willblaschko / benchmark.js
Created May 17, 2019 21:18
Alexa APL Benchmarking Script
const puppeteer = require('puppeteer');
const moment = require("moment");
let baseLayout = require('./layout_base.json');
const exec = require('child_process').execSync;
let sleep = function (ms) {
return new Promise(resolve => setTimeout(resolve, ms));
};
@willblaschko
willblaschko / audio_counter.json
Created April 13, 2019 23:13
Falling Blocks - an APL Tetris Clone (Voice Control)
...
{
"type": "Video",
"position": "absolute",
"top": "0dp",
"left": "0dp",
"source": "<my file>",
"id": "counter",
"autoplay": "false",
@willblaschko
willblaschko / data.json
Created March 24, 2019 22:53
An example of using nested APL elements (Containers, Pagers) to achieve over 200 items in a relatively small payload. Use sparingly, this starts to have impact on performance of rendering.
{
"grid": {
"values": [
[ 2, 2, 3, 4, 5, 6, 7, 8, 9, 10 ],
[ 1, 2, 4, 4, 5, 6, 7, 8, 9, 10 ],
[ 1, 1, 3, 4, 5, 6, 7, 8, 9, 10 ],
[ 2, 2, 3, 4, 5, 6, 7, 8, 9, 10 ],
[ 1, 2, 4, 4, 5, 6, 7, 8, 9, 10 ],
[ 1, 1, 3, 4, 5, 6, 7, 8, 9, 10 ],
[ 2, 2, 3, 4, 5, 6, 7, 8, 9, 10 ],
@willblaschko
willblaschko / spriteAnimations.js
Created March 23, 2019 22:20
An example of how to create rough APL sprite animations using Pagers and sequential page commands. Your mileage may vary on smoothness of transition based on other commands being executed.
...
let spriteCommands = [];
for (...) {
...
spriteCommands.push({
"type": "SetPage",
"componentId": "b",
@willblaschko
willblaschko / animations.js
Last active March 23, 2019 22:13
A Node.js support function (and example Sequences) that quickly creates all the commands required to animate a multi-item Sequence, including customization to control speed, jump, and whether the animation reverses.
module.exports = {
animate: function (componentId, count = 7, delay = 20, jump = 1, reverse = true) {
let commands = [];
for (let i = 0; i < count; i += jump) {
commands.push({
"type": "ScrollToIndex",
"componentId": componentId,
"index": i,
@willblaschko
willblaschko / RequestHandler.js
Created March 3, 2019 12:25
Inside the RequestHandler, override the ResponseBuilder to be able to send multiple "speak" requests to concat. This makes it easier to pass between different handlers/functions, each can add a preamble if required (e.g. "Game over..." + "Starting a new game").
const RequestHandler = {
process(handlerInput) {
//log our request
console.log("REQUEST ENVELOPE = " + JSON.stringify(handlerInput.requestEnvelope));
//required function taken from Alexa SDK
function trimOutputSpeech(speechOutput) {
if (!speechOutput) {
return '';
@willblaschko
willblaschko / build.gradle
Last active May 5, 2016 16:11
Signing config
if (file('signing.gradle').exists()) {
apply from: 'signing.gradle'
}
android{
...
buildTypes {
debug{
versionNameSuffix " Debug"
minifyEnabled false
shrinkResources true
...
if(BuildConfig.DEBUG) {
Log.i("Key", SigningKey.getCertificateMD5Fingerprint(this));
}
...
@willblaschko
willblaschko / LocationBitmapTransformation.java
Last active September 19, 2016 05:17
A Glide transformation to set the center of the crop()--similar to cropCenter(). This only affects the overflow dimension, not the fit dimension.
/**
*
* Most of this from:
* https://github.com/bumptech/glide/blob/master/library/src/main/java/com/bumptech/glide/load/resource/bitmap/CenterCrop.java
* and
* https://github.com/bumptech/glide/blob/master/library/src/main/java/com/bumptech/glide/load/resource/bitmap/TransformationUtils.java
*
* Created by wblaschko on 3/31/16.
*/
public class LocationBitmapTransformation extends BitmapTransformation {