Skip to content

Instantly share code, notes, and snippets.

View kayvank's full-sized avatar
🏠
@127.0.0.1

Kayvan ≅ کیوان kayvank

🏠
@127.0.0.1
View GitHub Profile
@kayvank
kayvank / markdownToHtml.hs
Created July 29, 2025 17:52
A simple, incomplete, Markdown to Html converter using megaparsec
#!/usr/bin/env nix-shell
#!nix-shell --pure -p "haskellPackages.ghcWithPackages(pkgs:[pkgs.text pkgs.megaparsec])" -i runghc
{- |
A megaparsec prototype to convert markdown to html.
Note: This is incomplete. There are a few more markdown `nodes` to convert to html
TODO
convert Paragrapsh, links, images
-}
@kayvank
kayvank / stateMonadToLazyStream.hs
Created July 17, 2025 20:09
State Monad to Lazy Stream
#!/usr/bin/env nix-shell
#!nix-shell --pure -p "haskellPackages.ghcWithPackages(pkgs:[pkgs.mtl pkgs.stm])" -i runghc
{- |
state monad to lazy stream
-}
{-# LANGUAGE LambdaCase #-}
import Control.Monad.State.Lazy(State, modify, runState, gets)
@kayvank
kayvank / budgeted-action.hs
Created July 6, 2025 16:32
exec-time budget an action
{- |
CLI parsing and budgetting execution time
-}
{-# LANGUAGE LambdaCase #-}
{-
CLI: --simulation-name ping-pong --number-seconds 45
-}
import Control.Concurrent.Async (async, race)
import Control.Concurrent (myThreadId, threadDelay)
@kayvank
kayvank / bubble-sort-st-monad.hs
Created July 5, 2025 03:21
Haskell, nixOS script to bubble sort using ST monad,
#!/usr/bin/env nix-shell
#!nix-shell --pure -p "haskellPackages.ghcWithPackages(pkgs:[pkgs.text pkgs.bytestring pkgs.array pkgs.containers pkgs.mtl])" -i runghc
-- \|
-- bubble sort array using ST monad
{-# LANGUAGE LambdaCase #-}
import Control.Monad
import Control.Monad.ST
import Data.Array.IArray
@kayvank
kayvank / bottle_factory.rs
Created April 18, 2025 18:01
Type driven State Machine in Rust, using nix script
#!/usr/bin/env nix-shell
//! ```cargo
//! [dependencies]
//! time = "0.1.25"
//! ```
/*
#!nix-shell -i rust-script -p rustc -p rust-script -p cargo
*/
#[derive(Debug, Clone, Copy)]
@kayvank
kayvank / flake.nix
Created December 28, 2024 19:22
nix flake to create a simple shell script
{
description = "A better simple script flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {self, nixpkgs, flake-utils}:
flake-utils.lib.eachDefaultSystem (system:
let
@kayvank
kayvank / vector.hs
Created December 22, 2024 21:42
Haskell Vectors
#!nix-shell --pure -p "haskellPackages.ghcWithPackages(pkgs:[pkgs.text pkgs.bytestring pkgs.vector])" -i runghc
{- |
haskell vectors
-}
import qualified Data.ByteString.Lazy.Char8 as C8Lazy
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as MV
import qualified Data.Maybe as Maybe
@kayvank
kayvank / st-monad.hs
Created December 22, 2024 18:13
Monad/ST
#!/usr/bin/env nix-shell
#!nix-shell --pure -p "haskellPackages.ghcWithPackages(pkgs:[pkgs.text pkgs.bytestring])" -i runghc
{- |
Linked list using ST Monad
This is based on @Evgenity work, https://www.youtube.com/watch?v=MJscn-m4KIo
-}
{-#language RecordWildCards #-}

plutus-tx upgrade

Upgrade trustless-sidechain ghc and plutus-tx per code review from the plutus team.

Problem

We can not upgreade to newer versions of plutus-tx. Consequently, we can not upgrade to newer cardano-node. The nature of upgrade is very similar to this snipet of code:

import PlutusLedgerApi.Common (serialiseCompiledCode)
import Data.ByteString.Short (fromShort)
@kayvank
kayvank / brokenlinks.py
Last active August 1, 2024 12:47
find-broken-http-links