Skip to content

Instantly share code, notes, and snippets.

@M1kep
M1kep / ConCommandTesting.cs
Last active January 16, 2024 06:57
CS2 Force CVar Flag
using System.Diagnostics;
using System.Runtime.InteropServices;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
namespace ConCommandTesting;
public class ConCommandTesting : BasePlugin
{
public override string ModuleName => "ConCommandTesting";
@M1kep
M1kep / backgroundHandler.ts
Last active August 22, 2022 02:52
TypeScript/Node Background task handler
export class BackgroundHandler {
#tasks: Record<
string,
{
task: () => void;
timer: ReturnType<typeof setTimeout>;
isPaused: boolean;
}
> = {};
@M1kep
M1kep / Get-AzPortalToken.ps1
Created February 5, 2022 23:43
Retrieves the token needed to make calls to the main.iam.ad.ext.azure.com/api/ Azure API
#Requires -module Az.Accounts
function Get-AzPortalToken {
<#
.SYNOPSIS
Refreshes the API token if required
.OUTPUTS
API Token Object
.NOTES
Inspired by https://github.com/Azure/azure-powershell/issues/7525#issuecomment-432384270
Stolen from https://github.com/JustinGrote/Az.PortalAPI/blob/master/Az.PortalAPI/Public/Get-Token.ps1
@M1kep
M1kep / Get-AzPortalEnterpriseApp.ps1
Created February 5, 2022 23:40
Example of retrieving a list of Azure AD Enterprise Applications
function Get-AzPortalEnterpriseApp {
[CmdletBinding(SupportsShouldProcess)]
param (
#Filter by display name or application ID
[String]$Filter,
#Set the result size. Default is first 50 results
[int]$ResultSize = 50
)
$InvokeApiRequestParams = @{
@M1kep
M1kep / Invoke-AzPortalRequest.ps1
Created February 5, 2022 23:38
Function for making a request to the Az Portal API
function Invoke-AzPortalRequest {
<#
.SYNOPSIS
Runs a command against the Azure Portal API
.NOTES
Originally stolen from https://github.com/JustinGrote/Az.PortalAPI/blob/master/Az.PortalAPI/Public/Invoke-Request.ps1
#>
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
@M1kep
M1kep / gist:620a60c022a96707c3d4af77f9745721
Created August 29, 2020 00:02
PowerShell "Spell Check"
Add-Type @"
using System.Linq;
using System;
public class EditDistance {
public static int CheckEditDistance (string original, string modified)
{
int len_orig = original.Length;
int len_diff = modified.Length;
var matrix = new int[len_orig + 1, len_diff + 1];
@M1kep
M1kep / BreadCrumbNavExample-WithMenuHelper.ps1
Last active August 4, 2020 04:21
A PowerShell example of using a stack for breadcrumb like navigation
# Initialize the Stack
$breadCrumb = [System.Collections.Stack]::new()
# Push Page "1"
$breadCrumb.Push(1)
#Initialize empty Pages object
$Pages = @{}
function New-Choice {
[CmdletBinding()]
param (
[Parameter()]
@M1kep
M1kep / custom.css
Last active January 27, 2018 04:48
/*
Copyright 2017 Bryan Keller (https://github.com/widget-)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software