Skip to content

Instantly share code, notes, and snippets.

View MohamedElashri's full-sized avatar

Mohamed Elashri MohamedElashri

View GitHub Profile
@MohamedElashri
MohamedElashri / REAMD.md
Created November 17, 2024 08:44
Script to make creating swap easier and quicker

What is this?

This is a simple Bash script designed to help easily create and manage swap files on a Linux system. It also allows easily configure kernel parameters vm.swappiness and vm.vfs_cache_pressure.


How to Use

@MohamedElashri
MohamedElashri / README.md
Last active November 15, 2024 21:53
install open snitch on debiad based linux distributions.

OpenSnitch Manager Script

A bash script to manage OpenSnitch installation, uninstallation, and repair on Linux systems. This script provides automated installation of both the OpenSnitch service and UI components, with proper desktop integration and autostart configuration.

Supported Distributions

  • Debian-based systems (Debian, Ubuntu, Linux Mint, Pop!_OS)
  • RHEL-based systems (CentOS, Fedora)
  • Arch Linux
@MohamedElashri
MohamedElashri / linux_shell_commands.md
Created November 6, 2024 13:47
List of Linux commands in tables categorized by tool types

List of Linux commands in tables categorized by tool types. source

File and Directory Operations

Command Description
cp Copy files to another location
mv Move or rename files or directories
rm Remove files
@MohamedElashri
MohamedElashri / mac_shell_commands.md
Created November 6, 2024 13:43
List of macOS commands in tables categorized by tool types

List of macOS commands in tables categorized by tool types. source

File and Directory Operations

Command Description
cp Copy files to another location
mv Move or rename files or directories
rm Remove files
mkdir Create new folders
@MohamedElashri
MohamedElashri / cern_sync.sh
Created November 4, 2024 02:25
script to sync between two machines via resync over ssh connection
#!/bin/bash
# Define colors for logs
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No color
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
@MohamedElashri
MohamedElashri / jupyter_tmux.md
Created October 9, 2024 16:40
Running a Long-Running Jupyter Notebook Remotely using tmux

Running a Long-Running Jupyter Notebook Remotely using tmux

Step-by-Step Instructions:

  1. Start tmux Session
    • Connect to your remote server via SSH:
      ssh user@remote-server
  • Start a tmux session to keep your terminal session active even after disconnection:
@MohamedElashri
MohamedElashri / update_cursor.md
Last active May 1, 2025 11:03
Update script for Cursor AI IDE on linux

Cursor IDE Update Script

This Python script automates the process of downloading, installing, and updating the Cursor IDE on Linux. It checks if a new version is available, updates the AppImage, and refreshes the desktop entry and icon.

Prerequisites

  • Python 3.x
  • urllib and hashlib modules (standard with Python 3)

Usage

@MohamedElashri
MohamedElashri / Persistent_SSH_Tunnel_with_systemd.md
Created September 28, 2024 22:14
Persistent SSH Tunnel with systemd

This guide explains how to create a persistent SSH reverse tunnel using systemd without relying on tools like autossh. This approach automatically restarts the SSH tunnel if it fails or gets stuck due to disconnections.

Why Use systemd for SSH Tunnels?

Using systemd provides several benefits over standalone SSH or autossh:

  • Automatic Restart: If the SSH connection fails, systemd restarts it automatically.
  • Keep Alive: Prevents stale SSH connections by using SSH's ServerAliveInterval and ServerAliveCountMax.
  • Clean and Simple: Avoids external tools and manages the service with native system management.

Steps to Set Up

@MohamedElashri
MohamedElashri / create_and_push_repo.md
Last active September 29, 2024 20:37
Automate GitHub Repo Creation and Push with a Bash Function

This bash function automates the process of initializing a Git repository, creating a GitHub repository, and pushing your local files—all from the command line using the GitHub CLI (gh). It also disables wikis and issues for the created repo.

Add the following function to your .bashrc or .zshrc file:

create_and_push_repo() {
    if ! command -v gh &> /dev/null
    then
        echo "Error: GitHub CLI (gh) is not installed. Please install it first."
@MohamedElashri
MohamedElashri / input_source_switch_comsic_desktop.md
Created September 25, 2024 22:12
Enable Input Source Switching in Cosmic Desktop by System76

Description

At present, Cosmic Desktop by System76 lacks a GUI to configure input source switching. However, the system uses the XKB (X Keyboard Extension) system, which allows manual configuration of input switching by modifying the relevant XKB settings.

The grp:win_space_toggle option defines a key combination (Super+Space or Win+Space) for switching between input sources. The provided workaround manually sets this option by editing the xkb_config file.

This approach gives users the flexibility to switch between keyboard layouts without waiting for native support in Cosmic Desktop.

Notes