Skip to content

Instantly share code, notes, and snippets.

type input =
| Insert_coin
| Turn;
module Machine_state = {
type t = {
locked: bool,
candies: int,
coins: int,
};
@ambientlight
ambientlight / amplify_example_generated.graphql
Created April 24, 2019 17:51
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
@ambientlight
ambientlight / redux_tutorial_loop0.swift
Last active February 2, 2020 11:56
Loop with a sum
let nums = [1, 2, 3, 6, 16, 4]
var sum = 0
for var i in (0..<nums.count) {
sum += nums[i]
}
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])
}
@ambientlight
ambientlight / redux_tutorial_reduce_sum.swift
Last active February 2, 2020 12:09
Sum with a reduce
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 February 2, 2020 14:32
Crude counter view controller
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 05:02
RFC: Organic backend architecture for offline-first application via logux

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

#!/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
@ambientlight
ambientlight / AccessiblePopups.tsx
Last active May 31, 2021 19:11
AccessiblePopups.tsx
import React, { memo, useContext, useEffect, useMemo, useState } from 'react';
import {
AzureMap,
AzureMapDataSourceProvider,
AzureMapFeature,
AzureMapLayerProvider,
AzureMapsProvider,
IAzureMapOptions,
AzureMapPopup,
IAzureMapFeature,
@ambientlight
ambientlight / AccessiblePopups.fix.tsx
Created June 1, 2021 09:29
AccessiblePopups.tsx example
import React, { memo, useMemo, useState } from 'react';
import {
AzureMap,
AzureMapDataSourceProvider,
AzureMapFeature,
AzureMapLayerProvider,
AzureMapsProvider,
IAzureMapOptions,
AzureMapPopup,
IAzureMapFeature