Skip to content

Instantly share code, notes, and snippets.

View omamkaz's full-sized avatar
🎯
Focusing

Osama Mohammed omamkaz

🎯
Focusing
View GitHub Profile
@omamkaz
omamkaz / env_path.py
Created April 29, 2022 21:56
print linux env paths
#!/usr/bin/python3
from os import getenv
_paths = getenv("PATH").split(":")
def print_type(title: str, _filter: tuple):
print(f"\n@{title.title()} dirs:")
for (index, fp) in enumerate(filter(lambda fp: fp.startswith(_filter), _paths), 1):
print(f"{index:3}- {fp}")
@omamkaz
omamkaz / snake.py
Created April 29, 2022 22:02
Simple python console snake game
#!/usr/bin/python3
from sys import argv
from random import randint, choice
from time import strftime, sleep
from curses import (textpad, curs_set, KEY_RIGHT,
KEY_LEFT, KEY_DOWN, KEY_UP,
wrapper, COLOR_RED)
####################### start advanced config #########################
@omamkaz
omamkaz / run_py.sh
Created March 6, 2023 23:23
run python file without create __pycache__ folder.
#!/usr/bin/bash
python3.9 -B $@
@omamkaz
omamkaz / run_java.sh
Created March 6, 2023 23:25
script to run java.java file direct.
#!/usr/bin/bash
_file=$1
_file_name=$(python3 -c "print('$_file'.split('.', maxsplit=1)[0])")
javac $_file &&
java $_file_name &&
rm $_file_name.class
@omamkaz
omamkaz / run_cpp.sh
Created March 6, 2023 23:26
run cpp file direct
#!/usr/bin/bash
_file=$1
_file_name=$(python3 -c "print('$_file'.split('.', maxsplit=1)[0])")
g++ $_file -o $_file_name &&
./$_file_name &&
rm $_file_name
#!/usr/bin/python3
from PIL import Image
import os.path
import sys
def resize_img(path: str, w: int, h: int) -> str:
image = Image.open(path)
new_image = image.resize((int(w), int(h)))
filename = os.path.basename(path).split(".", 1)
@omamkaz
omamkaz / plasma5_24_accent_color.py
Last active March 17, 2024 20:14
Change plasma v5.24 accent color.
#!/usr/bin/python3
from PIL import Image
import configparser
import subprocess
import sys
import os
def fetch_desktop_image() -> str:
@omamkaz
omamkaz / .zshrc
Created March 17, 2024 20:12
Fixing: sudo: [alias]: command not found
sudo() {
if alias "$1" &> /dev/null; then
command sudo $(alias $1 | cut -d '=' -f 2) ${@:2}
else
command sudo "$@"
fi
}
@omamkaz
omamkaz / List.py
Created October 12, 2024 23:34
simple built-in list instance, that can work with a dimensions array.
from typing import overload, Any
class List(list):
@overload
def __getitem__(self, t: tuple, /) -> list[Any]: ...
def __getitem__(self, v, /):
if isinstance(v, tuple):
_v = None
for i in v:
@omamkaz
omamkaz / greet.py
Created October 12, 2024 23:39
simple Python script that displays a "Good Morning," "Good Afternoon," or "Good Evening" message based on the current time
class Greet:
class Types(StrEnum):
morning: str = "morning"
afternoon: str = "afternoon"
evening: str = "evening"
@staticmethod
def morning(hour: int) -> bool:
return 5 <= hour < 12