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 / PowerShell Customization.md
Created March 12, 2019 23:58 — forked from jchandra74/PowerShell Customization.md
PowerShell, Cmder / ConEmu, Posh-Git, Oh-My-Posh, Powerline Customization

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 / 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 / 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 / LinkChecker.linq
Created January 30, 2019 00:14
Checks for broken links in HTML pages
<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 / TcpStats.cs
Created August 24, 2020 01:43
Get active TCP connection states and statistics
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.NetworkInformation
public static class TcpStats
{
private static int _stateLength = Enum.GetNames(typeof(TcpState)).Length;
private static int _longestState = Enum.GetNames(typeof(TcpState)).Max(s => s.Length);
@russcam
russcam / ThreadpoolStats.cs
Created August 24, 2020 01:59
Get Threadpool, worker and IOCP thread statistics
using System;
using System.Text;
using System.Threading;
public static class ThreadpoolStats
{
public static string GetThreadPoolStats()
{
ThreadPool.GetMaxThreads(out int maxWorkerThreads, out int maxIoThreads);
ThreadPool.GetAvailableThreads(out int freeWorkerThreads, out int freeIoThreads);
@russcam
russcam / elastic-gnaf.fsx
Last active October 1, 2020 07:22
Building a realtime Australian address search with the G-NAF dataset
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
@russcam
russcam / NEST_7x_NetTopologySuite_Geometries.linq
Created January 12, 2021 00:39
Using NetTopologySuite Geometries with NEST 7.x
<Query Kind="Program">
<NuGetReference>Elasticsearch.Net</NuGetReference>
<NuGetReference>NEST</NuGetReference>
<NuGetReference>NEST.JsonNetSerializer</NuGetReference>
<NuGetReference>NetTopologySuite.IO.GeoJSON</NuGetReference>
<Namespace>Elasticsearch.Net</Namespace>
<Namespace>Elasticsearch.Net.Specification.CatApi</Namespace>
<Namespace>Nest</Namespace>
<Namespace>Nest.JsonNetSerializer</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
@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()
private static void Main()
{
var defaultIndex = "icecreams";
var settings = new ConnectionSettings(new Uri("http://localhost:9200"))
.DefaultIndex(defaultIndex)
.DisableDirectStreaming()
.PrettyJson()
.OnRequestCompleted(callDetails =>
{