Skip to content

Instantly share code, notes, and snippets.

View CodeIter's full-sized avatar
🍊
Welcome

Muhammad Amin Boubaker CodeIter

🍊
Welcome
View GitHub Profile
@CodeIter
CodeIter / ip.ts
Last active May 20, 2025 18:28
Retrieves the client IP address from request headers, securely handling proxy configurations. Always ensure XFF and similar HTTP headers are set and controlled exclusively by your trusted reverse proxy.
type HttpRequestWithSocket = {
headers: Headers | Record<string, string | string[] | undefined>
socket?: { remoteAddress?: string }
}
/**
* Gets the client IP address from request headers with secure proxy handling
* @param request - The incoming Request object or IncomingMessage
* @returns The client IP address (with appropriate fallbacks)
@CodeIter
CodeIter / termux-x11-generate-startup-script.sh
Last active June 28, 2024 16:23
generates a set of shell scripts that can be used to launch various window managers in Termux's X11 environment.
for i in icewm jwm fluxbox openbox bspwm 2bwm fvwm xorg-twm awesome i3 ; do ( echo '#!/usr/bin/env -S bash -xeuo pipefail' ; echo ; echo 'export DISPLAY="${DISPLAY:-:0}"' ; echo 'export DISPLAY="${1:-${DISPLAY}}"' ; echo 'shift || true' ; echo ; echo 'if [[ "${1:-}" == "nodbus" ]] ; then' ; echo ' shift || true' ; echo ' export NO_DBUS="y"' ; echo 'fi' ; echo ; echo 'if [[ "${1:-}" == "dbus" ]] ; then' ; echo ' shift || true' ; echo ' export NO_DBUS=""' ; echo 'fi' ; echo ; echo 'if [[ -n "${NO_DBUS:-}" ]] ; then' ; echo ' export DBUS_CMD=""' ; echo 'else' ; echo ' export DBUS_CMD="${DBUS_CMD:-dbus-launch --exit-with-x11 --exit-with-session}"' ; echo ' if [[ -n "${1:-}" ]] ; then' ; echo ' export DBUS_CMD="${@}"' ; echo ' fi' ; echo 'fi' ; echo ; echo 'termux-x11 "${DISPLAY:-0}" v -p "${SCREENSAVER_MIN:-5}" -terminate "${RESET_SEC:-60}" -schedInterval "${SCHED_MS:-500}" -br -dpi "${DPI:-96}" -deferglyphs "${DIFFER_GLYPHS:-all}" -maxclients "${MAX_CLIENTS:-64}" -once -listen unix -nolisten tcp +bs
@CodeIter
CodeIter / termux-pacman-glibc-setup.sh
Last active May 5, 2025 20:40
Setup `glibc-runner` with pacman on Termux and install Deno.JS and Bun.JS .
#!/usr/bin/env -S bash -xeuo pipefail
set -xeuo pipefail
pkg install pacman patchelf \
which time ldd tree
echo
echo
@CodeIter
CodeIter / custom-tinycore.sh
Created April 13, 2024 10:50 — forked from dankrause/custom-tinycore.sh
Create a custom tinycore linux iso. Adjust the config at the beginning of the script, or supply a conf as the first arg. Requires xorriso.
#!/bin/bash
set -e
function cleanup() {
# clean up our temp folder
rm -rf "${TMPDIR}"
}
trap cleanup EXIT
@CodeIter
CodeIter / LICENSE
Last active June 4, 2024 18:22
Tmux Launcher - Session & Window Management. Effortlessly manage tmux sessions and open new windows with flexibility. This script checks for existing sessions, allows opening new ones in named groups, or attaches to the last session if preferred. Customize behavior with commented-out options.
MIT License
Copyright (c) 2024 Muhammad Amin Boubaker
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@CodeIter
CodeIter / load_ssh_keys_from_pass.md
Last active February 24, 2024 08:18
Automatically load ssh keys in bash

Automatically load ssh keys : Add to .bashrc and configure environment variable.

export SSH_DIR="${HOME}/.ssh"
command mkdir -p "${SSH_DIR}"
if [[ -z "${SSH_AUTH_SOCK:-}" ]] ; then
  eval "$(ssh-agent -s)" >/dev/null 2>&1
  export SSH_AUTH_SOCK="${SSH_AUTH_SOCK}"
fi
export SSH_AGENT_LIFE=14400 # 4 hours
@CodeIter
CodeIter / get_github_repo_size.bash
Last active June 4, 2024 18:31
bash function to retrieve and display the sizes of GitHub repositories.
#!/usr/bin/env -S bash -euo pipefail
get_github_repo_size() {
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
echo "Usage: get_github_repo_size [OPTIONS] {GITHUB_REPO_URLS...}"
echo
echo "Retrieve and display the sizes of GitHub repositories."
echo "The function will automatically use the GITHUB_TOKEN if it's set as an environment variable."
echo
@CodeIter
CodeIter / README.md
Created April 9, 2022 17:53
get git remote url as `https`. Whatever your remote Git repository settings are.

git-remote-http

get git remote url as https. Whatever your remote Git repository settings are.

use it :

  • for github.com repo :
    • git-remote-http.sh get first repo https url as ordered by git.
    • git-remote-http-all.sh get all repo https url as ordered by git.
/* https://stackoverflow.com/a/49434126 */
.CodeMirror {
resize : vertical !important;
overflow : auto !important;
}
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\FirefoxPortable.exe]
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\FirefoxPortable.exe\shell]
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\FirefoxPortable.exe\shell\open]
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\FirefoxPortable.exe\shell\open\command]