Skip to content

Instantly share code, notes, and snippets.

@bhaumikpatel
bhaumikpatel / utils.js
Created February 13, 2025 10:44
Each utility category provides specific functionality
/**
* String manipulation utilities
*/
const stringUtils = {
capitalize: (str) => str.charAt(0).toUpperCase() + str.slice(1),
camelCase: (str) => str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase()),
kebabCase: (str) => str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(),
snakeCase: (str) => str.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase(),
truncate: (str, length = 50, suffix = '...') => str.length > length ? `${str.slice(0, length)}${suffix}` : str,
reverse: (str) => str.split('').reverse().join(''),
@bhaumikpatel
bhaumikpatel / ActivePageTagHelper.cs
Created February 27, 2024 06:35
Add active class on current Razor Pages
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;
[HtmlTargetElement("a", Attributes = "is-active-page")]
public class ActivePageTagHelper : TagHelper
{
/// <summary>
/// The name of Page
/// </summary>
@bhaumikpatel
bhaumikpatel / Clear Node_Bower_Bin_Obj.bat
Last active November 20, 2023 04:59
Clear node_modules, bower_components, Debug, Release, obj and bin folder
@echo off
::SET mypath=%cd%
set mypath=%cd%
@echo %mypath%
::cd /d "F:\"
for /d /r %mypath% %%a in (node_modules\) do @if exist "%%d" echo "%%d" && rd /Q /s "%%a"
for /d /r %mypath% %%a in (bower_components\) do @if exist "%%d" echo "%%d" && rd /Q /s "%%a"
for /d /r %mypath% %%d in (node_modules) do @if exist "%%d" echo "%%d" && rd /s/q "%%d"
for /d /r %mypath% %%d in (bower_components) do @if exist "%%d" echo "%%d" && rd /s/q "%%d"
for /d /r %mypath% %%d in (Debug Release obj bin) do @if exist "%%d" echo "%%d" && rd /s/q "%%d"
@bhaumikpatel
bhaumikpatel / Clear.bat
Created November 20, 2023 04:50
Batch file to perform start, run, %TEMP% and delete all
@echo off
:: c:\windows\system32\cleanmgr.exe /dc
:: del c:\windows\prefetch\*.* /q
:: del c:\windows\temp\*.* /q
REM Clean Temp Folders
rmdir /Q /S "C:\Users\hb\AppData\Local\Temp" > nul
mkdir "C:\Users\hb\AppData\Local\Temp" > nul
rmdir /Q /S "C:\Users\hb\AppData\LocalLow\Temp" > nul
@bhaumikpatel
bhaumikpatel / Date and Time Conversions Using SQL Server.md
Created August 2, 2022 05:10
Date and Time Conversions Using SQL Server
DATE ONLY FORMATS
Format# Query Format Sample
--- --- --- ---
1 SELECT CONVERT(VARCHAR, GETDATE(), 1) mm/dd/yy 08/02/22
2 SELECT CONVERT(VARCHAR, GETDATE(), 2) yy.mm.dd 22.08.02
3 SELECT CONVERT(VARCHAR, GETDATE(), 3) dd/mm/yy 02/08/22
4 SELECT CONVERT(VARCHAR, GETDATE(), 4) dd.mm.yy 02.08.22
5 SELECT CONVERT(VARCHAR, GETDATE(), 5) dd-mm-yy 02-08-22
6 SELECT CONVERT(VARCHAR, GETDATE(), 6) dd-Mon-yy 02 Aug 22
@bhaumikpatel
bhaumikpatel / azure-pipelines.yml
Created July 25, 2022 10:56
Azure pipeline .Net Core 6
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: ubuntu-latest
@bhaumikpatel
bhaumikpatel / MySqlBackup.bat
Last active July 13, 2022 07:11
My SQL backup and zip
@echo off
:: make sure to change the settings from line 4-10
set dbUser=root
set dbPassword="root@123"
set backupDir=D:\Localhost_MySQL_Backup
set mysqldump="C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe"
set mysqlDataDir="C:\ProgramData\MySQL\MySQL Server 5.7\Data"
set zip="C:\Program Files\7-Zip\7z.exe"
set dbName="unicenta"
@bhaumikpatel
bhaumikpatel / Generate-Random-Password.sql
Created June 30, 2022 05:06
How to Generate Random Password in SQL Server? Length characters, upper and lower, special character and include a number
DECLARE @allowAtoZ BIT = 1,
@allow0to9 BIT = 1,
@allowSpecials1 BIT = 1,
@avoidAmbiguousCharacters BIT = 1,
@length INT = 8,
@range VARCHAR(100) = '';
IF @allowAtoZ = 1
BEGIN
@bhaumikpatel
bhaumikpatel / DNS_prefetching.html
Created February 28, 2020 05:53
Common Prefetch Links - DNS prefetching is another way to enhance the performance of the front-end of a website.
<!-- Amazon S3 -->
<link rel="dns-prefetch" href="//s3.amazonaws.com">
<!-- Google CDN -->
<link rel="dns-prefetch" href="//ajax.googleapis.com">
<!-- Microsoft CDN -->
<link rel="dns-prefetch" href="//ajax.microsoft.com">
<link rel="dns-prefetch" href="//ajax.aspnetcdn.com">
@bhaumikpatel
bhaumikpatel / TextColor.html
Created February 28, 2020 05:30
CSS Change Text Color Randomly
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Random color for text in html using css</title>
<style>
.hue {
color: #f35626;