powershell 找出我今年创造了多少个要点
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 找出我今年创造了多少个要点相关的知识,希望对你有一定的参考价值。
# Usage examples
# .\gist-listing.ps1
# .\gist-listing.ps1 -Username willprice76
# .\gist-listing.ps1 -Verbose
param (
[parameter(Mandatory=$false)]
[string] $Username = "jhorsman"
)
$apiUrl = "https://api.github.com"
$gistListingUrl = "/users/{0}/gists?page={1}&per_page=1000" # {0} = username {1} = page
$year = (Get-Date).Year
$ErrorActionPreference = "Stop"
Write-Verbose "getting list of gists for $Username..."
$gistCount = 0
$createCount = 0
$createCountByYear = @{}
$updateCountByYear = @{}
$UpdateCount = 0
$page = 1
$stop = $false
while ($stop -eq $false)
{
$request = ($apiUrl + $gistListingUrl -f $Username, $page)
Write-Verbose ("querying GitHub; request: {0}" -f $request)
$feed= ConvertFrom-Json(Invoke-WebRequest $request -Verbose:$false)
$page++
$gistCount = $gistCount + $feed.Count
if($feed.Count -eq 0)
{
$stop = $true
}
foreach ($entry in $feed)
{
$creationDate = Get-Date($entry.created_at)
if(($creationDate.Year) -eq $year)
{
$createCount++
}
$updateDate = Get-Date($entry.updated_at)
if(($updateDate.Year) -eq $year)
{
$updateCount++
}
$createCountByYear[$creationDate.Year] = $createCountByYear[$creationDate.Year] + 1
$updateCountByYear[$updateDate.Year] = $updateCountByYear[$updateDate.Year] + 1
#Write-Output ("create: {0} update: {1}" -f $creationDate, $updateDate)
}
}
Write-Output ("found a total of {0} gists for {1}" -f $gistCount, $Username)
Write-Host ("this year ({0}): created {1} gists and updated {2} gists" -f $year, $createCount, $UpdateCount)
foreach($y in $createCountByYear.Keys)
{
Write-Host ("{0}: created {1} gists" -f $y, $createCountByYear[$y])
}
以上是关于powershell 找出我今年创造了多少个要点的主要内容,如果未能解决你的问题,请参考以下文章
固定大小的 HashMap 的最佳容量和负载因子是多少?
text 创造新的要点
markdown 创造一个测试要点
PowerShell-自定义函数-强制参数:Mandatory
PowerShell-自定义函数 Function的另一种写法
Oracle:如何找出函数表使用了多少空间(在 RAM 上)?