Skip to content

Instantly share code, notes, and snippets.

View AmirMahdyJebreily's full-sized avatar
🙅
busy programmer ...

Code Agha AmirMahdyJebreily

🙅
busy programmer ...
View GitHub Profile
@AmirMahdyJebreily
AmirMahdyJebreily / Convert2dArrayToJsArray.go
Created February 11, 2025 16:17
A function that converts a golang 2d slice into a js 2d array
//go:build js && wasm
package main
import (
"iter"
)
// func js.ValueOf(x any) js.Value
// ValueOf returns x as a JavaScript value:
@AmirMahdyJebreily
AmirMahdyJebreily / timsort_main.go
Created February 7, 2025 17:25
Timsort implimentation in golang
package main
import "fmt"
func main() {
arr := []int{897, 265, 201, 86, 56, 657, 273, 25, 843, 625, 641, 332, 509, 463, 496, 97, 779, 241, 970, 665, 87, 765, 276, 442, 25, 311, 10, 765, 224, 465, 296, 415, 968, 40, 494, 151, 493, 159, 274, 444, 10, 792, 104, 200, 694, 193, 616, 126, 754, 3, 489, 415, 863, 589, 646, 264, 88, 733, 132, 922, 794, 149, 496, 135, 727, 355, 890, 102, 3, 668, 517, 852, 488, 445, 980, 964, 933, 754, 815, 496, 550, 2, 33, 191, 516, 455, 436, 41, 618, 596, 334, 10, 708, 348, 511, 752, 767, 129, 470, 698, 647, 604, 104, 811, 574, 52, 750, 319, 97, 45, 391, 42, 822, 712, 92, 664, 318, 702, 5, 303, 778, 799, 638, 430, 66, 944, 78, 40, 632, 919, 828, 851, 589, 75, 328, 774, 991, 305, 126, 996, 505, 463, 428, 972, 781, 697, 244, 98, 148, 670, 30, 328, 457, 673, 766, 69, 461, 44, 804, 986, 133, 169, 786, 950, 745, 63, 362, 857, 411, 12, 680, 9, 586, 827, 932, 54, 538, 509, 120, 287, 534, 866, 926, 351, 634, 842, 188, 57, 443, 296, 134, 254, 447, 350, 558, 418, 917, 492, 683, 702, 504, 96
@AmirMahdyJebreily
AmirMahdyJebreily / concurrentSum.go
Created September 30, 2024 16:26
An sum/sub program using Golang concurrency
package main
import "fmt"
func sum(inputs <-chan int, outputs chan<- int, num int) {
for input := range inputs {
num += input
outputs <- num // something like function return in non-goroutine functions
}
}
@AmirMahdyJebreily
AmirMahdyJebreily / RandomColor.cs
Created May 24, 2024 13:23
Random colors for Windows Form C#
using System;
using System.Collections.Generic;
using System.Drawing;
namespace CodeAgha
{
public static class ThemeColor
{
public static Color PrimaryColor { get; set; }
@AmirMahdyJebreily
AmirMahdyJebreily / deep-copy.cs
Created December 24, 2023 11:28
Deep copy, for copying a folder and all its contents
double _progressCopy;
double _progressAll;
string primeFolderPath = Console.ReadLine(),
destFolderPath = Console.ReadLine();
try
@AmirMahdyJebreily
AmirMahdyJebreily / description.txt
Last active September 3, 2024 21:29
Euclidean algorithm for GCD in C# By CodeAgha
Euclidean algorithm for GCD in C# By CodeAgha
The parenthesis is the GCD (Greatest common factor) sign and the 'mod' symbol is equal to the remainder of the division.
In any case, we write the smaller number first and the larger number second
Proof from division theorem
a/b => a = bq + r
v != 0 | gcd(u, v) = gcd(v, u mod v)
// Receiving database files from clients via http request
[ParameterRoute(HttpMethod.PUT, "/server/uploadFile/{fileName}")]
public static async Task GetFile(HttpContext ctx)
{
try
{
// Url data
string fileName = ctx.Request.Url.Parameters["fileName"];
// Variabels
@AmirMahdyJebreily
AmirMahdyJebreily / contacts_oop.py
Last active August 11, 2023 11:19
oop course : create an oop contacts app with python
import re
phonenumberValidateRegEx = r"((0?9)|(\+?989))((14)|(13)|(12)|(19)|(18)|(17)|(15)|(16)|(11)|(10)|(90)|(91)|(92)|(93)|(94)|(95)|(96)|(32)|(30)|(33)|(35)|(36)|(37)|(38)|(39)|(00)|(01)|(02)|(03)|(04)|(05)|(41)|(20)|(21)|(22)|(23)|(31)|(34)|(9910)|(9911)|(9913)|(9914)|(9999)|(999)|(990)|(9810)|(9811)|(9812)|(9813)|(9814)|(9815)|(9816)|(9817)|(998))\W?\d{3}\W?\d{4}"
# use this RegEx for encapsulate email field in contacts class
emailValidateRegEx = r"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"
# OOP (Object oriented Programming) => Class : Polymorphysm : Inheritance : Encapsulation
# S.O.L.I.D
@AmirMahdyJebreily
AmirMahdyJebreily / apcb-fcc-202357-contacts.py
Created July 25, 2023 14:34
Advanced Python course of besat school - first code chalange
# CodeAgha 2023 - Advanced Python course of besat school - first code chalange
import re # import regex module
# regex for phone number validation
regex = r"((0?9)|(\+?989))((14)|(13)|(12)|(19)|(18)|(17)|(15)|(16)|(11)|(10)|(90)|(91)|(92)|(93)|(94)|(95)|(96)|(32)|(30)|(33)|(35)|(36)|(37)|(38)|(39)|(00)|(01)|(02)|(03)|(04)|(05)|(41)|(20)|(21)|(22)|(23)|(31)|(34)|(9910)|(9911)|(9913)|(9914)|(9999)|(999)|(990)|(9810)|(9811)|(9812)|(9813)|(9814)|(9815)|(9816)|(9817)|(998))\W?\d{3}\W?\d{4}"
contacts = {
"Ali": "+989123458965",
"Sara": "+989121068969",
@AmirMahdyJebreily
AmirMahdyJebreily / gdc.cs
Created July 4, 2023 10:04
Compute GDC in C#
int num1 = int.Parse(Console.ReadLine());
int num2 = int.Parse(Console.ReadLine());
Console.WriteLine(GCD(num1, num2));
int GCD(int num1, int num2)
{
int res = 0;