Skip to content

Instantly share code, notes, and snippets.

View baetheus's full-sized avatar

Brandon Blaylock baetheus

View GitHub Profile
@baetheus
baetheus / README.md
Last active December 17, 2023 14:28
SmartOS Single IP with NAT using VLAN

WARNING

These intructions might work, but they need a bit of attention. I've been reading through ipf and smf documentation and have found a few ways to improve this process. When I have time I'll add that information here, until then, be sure to look into the ipf settings if you're having issues with routing. Good luck!

Foreword

This is a modified version of sjorge's instructions for Single IP with NAT. Those instructions can be found here: https://docu.blackdot.be/snipets/solaris/smartos-nat

The primary difference is that this version does not rely on etherstubs for internal switching, but instead uses a vlan configuration. The benefits of this method over using etherstubs are:

  1. Project Fifo (project-fifo.net) can create vms and zones with vlans, but does not currently have etherstub support.
  2. Vlan switching is supposedly more efficient than creating an etherstub to handle switching. I have not tested this statement.
@baetheus
baetheus / transformers.ts
Last active November 28, 2023 04:15
Monad Transformers in fun
import type { $, In, InOut, Kind, Out } from "../kind.ts";
import type { Option } from "../option.ts";
import type { Flatmappable } from "../flatmappable.ts";
import type { Fn } from "../fn.ts";
import * as F from "../fn.ts";
import { createBind, createTap } from "../flatmappable.ts";
import { createBindTo } from "../mappable.ts";
import { pipe } from "../fn.ts";
@baetheus
baetheus / ideas.ts
Created November 26, 2023 18:00
Idea for Route/Router types in pick
/**
* Here are some ideas for router and route. Handler is already set as an async
* indexed state monad.
*
* ```ts
* export type Handler<D, A, B> = (d: D) => Promise<[A, B]>;
* ```
*/
import type { Option } from "fun/option.ts";
@baetheus
baetheus / example.ts
Last active October 23, 2023 03:58
Basic Router
/** @jsx h */
import { pipe } from "fun/fn.ts";
import { h } from "https://esm.sh/preact@10.18.1";
import * as R from "../router.ts";
import { jsx } from "../jsx.ts";
type State = { count: number };
@baetheus
baetheus / const.ts
Created January 4, 2023 18:42
Const Types in Deno Doc
export const apply1 =
<A>(ua: Promise<A>) => <I>(ufai: Promise<(a: A) => I>): Promise<I> =>
Promise.all([ua, ufai]).then(([a, fai]) => fai(a));
export const apply2: <A>(
ua: Promise<A>,
) => <I>(ufai: Promise<(a: A) => I>) => Promise<I> = apply1;
@baetheus
baetheus / curry.ts
Last active January 4, 2023 18:35
Testing Deno Doc Gen
import type { $, Kind } from "https://deno.land/x/fun/kind.ts";
import type { Applicative } from "https://deno.land/x/fun/applicative.ts";
import { pipe } from "https://deno.land/x/fun/fn.ts";
export function curry2<A, B, C>(f: (a: A, b: B) => C): (a: A) => (b: B) => C {
return (a) => (b) => f(a, b);
}
export function curry3<A, B, C, D>(
@baetheus
baetheus / bench.txt
Created December 31, 2022 01:21
Pipe and Flow benchmarks
cpu: Apple M1 Max
runtime: deno 1.29.1 (aarch64-apple-darwin)
file:///Users/brandon/src/fun/main/benchmarks/fn.bench.ts
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------------------- -----------------------------
flowOptimized 262.67 ns/iter (251.3 ns … 443.08 ns) 259.91 ns 312.58 ns 341.9 ns
flowReduceConst 404.92 ns/iter (395.69 ns … 504.78 ns) 402.08 ns 504.4 ns 504.78 ns
flowReduceFunction 510.3 ns/iter (504.26 ns … 540.63 ns) 510.64 ns 539.74 ns 540.63 ns
@baetheus
baetheus / #note.md
Last active December 23, 2022 17:59
Kliesli Arrow Optics

This implementation can now be found in production here

@baetheus
baetheus / app.tsx
Last active December 12, 2022 19:13
Preact Hooks Experiment for Typescript
import { h, FunctionalComponent, render, options } from 'preact';
import { handleVnode } from './hooks';
// Wireup experimental hooks
options.vnode = handleVnode;
import Test from './component';
export const Main: FunctionalComponent<any> = () => (
@baetheus
baetheus / lazy_fn.ts
Last active December 11, 2022 00:18
Stack Safe Reader in TypeScript?
// deno-lint-ignore-file no-explicit-any
/**
* I think this is a stack safe implementation of Fn/Reader..
*
* I haven't really tested it though..
*
* The core idea here is to build up an array of "Controls"
* that represent a few core operations over a LazyFn. To
* keep things simple we only implement controls for id,