Skip to content

Instantly share code, notes, and snippets.

View mbbx6spp's full-sized avatar
:shipit:
emacsclient -nw README.org

Susan Potter mbbx6spp

:shipit:
emacsclient -nw README.org
View GitHub Profile
@mbbx6spp
mbbx6spp / covidate
Last active March 11, 2023 02:40
Only shows in UTC because timezones are bullshit and I needed to pick one. Sorry. It is what my servers use.
#!/usr/bin/env bash
main() {
local -ri mar_end=1583042400
local -ri today="$(date +"%s")"
local -r dow="$(date -u +"%a")"
local -r time="$(date -u +"%T")"
local -ri secs=86400
local -ri days_since="$(( ((${today} - ${mar_end}) / ${secs}) + 1 ))"
@mbbx6spp
mbbx6spp / Functor.purs
Last active December 24, 2020 21:41
Fast and loose reasoning as to why Functor and Cofunctor are the same. I have to answer this when coworkers as why Comonads are also Functors and not Cofunctors.
-- Informally showing that Cofunctor is essentially the same structure as Functor thus why Comonads are a Functor which is
-- effectively a Cofunctor.
-- In PureScript Functor is defined here: https://pursuit.purescript.org/packages/purescript-prelude/4.1.1/docs/Data.Functor#t:Functor
-- class Functor (f :: Type -> Type) where
-- map :: forall a b. (a -> b) -> f a -> f b
-- Informally: Making a dual of something is basically flipping the arrows. But to make is easier to see, let's flip the
-- arguments of map in Functor definition since that shouldn't change anything, like so:
const fruits = [ 'apples', 'bananas', 'cantelopes', 'durians', false];
const chunked = _.chunk(fruits, 2); // chunks elements of an arrary
const compacted = _.compact(fruits); // removes falsey values
const filled = _.fill(fruits, 'bananas'); // fill with my favorite fuit
const flattened = _.flatten(chunked); // flatten nested arrays
@mbbx6spp
mbbx6spp / Types.purs
Last active October 20, 2024 14:35
Accompanying PureScript demonstration of native ADTs for the 'Algebraic Data Types in PureScript': https://www.susanpotter.net/software/algebraic-data-types-in-typescript/
module Main (main) where
import Data.Unit (Unit)
import Data.Maybe (Maybe (..))
import Effect (Effect)
import Effect.Console (log)
main :: Effect Unit
main = log "hello world"
@mbbx6spp
mbbx6spp / git-tips-part-1.org
Last active April 29, 2023 02:17
Git tips and tricks for dev group presentation

Git Tips

Config

Git has different levels of configuration that apply to different “scopes”:

  • system (almost never needed; not covered here)
  • global (which is “global for a user” scoped)
  • local (which is specific to one local clone)
  • worktree (which only applies to the current worktree; only relevant if you work with worktree s)
  • file (not covered here but you can set a git configuration option, when relevant at the file level, to one file)
@mbbx6spp
mbbx6spp / encrypted-zfs-nixos.org
Last active September 17, 2021 02:14
Encrypted ZFS for NixOS

Encrypted ZFS for NixOS

Assumptions

We will have add one partition to a zpool.

You have the following set to appropriate values:

  • disk: the path for your disk device, e.g. /dev/sdb or /dev/nvme0
  • efi: the path for the EFI boot partition’s device, e.g. /dev/sdb1
  • part: the path to the partition of your root filesystem, e.g. /dev/sdb2
@mbbx6spp
mbbx6spp / mword.md
Last active May 27, 2020 01:16
An M-word work rant of work Slack February 2020 edition.

Below is an excerpt from a Slack work rant from Feburary 4, 2020.

Over the last few weeks I have learned about some of the new additions to both ECMAScript 2019 and 2020 (for reasons!!!!) anyway, the following are relevant to an FP setting: flatMap flattens nested list structure then maps over the elements. Usage:

> let arr1 = ["Australia is", "on", "fire still"];
undefined
@mbbx6spp
mbbx6spp / Main.purs
Last active May 4, 2020 18:09
Fun with the state transformer with a coworker showing them functional programming constructs. Notice there are more lines of imports than there are lines of code.
module Main (main) where
import Control.Applicative (pure)
import Control.Bind (bind, discard)
import Control.Monad (void)
import Control.Monad.State (StateT, get, runStateT)
import Data.Array (range)
import Data.Eq ((==))
import Data.Function (($))
import Data.Functor (map)
@mbbx6spp
mbbx6spp / Models.Swagger.purs
Last active March 12, 2020 03:08
Outline of describing schema with algebraic data types for basic descriptions of data, in this case a Swagger "schema". Eventually we can evolve it in class to generating YAML/JSON Swagger from this data description and possible build swagger representations from Generic Reps
module Models.Swagger where
import Data.Map (Map)
import Data.Maybe (Maybe (..))
import Data.String.Regex (Regex)
import Data.Show (class Show, show)
data SwaggerFormatString
= DateFormat
| DateTimeFormat
@mbbx6spp
mbbx6spp / CatTheory.UniversalConstructions.purs
Last active January 16, 2020 15:21
Having fun with universal constructions for And and Or types and the correspondance of pairs (fanout, bimap) and (either, fanin) for each.
-- Module to demonstrate simple applications of the concept of universal construtions
module CatTheory.UniversalConstructions
-- * Types
( And (..)
, Or (..)
-- * Introducers
, and
, left
, right
, fanin