Skip to content

Instantly share code, notes, and snippets.

@ambientlight
ambientlight / provision.sh
Created February 13, 2022 16:34
arch provision.sh with SERIAL
#!/bin/bash
echo "Creating a GPT partition on /dev/sda1"
echo -e "g\nn\n\n\n\nw" | fdisk /dev/sda
# In case you might want to create a DOS partition instead. It doesn't really matter.
#echo "Creating a DOS partition on /dev/sda1"
#echo -e "o\nn\np\n1\n\n\nw" | fdisk /dev/sda
echo "Formatting /dev/sda1 to ext4"
mkfs -t ext4 /dev/sda1
@ambientlight
ambientlight / gen_all.sh
Last active October 9, 2021 15:03
Autorest codegen for python, typescript, golang, c#, java
#!/bin/bash
if [[ -z $1 ]] ; then
echo "Missing swagger readme search path, usage: ./gen_all.sh SEARCH_PATH"
echo 'Sample: ./gen_all.sh "specification/maps/data-plane/Render/readme.md"'
exit 0
else
SEARCH_PATH=$1
fi
@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
@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,
#!/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 / 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

@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 / 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);
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_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]
}