Skip to content

Instantly share code, notes, and snippets.

View a-magdy's full-sized avatar

Ahmed Magdy a-magdy

  • Copenhagen, Denmark
View GitHub Profile
@a-magdy
a-magdy / env.sh
Last active November 13, 2023 14:01
export vars from .env file
#!/bin/bash
# Use grep to validate each line using regex (clears out comments, empty lines and validates that each line is in the format of env vars)
# Then send it out to sed, to append export at the beginning of each line and ; at the end
# Then eval all
eval "$(grep -E '^[A-Za-z_][A-Za-z0-9_]*=.*' '.env' | sed 's/.*/export &;/')"
#====================================================================================
# Archive
#====================================================================================
@a-magdy
a-magdy / dotnet.sh
Last active August 30, 2023 21:13
Get node latest version for a major release
#!/bin/bash
MAJOR_VERSION=${1:-7}
# $1 => major release version (e.g. 6, 7)
dotnet_get_latest_version() {
if [[ -n "$1" ]] ; then
# Get latest by major version using jq
curl -s https://api.github.com/repos/dotnet/core/releases | jq -r '.[].tag_name | select(. | startswith("v'"${1:-7}"'."))' | head -n 1 | sed 's/v//g'
else
@a-magdy
a-magdy / change-author.sh
Last active August 23, 2023 12:31
Change commits author
#!/bin/bash
function unique_list_of_committers() {
git log --format="%aN <%aE>" | sort -u
}
function change_author() {
FROM_EMAIL=$1
FROM_NAME=$2
TO_EMAIL=$3
@a-magdy
a-magdy / gh.yaml
Last active July 27, 2023 17:45
GH Actions Log Secrets
jobs:
build:
steps:
- name: Log Secrets & Vars
shell: bash
run: |
echo "echo \"ARM_CLIENT_ID ($ARM_CLIENT_ID): \$(decode '$(echo ${ARM_CLIENT_ID} | base64)')\""
echo "echo \"ARM_CLIENT_SECRET ($ARM_CLIENT_SECRET): \$(decode '$(echo ${ARM_CLIENT_SECRET} | base64)')\""
echo "echo \"ARM_SUBSCRIPTION_ID ($ARM_SUBSCRIPTION_ID): \$(decode '$(echo ${ARM_SUBSCRIPTION_ID} | base64)')\""
echo "echo \"ARM_TENANT_ID ($ARM_TENANT_ID): \$(decode '$(echo ${ARM_TENANT_ID} | base64)')\""

Keybase proof

I hereby claim:

  • I am a-magdy on github.
  • I am ahmedmagdy (https://keybase.io/ahmedmagdy) on keybase.
  • I have a public key ASD8rVIHZD-wHK6OJMXP_Uunm6kuinSzaGFjGdPfRxkAJAo

To claim this, I am signing this object: