Skip to content

Instantly share code, notes, and snippets.

View dfinke's full-sized avatar

Doug Finke dfinke

View GitHub Profile
$template = @'
{[DateTime]Date*:Tue Nov 11, 2014} {Home:Penguins}{Away:Rangers} {[DateTime]Time:7:00 PM} FINAL PIT (0) - NYR (5) Recap
{Date*:Sat Mar 14, 2015} {Home:Bruins}{Away:Penguins} 1:00 PM ROOT, NHLN-US, TVA Tickets BUY/SELL
Thu Mar 26, 2015 PenguinsHurricanes 7:00 PM ROOT
Sat Nov 22, 2014 PenguinsIslanders 7:00 PM ROOT, CITY
Sat Nov 1, 2014 SabresPenguins 7:00 PM FINAL BUF (0) - PIT (5) Recap
Fri Jan 16, 2015 PenguinsIslanders 7:00 PM ROOT, TVA2
'@
(Invoke-WebRequest http://penguins.nhl.com/club/schedule.htm).AllElements |
@dfinke
dfinke / GeometryNumber,.ps1
Last active August 29, 2015 14:11
Fluent API Using PowerShell v5 Classes
class GeometryNumber {
[double]$Number
GeometryNumber() {}
GeometryNumber($Number) { $this.Number=$Number }
[GeometryNumber] Sqrt() { return [GeometryNumber]::new([Math]::Sqrt($this.Number)) }
[GeometryNumber] Reciprocal() { return [GeometryNumber]::new(1/$this.Number) }
[GeometryNumber] TangetAngle() { return [GeometryNumber]::new([System.Math]::Atan($this.Number)) }
[GeometryNumber] AsDegrees() { return [GeometryNumber]::new($this.Number*180/[Math]::PI) }
@dfinke
dfinke / MagicSquares.ps1
Last active August 29, 2015 14:13
Lusus Numerorum - . Strange coincidences of a lusus numerorum. "Magic squares and cubes" - Paul Carus
1..10 | ForEach {
$r = 0..($_-1) -join ''
$exp = "$($r)*9+$_"
"{0,15}={1}" -f $exp, ($exp|Invoke-Expression)
}
''
@dfinke
dfinke / maze.ps1
Last active August 29, 2015 14:14
Using PowerShell Classes - works simply by visiting each cell in the grid, and choosing to carve a passage either north, or east
param($Rows=8, $Columns=8)
Add-Type -AssemblyName System.Drawing
class Cell {
[int]$Row
[int]$Col
$links = @{}
$startDate = (Get-Date).ToString('Mddyy') # 51515
$ca=$startDate.ToCharArray()
[array]::Reverse($ca)
$ofs=''
$startDate -eq "$ca" # prints True
@dfinke
dfinke / cal.ps1
Created May 19, 2015 00:15
PowerShell WolframAlpha Calendar Cmdlet
function cal {
param(
[string[]]$TargetMonth=(Get-Date).ToString('MMM'),
$Year=(Get-Date).year
)
foreach ($month in $TargetMonth) {
$q = "$month $year calendar"
Configuration DotNetFrameWork{
param($TargetMachine)
Node $TargetMachine {
WindowsFeature NET-Framework-Features {
Ensure = 'Present'
Name = "NET-Framework-Features"
}
Function MoonRiseLCT(DY As Double, MN As Double, YR As Double, DS As Double, ZC As Double, GLong As Double, GLat As Double) As Double
Dim K As Integer
GDY = LctGDay(12, 0, 0, DS, ZC, DY, MN, YR)
GMN = LctGMonth(12, 0, 0, DS, ZC, DY, MN, YR)
GYR = LctGYear(12, 0, 0, DS, ZC, DY, MN, YR)
LCT = 12#: DY1 = DY: MN1 = MN: YR1 = YR
GoSub 6700: LA = LU
For K = 1 To 8
##
## Thanks to Jum Truher on the PowerShell team https://jtruher3.wordpress.com/
##
$scriptRoot = Split-Path $MyInvocation.MyCommand.Path
. "$scriptRoot\RubyArraylistConstructs.ps1"
Describe "Ruby array constructs are available on an ArrayList" {
BeforeEach {
##
## Thanks to Jum Truher on the PowerShell team https://jtruher3.wordpress.com/
##
Update-TypeData -Force -TypeName System.Collections.ArrayList -MemberType ScriptMethod -MemberName Push -Value {
foreach($v in $args) {
[void]$this.Add($v)
}
}