Skip to content

Instantly share code, notes, and snippets.

View sayedihashimi's full-sized avatar

Sayed Ibrahim Hashimi sayedihashimi

View GitHub Profile
@sayedihashimi
sayedihashimi / transform-xml.ps1
Last active January 17, 2024 20:02
Script which can be used to transform an XML file using XDT. All you need to do is download the script and call it. The script will download the files it needs to run.
#!/usr/bin/env powershell
<#
.SYNOPSIS
You can use this script to easly transform any XML file using XDT.
To use this script you can just save it locally and execute it. The script
will download its dependencies automatically.
Created by sayediHashimi
Modified by obscurerichard
Thanks Stack Overflow: https://stackoverflow.com/questions/8989737/web-config-transforms-outside-of-microsoft-msbuild
@sayedihashimi
sayedihashimi / msbuild-get-date.proj
Created March 23, 2012 03:02
MSBuild how to get a good formatted date
<Project
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="4.0"
DefaultTargets="Demo" >
<Target Name="Demo">
<PropertyGroup>
<CurrentDate>$([System.DateTime]::Now.ToString(yyyyMMdd-mmss))</CurrentDate>
</PropertyGroup>
@sayedihashimi
sayedihashimi / xml-module-ps4.psm1
Created March 30, 2014 21:46
XML DSL module by Joel Bennett updated for PowerShell 4
# original by JOEL 'JAYKUL' BENNETT http://huddledmasses.org/a-dsl-for-xml-in-powershell-new-xdocument/
# modified by Sayed Ibrahim Hashimi for PowerShell 4
# Improves over the built-in Select-XML by leveraging Remove-XmlNamespace http`://poshcode.org/1492
# to provide a -RemoveNamespace parameter -- if it's supplied, all of the namespace declarations
# and prefixes are removed from all XML nodes (by an XSL transform) before searching.
# IMPORTANT: returned results *will not* have namespaces in them, even if the input XML did.
# Also, only raw XmlNodes are returned from this function, so the output isn't completely compatible
# with the built in Select-Xml. It's equivalent to using Select-Xml ... | Select-Object -Expand Node
@sayedihashimi
sayedihashimi / _webjob-env-vars.txt
Last active August 1, 2022 02:46
Environment variables when your app is running as a Microsoft Azure Web Job
ALLUSERSPROFILE C:\DWASFiles\Sites\WebjobsEnvvars\ProgramData
APP_POOL_CONFIG C:\DWASFiles\Sites\WebjobsEnvvars\Config\applicationhost.config
APP_POOL_ID WebjobsEnvvars
APPDATA C:\DWASFiles\Sites\WebjobsEnvvars\AppData
APPSETTING_REMOTEDEBUGGINGVERSION 11.0.611103.400
APPSETTING_ScmType None
APPSETTING_WEBSITE_NODE_DEFAULT_VERSION 0.10.29
APPSETTING_WEBSITE_SITE_NAME WebjobsEnvvars
aspnet:DisableFcnDaclRead true
aspnet:PortableCompilationOutput true
@sayedihashimi
sayedihashimi / getnuget.proj
Last active July 26, 2022 19:53
Samples showing how to download nuget in a scrpit to avoid checking it in
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="GetNuget">
<!--
This is an MSBuild snippet that can be used to download nuget to the path
in the property NuGetExePath property.
Usage:
1. Copy and paste this into your build script
2. Call the GetNuGet target before you use nuget.exe from $(NuGetExePath)
@sayedihashimi
sayedihashimi / 10M-01-number-details.txt
Last active April 14, 2022 19:44
Stats from roulette simulator
Number of spin: 100,000,000
Number details ---------------------------------------------
Number of black and red swaps: 47,364,836
---- 1 ----
Number of hits: 2,633,633
Max # spins since last hit: 551
Max # of consecutive hits: 5
@sayedihashimi
sayedihashimi / how-to-publish-to-multiple-iis.md
Last active March 19, 2022 19:32
How to publish a web project to multiple IIS sites

Scenario:

  • I have a web project that I want to publish to multiple IIS sites
  • Publish in VS should publish to devs local IIS server (MSDeploy)
  • Publish from CI/CLI should publish to remote env (MSDeploy)
  • CI/CLI and VS publish should be the same
  • Building the solution takes ~3 min and should only be performed once
  • Config files need to be transformed based on the dest env

Question:

How can I accomplish this?

@sayedihashimi
sayedihashimi / msbuild-error-format.md
Last active February 17, 2022 18:54
MSBuild and Visual Studio Known Error Message Formats

MSBuild and Visual Studio Known Error Message Formats

When a tool is executed that outputs some text, MSBuild will examine the text for errors and warnings. Many tools use a known format to report these messages. By default, MSBuild will examine the text and report errors and/or warnings based on the output. This behavior can be changed or disabled by using these parameters on the Exec task: IgnoreStandardErrorWarningFormat, CustomErrorRegularExpression, and CustomWarningRegularExpression.

NOTE: If you do decide to use your own regular expression to detect error and warnings, then

@sayedihashimi
sayedihashimi / show-console-colors.ps1
Last active May 29, 2021 17:07
PowerShell loop through console colors to display different results for foreground color & background color
[enum]::getvalues([type]'ConsoleColor') | ForEach-Object{
$curForeground = $_
[enum]::getvalues([type]'ConsoleColor') | ForEach-Object{
$curBackground = $_
$msgStart= "Foreground={0}, Background={1}" -f $curForeground,$curBackground
$msgStart += (New-Object string -ArgumentList @(' ',(50-$msgStart.Length)))
$msgStart | Write-Host -NoNewline
@sayedihashimi
sayedihashimi / allowlistforpihole.txt
Created March 26, 2021 19:00 — forked from shanselman/allowlistforpihole.txt
A gist with an ALLOW LIST for a PiHole to make sure your XBox and Windows Services keeps working and appropriate anonymized telemetry goes where it needs to go
analytics.twitter.com
api.mixpanel.com
api.segment.io
attestation.xboxlive.com
az416426.vo.msecnd.net
browser.pipe.aria.microsoft.com
c.bing.com
c.msn.com
c1.microsoft.com
cdn-gl.imrworldwide.com