Skip to content

Instantly share code, notes, and snippets.

View spiceFlowMatrix's full-sized avatar
🎯
Focusing

Hamza Yazar spiceFlowMatrix

🎯
Focusing
View GitHub Profile
@spiceFlowMatrix
spiceFlowMatrix / auth-guard.ts
Last active September 10, 2021 11:33
Loading firebase auth token from NGXS auth state in Angular interceptor.
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
import { map, Observable, take, tap } from 'rxjs';
import { AngularFireAuth } from '@angular/fire/auth';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(
private router: Router,
@spiceFlowMatrix
spiceFlowMatrix / isOwnerPolicy.js
Last active August 13, 2025 14:56
Owner policy for keycloak authorization services
/**
* To be added as a custom provider into Keycloak.
* Must be placed in a .jar with the associated `keycloak-scripts.json` file in the META-INF folder.
* The created .jar must be placed in the keycloak container's `/opt/keycloak/providers` directory.
*/
var context = $evaluation.getContext();
var permission = $evaluation.getPermission();
isOwnerPolicy(permission, context);
@spiceFlowMatrix
spiceFlowMatrix / Program.cs
Last active September 25, 2025 14:26
O(n log(n)) solution for finding minimum sub-array length to get a target sum
Solution solution = new Solution();
Console.WriteLine(solution.MinSubArrayLen(7, [2, 3, 1, 2, 4, 3]));
public class Solution
{
public int MinSubArrayLen(int target, int[] nums)
{
int n = nums.Length;
int[] prefixSum = new int[n + 1];
@spiceFlowMatrix
spiceFlowMatrix / Program.cs
Created September 26, 2025 14:15
O(m+n) solution for finding the minimum string that contains the target string
Solution solution = new Solution();
Console.WriteLine(solution.MinWindow("ADOBECODEBANC", "ABC"));
public class Solution
{
public string MinWindow(string s, string t)
{
int left = 0;
int right = 0;