Skip to content

Instantly share code, notes, and snippets.

View muhammad-asn's full-sized avatar
🎯
Focusing

Muhammad Ardivan muhammad-asn

🎯
Focusing
View GitHub Profile
@muhammad-asn
muhammad-asn / deployment.tcp.yaml
Created April 28, 2025 03:43
Test UDP and TCP Connection in Kubernetes
## TCP Connection
apiVersion: v1
kind: Service
metadata:
name: nginx-service
namespace: monitoring
spec:
type: ClusterIP
selector:
app: nginx
@muhammad-asn
muhammad-asn / script.py
Created April 16, 2025 06:37
Script python to generate 6 chars
#!/bin/python3
import random; import string; ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(6))
@muhammad-asn
muhammad-asn / script.sh
Created April 8, 2025 02:43
WSL /var/run/docker.sock permissions fix
## Context: https://github.com/rancher-sandbox/rancher-desktop/issues/1156
sudo addgroup --system docker
sudo adduser $USER docker
newgrp docker
# And something needs to be done so $USER always runs in group `docker` on the `Ubuntu` WSL
sudo chown root:docker /var/run/docker.sock
sudo chmod g+w /var/run/docker.sock
@muhammad-asn
muhammad-asn / README.md
Created December 18, 2024 23:15
GCP Presigned URL bucket

GCS Signed URL Generator

This Python script generates a signed URL for downloading a blob from Google Cloud Storage (GCS). The signed URL allows users to access the blob without requiring authentication.

Prerequisites

  • Python >= 3.10.x
  • Google Service Account

How to Use

@muhammad-asn
muhammad-asn / script.sh
Created December 11, 2024 16:15
Generate AWS pricing and save to csv
#!/bin/bash
wget -q -O - https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/index.json | jq -r '.offers[].currentVersionUrl' | sed 's/\.json$/.csv/' | wget -x --base="https://pricing.us-east-1.amazonaws.com" --no-host-directories --cut-dirs=3 -i
@muhammad-asn
muhammad-asn / script.sh
Created October 10, 2024 09:15
Git Reset / Undo latest commit
$ git commit -m "Something terribly misguided" # (0: Your Accident)
$ git reset HEAD~ # (1)
[ edit files as necessary ] # (2)
$ git add . # (3)
$ git commit -c ORIG_HEAD # (4)
# Reference: https://stackoverflow.com/questions/927358/how-do-i-undo-the-most-recent-local-commits-in-git
```
Make sure your macOS version meets the prerequisites
https://learn.microsoft.com/en-us/dotnet/core/macos-prerequisites?tabs=netcore2x
If it does, then after installing via the installer, in a new terminal run this command
ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/
Then try dotnet --version
@muhammad-asn
muhammad-asn / script.sh
Created August 3, 2024 08:05
Check hidden process that used bind mounts
function procbindmounts {
cat /proc/*/mounts | awk '$2 ~ /^\/proc\/[0-9]*($|\/)/ { print $2 }' | sort -ur |
while read dir; do
echo ===== POSSIBLE PROCESS HIDING $dir
echo -ne Overlay:\\t
cut -d' ' -f1-7 $dir/stat
umount $dir
echo -ne Hidden:\\t\\t
cut -d' ' -f1-7 $dir/stat
done
@muhammad-asn
muhammad-asn / script.sh
Created July 25, 2024 06:59
Add ssh-key Github in MacOS/Linux
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
@muhammad-asn
muhammad-asn / postgres-grant-permission.txt
Last active June 15, 2024 05:58
Grant All Permission to Database User
CREATE USER dev WITH PASSWORD 'hiiiiiiiiii';
ALTER DEFAULT PRIVILEGES
IN SCHEMA public
GRANT ALL PRIVILEGES ON TABLES TO dev;
GRANT CONNECT ON DATABASE database_name TO dev;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO dev;
GRANT ALL PRIVILEGES ON DATABASE database_name TO dev;
GRANT ALL ON SCHEMA public TO dev;