Skip to content

Instantly share code, notes, and snippets.

View thehaseebahmed's full-sized avatar

Haseeb Ahmed thehaseebahmed

View GitHub Profile
@thehaseebahmed
thehaseebahmed / trap-focus.directive.ts
Last active August 8, 2021 18:52
An angular directive that enables you to trap focus to a certain HTML element. You can read more about it here: http://bit.ly/how-to-trap-focus
import { Directive, ElementRef, AfterViewInit } from '@angular/core';
@Directive({
selector: '[trapFocus]'
})
export class TrapFocusDirective implements AfterViewInit {
constructor(
private el: ElementRef
) {}
@thehaseebahmed
thehaseebahmed / HA-DeleteKeysFromAzAppConfig.ps1
Created July 12, 2021 12:56
This is a simple PowerShell script which lets you delete multiple Azure App Configurations in any instance across all labels.
param (
$Key = 'THIS WILL NOT MATCH WITH ANYTHING',
$Subscription = '',
$AppConfigName = ''
)
az account set -s $Subscription
Write-Host "Fetching all key-values..."
$configs = (az appconfig kv list -n $AppConfigName --all | ConvertFrom-Json)
@thehaseebahmed
thehaseebahmed / ValidatorActionFilter.cs
Created December 4, 2018 06:10
A generic action filter for validating the ModelState before request reaches the controller. This takes out the cross-cutting concern of model validation and puts it in a single place.
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;