Skip to content

Instantly share code, notes, and snippets.

View ammarshah's full-sized avatar

Ammar Shah ammarshah

View GitHub Profile
@ammarshah
ammarshah / set_up_your_own_git_server_on_windows_10_using_gitea.md
Last active November 8, 2025 13:49
Set Up Your Own Git Server on Windows 10 Using Gitea

Set Up Your Own Git Server on Windows 10 Using Gitea

Gitea is a self-hosted, open-source Git service similar to GitHub, but lightweight, free, and perfect for personal or local setups.

While the official Gitea installation guide is simple, the process you'll see here might seem a bit extra - and that's because I wanted something very specific.

Let's put it this way: I wanted to run my own local github.com, completely offline.

My top priority was to host everything locally on my own network, where the host and client machines could communicate both wirelessly (through a Wi-Fi router) and directly through a LAN cable (peer-to-peer).

@ammarshah
ammarshah / set_up_your_own_git_server_on_fedora_43_using_gitea.md
Last active November 8, 2025 13:49
Set Up Your Own Git Server on Fedora 43 Using Gitea

Set Up Your Own Git Server on Fedora 43 Using Gitea

Gitea is a self-hosted, open-source Git service similar to GitHub, but lightweight, free, and perfect for personal or local setups.

While the official Gitea installation guide is simple, the process you'll see here might seem a bit extra - and that's because I wanted something very specific.

Let's put it this way: I wanted to run my own local github.com, completely offline.

My top priority was to host everything locally on my own network, where the host and client machines could communicate both wirelessly (through a Wi-Fi router) and directly through a LAN cable (peer-to-peer).

@ammarshah
ammarshah / an_encrypted_ssh_and_gpg_keys_backup_and_restore_guide.md
Last active October 9, 2025 02:33
Encrypted SSH and GPG Keys Backup & Restore

Encrypted SSH and GPG Keys Backup & Restore

A pair of bash scripts to securely backup and restore your SSH keys, GPG keys, and Git configuration with symmetric encryption.

Backup Script (backup-keys.sh)

This script creates an encrypted backup of the following:

  • All SSH keypairs in ~/.ssh/ starting with id_ (e.g., id_rsa, id_ed25519)
  • All GPG keys (private keys, public keys, and trust database)
@ammarshah
ammarshah / force_garbage_collection_of_dangling_objects_in_git.md
Created October 6, 2025 06:48
Git: Force Garbage Collection of Dangling Objects

Git: Force Garbage Collection of Dangling Objects

What Are Dangling Objects?

Dangling objects are commits, blobs, or trees that are no longer referenced by any branch, tag, or the reflog. They exist in Git's object database but aren't part of any reachable history.

commit A -- commit B -- commit C (HEAD)
            \
 commit B' (dangling after amending B)
@ammarshah
ammarshah / how_to_create_dummy_files_in_linux.md
Created October 6, 2025 04:26
How to Create Dummy/Test Files in Linux

How to Create Dummy/Test Files in Linux

TL;DR

  • fallocate: Allocates actual disk space (reserves it upfront)
  • truncate: Changes file size without allocating space (creates sparse files)

What are "Sparse Files"?

Sparse files have "holes" - regions that claim to exist but have no actual data. When read, the OS returns zeros for holes without storing them on disk. This saves space but may cause issues if the disk fills up later when you try to write real data.

@ammarshah
ammarshah / manage_multiple_ruby_versions_with_rbenv_in_fedora43.md
Last active November 4, 2025 06:38
Setup rbenv on Fedora 43 and use .ruby-version file to install the version your project requires

How to setup rbenv on Fedora 43

This guide will not install a specific Ruby version you want, although, it will setup rbenv so you can manage multiple Ruby versions.

It assumes that the project that requires a specific Ruby version has a file .ruby-version in the root of the project. So, simply running rbenv install from project root directory will use the version specified in that file and install it.

But if you still want to install a specific version of Ruby without using .ruby-version file, you can do so using:

$ rbenv install 3.4.6
@ammarshah
ammarshah / transfer_data_between_fedora43_and_windows10.md
Last active November 4, 2025 06:36
Transfer Data between Two Laptops (Fedora 43 and Windows 10) using a LAN Cable and FileZilla

Transfer Data between Two Laptops (Fedora 43 and Windows 10) using a LAN Cable and FileZilla

Transferring files between a Fedora 43 machine and a Windows 10 machine over a LAN using FileZilla involves a few key steps. The general process is to set up one machine as an FTP server (Fedora) and the other as an FTP client (Windows). Here's how you can do that:

1. Connect Both Computers via LAN Cable

  • Plug one end of the LAN cable into the Ethernet port of the first laptop.
  • Plug the other end of the LAN cable into the Ethernet port of the second laptop.

2. Configure Network Settings

@ammarshah
ammarshah / install_postgresql_18_on_fedora.md
Last active November 4, 2025 06:18
Install PostgreSQL 18 on Fedora 43

Install PostgreSQL 18 on Fedora 43

1. Installation

You can follow the PostgreSQL installation steps from its official website and you'll be good to go but I prefer to keep only the latest version's repo i.e. pgdg18, since the first command would add pgdg repos for version 13 through 18.

# Add the pgdg repo
sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/F-43-x86_64/pgdg-fedora-repo-latest.noarch.rpm

# Disable all pgdg repos except pgdg18
@ammarshah
ammarshah / install_postgresql_17_on_ubuntu.md
Last active November 16, 2025 12:46
Install PostgreSQL 17 on Ubuntu 24.04

Install PostgreSQL 17 on Ubuntu 24.04

1. Import the repository signing key:

$ sudo apt install curl ca-certificates
$ sudo install -d /usr/share/postgresql-common/pgdg
$ sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc

2. Create the repository configuration file:

@ammarshah
ammarshah / manage_multiple_ruby_versions_with_rbenv_in_ubuntu24_04.md
Last active September 16, 2025 08:47
Setup rbenv on Ubuntu 24.04 and use .ruby-version file to install the version your project requires

How to setup rbenv on Ubuntu 24.04

This guide will not install a specific Ruby version you want, although, it will setup rbenv so you can manage multiple Ruby versions.

It assumes that the project that requires a specific Ruby version has a file .ruby-version in the root of the project. So, simply running rbenv install from project root directory will use the version specified in that file and install it.

But if you still want to install a specific version of Ruby without using .ruby-version file, you can do so using:

$ rbenv install 3.4.1