Skip to content

Instantly share code, notes, and snippets.

@sabbour
sabbour / delete-empty-resourcegroups.sh
Created October 24, 2023 18:08
Deletes empty resource groups using Azure CLI
#!/bin/bash
# Get a list of all resource groups in the subscription
resource_groups=$(az group list --query '[].name' -o tsv)
# Loop through the list of resource groups
for rg in $resource_groups
do
# Check if the resource group has any resources
resources=$(az resource list --resource-group $rg --query '[].id' -o tsv)
#!/bin/bash
# Define Environment Variables
export RANDOM_STRING=$RANDOM
export RESOURCE_GROUP_NAME=rg-${RANDOM_STRING}
export RESOURCE_LOCATION=eastus
export AKS_CLUSTER_NAME=aks-${RANDOM_STRING}
export KEYVAULT_NAME=kv-${RANDOM_STRING}
export KEYVAULT_CERTIFICATE_NAME=myKvCertificate
export AZUREDNSZONE_NAME=contoso-${RANDOM_STRING}.com
@sabbour
sabbour / aro-create.sh
Created January 24, 2023 19:13
Create an Azure Red Hat OpenShift cluster
LOCATION=eastus # the location of your cluster
RESOURCEGROUP=aro-rg # the name of the resource group where you want to create your cluster
CLUSTER=asabbour # the name of your cluster
az group create \
--name $RESOURCEGROUP \
--location $LOCATION
az network vnet create \
--resource-group $RESOURCEGROUP \
@sabbour
sabbour / git-sync-upstream.sh
Last active January 24, 2023 19:13
How to sync fork with upstream
git checkout master
git fetch upstream
git merge upstream/master
git push
@sabbour
sabbour / fix-dslr-teams.sh
Last active December 16, 2020 18:54
Fix Teams DSLR WebCam on Mac OS
# gist=<rawurl>
# curl -o fix-dslr-teams.sh $gist && chmod +x fix-dslr-teams.sh && sudo ./fix-dslr-teams.sh
#!/bin/bash
echo "Removing signatures"
sudo codesign --remove-signature "/Applications/Microsoft Teams.app" && \
sudo codesign --remove-signature "/Applications/Microsoft Teams.app/Contents/MacOS/Teams" && \
sudo codesign --remove-signature "/Applications/Microsoft Teams.app/Contents/Frameworks/Microsoft Teams Helper.app" && \
sudo codesign --remove-signature "/Applications/Microsoft Teams.app/Contents/Frameworks/Microsoft Teams Helper (GPU).app" && \
sudo codesign --remove-signature "/Applications/Microsoft Teams.app/Contents/Frameworks/Microsoft Teams Helper (Plugin).app" && \
sudo codesign --remove-signature "/Applications/Microsoft Teams.app/Contents/Frameworks/Microsoft Teams Helper (Renderer).app"
#!/bin/bash
# IMPORTANT: Make sure your VM's network security rules allows access over TCP Port 80.
# This is required to pass the HTTP challenge.
# Download: curl -o setup.sh <raw URL of this gist>
# Enable execution: sudo chmod +x setup.sh
# Run: ./setup.sh -d "yourdomain.tld" -e "youremail@yourdomain.tld"
while getopts d:e: option
#!/bin/bash
# update-openvpn-certs.sh
/usr/local/openvpn_as/scripts/sacli --key "cs.priv_key" --value_file "/etc/letsencrypt/live/<YOUR DOMAIN NAME>/privkey.pem" ConfigPut
/usr/local/openvpn_as/scripts/sacli --key "cs.cert" --value_file "/etc/letsencrypt/live/<YOUR DOMAIN NAME>/fullchain.pem" ConfigPut
/usr/local/openvpn_as/scripts/sacli --key "cs.ca_bundle" --value_file "/etc/letsencrypt/live/<YOUR DOMAIN NAME>/chain.pem" ConfigPut
/usr/local/openvpn_as/scripts/sacli start
@sabbour
sabbour / cleanup-docker.sh
Last active August 22, 2023 20:07
Clean up docker images and volumes to fix the "No space left on device" error.
#!/usr/bin/env bash
docker rm $(docker ps -qf 'status=exited')
docker rmi $(docker images -qf 'dangling=true')
docker volume rm $(docker volume ls -qf 'dangling=true')
@sabbour
sabbour / Web.config
Last active March 23, 2022 20:37
Magento IIS Web.config for URL Rewriting
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Remove index.php rule" stopProcessing="true">
<match url=".*" ignoreCase="false"/>
<conditions>
<add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
@sabbour
sabbour / AccountController.cs
Last active March 15, 2017 19:32
Augmenting the Register method to pass on the Country Code, PIN and Phone number to the Application User
//
// POST: /Account/Register
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser() { UserName = model.Email, Email = model.Email, CountryCode = mode.CountryCode, PIN = model.PIN, Phone = model.Phone };