Skip to content

Instantly share code, notes, and snippets.

View adamdriscoll's full-sized avatar
:bowtie:

Adam Driscoll adamdriscoll

:bowtie:
View GitHub Profile
@adamdriscoll
adamdriscoll / RenderMap.ps1
Created September 21, 2019 08:24
Renders a map based on GPX files
New-UDMap -Endpoint {
New-UDMapLayerControl -Id 'layercontrol' -Content {
New-UDMapBaseLayer -Name "Mapnik" -Content {
New-UDMapRasterLayer -TileServer 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
} -Checked
New-UDMapOverlay -Name "Day 1" -Content {
New-UDMapVectorLayer -Polyline -Positions $Cache:Day1 -Color Red
}
@adamdriscoll
adamdriscoll / ConvertToUDMap.ps1
Created September 21, 2019 08:21
Converts a GPX file to the UDMap format
[Xml]$Gpx = Get-Content (Join-Path $PSScriptRoot 'day3.gpx')
$Cache:Day3 = $Gpx.gpx.trk.trkseg.trkpt | ForEach-Object {
,@($_.lat , $_.lon)
}
@adamdriscoll
adamdriscoll / strava.gpx
Created September 21, 2019 08:17
Example strava GPX file
<?xml version="1.0" encoding="UTF-8"?>
<gpx creator="StravaGPX" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd" version="1.1" xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
<metadata>
<time>2019-09-17T05:00:51Z</time>
</metadata>
<trk>
<name>Morning Run</name>
<type>9</type>
<trkseg>
<trkpt lat="12.9662620" lon="77.6015510">
@adamdriscoll
adamdriscoll / dashboard.ps1
Created September 16, 2019 11:29
UDInput that takes some input and redirects the user to another page based on that input
$Pages = @()
$Pages += New-UDPage -Name 'Test' -Endpoint {
New-UDInput -Title "What should we do today?" -Endpoint {
param($WhatShouldWeDo)
# This could load any page (doesn't have to be UD)
Invoke-UDRedirect -Url "/todo/$WhatShouldWeDo"
}
}
@adamdriscoll
adamdriscoll / map.ps1
Created September 16, 2019 10:07
Dynamically add markers to a map using geocoding
$Dashboard = New-UDDashboard -Title "PowerShell Conference Asia 2019" -Content {
New-UDMap -Id 'map' -Endpoint {
New-UDMapLayerControl -Id 'layercontrol' -Content {
New-UDMapBaseLayer -Name "Bing" -Content {
New-UDMapRasterLayer -Bing -ApiKey '11111111' -Type Road
} -Checked
New-UDMapOverlay -Name "Cluster" -Content {
New-UDMapMarkerClusterLayer -Id 'cluster-layer' -Markers @(
@adamdriscoll
adamdriscoll / geocoding.ps1
Created September 16, 2019 10:03
Geocoding API call for UDMap
$item = Invoke-RestMethod "https://geocoder.cit.api.here.com/6.2/geocode.json?searchtext=Hailey, Idaho&app_id=1111111&app_code=222222222&gen=8"
$position = $item.response.view.result.location.displayposition
@adamdriscoll
adamdriscoll / deploy.ps1
Created September 15, 2019 21:12
Deployment script for UDChatroom.
param($Staging)
Copy-Item ./ud-chatroom.psd1 $Staging
Copy-Item ./ud-chatroom.psm1 $Staging
Copy-Item ./dashboard.ps1 $Staging
Save-Module -Name UniversalDashboard -Path $Staging -AcceptLicense -RequiredVersion 2.6
Copy-Item -Path "$Staging/UniversalDashboard/2.6.0/*" -Destination $Staging -Container -Recurse
Remove-Item -Path "$Staging/UniversalDashboard" -Force -Recurse
Save-Module -Name UniversalDashboard.CodeEditor -Path $Staging -RequiredVersion 1.0
@adamdriscoll
adamdriscoll / azure-pipelines.yml
Created September 15, 2019 20:54
UDChatroom Azure Pipelines Deployment Script
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- script: pwsh -File './deploy.ps1' -Staging $(Build.ArtifactStagingDirectory)
displayName: 'Copy and Download UDs'
@adamdriscoll
adamdriscoll / EndpointInit.ps1
Created September 15, 2019 20:53
UDChatroom Endpoint Initialization
$EndpointInit = New-UDEndpointInitialization
$Path = Split-Path (Get-Module UniversalDashboard).Path -Parent
$EndpointInit.ImportPSModulesFromPath($Path)
@adamdriscoll
adamdriscoll / dashboard.ps1
Created September 15, 2019 20:52
Dashboard script for UDChatroom.
Import-Module "$PSScriptRoot/UniversalDashboard.psd1"
Import-Module "$PSScriptRoot/UniversalDashboard.CodeEditor/1.0.0/UniversalDashboard.CodeEditor.psd1"
Import-Module "$PSScriptRoot/ud-chatroom.psd1"
Start-UDChatroom -Wait