Created
March 24, 2021 07:46
-
-
Save re4388/e3841872f1eaa6dd60d7e03b1307a281 to your computer and use it in GitHub Desktop.
Powershell Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace System.Management.Automation.Host | |
Add-Type -AssemblyName System.Device #Required to access System.Device.Location namespace | |
function get-weather{ | |
$GeoWatcher = New-Object System.Device.Location.GeoCoordinateWatcher #Create the required object | |
$GeoWatcher.Start() #Begin resolving current locaton | |
while (($GeoWatcher.Status -ne 'Ready') -and ($GeoWatcher.Permission -ne 'Denied')) { | |
Start-Sleep -Milliseconds 100 #Wait for discovery. | |
} | |
if ($GeoWatcher.Permission -eq 'Denied'){ | |
Write-Error 'Access Denied for Location Information' | |
} | |
$Latitude = ($GeoWatcher.Position.Location).Latitude | |
$Longitude = ($GeoWatcher.Position.Location).Longitude | |
(curl http://wttr.in/"$Latitude,$Longitude"?lang=zh-tw -UserAgent "curl" ).Content | |
} | |
function get-info { | |
Start-Process "chrome.exe" "https://www.google.com/maps/dir/709%E5%8F%B0%E5%8D%97%E5%B8%82%E5%AE%89%E5%8D%97%E5%8D%80%E5%AE%89%E4%B8%AD%E8%B7%AF%E4%B8%80%E6%AE%B5705%E5%B7%B7/%E5%8F%B0%E5%8D%97%E5%B8%82%E6%AD%B8%E4%BB%81%E5%8D%80%E6%AD%B8%E4%BB%81%E5%A4%A7%E9%81%93%E5%8F%B0%E5%8D%97%E9%AB%98%E9%90%B5%E7%AB%99/@23.0072324,120.1671219,12z/data=!3m1!4b1!4m14!4m13!1m5!1m1!1s0x346e77a3458f3301:0xa2bf1af311313f6e!2m2!1d120.1948315!2d23.0427458!1m5!1m1!1s0x346e73a601a91ea5:0x23e545d7cc3c9e7!2m2!1d120.285662!2d22.92464!3e0" | |
} | |
Set-Alias ll Get-ChildItem | |
# open profile with vscode | |
function Edit-ProfileFile{ | |
code $profile | |
} | |
Set-Alias open-profile Edit-ProfileFile | |
# 1. get clond 3 Bioclincal repos and also auto npm install | |
# 2. also can git clone other repo and you have to provide the repo name | |
function get-Bioclincal-repos { | |
[CmdletBinding()] | |
$web = [ChoiceDescription]::new('&web-app','web-app') | |
$img = [ChoiceDescription]::new('&img-lib','imging-library') | |
$view = [ChoiceDescription]::new('&view','view-service') | |
$abort = [ChoiceDescription]::new('&abort','Abort') | |
$other = [ChoiceDescription]::new('&other','other') | |
$options = [ChoiceDescription[]]($web, $img, $view, $abort, $other ) | |
$result = $host.ui.PromptForChoice($Title, $Question, $options, 0) | |
switch ($result) { | |
0 { get-web2 } | |
1 { get-img2 } | |
2 { get-view2 } | |
3 { "Do nothing, Abort mission.." } | |
4 { get-repo3 } | |
} | |
} | |
function get-repo3 { | |
$url = Read-Host -Prompt 'What is the repo gist?' | |
$time = (Get-Date).ToString("yyyy_MMdd_HHmm") | |
$repoName = $url.Split('/')[-1] | |
git clone $url D:\workspace\$time-$repoName | |
cd D:\workspace\$time-$repoName | |
code . | |
} | |
function get-view2 { | |
$time = (Get-Date).ToString("yyyy_MMdd_HHmm") | |
git clone https://stash.imgdev.bioclinica.com/scm/vf/view-service.git D:\workspace\$time-view-service | |
cd D:\workspace\$time-view-service | |
npm i | |
} | |
function get-img2 { | |
$time = (Get-Date).ToString("yyyy_MMdd_HHmm") | |
git clone https://stash.imgdev.bioclinica.com/scm/vf/imaging-library.git D:\workspace\$time-img-lib | |
cd D:\workspace\$time-img-lib | |
npm i | |
} | |
function get-web2 { | |
$time = (Get-Date).ToString("yyyy_MMdd_HHmm") | |
git clone https://stash.imgdev.bioclinica.com/scm/vf/view-webapp.git D:\workspace\$time-web-app | |
cd D:\workspace\$time-web-app | |
npm i | |
} | |
# show all self-hand command | |
function show { | |
Write-Output "" | |
Write-Output "Open Profile with Vscode" | |
Write-Output "> open-profile" | |
Write-Output "" | |
Write-Output "" | |
Write-Output "Git clone Utility" | |
Write-Output " hotstring: fff" | |
Write-Output "" | |
Write-Output "" | |
Write-Output "Check global npm packages" | |
Write-Output "> npm list -g --depth 0" | |
Write-Output "" | |
Write-Output "" | |
Write-Output "Reload config" | |
Write-Output "> . $profile" | |
Write-Output "" | |
Write-Output "" | |
Write-Output "Weahther of current location" | |
Write-Output "> get-weather" | |
Write-Output "" | |
Write-Output "" | |
Write-Output "Open Chrome to get "hard-coded" web-information fast" | |
Write-Output "> get-info (hotstring: ggg)" | |
Write-Output "" | |
Write-Output "" | |
Write-Output "" | |
} | |
# some old code...I don't want to delete | |
# because I think I may need to refernece these in the future | |
# I will delete them if I think they are no value to reference | |
############################################################################# | |
# Why this not work? | |
# function get-update{ | |
# & $profile | |
# } | |
# open 3 biolinical repo and npm install | |
# function get-web { | |
# param($f) | |
# git clone https://stash.imgdev.bioclinica.com/scm/vf/view-webapp.git D:\workspace\$f-web-app | |
# cd D:\workspace\$f-web-app | |
# npm i | |
# } | |
# function get-img { | |
# param($f) | |
# git clone https://stash.imgdev.bioclinica.com/scm/vf/imaging-library.git D:\workspace\$f-img-lib | |
# cd D:\workspace\$f-img-lib | |
# npm i | |
# } | |
# function get-view { | |
# param($f) | |
# git clone https://stash.imgdev.bioclinica.com/scm/vf/view-service.git D:\workspace\$f-view-service | |
# cd D:\workspace\$f-view-service | |
# npm i | |
# } | |
# interactive promp v1 | |
# function get-interactive { | |
# $repo = Read-Host -Prompt 'What repo? web | img-lib | view-service' | |
# if ($favColor -eq 'Red') { | |
# 'My favorite, too!' | |
# } else { | |
# "Eww..$favColor is not a nice color!" | |
# } | |
# git clone https://stash.imgdev.bioclinica.com/scm/vf/view-webapp.git D:\workspace\$f-web-app | |
# cd D:\workspace\$f-web-app | |
# npm i | |
# } | |
# git clone repo | |
# how to use? | |
# git-clone1 -u http://xxxx.git -f 20210207 -n test1 | |
# function git-clone1 { | |
# param($f, $u, $n) | |
# git clone $u D:\workspace\$f-$n | |
# cd D:\workspace\$f-$n | |
# } | |
# git-clone2 -u http://xxxx.git | |
# function git-clone2{ | |
# param($u) | |
# $time = (Get-Date).ToString("yyyy-MM-dd-HH-mm") | |
# $repoName = $u.Split('/')[-1] | |
# git clone $u D:\workspace\$time-$repoName | |
# cd D:\workspace\$time-$repoName | |
# code . | |
# } | |
# function get-gps{ | |
# $GeoWatcher = New-Object System.Device.Location.GeoCoordinateWatcher #Create the required object | |
# $GeoWatcher.Start() #Begin resolving current locaton | |
# while (($GeoWatcher.Status -ne 'Ready') -and ($GeoWatcher.Permission -ne 'Denied')) { | |
# Start-Sleep -Milliseconds 100 #Wait for discovery. | |
# } | |
# if ($GeoWatcher.Permission -eq 'Denied'){ | |
# Write-Error 'Access Denied for Location Information' | |
# } else { | |
# $GeoWatcher.Position.Location | Select Latitude,Longitude #Select the relevent results. | |
# } | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment