Skip to content

Instantly share code, notes, and snippets.

View martin9700's full-sized avatar
💭
Updated Set-CellColor -- CICD built too. Now need to make a module out of this.

MartinPugh martin9700

💭
Updated Set-CellColor -- CICD built too. Now need to make a module out of this.
View GitHub Profile
$Test = "this is a test, love it or <leave> it."
$Test
$Ping = Get-WMIObject Win32_PingStatus -Filter "Address = '$IP' AND ResolveAddressNames = TRUE"
If ($Ping.StatusCode -eq 0)
{ $ComputerName = $Ping.ProtocolAddressResolved
}
Else
{ $ComputerName = "Unable to resolve"
}
[CmdletBinding()]
Param (
[string]$Path,
[Alias("q")]
[int]$Quakes = 5,
[Alias("h")]
[int]$Height = 500,
[Alias("w")]
[int]$Width = 800
)
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Earthquakes Map</title>
<style>
html, body, #map-canvas {
height: $($Height)px;
width: $($Width)px;
$QuakesData = Invoke-RestMethod -uri "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_month.geojson"
$Count = 1
[array]$Locations = ForEach ($Quake in $QuakesData.Features)
{ [PSCustomObject]@{
Title = $Quake.properties.place
Magnitude = $Quake.properties.mag
TimeDate = [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddMilliseconds($Quake.properties.time))
Lon = $Quake.geometry.coordinates[0]
Lat = $Quake.geometry.coordinates[1]
$QuakesData = Invoke-RestMethod -uri "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_month.geojson"
[array]$Locations = ForEach ($Quake in ($QuakesData.Features | Select -First $Quakes))
{ [PSCustomObject]@{
Title = $Quake.properties.place
Magnitude = $Quake.properties.mag
TimeDate = [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddMilliseconds($Quake.properties.time))
Lon = $Quake.geometry.coordinates[0]
Lat = $Quake.geometry.coordinates[1]
}
$Locations = @(Invoke-RestMethod -Uri "http://www.seismi.org/api/eqs" -ErrorAction Stop | Select -ExpandProperty Earthquakes | Select -First $Quakes)
$Markers = "var markers = [`n"
ForEach ($Num in (0..($Locations.Count - 1)))
{ $Region = $Locations[$Num].Region.Replace("`'","\'")
$Markers += " ['$Region',$($Locations[$Num].Lat),$($Locations[$Num].Lon),'$($Locations[$Num].timedate)','$($Locations[$Num].magnitude)']"
If ($Num -lt ($Locations.Count - 1))
{ $Markers += ",`n"
}
}
$Data = @"
Place,Address,Item,Qty,Tot
Gillette Stadium,1 Patriot Pl Foxborough MA 02035,Green Frogs,550,1100
Fenway Park,4 Yawkey Way Boston MA 02215,Yellow Toads,100,5000
Boston Garden,100 Legends Way Boston MA 02114,Blue Dragons,5,10000
"@
$Locations = ForEach ($Addr in ($Data | ConvertFrom-Csv ))
$Locations = ForEach ($Addr in ($Data | ConvertFrom-Csv ))
{ $Addr.Address = $Addr.Address -replace " ","+"
$Location = Invoke-RestMethod -uri "http://maps.googleapis.com/maps/api/geocode/json?address=$($Addr.Address)&sensor=false"
[PSCustomObject]@{
Place = $Addr.Place
Location = $Location.Results.Formatted_Address
Lat = $Location.Results.Geometry.Location.Lat
Lng = $Location.Results.Geometry.Location.Lng
Item = $Addr.Item
<table>
<td id="map-canvas"></td>
<td><b><ol>$TableInfo</ol></b></td>
</table>
</body>