Skip to content

Instantly share code, notes, and snippets.

View russcam's full-sized avatar
🤓
Always learning!

Russ Cam russcam

🤓
Always learning!
View GitHub Profile
@russcam
russcam / pkcs12_change_pass.sh
Last active September 26, 2018 11:10
Change the passphrase and private key password for a PKCS#12 archive
#!/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
// 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 July 25, 2018 03:46
Creates a Service Principal within the Tenant of the selected Subscription
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 July 17, 2018 02:30
Azure Portal Custom Probe matching conditions

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 October 24, 2019 08:03
PowerShell module to provide a curl like experience interacting with Elasticsearch from PowerShell
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/
@russcam
russcam / keybase.md
Created February 5, 2018 07:34
keybase.md

Keybase proof

I hereby claim:

  • I am russcam on github.
  • I am russcam (https://keybase.io/russcam) on keybase.
  • I have a public key ASA-7ffVHxpC0Qs_F5orNv3SREep4hhx8m5fAuWhsItNaAo

To claim this, I am signing this object:

private static void Main()
{
var defaultIndex = "icecreams";
var settings = new ConnectionSettings(new Uri("http://localhost:9200"))
.DefaultIndex(defaultIndex)
.DisableDirectStreaming()
.PrettyJson()
.OnRequestCompleted(callDetails =>
{
@russcam
russcam / completion-suggester.cs
Last active November 1, 2021 00:52
Using Completion Suggester with NEST
void Main()
{
var indexName = "stackoverflow";
var node = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var settings = new ConnectionSettings(node)
.InferMappingFor<Question>(m => m
.IndexName(indexName)
)
.PrettyJson()
.DisableDirectStreaming()
@russcam
russcam / ElasticStack.ps1
Last active July 19, 2018 17:36
Download, unzip and run Elasticsearch, Logstash, Kibana 5.x-6.x on Windows
New-Module -Name ElasticStack -Scriptblock {
function WriteLog {
[CmdletBinding()]
Param
(
[Parameter(Position=0, Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
[ValidateNotNullOrEmpty()]
[Alias("M")]
[string]$Message
void Main()
{
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var defaultIndex = "default-index";
var connectionSettings = new ConnectionSettings(pool)
.DefaultIndex(defaultIndex)
.PrettyJson()
.DisableDirectStreaming()
.OnRequestCompleted(response =>
{