Skip to content

Instantly share code, notes, and snippets.

View williammartin's full-sized avatar

William Martin williammartin

  • Amsterdam
  • 01:48 (UTC +02:00)
View GitHub Profile
@williammartin
williammartin / hijack.go
Last active September 15, 2023 14:58
hijack.go
package main
import (
"fmt"
"io"
"os/exec"
"syscall"
"github.com/creack/pty"
)
# typed: true
require "minitest/autorun"
require_relative "../lib/option"
class TestOption < Minitest::Test
extend T::Sig
def test_unwrap_on_some
o = Option.some("value")
# typed: strict
require 'sorbet-runtime'
require_relative "./result"
module Option
extend T::Sig
extend T::Helpers
extend T::Generic
# typed: true
require "minitest/autorun"
require_relative "../lib/result"
class TestResult < Minitest::Test
def test_unwrap_success_returns_value
r = Result.ok("val")
assert_equal r.unwrap, "val"
end
# typed: strict
require 'sorbet-runtime'
module Result
extend T::Sig
extend T::Helpers
extend T::Generic
interface!
# typed: strict
require 'sorbet-runtime'
module Result
extend T::Sig
extend T::Helpers
extend T::Generic
interface!
@williammartin
williammartin / circular-buffer.ts
Created June 16, 2022 09:39
circular-buffer.ts
export default class CircularBuffer<T> {
readonly #capacity: number
readonly #values: T[]
#size: number
#head: number
#tail: number
constructor(capacity: number) {
package retry
import (
"context"
"errors"
"fmt"
"math"
"time"
)
@williammartin
williammartin / main.ts
Last active June 19, 2021 13:27
Empty GCP bucket
import * as core from '@actions/core';
import { Storage } from '@google-cloud/storage';
import * as E from 'fp-ts/lib/Either';
import { pipe } from 'fp-ts/lib/function';
import * as IOEither from 'fp-ts/lib/IOEither';
import * as T from 'fp-ts/lib/Task';
import * as TE from 'fp-ts/lib/TaskEither';
import * as t from 'io-ts';
import { failure } from 'io-ts/PathReporter';
// Helpers
// optional
type Some<T> = {
_tag: "some";
value: T;
};
type None = {
_tag: "none";