Skip to content

Instantly share code, notes, and snippets.

View sabine's full-sized avatar

sabine sabine

View GitHub Profile
@sabine
sabine / rfc.md
Created March 13, 2025 15:25
RFC: Terminal Coffee Shop Integration with Dune Build System

RFC: Terminal Coffee Shop Integration with Dune Build System

  • Feature Name: terminal-coffee-integration
  • Start Date: 2025-03-13
  • RFC PR: (leave blank until submitted)
  • Implementation PR: (leave blank until implemented)

Summary

This RFC proposes integrating the 'terminal' coffee shop (an online shop accessible via SSH) with the Dune build system. This integration will allow developers to order coffee directly from their build environment, improving developer experience and productivity by streamlining the coffee procurement process.

@sabine
sabine / main.ml
Created August 5, 2023 10:40
Run 25 tasks at a time with Eio at maximum concurrency while capturing errors
open Eio
let process item = if Random.int 4 = 0 then Error (`Item item) else Ok ()
let () =
Eio_main.run @@ fun env ->
let clock = Eio.Stdenv.clock env in
(* stream with capacity of 25 limits concurrent execution *)
let stream = Eio.Stream.create 25 in
let errors = ref [] in
@sabine
sabine / gen_routes.ts
Last active October 20, 2022 18:34
Script to generate typed routes for SvelteKit
import * as fs from 'fs';
import * as path from 'path';
type Route = {
name: string,
parameters: string[],
path: string,
subroutes: Route[],
}
fn main() {
let nc = match nats::connect("127.0.0.1:4222") {
Ok(nc) => nc,
Err(err) => panic!("Error: {}", err),
};
nc.delete_stream("file_processing");
let stream = nats::jetstream::StreamConfig {
name: "file_processing".to_string(),
@sabine
sabine / revisions.sql
Created February 16, 2021 10:37
Using triggers to keep a revision history for rows in table in PostgreSQL
CREATE TABLE projects (
id BIGINT DEFAULT pseudo_encrypt(nextval('projects_id_seq')),
created_by BIGINT REFERENCES profiles(user_id) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NULL,
deleted BOOLEAN NOT NULL DEFAULT FALSE,
slug VARCHAR(100) DEFAULT NULL,
featured_image_id BIGINT REFERENCES images(id),
@sabine
sabine / form.rs
Last active July 26, 2020 22:23
Form API
pub mod form2 {
use seed::{prelude::*, *};
use seed_hooks::*;
#[derive(Clone, Debug)]
pub struct FormData {
pub name: String,
pub color: Option<crate::form_fields::color_picker::Color>, //Option<(i32, f64, f64)>,
}
@sabine
sabine / example.rs
Created July 25, 2020 05:29
Storing and Restoring Session from LocalStorage in Seed
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum Session {
LoggedIn(crate::entities::user::User),
Guest,
}
pub fn remove_session_from_local_storage() {
use seed::browser::web_storage::WebStorage;
@sabine
sabine / client.rs
Last active July 18, 2020 12:54
Decoding the WebSocketMessage, so that `Msg` can be expressed in terms of `shared::ServerMessage`. Modified client.rs of the seed websocket example.
use seed::{prelude::*, *};
mod shared;
thread_local! {
pub static GLOBAL_APP: std::cell::RefCell<Option<seed::app::App<Msg,Model,Vec<Node<Msg>>>>> = std::cell::RefCell::new(None);
}
const WS_URL: &str = "ws://127.0.0.1:9000/ws";
newtype Created = Created UTCTime
deriving (Show, Read, Eq, Generic, PersistField, PersistFieldSql, Ord)
instance FromJSON Created
instance ToJSON Created
newtype Updated = Updated UTCTime
deriving (Show, Read, Eq, Generic, PersistField, PersistFieldSql)
instance FromJSON Updated
instance ToJSON Updated
@sabine
sabine / Templates.elm
Last active December 12, 2017 19:10
SVG spritesheet builder snippet (using svgstore + SVGO) for use with Elm
import Svg
import Svg.Attributes as SvgA
import SVGSprites
icon : Types.Taco -> (SVGSprites.Sprites -> String) -> List (Svg.Attribute msg) -> Html msg
icon taco name attrs =
Svg.svg
attrs
[ Svg.use [ SvgA.xlinkHref (taco.staticUrl ++ "icons/sprites.svg#" ++ (name SVGSprites.sprites)) ] []
]