Skip to content

Instantly share code, notes, and snippets.

View Warrenn's full-sized avatar

Warrenn Enslin Warrenn

  • Busyweb
  • South Africa
View GitHub Profile
@Warrenn
Warrenn / bloc-module.ts
Last active July 25, 2019 07:35
ts traversal
interface Declaration {
transforms: { [key: string]: (ctx: any) => void }
asyncs: { [key: string]: (ctx: any) => Promise<void> }
middlewares: { (ctx: any): void }[]
context: { [key: string]: (config: any) => ((state: any) => any) }
state: any
}
export default <Declaration>{
transforms: {
@Warrenn
Warrenn / seperate.cs
Created July 18, 2019 16:47
article - seperate
public class Client
{
public int Id { get; set; }
public string Name { get; set; }
public int Amount { get; set; }
}
public class Repository
@Warrenn
Warrenn / srp.cs
Last active July 18, 2019 16:48
articles
public class Client
{
public int Id { get; set; }
public string Name { get; set; }
public int Amount { get; set; }
public DataContext Context { get; set; }
@Warrenn
Warrenn / awaitable.js
Created June 27, 2019 11:54
make a node function call with a callback awaitable
function awaitable(fn) {
return new Promise((resolve, reject) => {
let callback = (err, data) => {
if (err) {
reject(err);
return;
}
resolve(data);
};
var newArgs = Array.prototype.slice.call(arguments, 1);
@Warrenn
Warrenn / ServerCertificateValidationCallback.ps1
Created November 8, 2018 14:37
ServerCertificateValidationCallback
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
{
$certCallback = @"
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class ServerCertificateValidationCallback
{
public static void Ignore()
@Warrenn
Warrenn / install-servicefabric.ps1
Last active October 31, 2018 23:16
service fabric
# # Install visual c++ 2012 SP1 redistributable package
Invoke-WebRequest "http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU1/vcredist_x64.exe" -OutFile "C:\vcredist.exe" -UseBasicParsing;
Start-Process "C:\vcredist.exe" -ArgumentList '/install', '/passive' -NoNewWindow -Wait;
rm "C:\vcredist.exe"
# Install Service Fabric Runtime
Invoke-WebRequest "http://download.microsoft.com/download/3/2/1/3217654F-6882-4CEA-BD51-49287EDECE9B/MicrosoftServiceFabric.6.0.232.9494.exe" -OutFile "C:\ServiceFabricRuntime.exe" -UseBasicParsing;
Start-Process "C:\ServiceFabricRuntime.exe" -ArgumentList '/AcceptEULA', '/QUIET' -NoNewWindow -Wait;
rm "C:\ServiceFabricRuntime.exe"
@Warrenn
Warrenn / routeguard.ts
Created June 11, 2018 09:07
ng6 rout guard
import {Injectable} from '@angular/core';
import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import {AuthService} from '../services/auth.service';
@Injectable()
export class RouteGuard implements CanActivate {
constructor(
private router: Router,
private auth: AuthService
@Warrenn
Warrenn / EncryptionHelper.cs
Created January 5, 2018 14:15
Encryption using CBC
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Web;
namespace RealID.API.Helpers
{
/// <summary>
@Warrenn
Warrenn / PropertyFunctionProvider
Last active June 19, 2017 14:53
allows class to be populated based on convention
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text.RegularExpressions;
public class PropertyFunctionProvider
function Invoke-SqlCommand() {
[cmdletbinding(DefaultParameterSetName="integrated")]Param (
[Parameter(Mandatory=$true)][Alias("Serverinstance")][string]$Server,
[Parameter(Mandatory=$true)][string]$Database,
[Parameter(Mandatory=$true, ParameterSetName="not_integrated")][string]$Username,
[Parameter(Mandatory=$true, ParameterSetName="not_integrated")][string]$Password,
[Parameter(Mandatory=$false, ParameterSetName="integrated")][switch]$UseWindowsAuthentication = $true,
[Parameter(Mandatory=$true)][string]$Query,
[Parameter(Mandatory=$false)][int]$CommandTimeout=0
)