Skip to content

Instantly share code, notes, and snippets.

💭
😃 Set status

Russ Cam russcam

💭
😃 Set status
Block or report user

Report or block russcam

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@russcam
russcam / Ingesting_Attachments.cs
Last active Aug 5, 2019
Ingesting attachments with Elasticsearch and NEST
View Ingesting_Attachments.cs
using System;
using Elasticsearch.Net;
using Nest;
namespace Example
{
private static void Main()
{
var defaultIndex = "attachments";
@russcam
russcam / PowerShell Customization.md
Created Mar 12, 2019 — forked from jchandra74/PowerShell Customization.md
PowerShell, Cmder / ConEmu, Posh-Git, Oh-My-Posh, Powerline Customization
View PowerShell Customization.md

Pimping Up Your PowerShell & Cmder with Posh-Git, Oh-My-Posh, & Powerline Fonts

Backstory (TLDR)

I work as a full-stack developer at work. We are a Windows & Azure shop, so we are using Windows as our development platform, hence this customization.

For my console needs, I am using Cmder which is based on ConEmu with PowerShell as my shell of choice.

Yes, yes, I know nowadays you can use the Linux subsystem on Windows 10 which allow you to run Ubuntu on Windows. If you are looking for customization of the Ubuntu bash shell, check out this article by Scott Hanselman.

@russcam
russcam / GuestUsers.ps1
Created Feb 26, 2019
PowerShell script module for creating and adding guest users to Azure AD
View GuestUsers.ps1
New-Module -Name GuestUsers -Scriptblock {
$modules = Get-Module -ListAvailable AzureAD*
if ($null -eq $modules) {
Write-Output "Install AzureADPreview module"
Install-Module AzureADPreview
}
elseif (($modules | ?{ $_.Name -eq "AzureAD" }).Count -eq 1) {
Write-Output "Uninstall AzureAD module and install AzureADPreview module"
@russcam
russcam / LinkChecker.linq
Created Jan 30, 2019
Checks for broken links in HTML pages
View LinkChecker.linq
<Query Kind="Program">
<Reference>&lt;RuntimeDirectory&gt;\System.Net.Http.dll</Reference>
<NuGetReference>HtmlAgilityPack</NuGetReference>
<Namespace>HtmlAgilityPack</Namespace>
<Namespace>System.Net.Http</Namespace>
<Namespace>System.Threading.Tasks</Namespace>
<Namespace>System.Collections.Concurrent</Namespace>
</Query>
void Main()
@russcam
russcam / Procmon.ps1
Created Nov 3, 2018
PowerShell Script module for interacting with Process Monitor (Procmon)
View Procmon.ps1
<#
.Synopsis
Functions for working with Process monitor
.Link
https://docs.microsoft.com/en-us/sysinternals/downloads/procmon
#>
#Requires -Version 3.0
New-Module -Name Procmon -Scriptblock {
@russcam
russcam / pkcs12_change_pass.sh
Last active Sep 26, 2018
Change the passphrase and private key password for a PKCS#12 archive
View pkcs12_change_pass.sh
#!/bin/bash
current_archive=$1
current_password=$2
new_password=$3
new_archive=$4
if [[ -z "$new_archive" ]]; then
new_archive="${current_archive%.*}_new.p12"
fi
View Example.cs
// Using NEST 6.2.0 with NEST.JsonNetSerializer 6.2.0
private static void Main()
{
var defaultIndex = "documents";
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var connectionSettings = new ConnectionSettings(pool, new InMemoryConnection(), (builtin, settings) =>
new JsonNetSerializer(builtin, settings, contractJsonConverters: new JsonConverter[] { new StringEnumConverter() }))
.DefaultIndex(defaultIndex)
@russcam
russcam / AzureServicePrincipal.ps1
Created Jul 25, 2018
Creates a Service Principal within the Tenant of the selected Subscription
View AzureServicePrincipal.ps1
param
(
[Parameter(Mandatory=$true, HelpMessage="Provide a unique name for Service Principal")]
[ValidateScript({if ($_ -match '^[a-zA-Z0-9\-_]{8,}$') {
$true
} else {
throw "name must be a minimum 8 alphanumeric characters with no spaces. Hyphens and underscores also allowed"
}})]
[string] $name,
@russcam
russcam / Custom-probe-matching-conditions.md
Last active Jul 17, 2018
Azure Portal Custom Probe matching conditions
View Custom-probe-matching-conditions.md

When a custom probe is specified in an Azure Resource Manager template that includes custom matching status codes to consider the backend pool as healthy, the Custom probe matching checkbox in the portal remains unchecked; when checked, the status codes defined in the ARM template do not appear in the portal UI, although it does appear that Application Gateway is using the provided status codes.

Here's an example of the match condition for a probe in a template:

"match": {
    "statusCodes": ["200-399", "401"]
}
@russcam
russcam / ElasticShell.ps1
Last active Aug 2, 2019
PowerShell module to provide a curl like experience interacting with Elasticsearch from PowerShell
View ElasticShell.ps1
New-Module -Name ElasticShell -Scriptblock {
<#
.Synopsis
Execute REST API requests against Elasticsearch
.Description
Execute REST API requests against Elasticsearch.
Provides a curl-like experience for interacting with Elasticsearch, but with \m/ PowerShell \m/
You can’t perform that action at this time.