Skip to content

Instantly share code, notes, and snippets.

View sayedihashimi's full-sized avatar

Sayed Ibrahim Hashimi sayedihashimi

View GitHub Profile
@sayedihashimi
sayedihashimi / gist:1984836
Created March 6, 2012 08:05 — forked from half-ogre/NuGet.targets.xml
An MSBuild target to add to your project files that will restore packages *if* nuget.exe is available via the PATH environment variable.
<!-- add this target to *each* project file, and modify the BeforeBuild target that's already in the project file (usually commented out) to depend on it -->
<Target Name="RestoreNuGetPackages" Condition="Exists('.\packages.config')" BeforeTargets="Build">
<!-- try to execute `nuget help` to see if it's available from what's in the PATH -->
<Exec Command="cmd.exe /c nuget help &gt; NUL" IgnoreExitCode="True">
<Output TaskParameter="ExitCode" PropertyName="NuGetExitCode"/>
</Exec>
<!-- raise an error if nuget.exe wassn't available from what's in the PATH -->
<Error Text="Failed to execute nuget.exe; please make sure your PATH environment variable provides a path to nuget.exe." Condition="'$(NuGetExitCode)' != '' and '$(NuGetExitCode)' > '0'" />
<!-- restore packages -->
<Exec Command="nuget install .\packages.config -o $(SolutionDir)\packages" />
@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 / web.config
Created March 28, 2012 00:38
How to enable directory browsing in web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
This shows how you can get the name of the generated assembly when building a project
using the MSBuild task.
Note: the result of this is shown at https://dl.dropbox.com/u/40134810/twitter/msbuild-target-outputs.png
-->
<!-- The .csproj/.vbproj files to build, this can be named whatever you want -->
@sayedihashimi
sayedihashimi / 18-steps-for-perfect-rice
Last active October 13, 2015 10:58
How to cook rice
1. Place basmati rice into a bowl, rinse it with water a couple times
2. Soak the rice with clean cold water for at least 4 hours. Make sure to stir the rice good when soaking so that the grains don't stick together
3. After rice has soaked, dump the water it was soaking in. Rinse the rice with fresh water a few times
4. Bring some water to a boil in a pot, add some salt to the water too
5. Add rice to water (there water should fully cover the rice with some room to spare)
6. Let the rice come to a solid boil (stirring occasionally to ensure rice doesn't stick together)
7. Let the rice boil until the rice has softened up (crush some rice between your figers to judge). When its almost soft enough to eat take it off the heat
8. Drain out the water from the rice
9. Rinse rice with fresh cold water
10. Drain out the water from the rice (make sure its really dry you want to avoid any left over water here)
@sayedihashimi
sayedihashimi / get-full-path.proj
Created December 23, 2012 23:06
Demonstrates how you can convert a relative path to an absolute path in MSBuild
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Demo">
<!-- Demonstrates how you can convert a relative path to a full path in MSBuild -->
<PropertyGroup>
<Filepath>sample\file.txt</Filepath>
</PropertyGroup>
<Target Name="Demo">
<PropertyGroup>
@sayedihashimi
sayedihashimi / sc-azure-publish.proj
Created January 9, 2013 06:56
You can use this gist to ensure that SlowCheetah transforms are enabled for the Azure CD build template in hosted TFS.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="RestoreNuGetPackages">
<Message Text="Restoring nuget packages" />
<MSBuild Projects="$(MSBuildThisFileDirectory)WorkerRole1\packageRestore.proj"/>
</Target>
<Target Name="Build" DependsOnTargets="RestoreNuGetPackages">
<Message Text="Invoking solution build/publish" />
@sayedihashimi
sayedihashimi / msdeploy-setAcl-rootDir.xml
Created February 23, 2013 06:35
Shows how you can use the setAcl provider to set a permission on the root directory on publish.
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludeSetAclProviderOnDestination>false</IncludeSetAclProviderOnDestination>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
@sayedihashimi
sayedihashimi / .gitignore
Last active January 3, 2016 19:59
Sample which shows how to create a nuget pkg with a module which another nuget pkg uses
# Folders to ignore #
OutputRoot/
@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