Skip to content

Instantly share code, notes, and snippets.

View imhalawa's full-sized avatar
🫠
Here we go again!

Mohamed Halawa imhalawa

🫠
Here we go again!
View GitHub Profile
@imhalawa
imhalawa / IHeap
Created April 22, 2026 17:41
min-heap-implementation-c#
public interface IHeap<T> where T : IComparable<T>
{
static abstract List<T> Heapify(List<T> collection);
void Push(T element);
T Pop();
T Peek();
int Count { get; }
bool IsEmpty { get; }
}
@imhalawa
imhalawa / csharp-directory-tree-console.cs
Created April 15, 2026 18:47
Recursive DFS in C# that prints a directory tree to the console with tree-style connectors, threading the prefix string down each branch.
var path = @"";
if (!Directory.Exists(path))
{
throw new ArgumentException("Invalid directory path");
}
PrintFileSystemEntries(path);
return;
void PrintFileSystemEntries(string path)
{
@imhalawa
imhalawa / bfs_directory_listing.cs
Last active April 15, 2026 18:12
Breadth-first directory listing in C#
void BFS(string startingPath)
{
var paddingFactor = 2;
var paddingMultiplier = 1;
var format = (int padding, string arg1, string arg2) => String.Format("{0}: {1}", arg1.PadLeft(padding * paddingMultiplier, ' '), arg2);
var traversalQueue = new Queue<DirectoryWithMeta>();
traversalQueue.Enqueue(new DirectoryWithMeta(path, 0));
while (traversalQueue.Count != 0)
@imhalawa
imhalawa / obsidian-rem-bullets.css
Created April 7, 2026 17:22
REM-style bullet handles for Obsidian — dot with ghost ring on hover, accent fill on active line. Compatible with the Outliner plugin.
.cm-s-obsidian .list-bullet::after {
content: '';
width: 7px;
height: 7px;
border-radius: 50%;
background-color: var(--text-muted);
position: relative;
z-index: 1;
box-shadow: none;
/* explicit reset */