Skip to content

Instantly share code, notes, and snippets.

View Sy3Omda's full-sized avatar
🎯
Focusing

Emad Youssef Sy3Omda

🎯
Focusing
View GitHub Profile
@Sy3Omda
Sy3Omda / Create-Task-Scheduler-Restart-Service.ps1
Created August 26, 2025 11:10
powershell script to auto restart certain service on 12.00 AM every day
$taskName = "Restart-Service"
$serviceName = "ServiceName" # Specify the service name
$scriptPath = "C:\Dir_Name\Restart-Service.ps1"
$logFile = "C:\Dir_Name\Service_Restart_log.txt"
$dirPath = "C:\Dir_Name"
$taskDescription = "Restarts $serviceName daily at 12:00 AM and logs to $logFile"
# Ensure the directory exists
if (-not (Test-Path $dirPath)) {
try {
@Sy3Omda
Sy3Omda / Excel custom number format.md
Created August 19, 2025 11:40
Excel custom number format designed to display file sizes

Excel custom number format

[<1000000]##0.00," KB";[<1000000000]##0.00,," MB";##0.00,,," GB"
#Variables and current TimeZone
$InternetTimeZone = Invoke-RestMethod https://ident.me/json
$CurrentTimeZone = Get-TimeZone
$timezones = [PSCustomObject]@{ #https://secure.jadeworld.com/JADETech/JADE2020/OnlineDocumentation/content/resources/encyclosys2/jadetimezone_class/ianawindowstimezonemapping.htm
"Etc/GMT+12" = "Dateline Standard Time"
"Etc/GMT+11" = "UTC-11"
"Pacific/Pago_Pago" = "UTC-11"
"Pacific/Niue" = "UTC-11"
"Pacific/Midway" = "UTC-11"
"America/Adak" = "Aleutian Standard Time"

Type "allow pasting" first in console, then copy paste follwoing command

sendCommand(SecurityInterstitialCommandId.CMD_PROCEED);
Get-ChildItem -Recurse -File | Where-Object { $_.Extension -notin @('.doc','.docx','.pdf','.xls','.xlsx','.ppt','.pptx','.txt','.zip') } | ForEach-Object { $_ } ; Get-ChildItem -Recurse -File -Include *.zip | ForEach-Object { $zip = $_.FullName; Expand-Archive -Path $zip -DestinationPath "temp_$($_.BaseName)" -Force; Get-ChildItem -Path "temp_$($_.BaseName)" -Recurse -File | Where-Object { $_.Extension -notin @('.doc','.docx','.pdf','.xls','.xlsx','.ppt','.pptx','.txt','.zip') } ; Remove-Item "temp_$($_.BaseName)" -Recurse -Force }
@Sy3Omda
Sy3Omda / Robocopy_File_Transfer_Commands.md
Last active April 25, 2025 18:15
Robocopy commands for file transfer: one with admin access (/COPYALL) and one without (/COPY:DAT). Includes retry, verbose logging, progress, and desktop log output.

With Administrative Access

robocopy \\source_server\path \\destination_server\share\path /E /COPYALL /ZB /R:5 /W:10 /J /V /ETA /TEE /LOG+:%USERPROFILE%\Desktop\robocopy_log.txt

Without Administrative Access

robocopy \\source_server\path \\destination_server\share\path /E /COPY:DAT /R:5 /W:10 /J /V /ETA /TEE /LOG+:%USERPROFILE%\Desktop\robocopy_log.txt
@Sy3Omda
Sy3Omda / Monitor_Network_Connections.md
Created February 5, 2025 19:45
Monitor Network Connections in different OS

Windows

while($true) {
    Get-Process ollama | ForEach-Object { 
        $id = $_.Id
        Write-Host "`nConnections for Ollama process $id" -ForegroundColor Green
        Get-NetTCPConnection | Where-Object OwningProcess -eq $id | Select-Object LocalAddress, LocalPort, RemoteAddress, RemotePort, State 
    }
    Start-Sleep -Seconds 2
    Clear-Host

Create a Systemd Service File:

sudo nano /etc/systemd/system/vboxconfig.service
[Unit]
Description=VirtualBox Kernel Modules Setup
After=network.target

[Service]
@Sy3Omda
Sy3Omda / start_https_server.sh
Created September 25, 2024 19:28
self-signed certificate with python http.server
#!/bin/bash
CERT_FILE="localhost.pem"
cleanup() {
rm -f "$CERT_FILE"
exit 0
}
trap cleanup SIGINT
@Sy3Omda
Sy3Omda / choco-install.bat
Created August 3, 2024 17:08
Official Installation of chocolatey package by cmd
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"