Skip to content

Instantly share code, notes, and snippets.

@bhaumikpatel
bhaumikpatel / contenteditable.html
Created February 28, 2020 05:18
data:text/html, <html contenteditable> with some extra styling to make it easier to use. Just copy/paste the code in your browser and type away. Or make it a bookmark.
data:text/html;charset=utf-8,<title>TextEditor<%2Ftitle><style>body.dark-mode%2Cbody.dark-mode%20*%7Bbackground-color%3A%23111%3Bcolor%3A%23eee%7Dbody.light-mode%2Cbody.light-mode%20*%7Bbackground-color%3A%23eee%3Bcolor%3A%23111%7Dbody%7Bmargin%3A0%20auto%3Bwidth%3A50rem%7Dtextarea%7Bborder%3A0%3Bfont-family%3Asans-serif%3Bfont-size%3A1rem%3Bheight%3A98%25%3Bline-height%3A1.3%3Bmargin%3A0%20auto%3Boutline%3A0%3Bpadding%3A3rem%3Bwidth%3A100%25%7Dbutton%7Bmin-height%3A30px%3Bbackground-color%3A%23fbfbfb%3Bborder%3A1px%20%23ccc%20solid%3Bcolor%3A%23999%3Bcursor%3Apointer%3Bfloat%3Aright%3Bmargin%3A10px%200%3Bpadding%3A5px%2010px%7D@media%20%28max-width%3A768px%29%7Bbody%7Bwidth%3A100%25%3Bpadding%3A0%7Dtextarea%7Bpadding%3A10px%7Dbutton%7Bfloat%3Anone%7D%7D<%2Fstyle><body%20id%3Dbody%20class=light-mode><button%20type%3D"button"%20onclick%3D"tDL%28%29"%20title%3D"Toggle%20dark%2Flight%20mode">🌛<%2Fbutton><button%20onclick%3D"sM%28%29%3B%20return%20false">Email%20this<%2Fbutton><textarea%20contenteditable%20id%3DT
@bhaumikpatel
bhaumikpatel / EnumValidation.cs
Created November 17, 2019 19:12
Enum Validation MVC .Net Core
public class EnumValidation : ValidationAttribute
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
if (value != null)
{
if (!string.IsNullOrWhiteSpace(Convert.ToString(value)))
{
var type = value.GetType();
if (!(type.IsEnum && Enum.IsDefined(type, value)))
@bhaumikpatel
bhaumikpatel / EmailSender.cs
Created August 20, 2019 06:12
Email Sender
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.IO;
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
@bhaumikpatel
bhaumikpatel / .gitignore
Created August 20, 2019 05:37
.gitignore file - ignoring files in Git
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
@bhaumikpatel
bhaumikpatel / .tfsignore
Created August 20, 2019 05:34
TFS file .tfsignore
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
bin
obj
logs
dist
@bhaumikpatel
bhaumikpatel / Publish.ps1
Created August 20, 2019 05:31
DotNet Core Publish project using Powershell script file
#@echo off
#title Publish
#Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Write-Output ("IIS attempts to stop all services.")
iisreset /stop
Write-Output ("Publish Starting...")
Write-Output ("Project publish start...")
dotnet publish "src\Project.csproj" -c Release -o D:\Publish\Project
@bhaumikpatel
bhaumikpatel / Publish.cmd
Created August 20, 2019 05:24
DotNet Core Publish project using CMD file
#@echo off
cls
#title Publish
echo  IIS attempts to stop all services.
iisreset /stop
echo  Publish Starting...
echo  Project publish start...
dotnet publish "src\Project.csproj" -c Release -o D:\Publish\Project
@bhaumikpatel
bhaumikpatel / DeleteBinObjFolders.cmd
Created August 20, 2019 05:18
Clean Visual Studio bin, obj and logs folders
@echo off
@echo Deleting all BIN and OBJ folders...
for /d /r . %%d in (bin,obj,logs) do @if exist "%%d" rd /s/q "%%d"
@echo BIN, OBJ and logs folders successfully deleted :) Close the window.
pause > nul
@bhaumikpatel
bhaumikpatel / Property_Copier.cs
Created July 27, 2019 09:37
Property Copier
public static class PropertyCopier<TParent, TChild> where TParent : class where TChild : class
{
public static void Copy(TParent parent, TChild child)
{
var parentProperties = parent.GetType().GetProperties();
var childProperties = child.GetType().GetProperties();
foreach (var parentProperty in parentProperties)
{
foreach (var childProperty in childProperties)
@bhaumikpatel
bhaumikpatel / SQL_Table_To_Class_Model.sql
Created July 13, 2019 14:06
SQL Table to C# Class Model
declare @TableName sysname = 'Document'
declare @Result varchar(max) = 'public class ' + @TableName + '
{'
select @Result = @Result + '
public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }
'
from
(
select