Skip to content

Instantly share code, notes, and snippets.

View antonkuzmin's full-sized avatar

Anton Kuzmin antonkuzmin

View GitHub Profile
/* package.json:
{
"name": "sgr_demo",
"version": "1.0.0",
"description": "TS-port of https://abdullin.com/schema-guided-reasoning/demo",
"scripts": {
"start": "bun src/sgr.ts"
},
"keywords": [],
"author": "[email protected]",
@antonkuzmin
antonkuzmin / reduceRecursive.ts
Last active March 2, 2022 09:36
Function, that traverse through arrays and objects. The behaviour and callback signature mimics Array.reduce().
const isArray = (x: any): x is Array<any> =>
Array.isArray(x);
const isObject = (x: any): x is Object =>
x !== null && typeof x === 'object' && !(x instanceof Date || x instanceof Number || x instanceof String);
type ReduceRecursiveCb<OUT, IN> = (acc: OUT, x, path: Array<string | number>, source: IN, parent) => OUT;
export const reduceRecursive = <OUT, IN = any>(fn: ReduceRecursiveCb<OUT, IN>) =>
(initialValue: OUT, input: any, path: Array<string | number> = [], source: IN = input, parent?: any): OUT => {
@antonkuzmin
antonkuzmin / php_setup
Created July 18, 2021 09:39
php_setup
#!/bin/sh
apt-get update
apt-get install wget curl nginx
echo "1. INSTALLING PHP"
apt-get install php7.3
apt-get install php7.3-fpm
sed -i /etc/nginx/sites-available/default 's/^[\t ]*index index.html/index index.html index.php/' /etc/nginx/sites-available/default
echo "2. INSTALLING GEOIP"
@antonkuzmin
antonkuzmin / machine.js
Last active June 30, 2020 09:52
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@antonkuzmin
antonkuzmin / machine.js
Last active June 30, 2020 08:36
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions