Skip to content

Instantly share code, notes, and snippets.

View mbbx6spp's full-sized avatar
🎯
Focusing

Susan Potter mbbx6spp

🎯
Focusing
View GitHub Profile
# make sure you put this in the root of the generate site build, not just in the root of your netlify repository!
/.well-known/webfinger* https://APPNAME.deno.dev/:splat 200
import cats.effect.{IO, IOApp, ExitCode}
import io.circe.generic.auto._
import org.http4s.Status._
import org.http4s.blaze.client.BlazeClientBuilder
import org.http4s.circe._
import org.http4s.client.Client
import org.http4s.syntax.all._
sealed trait IpResult
case class IpInfo(ip: String) extends IpResult

Rewriting Git history on feature branches

Assumes:

  • feature branch is feature/add_csv_file
  • mainline is deploy

If you want to rewrite Git history on your feature branch here is how to do it.

  1. Make sure you are on the branch you want to rewrite the history of:
{
name = "mbbx6spp-test";
epoch = 2021;
description = "A test of /proc fs inputs for a Hydra jobset";
inputs = {
uptime = builtins.readFile /proc/uptime;
nixpkgs.url = "github:NixOS/nixpkgs/release-21.05";
};
outputs = { self, nixpkgs, uptime }: {
checks."x86_64-linux".test = nixpkgs.hello.override { name = "hello-${uptime}"; };
let
version = {
name = "nixpkgs-21.05-darwin-20210827";
url = "https://github.com/nixos/nixpkgs.git";
rev = "9d6766c0f0b3b03bd63ffc08b2e23e476145719d";
ref = "nixpkgs-21.05-darwin";
};
jvmOverlay = self: super:
let
scala = super.scala.override { jre = self.jre_headless; };
@mbbx6spp
mbbx6spp / branded.ts
Last active August 26, 2021 22:09
A solution to the problem where you want to distinguish identical data payload at both typechecking time and provide a way to inspect that type at runtime via values in TypeScript. Leverages branded parameter types with intersection types.
type Brand<Shared, EventType> = Shared & { readonly __eventType: EventType; };
type SharedCommentEventFields = {
otherField: string;
};
type CommentFlagged = Brand<SharedCommentEventFields, 'CommentFlagged'>;
type CommentRec = Brand<SharedCommentEventFields, 'CommentRec'>;
const makeCommentFlagEvent = (eventFields: SharedCommentEventFields): CommentFlagged => (
@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 August 11, 2020 16:34
Accompanying PureScript demonstration of native ADTs for the 'Algebraic Data Types in PureScript': https://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"