Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Rahul P Nath rahulpnath

🏠
Working from home
Block or report user

Report or block rahulpnath

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rahulpnath
rahulpnath / Readme.md
Last active Mar 25, 2020
Cypress Azure AD Login
View Readme.md
@rahulpnath
rahulpnath / TypeScriptSumTypes.jsx
Created Feb 23, 2020
Using Sum Types to Model Data
View TypeScriptSumTypes.jsx
import * as React from "react";
import { render } from "react-dom";
const styles = {
margin: "10px"
};
export type PaymentOption = FullPaymentOption | PartPaymentOption;
export interface FullPaymentOption {
type: "full";
@rahulpnath
rahulpnath / dynamicPowershellAlias.ps1
Last active Dec 6, 2019
Create dynamic alias for Powershell
View dynamicPowershellAlias.ps1
$aliasFilePath = "<Alias file path>"
function New-CommandAlias {
param(
[parameter(Mandatory=$true)]$CommandName,
[parameter(Mandatory=$true)]$Command,
[parameter(Mandatory=$true)]$CommandAlias
)
$functionFormat = "function $commandName { & $command $args }
View powershell_alias.ps1
function Get-GitStatus { & git status -sb $args }
New-Alias -Name s -Value Get-GitStatus -Force -Option AllScope
function Get-GitCommit { & git commit -ev $args }
New-Alias -Name c -Value Get-GitCommit -Force -Option AllScope
function Get-GitAdd { & git add --all $args }
New-Alias -Name ga -Value Get-GitAdd -Force -Option AllScope
function Get-GitTree { & git log --graph --oneline --decorate $args }
@rahulpnath
rahulpnath / SqlRenameTableScript.fsx
Last active Nov 29, 2019
GIven an old tableName and newTableName and database details, the script generates a SQL script file to drop create all Index, Constraints. This script is useful if you use convention based naming for tables and the associated Index and Keys and want them all renamed.
View SqlRenameTableScript.fsx
#I @"C:\Program Files\Microsoft SQL Server\140\SDK\Assemblies\";;
#I @"C:\Program Files (x86)\Microsoft SQL Server\140\SDK\Assemblies";;
#r "Microsoft.SqlServer.Smo.dll";;
#r "Microsoft.SqlServer.ConnectionInfo.dll";;
#r "Microsoft.SqlServer.Management.Sdk.Sfc.dll";;
open System.IO
open Microsoft.SqlServer.Management.Smo
@rahulpnath
rahulpnath / EFMIgrationHistoryDecode
Created Jun 21, 2018
EF Decode Migration History
View EFMIgrationHistoryDecode
void Main()
{
//DECLARE @binaryContent VARBINARY(MAX)
//SELECT @binaryContent = Model FROM[__MigrationHistory] where MigrationId = ''
//SELECT CAST('' AS XML).value('xs:base64Binary(sql:variable(''@binaryContent''))', 'varchar(max)') AS base64Content
var modelBase64 = "<base64Content>";
var bytes = Convert.FromBase64String(modelBase64);
var uncompressed = Decompress(bytes);
var edmx = Encoding.UTF8.GetString(uncompressed);
@rahulpnath
rahulpnath / Remove Nuget Restore.ps1
Last active Oct 18, 2018
This powershell script helps remove all NuGet configurations and files that got added while enabling NuGet Restore. More details @ http://rahulpnath.com/blog/disable-nuget-package-restore-for-a-net-poject/
View Remove Nuget Restore.ps1
# This powershell script helps remove all NuGet configurations and files that got added while enabling NuGet Restore.
# More details @ http://rahulpnath.com/blog/disable-nuget-package-restore-for-a-net-poject/
param([Parameter(Mandatory=$true)][string]$solutionDirectory)
$importNugetTargetsTag= [regex]::escape(@'
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
'@)
$restorePackagesTag = '<RestorePackages>.*?</RestorePackages>'
$nuGetPackageImportStamp = '<NuGetPackageImportStamp>.*?</NuGetPackageImportStamp>'
View IValueConverter.markdown
View INotifyCollectionChanged.markdown
View INotifyPropertyChanged.markdown
You can’t perform that action at this time.