Skip to content

Instantly share code, notes, and snippets.

@wokalski
wokalski / jest.res
Created September 16, 2022 08:01
Nice jest bindings for rescript
type expectException
type expect<'a, 'ret>
@module("@jest/globals") external describe: (string, unit => unit) => unit = "describe"
@module("@jest/globals") external test: (string, unit => unit) => unit = "test"
@module("@jest/globals") external testAsync: (string, unit => Js.Promise.t<unit>) => unit = "test"
@module("@jest/globals") external expect: 'a => expect<'a, unit> = "expect"
@module("@jest/globals") external expectF: (unit => 'a) => expect<expectException, unit> = "expect"
@module("@jest/globals")
@wokalski
wokalski / k.sh
Created July 31, 2022 10:30
Boundary Kubectl connect with persistent sessiosn
#!/bin/zsh
PID_FILE="$HOME/.boundary_session_ttcp_BRTTDbGBAK"
connect() {
echo "Inititating a boundary session to k8s..."
TMP_FILE=$(mktemp)
nohup -- boundary connect -target-id ttcp_BRTTDbGBAK -format json &> $TMP_FILE &
CONNECT_PID=$!
@wokalski
wokalski / complex.md
Created February 18, 2021 18:08
Complex algorithms

My approach to complex programming tasks (iteration 1)

  1. Define the input
  2. Define the output
  3. Define the steps leading from the input to output in either direction
  4. Spot the weak links/hard parts
  5. Understand if the weak links can be avoided - if yes go to 3
  6. Start implementing the algorithm from the end (starting from the step which generates the output and threading back)
@wokalski
wokalski / Buttons.tsx
Last active January 28, 2021 13:08
Styling at dialo
import * as React from "react";
import { css } from "styled-components";
import { Color, Text, Elevation } from "./Styles";
import { size, spacing, opacity } from "./BaseUnit";
import { keyframes } from "styled-components";
const fadeIn = keyframes`
from {
transform: rotate(0deg);
}
Sending build context to Docker daemon 1.931MB
Step 1/7 : FROM ulrikaugustsson/esy:latest
---> e2f92066e3df
Step 2/7 : ARG ocaml_version=4.9.0
---> Using cache
---> eb02038ad958
Step 3/7 : ENV TERM=dumb LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib
---> Using cache
---> 2602c8833912
@wokalski
wokalski / Readme.md
Last active February 21, 2020 12:44
BuckleScript friendly `vim` + official ocaml-lsp setup for Reason/OCaml

BuckleScript friendly vim + official ocaml-lsp setup for Reason/OCaml

Prerequisite: Install esy 0.6.0.

Steps

  1. Check esy version (it has to be >0.6.0)
  2. Create esy.json with the following contents next to package.json:
@wokalski
wokalski / @opam_postgresql.json
Last active January 25, 2020 07:53
build plan of @opam/postgrseql
λ esy build-plan -p @opam/postgresql
{
"id": "opam__s__postgresql-opam__c__4.5.2-7fdcd1e6",
"name": "@opam/postgresql",
"version": "opam:4.5.2",
"sourceType": "immutable",
"buildType": "in-source",
"build": [ [ "dune", "build", "-p", "postgresql", "-j", "4" ] ],
"install": [],
"sourcePath":
@wokalski
wokalski / Form.re
Last active August 23, 2020 05:58
sensible forms for reason-react
type validatorData('a) = {
value: 'a,
isTouched: bool,
submitted: bool,
};
type shouldDisplayError('error) = {
error: 'error,
isTouched: bool,
submitted: bool,
@wokalski
wokalski / Ppx_driver_with_bucklescript.md
Created August 26, 2019 07:38
How to run a driver based ppx with bucklescript
  1. Create a dune file:
(library
 (public_name aggregate_ppx_name)
 (kind ppx_rewriter)
 (libraries ppx_deriving_protobuf other_ppx another_ppx))
  1. Build:
dune build --profile release
type t('list, 'last) =
| []: t('a, 'a)
| ::('a, t('l, 't)): t('a => 'l, 't);
let rec (@):
type start mid rest. (t(start, mid => rest), mid) => t(start, rest) =
(l, r) =>
switch (l) {
| [] => [r]
| [a, ...q] => [a, ...q @ r]