Skip to content

Instantly share code, notes, and snippets.

@rezanid
rezanid / Add-Path.ps1
Last active August 28, 2023 14:38
Adding PATH to Windows permanently (and safely) the right way using PowerShell
function Add-Path {
param(
[Parameter(Mandatory, Position=0)]
[string] $LiteralPath,
[ValidateSet('User', 'CurrentUser', 'Machine', 'LocalMachine')]
[string] $Scope
)
Set-StrictMode -Version 1; $ErrorActionPreference = 'Stop'
@rezanid
rezanid / Directory.Build.props
Created September 18, 2023 16:56
Upgrade C# language version for .NET Framework 4.x
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<LangVersion>11</LangVersion>
<Nullable>disable</Nullable>
</PropertyGroup>
<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>
@rezanid
rezanid / Postman-PreRequest-Authentication.js
Last active April 5, 2024 05:37
Postman Pre-Request script to authenticate and refresh authentication token using OAuth2 device flow
// Environment Variables:
// url: <your-resource> example: https://myfancyapp.crm4.dynamics.com
// clientid: <user-clientid-from-appreg> example: 1950a258-227b-4e31-a9cf-717495945fc2
// To know how to use this script, please read the following blog post:
// https://bycode.dev/2024/04/04/automatically-authenticate-in-postman-with-pre-request-scripts/
const utils = {
auth: {
message: "",
async refreshAuth() {
@rezanid
rezanid / postman-visualize-plugintracelogs.js
Created April 7, 2024 12:12
Visualize Postman results for Power Platform's Plugin Trace Logs
const moment = require('moment');
var template = `
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V" crossorigin="anonymous"></script>
<style>
.table-responsive-custom {
display: block;
width: 100%;
overflow-x: auto;