Skip to content

Instantly share code, notes, and snippets.

View eshess's full-sized avatar

Eli Hess eshess

  • Netgain Technology
  • Saint Cloud, MN
View GitHub Profile
@eshess
eshess / gist:6623971c65855e58b279c447247d34d4
Last active December 2, 2019 04:26
adventofcode.com/2019/day/1/answer
function Get-Fuel
{
[CmdletBinding()]
param(
[int]$Mass
)
$fuel = ([math]::Floor($Mass / 3) -2)
if ($fuel -le 0)
{
return 0
@eshess
eshess / LeftOuterJoin.ps1
Created June 5, 2018 15:04
Performing a left outer join using PowerShell LINQ
#Initialize mock data to join
$Left = @()
$Right = @()
$ProductionStatusArray = @('In Production','Retired')
$PowerStatusArray = @('Online','Offline')
1..15 | Foreach-Object {
$Prop = @{
Name = "Server$_"
PowerStatus = $PowerStatusArray[(Get-Random -Minimum 0 -Maximum 2)]
}
@eshess
eshess / NestedJoin.ps1
Created May 28, 2018 23:15
Multiple joins in a PowerShell LINQ query
$Keydelegate = [System.Func[Object,string]] {param ($x);$x.Name}
$FirstJoin = [System.Linq.Enumerable]::Join(
$DatasetA, $DatasetB,
$Keydelegate,$Keydelegate,
[System.Func[Object,Object,Object]]{
param ($x,$y);
New-Object -TypeName PSObject -Property @{
Name = $x.Name;
PowerStatus = $x.PowerStatus;