Skip to content

Instantly share code, notes, and snippets.

View odytrice's full-sized avatar

Ody Mbegbu odytrice

View GitHub Profile
@odytrice
odytrice / ExcelProcessor.cs
Last active September 28, 2019 07:37
Excel Processor using EPPlus Nuget Package
public class ExcelProcessor
{
public Stream Generate<T>(Dictionary<string, IEnumerable<T>> Sheets)
{
//Generate Excel Workbook in Memory
using (var excel = new ExcelPackage())
{
if (Sheets.Any() == false) throw new Exception("No Sheets were supplied");
foreach (var pair in Sheets)
@odytrice
odytrice / ImageService.cs
Last active September 28, 2019 07:36
Image Processor
public class ImageService : IImageService
{
#region Scale Stream
public Stream ScaleWidth(Stream imageStream, int maxWidth)
{
var output = new MemoryStream();
//Get Image from Stream
using (var image = Image.FromStream(imageStream))
{
@odytrice
odytrice / self-signed-certificate-with-custom-ca.md
Created September 12, 2019 08:30 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@odytrice
odytrice / minikube.ps1
Last active January 31, 2019 12:35
Minikube PowerShell
# This starts minikube and configures docker to point to minikube cluster
"
====================================
Welcome to Minikube Docker Shell
====================================
"
"- Checking Minikube Status"
$isRunning = ((minikube status) -join ' ' ).Contains("Running")
@odytrice
odytrice / Conversion.bat
Created December 31, 2018 20:28 — forked from andrewabest/Conversion.bat
Convert a crt + p7b (from godaddy) to pfx
echo off
:: download OpenSSL if you don't have it for the below
:: Conver the p7b into PEM format
openssl pkcs7 -in mydomain.p7b -print_certs -out mydomain.pem
:: Combine this with the crt server certificate and private key into a PFX
openssl pkcs12 -export -in mydomain.crt -inkey mydomain.key -certfile mydomain.pem -out mydomain.pfx
@odytrice
odytrice / Sql Server Kill Processes.sql
Last active October 18, 2018 05:19
Troubleshooting SQL Server
# DANGER - Kills all processes for a specific database
-- DECLARE @SQL varchar(max);
-- SELECT @SQL = COALESCE(@SQL,'') + 'Kill ' + Convert(varchar, r.session_id) + ';' from sys.dm_exec_requests r left join sys.dm_os_waiting_tasks t
-- on r.session_id = t.session_id where r.session_id >= 50 and r.session_id <> @@spid
-- EXEC(@SQL)
@odytrice
odytrice / AssignExtension.cs
Last active July 27, 2018 10:10
Extension Method to Assign Object properties in an Optimistic way
public static class Extensions
{
[DebuggerStepThrough]
/// <summary>
/// Update properties with properties of the object Supplied (typically anonymous)
/// </summary>
/// <typeparam name="T">Type of Source Object</typeparam>
/// <param name="destination">Object whose property you want to update</param>
/// <param name="source">destination object (typically anonymous) you want to take values from</param>
/// <returns>Update reference to same Object</returns>
@odytrice
odytrice / MD5.ts
Created February 8, 2016 14:51
MD5 algorithm implemented in TypeScript
/**
* Credit http://www.myersdaily.org/joseph/javascript/md5-text.html
*/
module MD5 {
function md5cycle(x, k) {
var a = x[0],
b = x[1],
c = x[2],
d = x[3];
@odytrice
odytrice / migrate.bat
Last active March 28, 2018 10:58
Migration File for Fluent Migrator for F# projects
REM Migrate Database
packages\FluentMigrator\tools\Migrate.exe --db=sqlserver --target=Dumia.Migrations\bin\Debug\Dumia.Migrations.dll --configPath=Dumia.Http\web.config --c=Dumia %*
REM Update Database DBML file
.\utils\SqlMetal.exe /server:"(local)" /database:dumia /user:admin1 /password:admin1 /dbml:"Dumia.Infrastructure/Database.dbml"
@odytrice
odytrice / Paging.cs
Last active December 11, 2017 13:10
ASP.NET MVC Paging Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace System.Web.Mvc
{