Skip to content

Instantly share code, notes, and snippets.

View afifmohammed's full-sized avatar
💭
(+2)(-3)

Afif Mohammed afifmohammed

💭
(+2)(-3)
View GitHub Profile
@afifmohammed
afifmohammed / README.md
Last active December 18, 2025 01:54
Ghostty Terminal Dotfiles

Ghostty Terminal Enhancement Dotfiles

One-click setup for a Warp-like terminal experience in Ghostty.

Features

  • Syntax highlighting - Valid commands green, invalid red
  • Autosuggestions - Ghost text from history (press → to accept)
  • Fuzzy history - Ctrl+R to search
  • Fuzzy file finder - Ctrl+T to find files
  • Smart cd - z docs jumps to your most-used "docs" directory
@afifmohammed
afifmohammed / async-command-dispatch.md
Last active May 9, 2025 06:58
Async Command dispatch

Asynchronous Command Dispatch

Scenario

Imagine a Checkout Service (producer) asking an Order Fulfilment Service (consumer) to ship an order.
It does not need to wait for the Order to be shipped; only assurance the fulfilment service will process the request.

Here producer means “producer of the async request
And consumer as "consumer of the async request".


@afifmohammed
afifmohammed / streams-over-amqp.md
Last active May 8, 2025 06:10
Why EventHub over Service bus for Eventing

AzureServiceBus vs. EventHub

ASB has been around for a while and is a familiar tool for inter service eventing using publish subscribe. This document outlines

  1. Where ASB is good at.
  2. What are the primary constraints it introduces.
  3. How EH addresses this by design and how to address the trade-offs with EH.

And draws the conclusion to what scenarios are best suited to EH vs ASB.


@afifmohammed
afifmohammed / drop_restore_dependencies.sql
Created October 8, 2021 06:01
Drop and restore dependencies
create schema infra;
-- @formatter:off
drop function if exists infra.restore_dependencies(
p_view_schema name,
p_view_name name,
p_options jsonb
);
drop function if exists infra.save_and_drop_dependencies(
@afifmohammed
afifmohammed / Unions.cs
Created December 16, 2019 23:22
Discriminated unions in C#
using System;
namespace Juliet
{
class Program
{
static void Main(string[] args)
{
Union3<int, char, string>[] unions = new Union3<int,char,string>[]
{
@afifmohammed
afifmohammed / io_interpreter_via_yield.cs
Last active April 10, 2025 05:18
Interpreting IO vai the yield operator
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
@afifmohammed
afifmohammed / FreeIOMonad.cs
Created June 14, 2018 13:32 — forked from dadhi/FreeIOMonad.cs
Example of Free IO monad in pure C# with separated re-usable monad implementation
/*
Modified from the original https://gist.github.com/louthy/524fbe8965d3a2aae1b576cdd8e971e4
- removed dependency on [language-ext](https://github.com/louthy/language-ext)
- separated monadic boilerplate, so you may concentrate on describing the operations and interpretation of the program
- removed `IO<A>.Faulted` to simplify the examples. It can be added back in straightforward manner.
Useful links:
- [John DeGoes: Beyond Free Monads - λC Winter Retreat 2017](https://www.youtube.com/watch?v=A-lmrvsUi2Y)
- [Free and tagless compared - how not to commit to a monad too early](https://softwaremill.com/free-tagless-compared-how-not-to-commit-to-monad-too-early)
//
// See https://github.com/louthy/language-ext
//
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using LanguageExt;
using static LanguageExt.Prelude;
@afifmohammed
afifmohammed / AggregateCorrelations.cs
Last active March 16, 2017 03:39
Aggregate correlations
void Main()
{
var events = new Event[]
{
new ItemAddedToCart(lead:"1", cart:"2", product:"44", title:"products/44/title/iphone-6s", when:DateTimeOffset.Now),
new ItemAddedToCart(lead:"1", cart:"2", product:"4", title:"products/4/title/iphone-5-SE", when:DateTimeOffset.Now),
new ItemRemovedFromCart(lead:"1", cart:"2", product:"44", when:DateTimeOffset.Now),
new OrderPlaced(customer:"1", order:"2", when:DateTimeOffset.Now.AddSeconds(123)),
new ItemShipped(order:"2", sku:"4", trackingid:"orders/2/skus/4/track/12", when:DateTimeOffset.Now.AddMinutes(33)),
new ItemAddedToCart(lead:"12", cart:"22", product:"42", title:"products/42/title/iphone-6s-plus", when:DateTimeOffset.Now.AddSeconds(12)),
@afifmohammed
afifmohammed / reader.cs
Created February 28, 2017 06:37
reader spik
void Main()
{
var id = new Id();
Func<Id, Customer> customerById = x => new Customer();
Func<Criteria, CreditHistory> creditHistoryByCriteria = x => new CreditHistory();
Func<Report, Unit> print = x => new Unit();
var history = GetCustomer(id)
.Map(GetCustomerCreditHistory)
.Uncurry()