Skip to content

Instantly share code, notes, and snippets.

View rahulpnath's full-sized avatar
🏠
Working from home

Rahul Nath rahulpnath

🏠
Working from home
View GitHub Profile
@rahulpnath
rahulpnath / Program.cs
Created May 9, 2021 19:46
Connect to Local instance of DynamoDB
using System;
using System.Threading.Tasks;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.DataModel;
using Amazon.Runtime;
using ConsoleTables.Core;
namespace dynamodb_local_sample
{
class Program
@rahulpnath
rahulpnath / Readme.md
Last active April 27, 2022 15:16
Cypress Azure AD Login
@rahulpnath
rahulpnath / TypeScriptSumTypes.jsx
Created February 23, 2020 20:11
Using Sum Types to Model Data
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 December 6, 2019 09:36
Create dynamic alias for Powershell
$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 }
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 November 29, 2019 19:48
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.
#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 June 21, 2018 03:46
EF Decode Migration History
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 October 18, 2018 15:54
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/
# 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>'
@rahulpnath
rahulpnath / IValueConverter.markdown
Created July 9, 2014 06:46
A Pen by Rahul P Nath.