Skip to content

Instantly share code, notes, and snippets.

View fakhrulhilal's full-sized avatar
🎯
Focusing

Fakhrulhilal M fakhrulhilal

🎯
Focusing
View GitHub Profile
@fakhrulhilal
fakhrulhilal / docker-compose.yml
Created August 18, 2023 03:13
A docker compose for running multiple services and joining into global private net
version: "3.9"
name: common-services
services:
dbserver:
image: mcr.microsoft.com/mssql/server:2022-latest
container_name: mssql
ports:
- "1433:1433"
networks:
@fakhrulhilal
fakhrulhilal / Functional.cs
Last active September 28, 2024 08:39
C# functional style for wrapping result without using actual exception
internal readonly struct Result<T>(bool successful, T result, Exception exception)
{
private bool Successful { get; } = successful;
public static implicit operator T(Result<T> wrapped) => wrapped.UnwrapOrThrow();
public static implicit operator Result<T>(T result) => new(true, result, default!);
public static implicit operator Result<T>(Exception error) => new(false, default!, error);
/// <summary>
/// Get backing value and convert it to another type
@fakhrulhilal
fakhrulhilal / rebuild-all-indexes.sql
Last active November 8, 2024 09:45
Rebuild all MSSQL tables' indexes
/* Original source: https://stackoverflow.com/a/74454347/399845 */
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
DECLARE @TableName varchar(255);