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 / 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
)
function Get-Downloader {
param (
[string]$url
)
$downloader = new-object System.Net.WebClient
$defaultCreds = [System.Net.CredentialCache]::DefaultCredentials
if ($defaultCreds -ne $null) {
$downloader.Credentials = $defaultCreds
@Warrenn
Warrenn / ServiceDispatcher.cs
Created March 13, 2017 07:05
ServiceDispatcher
using AbCap.Digital.ApiGateway.ContainerBase.Compression;
using AbCap.Digital.ApiGateway.ContainerBase.Configuration;
using AbCap.Digital.ApiGateway.ContainerBase.Encryption;
using AbCap.Digital.ApiGateway.ContainerBase.Extentions;
using AbCap.Digital.ApiGateway.ContainerBase.Model;
using AbCap.Digital.ApiGateway.ContainerBase.Model.Message.Request;
using AbCap.Digital.ApiGateway.ContainerBase.Model.Message.Response;
using AbCap.Digital.ApiGateway.ContainerBase.Request;
using AbCap.Digital.ApiGateway.ContainerBase.Request.Enumerations;
using AbCap.Digital.ApiGateway.ContainerBase.Serializers;
function registerCertificate(
[System.Security.Cryptography.X509Certificates.StoreName]$storeName,
[string]$certPath,
[string]$pfxPass
)
{
$pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2
$keyStorageFlags = [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable -bxor [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::MachineKeySet -bxor [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::PersistKeySet;
$pfx.import($certPath,$pfxPass,$keyStorageFlags)
$store = new-object System.Security.Cryptography.X509Certificates.X509Store(
$downloadfolder = "C:\npmupload\"
$scopes = gc ".\.npmrc" | %{ $_.Split(':')[0]}
$packageJson = gc ".\package.json" -Raw | ConvertFrom-Json -Verbose
$packages = $packageJson.dependencies | Get-Member | ?{$scopes -contains $_.Name.Split('/')[0]} | %{$_.Name}
$urls = $packages | %{ &npm view $_ dist.tarball}
$account = [System.Net.CredentialCache]::DefaultCredentials
$client = New-Object System.Net.WebClient
$client.Credentials = $account
param (
[Parameter(Mandatory=$true)] [System.Uri]
$Uri,
[Parameter()] [Switch]
$UseSystemProxy,
[Parameter()] [Switch]
$UseDefaultCredentials
)
$request = [System.Net.WebRequest]::Create($Uri)
if ($UseSystemProxy) {