Skip to content

Instantly share code, notes, and snippets.

@giuliohome
giuliohome / ubuntu-sleep.yaml
Created November 1, 2023 16:52 — forked from tcdowney/ubuntu-sleep.yaml
Ubuntu Sleep Pod
apiVersion: v1
kind: Pod
metadata:
name: ubuntu
labels:
app: ubuntu
spec:
containers:
- image: ubuntu
command:
package io.github.nomisrev
import app.cash.sqldelight.driver.jdbc.asJdbcDriver
import arrow.continuations.SuspendApp
import arrow.continuations.ktor.server
import arrow.fx.coroutines.autoCloseable
import arrow.fx.coroutines.closeable
import arrow.fx.coroutines.resourceScope
import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource
@giuliohome
giuliohome / scala-http-postgres-html-docker.scala
Created September 30, 2023 08:18 — forked from keynmol/scala-http-postgres-html-docker.scala
Sample gist showing how to run a HTTP server with Typelevel Scala libraries, and a postgres docker container
//> using dep "org.http4s::http4s-scalatags::0.25.2"
//> using dep "org.http4s::http4s-dsl::0.23.23"
//> using dep "org.http4s::http4s-ember-server::0.23.23"
//> using dep "org.tpolecat::skunk-core::0.6.0"
//> using dep "com.dimafeng::testcontainers-scala-postgresql::0.41.0"
//> using dep "com.outr::scribe-slf4j::3.12.2"
import skunk.*, codec.all.*, syntax.all.*
import cats.effect.*
import scalatags.Text.all.*
open Donald
open System.Data.Common
open System.Data.SQLite
open System.Threading.Tasks
open Giraffe
open Giraffe.ViewEngine
open FsToolkit.ErrorHandling
open Microsoft.AspNetCore.Builder
[<RequireQualifiedAccess>]
@giuliohome
giuliohome / 2serv.py
Last active June 1, 2020 18:11 — forked from phrawzty/2serv.py
simple python http server to dump request headers
#!/usr/bin/env python2
import SimpleHTTPServer
import SocketServer
import logging
PORT = 8000
class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
@giuliohome
giuliohome / app_offline.htm
Created May 14, 2019 02:10 — forked from robert-claypool/app_offline.htm
A simple "app offline" template for ASP.NET
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Offline</title>
</head>
<body style="margin:3em;font-family:sans-serif">
<h2>Offline</h2>
<p>This site is offline for maintenance.</p>
<!--

A quadratic space is a real vector space V with a quadratic form Q(x), e.g. V = R^n with Q as the squared length. The Clifford algebra Cl(V) of a quadratic space is the associative algebra that contains V and satisfies x^2 = Q(x) for all x in V. We're imposing by fiat that the square of a vector should be the quadratic form's value and seeing where it takes us. Treat x^2 = Q(x) as a symbolic rewriting rule that lets you replace x^2 or x x with Q(x) and vice versa whenever x is a vector. Beyond that Cl(V) satisfies the standard axioms of an algebra: it lets you multiply by scalars, it's associative and distributive, but not necessarily commutative.

Remarkably, this is all you need to derive everything about Clifford algebras.

Let me show you how easy it is to bootstrap the theory from nothing.

We know Cl(V) contains a copy of V. Since x^2 = Q(x) for all x, it must also contain a copy of some nonnegative reals.

@giuliohome
giuliohome / Differ.fs
Created March 21, 2018 14:33 — forked from pirrmann/Differ.fs
Differ
type DifferenceType<'TKey, 'T> =
| Added of 'TKey * 'T
| Removed of 'TKey * 'T
| Modified of 'TKey * 'T * 'T * seq<string * (string * string)> with
member this.Key =
match this with
| Added (key, _)
| Removed (key, _)
| Modified (key, _, _, _) -> key
@giuliohome
giuliohome / Hylo.fs
Created February 19, 2018 07:08 — forked from CarstenKoenig/Hylo.fs
Factorial using a Hylomorphism in F#
type List<'i,'r> = Nil | Cons of 'i*'r
type FixList<'i> = FixList of List<'i,FixList<'i>>
let rec fmap (f : 'a -> 'b) (l : List<'i,'a>) : List<'i,'b> =
match l with
| Nil -> Nil
| Cons (x, tail) -> Cons (x, f tail)
// you can express hylo directly without using ana and cata (by either following the
@giuliohome
giuliohome / free.fsx
Created August 1, 2017 17:29 — forked from battermann/free.fsx
Free Monad like pattern in F#
#load @"paket-files/fsprojects/Chessie/src/Chessie/ErrorHandling.fs"
type Continuation<'output, 'next> = 'output -> 'next
module TerminalDsl =
open Chessie.ErrorHandling
type Terminal<'next> =
| WriteLine of string * Continuation<unit, 'next>
| ReadLine of unit * Continuation<string, 'next>