Skip to content

Instantly share code, notes, and snippets.

View candy_dispenser.re
type input =
| Insert_coin
| Turn;
module Machine_state = {
type t = {
locked: bool,
candies: int,
coins: int,
};
@ambientlight
ambientlight / amplify_example_generated.graphql
Created Apr 24, 2019
amplify_example_generated.graphql
View amplify_example_generated.graphql
type Blog {
id: ID!
name: String!
posts(filter: ModelPostFilterInput, sortDirection: ModelSortDirection, limit: Int, nextToken: String): ModelPostConnection
}
type Post {
id: ID!
title: String!
blog: Blog
View redux_tutorial_loop0.swift
let nums = [1, 2, 3, 6, 16, 4]
var sum = 0
for var i in (0..<nums.count) {
sum += nums[i]
}
View redux_tutorial_loop1.swift
let nums = [1, 2, 3, 6, 16, 4]
let accumulator: (Int, Int) -> Int = { (sum, increment) in
sum + increment
}
var sum = 0
for var i in (0..<nums.count) {
sum = accumulator(sum, nums[i])
}
View redux_tutorial_reduce_sum.swift
let nums = [1, 2, 3, 6, 16, 4]
let reducer: (Int, Int) -> Int = { (sum, increment) in
sum + increment
}
let sum = nums.reduce(0, reducer);
@ambientlight
ambientlight / CounterViewController.swift
Last active Feb 2, 2020
Crude counter view controller
View CounterViewController.swift
var appState = 0
let reducer: (Int, Int) -> Int = { (sum, increment) in sum + increment };
class CounterViewController: UIViewController {
@IBOutlet var inputField: UITextField!
@IBOutlet var addButton: UIButton!
@IBOutlet var sumLabel: UILabel!
@IBAction func addButtonPressed(_ sender: UIButton) {
appState = reducer(appState, Int(self.inputField.text!)!)
self.sumLabel.text = "\(appState)"
@ambientlight
ambientlight / rfc_offline_first_backend_arch.md
Last active May 26, 2020
RFC: Organic backend architecture for offline-first application via logux
View rfc_offline_first_backend_arch.md

RFC: Organic backend architecture for offline-first application via logux

Goal

Lay out the base ground-work for distributed backend system architecture designed to support offline usecases that involve synchronization of client application during the events when client applications are offline for a periods that exceed days or weeks. Additionally the architecture is meant to support easy-to-replicate offline servers, which act as ad-hoc (edge) synchronization endpoints that are capable of supporting a full range of available business-specific functionality, thus making clients unaware of unexisting internet connectivity between ad-hoc and cloud-hosted server.

Non-goal

This RFC is not meant to describe any application-specific business logic (another one for this) such as features provided by solution hosted in such backend system, entity-relationship diagrams modeled in DBs etc.

Basis

The base area of exploration / experimentation lies around Logux which conceptually can

View upload_indoor.sh
#!/bin/bash
if [[ -z $1 ]] ; then
echo "Resource path is required"
exit 1
fi
RESOURCE=$1
# azure maps primary subscription key
SUBSCRIPTION_KEY=YOUR_KEY