Skip to content

Instantly share code, notes, and snippets.

@OnurGumus
OnurGumus / index.html
Created November 15, 2024 11:48
MPA View Transition
<!DOCTYPE html>
<html lang="en" class="home">
<head>
<meta charset="UTF-8">
<title>View Transitions</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
<link rel="stylesheet" href="view-transitions.css">
<script src="view-transitions.js"></script>
</head>
@OnurGumus
OnurGumus / grid.css
Last active October 25, 2024 09:41
grid
/* Define the typography layer */
@layer typography {
/* Define the fonts layer */
@layer fonts {
/* Example of @font-face declarations */
@font-face {
font-family: "Inter";
src: url("/fonts/Inter-Regular.woff2") format("woff2"),
url("/fonts/Inter-Regular.woff") format("woff");
font-weight: 400;
@OnurGumus
OnurGumus / draggable.html
Last active October 21, 2024 12:59
draggable table
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Interactive Draggable Table with Resizable and Reorderable Columns</title>
<style>
/* General table styles */
table.draggable-table {
border-collapse: collapse;
@OnurGumus
OnurGumus / fix-references.fsx
Created October 5, 2024 21:02
Fixes generated fsi references
open System.IO
let lines = File.ReadAllLines "references.fsx"
let fixedLines = lines |> Array.map (fun line ->
if line.StartsWith("#r") then
if line.Contains("/usr/share/dotnet/packs/") then
line.Replace("/packs/", "/shared/")
.Replace(".Ref/","/")
.Replace("/ref/net8.0/", "/")
@OnurGumus
OnurGumus / freemonad.fs
Last active September 15, 2024 01:13
async result free monad
// Define the types for the inputs and outputs
type AccountID = AccountID of int
type Balance = Balance of decimal
type Deposit = Deposit of AccountID * decimal
type NewBalance = NewBalance of decimal
type LogMessage = string
// Define an error type for your operations
type BankError =
| AccountNotFound of int
@OnurGumus
OnurGumus / AkkaTimeProvider.fs
Last active September 14, 2024 20:04
AkkaTimeProvider
type ExecuteCallback = ExecuteCallback
// Actor that executes the timer callback
type CallbackActor(callback: TimerCallback, state: obj) =
inherit UntypedActor()
override x.OnReceive(message: obj) =
match message with
| :? ExecuteCallback ->
try
@OnurGumus
OnurGumus / AutoReturnArrayPool.cs
Last active September 12, 2024 19:17
AutoReturnArrayPool
using System;
using System.Buffers;
using System.Runtime.CompilerServices;
using System.Collections.Generic;
using System.Threading;
var allocatedArrays = new HashSet<int>(); // To track allocated arrays
int i = 0;
while (true)
{
@OnurGumus
OnurGumus / User.fs
Last active September 12, 2024 15:29
CQRS example
module AlarmsGlobal.Command.Domain.User
open CQRS
open Akkling
open Akkling.Persistence
open AkklingHelpers
open Akka
open Common
open Serilog
open System
@OnurGumus
OnurGumus / fable.fs
Created July 24, 2024 08:59
Fable Async
open System.Threading
let taskGrandchild(order: int) : Async<unit> =
async {
printfn $"Starting Grandchild({order})"
let! ct = Async.CancellationToken
printfn $"Cancellation token GrandChild({order}): {ct.GetHashCode()}"
// use! c = Async.OnCancel(fun () -> printfn $"Cancelled Task Grandchild: {order}")
@OnurGumus
OnurGumus / FreeMonad.fs
Last active September 15, 2024 01:18
free monad
// Define the types for the inputs and outputs
type AccountID = AccountID of int
type Balance = Balance of decimal
type Deposit = Deposit of AccountID * decimal
type LogMessage = string
// Define an error type for your operations
type BankError =
| AccountNotFound of int
| InsufficientFunds of decimal