Skip to content

Instantly share code, notes, and snippets.

@hgirish
hgirish / OpenXmlSearchString.cs
Created August 2, 2022 04:37
Search string in OpenXml SpreadsheetDocument and return Cell Reference
private static StringValue? SearchString(string searchString, WorkbookPart workbookPart, WorksheetPart worksheetPart)
{
var sharedTable = workbookPart.SharedStringTablePart;
var sharedStringValues = new List<SharedStringItem>();
if (sharedTable != null)
{
sharedStringValues =
sharedTable.SharedStringTable.Elements<SharedStringItem>().ToList();
}
<link href="~/lib/datatables/buttons.bootstrap5.min.css" rel="stylesheet" />
<link href="~/lib/datatables/dataTables.bootstrap5.min.css" rel="stylesheet" />
<script src="~/lib/datatables/jquery.dataTables.min.js"></script>
<script src="~/lib/datatables/dataTables.bootstrap5.min.js"></script>
<script src="~/lib/jszip/jszip.min.js"></script>
<script src="~/lib/datatables/js/dataTables.buttons.min.js"></script>
<script src="~/lib/datatables/js/buttons.colVis.min.js"></script>
<script src="~/lib/datatables/js/buttons.html5.min.js"></script>
@hgirish
hgirish / datatables.net-button-display.js
Created June 9, 2022 03:04
Display buttons on datatables before and after the table
$('#myTable').DataTable( {
dom: '<B<frtip>B>',
buttons: [
'colvis',
'excel',
'print'
]
} );
<link href="https://fonts.googleapis.com/css2?family=Libre+Barcode+39+Extended+Text&display=swap" rel="stylesheet">
<style>
.barcode39 {
font-family: 'Libre Barcode 39 Extended Text', cursive;
font-size: 40px;
}
</style>
@hgirish
hgirish / ApplicationUser.cs
Created June 4, 2022 07:05
Update Asp.Net Identity to Latest .net Core Identity, tested with Net6
// https://stackoverflow.com/questions/53878000/how-to-migrate-identity-users-from-a-mvc5-app-to-a-asp-net-core-2-2-app
/* We need a way to differentiate what users are using the new hash version or not.
One way is to add a new property to IdentityUser:
*/
using Microsoft.AspNetCore.Identity;
public class ApplicationUser: IdentityUser
{
@hgirish
hgirish / get-all-migrations-name.ps1
Created December 17, 2019 07:10
Gets the list of EF migrations from C# aspnet core project
Get-ChildItem -Path . -Filter *.cs | Where-Object { $_.Name -match "^\d{14}_.*\.cs" } | Where-Object Name -NotLike "*Designer*"| Select-Object -ExpandProperty Name | Set-Content -path D:\Downloads\migrations.txt
@hgirish
hgirish / set-ineternet-connection-private.ps1
Created December 10, 2019 19:57
Changes internet connection type to private in windows using powershell
Get-NetConnectionProfile -InterfaceAlias vEthernet* | Set-NetConnectionProfile -NetworkCategory Private
@hgirish
hgirish / IssueClassificationWithMLNetApi.cs
Created December 5, 2019 03:35
Getting Scores and Labels for prediction in multiclass classification with ML .NET
/*
* Based on dotnet github issue https://github.com/dotnet/docs/issues/14265
*/
using Microsoft.ML;
using Microsoft.ML.Data;
using RestaurantViolationsML.Model;
using System;
using System.Collections.Generic;
using System.Linq;
# Using PowerShell, find which process is using the port to solve port in use error.
$portNumber = 1433
Get-Process -Id (Get-NetTCPConnection -LocalPort $portNumber).OwningProcess