Skip to content

Instantly share code, notes, and snippets.

View A-Maged's full-sized avatar

A-Maged A-Maged

  • Holo (Dubai, UAE)
  • Remote (Cairo, Egypt)
  • X @Maged_Dev
View GitHub Profile
@A-Maged
A-Maged / DeepKeys.ts
Created April 8, 2025 04:31
Generate Dot-Notation Key Paths for Nested Types in TypeScript
type Increment<N extends number, Arr extends any[] = []> = Arr['length'] extends N
? [...Arr, any]['length']
: Increment<N, [...Arr, any]>;
type FilteredKeys<T> = Exclude<keyof T, keyof any[]>;
type DeepKeysPrefix<T, K extends keyof T, MaxDepth extends number, Depth extends number> = Depth extends MaxDepth
? never
: K extends string | number
? `${K}.${DeepKeys<T[K], MaxDepth, Increment<Depth>> & string}`
/*
Strategy Pattern
Co-Author: https://github.com/WaseemMansour
reference: https://refactoring.guru/design-patterns/strategy
*/
/* Strategies context */
class Context<Strategy> {
/* reference to concrete strategy */
private strategy: Strategy;
sudo apt update
# docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
# docker-compose
class Adult {
age: AdultAge;
constructor(age: AdultAge) {
this.age = age;
}
}
/* value object */
class AdultAge {
@A-Maged
A-Maged / Custom_Mailer.php
Last active May 27, 2021 07:32
inline images with wp_mail
<?php
/*
* Send HTML Emails with inline images
*/
class Custom_Mailer
{
public $email_attachments = [];
public function send($to, $subject, $body, $headers, $attachments)