Skip to content

Instantly share code, notes, and snippets.

View vibs2006's full-sized avatar

vibs2006

View GitHub Profile
@vibs2006
vibs2006 / Dockerfile_mssql
Created December 14, 2023 10:44 — forked from pbthorste/Dockerfile_mssql
Docker image with msssql 2022 with full text search enabled
# Docker image with msssql 2022 with full text search enabled
# based on work in: https://github.com/Microsoft/mssql-docker
# Base OS layer: Latest Ubuntu LTS
FROM --platform=linux/amd64 ubuntu:focal
# Install prerequistes since it is needed to get repo config for SQL server
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -yq curl apt-transport-https gnupg && \
@vibs2006
vibs2006 / ModelStateHelpers.cs
Created August 31, 2023 13:40
Validation C#
public static List<string> GetListOfErrorMessagesFromModelState(Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary modelState)
{
if (modelState is null || modelState.Count == 0 || modelState.IsValid) return new List<string>();
List<string> errors = new List<string>();
foreach(var item in modelState.Values)
{
foreach(var error in item.Errors)
{
@vibs2006
vibs2006 / POCO_Generators.cs
Last active August 29, 2023 14:25
Dapper Utils Helpers
//Generate CRUD Operations from Tablename
public async Task GenerateSQLMethodsForParams()
{
string tableName = "MerchantInfo";
string dbInstance = "_db";
string tableClassName = tableName;
var resultObjectMerchanInfo = await _db.QueryAsync<SQLTablesSchema>(@"SELECT c.column_id,c.NAME,c.[object_id],c.system_type_id,tt.[name] AS TypeName,c.max_length,c.PRECISION,c.is_nullable,c.is_identity, c.is_rowguidcol FROM sys.columns C INNER JOIN sys.tables t ON t.object_id = c.object_id INNER JOIN sys.types tt ON tt.system_type_id = c.system_type_id WHERE t.NAME = @TableName", new
{
TableName = tableName
@vibs2006
vibs2006 / AesEncryptDecrypt.cs
Last active August 7, 2023 15:48
Security Related
public class EncryptDecryptUtils
{
private readonly string _aesKey;
public EncryptDecryptUtils(string aesKey)
{
_aesKey = aesKey ?? throw new NullReferenceException("_aesKey cannot be null or empty");
}
public string encrypt(string encryptString)
{
@vibs2006
vibs2006 / GetNullableType.cs
Created August 7, 2023 07:05
C# Small codes
//Get Nullable Type
namespace TestConsoleApp
{
public class PaginationRequestParams
{
public string? page_cursor { get; set; }
public int? count { get; set; }
public string? response_fields { get; set; }
@vibs2006
vibs2006 / CustomLogger.cs
Created June 14, 2023 12:34
Logging Utilities and Helper Methods
using System;
namespace CoreApp
{
public class CustomLogger
{
private static object lockObject = new object();
private string _baseFolderForLogs = string.Empty;
private string _baseFileNameForLogs = string.Empty;
@vibs2006
vibs2006 / Readme.md
Last active June 14, 2023 12:35
Windows Commandline Common UTILs

#Windows Command Line Batch Examples

@vibs2006
vibs2006 / VatCalculation.sql
Last active March 17, 2023 15:27
Vat CalculationSQL
declare @netprice decimal(18,2) = 120;
declare @vatrate decimal(18,2) = 20;
DECLARE @baseprice decimal(18,2)
SET @baseprice = @netprice / (1 + (@vatrate/100))
select @baseprice as BasePrice, ((@vatrate/100)*(@baseprice)) as Vat , @baseprice + ((@vatrate/100)*(@baseprice)) as NetPrice
@vibs2006
vibs2006 / AdminController.cs
Last active April 22, 2023 13:05
View Logs via API Controllers
[RoutePrefix("")]
public class AdminController : ApiController
{
[Route("Admin/{id}")]
[HttpGet]
public IHttpActionResult Admin(string id)
{
if (
(ConfigurationManager.AppSettings["LogsKey"] != null && ConfigurationManager.AppSettings.Get("LogsKey") == id )
||
@vibs2006
vibs2006 / MailHelper.cs
Last active June 14, 2023 12:11
Mail Helpers
using MailKit.Net.Smtp;
using MimeKit;
using System;
using System.Collections.Generic;
using System.Linq;
namespace HelperUtilities.MailKitNew
{
public class MailHelper