Skip to content

Instantly share code, notes, and snippets.

View YektaDev's full-sized avatar
𝐼𝓃 𝓈𝑒𝒶𝓇𝒸𝒽 𝑜𝒻 𝓁𝒾𝑔𝒽𝓉

Ali Khaleqi Yekta YektaDev

𝐼𝓃 𝓈𝑒𝒶𝓇𝒸𝒽 𝑜𝒻 𝓁𝒾𝑔𝒽𝓉
View GitHub Profile
@YektaDev
YektaDev / Shade.kt
Last active June 4, 2021 01:50
All colors of the Material Palette as an enum class.
/*
* Copyright © 2021 Ali Khaleqi Yekta, All Rights Reserved.
*
* Author: Ali Khaleqi Yekta [YektaDev]
* Website: https://Yekta.Dev
* Email: [email protected]
*/
enum class Shade(val hex: Int) {
Red50(0xffebee),
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@YektaDev
YektaDev / Summary 3, 4, 5 - Computer Networking (A Top-down Approach).md
Last active November 3, 2023 03:48
A partial (and informal!) summary of chapters 3, 4, and 5 of "Computer Networking: A Top-down Approach" by Jim Kurose & Keith W. Ross
"Computer Networking: A Top-down Approach" by Jim Kurose & Keith W. Ross (8th edition)
A Partial (and Informal!) Summary of Chapters 3, 4, and 5
Ali Khaleqi Yekta - Jun 2023

📗 Chapter 3 - Transport Layer

Sockets are in App layer. When they reach Transport layer, it merges (multiplexes) all of them & adds its own header (headers are responsible to find the correct socket).

@JvmInline
@Serializable
value class Username private constructor(@JvmField val value: String) {
companion object {
private const val MIN_LENGTH = 5
private const val MAX_LENGTH = 20
fun getOrNull(value: String): Username? = if (value.isValid()) Username(value) else null
private fun String.isValid(): Boolean {
if (length !in MIN_LENGTH..MAX_LENGTH) return false
@YektaDev
YektaDev / TerminalExt.kt
Last active March 17, 2024 14:50
A handy set of extensions for quick terminal-based projects.
/*
* QuickTerminalExt.kt - A handy set of extensions for quick terminal-based projects.
* https://gist.github.com/YektaDev/12c0f5a26ad9a86712bfefb252267ef0
* ---
* QuickTerminalExt.kt is licensed under the MIT License.
* ---
* Copyright (c) 2024 Ali Khaleqi Yekta
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@YektaDev
YektaDev / cecho
Last active November 22, 2023 12:35
C(olored) Echo
#!/bin/zsh
#
# cecho - A script to echo colored text using tput
# Author: Ali Khaleqi Yekta
#
# Ensure the inputs are provided.
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: cecho <color> <text>"
exit 1
@YektaDev
YektaDev / Assertion.ts
Last active April 4, 2025 17:34
A simple, type-safe assertion utility for JavaScript/TypeScript.
/*
* Assertion.ts - A simple, type-safe assertion utility for JavaScript/TypeScript.
* https://gist.github.com/YektaDev/aee5b9996f5418a84376c837975293c7
*
* The Assert class provides a robust set of methods to validate various data types, structures,
* and values. It simplifies runtime checks and ensures that the program behaves as expected by
* throwing detailed `AssertionError` exceptions when validation fails.
*
* ---
*
export class ClassObserver {
private readonly target: Element;
private readonly className: string;
private readonly onClassAdd: () => void;
private readonly onClassRemove: () => void;
private readonly observer: MutationObserver | null;
private hadClass: boolean;
constructor(target: Element, className: string, onClassAdd: () => void, onClassRemove: () => void) {
#!/bin/bash
# ----------------------------------------------------------------------------------------------------------------------
# docker_unload.sh - Unloads images from a tarball. Returns 0 if any images are removed or skipped, 1 otherwise.
# ----------------------------------------------------------------------------------------------------------------------
# MIT License - Ali Khaleqi Yekta (@YektaDev - https://yekta.dev)
# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
# ----------------------------------------------------------------------------------------------------------------------
set -euo pipefail
#!/usr/bin/env python
# ----------------------------------------------------------------------------------------------------------------------
# Implementation of the Needleman-Wunsch Algorithm with Variable Gap Penalty + Breast Cancer Sample
# ----------------------------------------------------------------------------------------------------------------------
import numpy as np
def nw(x: str, y: str, match: int = 3, mismatch: int = -3, gap_start: int = -5, gap_extend: int = -3):