小编Ish*_*han的帖子

使用PowerShell获取进程位置路径

我试图使用PowerShell在您的计算机上获取当前正在运行的进程的位置.

C:\Program Files (x86)\Mozilla Firefox
C:\Windows\sysWOW64\WindowsPowerShell\v1.0
C:\Program Files (x86)\Internet Explorer
Run Code Online (Sandbox Code Playgroud)

当我运行命令

$path = Get-Process | Select-Object Path
Split-Path $path
Run Code Online (Sandbox Code Playgroud)

我得到以下输出,我不是我想要的.为什么要添加@ {Path =

@{Path=C:\Program Files (x86)\Mozilla Firefox
@{Path=C:\Windows\sysWOW64\WindowsPowerShell\v1.0
@{Path=C:\Program Files (x86)\Internet Explorer
Run Code Online (Sandbox Code Playgroud)

当我Split-Path按如下方式运行时,它会给我正确的输出C:\Windows\sysWOW64\WindowsPowerShell\v1.0.

$pshpath = "C:\Windows\sysWOW64\WindowsPowerShell\v1.0\powershell.exe"
Split-Path $pshpath
Run Code Online (Sandbox Code Playgroud)

powershell location path

6
推荐指数
2
解决办法
2万
查看次数

更改在Visual Studio Code中最近使用的列表中存储的项目数

如何更改File -> Open RecentVisual Studio Code中最近使用的列表中存储的项目数。默认情况下,它将存储您最近使用的10个文件夹和10个文件。

visual-studio-code

6
推荐指数
2
解决办法
237
查看次数

在树上的haskell折叠操作

data Tree a = Tree a [Tree a]
Run Code Online (Sandbox Code Playgroud)

请注意,我们不允许空树,并且叶子是具有空子列表的树.

treeFold :: (a -> [b] -> b) -> Tree a -> b
treeFold f (Tree x s) = f x (map (treeFold f) s)
Run Code Online (Sandbox Code Playgroud)

鉴于上述信息,我不明白树折叠函数如何通过递归地将折叠操作应用于子树,然后将函数应用于根处的标签以及从子树返回的结果来返回结果.

我也没有得到树Fold函数如何只接受一个参数而不是2,当它作为参数传递给map函数并且它仍然编译并正确运行时.

例如,下面的树大小函数计算树的节点.

treeSize :: Tree a -> Int
treeSize = treeFold (\x ys -> 1 + sum ys)
Run Code Online (Sandbox Code Playgroud)

因此运行treeSize树,其中tree = Tree 4 [Tree 1 [Tree 2 [], Tree 3 []]]的大小为4.

在上面的树大小函数中,树折函数也传递一个参数而不是两个.另外,传递给树折函数的x并没有在任何地方使用,所以为什么你需要它.删除它会导致程序无法编译,并提供以下错误消息.

 Couldn't match type `a' with `[[Int] …
Run Code Online (Sandbox Code Playgroud)

tree haskell fold

5
推荐指数
2
解决办法
5815
查看次数

Eclipse 3.7 的 Google 插件未显示

我正在运行 Windows 7 64 位和 Eclipse 32 位。

问题是在我完成安装GPE 3.7GWT SDK 2.5.1插件后,Eclipse 工具栏中带有 g 图标的 Google 按钮没有显示。当我转到 时Preferences,应该有一个 google 标签,但也没有显示。当我转到文件菜单 -> 新建 ->我应该看到Web 应用程序项目,但我没有看到。当我转到Window -> Customize Perspective然后是 Tool Bar Visibility 选项卡时,我在那里没有看到 Google 树项目。

我通过转到Window menu > Reset Perspective... 来重置我的视角。我什至在安装后多次重新启动 Eclipse。

安装没有问题。如果我转到Eclipse -> About Eclipse -> Installation details,我会看到Google App Engine Java SDK 1.8.1, Google Plugin for Eclipse 3.7, 以及Google Web Toolkit …

eclipse gwt plugins eclipse-plugin

5
推荐指数
1
解决办法
2047
查看次数

使用Click在python中创建命令行应用程序

我正在使用Click库创建一个命令行应用程序,该库接受名称作为输入,但如果没有输入名称,则返回默认值.

这是我到目前为止的代码.

hello.py

import click

@click.version_option(1.0)

@click.command()
@click.argument('string', default='World')
@click.option('-r', '--repeat', default=1, help='How many times should be greeted.')

def cli(string,repeat):
    '''This string greets you.'''
    for i in xrange(repeat): 
        click.echo('Hello %s!' % string)

if __name__ == '__main__':
    cli()
Run Code Online (Sandbox Code Playgroud)

当我运行它.

$你好

Hello World!
Run Code Online (Sandbox Code Playgroud)

$ hello Bob

Hello Bob!
Run Code Online (Sandbox Code Playgroud)

$ hello Bob -r 3

Hello Bob!
Hello Bob!
Hello Bob!
Run Code Online (Sandbox Code Playgroud)

这正是我想要的.

现在,我希望能够接受来自stdin的输入,如下面的示例所示.

$ echo John | 你好

Hello John!
Run Code Online (Sandbox Code Playgroud)

$ echo John | 你好-r 3

Hello John!
Hello John!
Hello John!
Run Code Online (Sandbox Code Playgroud)

python stdin command-line-arguments python-click

5
推荐指数
2
解决办法
3080
查看次数

Jekyll 中多次重复字符串

如何在 Jekyll 中多次重复字符串?

例如:在 Python 中,您可以"hello" * 5获取'hellohellohellohellohello'. 在 Jekyll 中,有比这更简单的方法来做同样的事情吗?

{% for i in (1..5) %}
  Hello
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

例子

假设您想要显示星级,并且您正在使用它<i class="fa fa-star"></i>来显示每颗星。因此,要显示 5 星评级,您就可以这样做。

{% for i in (1..5) %}
    <i class="fa fa-star"></i>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

单个页面上可能会显示许多评级,因此您将使用该 for 循环的多个实例。

templating-engine liquid static-site jekyll

5
推荐指数
1
解决办法
686
查看次数

使用Hugo,如何从基本文件中定义的部分文件中访问变量?

我不熟悉使用Hugo和Go模板.如何使用Hugo从基本文件中定义的部分文件中访问变量?

例如:我有一个index.html文件,其中包含读取存储在events.json数据目录中的文件中的数据并将其存储在变量中的代码.如何从其他文件访问该变量?

的index.html

{{ $events := .Site.Data.events }}

{{ partial "people" . }}
Run Code Online (Sandbox Code Playgroud)

people.html

// access the events variable from the index.html
{{ $events }}
Run Code Online (Sandbox Code Playgroud)

我真的希望这是有道理的.如果需要,我可以尝试澄清更多.

template-engine global-variables partials go-templates hugo

3
推荐指数
2
解决办法
3134
查看次数

使用 PowerShell 将 CSV 转换为 JSON 并将 JSON 转换为 CSV

我有一个 CSV 文件,我正在尝试使用 PowerShell 将其转换为 JSON。

CSV 文件包含以下数据。

web_url.csv

wikipedia,https://en.wikipedia.org/wiki/%s
wolframalpha,http://www.wolframalpha.com/input/?i=%s
drive,http://www.drive.google.com/
Run Code Online (Sandbox Code Playgroud)

我想按以下格式转换为 json。同样,您如何以上述格式将此 json 转换回原始 csv?

web_url.json

{
    "wikipedia": "https://en.wikipedia.org/wiki/%s",
    "wolframalpha": "http://www.wolframalpha.com/input/?i=%s",
    "drive": "http://www.drive.google.com/"
}
Run Code Online (Sandbox Code Playgroud)

当我运行命令时,

Get-Content -path web_url.csv | ConvertFrom-Csv -Delimiter ',' | ConvertTo-Json

它返回以下输出,这不是我想要的。

[
    {
        "wikipedia":  "wolframalpha",
        "https://en.wikipedia.org/wiki/%s":  "http://www.wolframalpha.com/input/?i=%s"
    },
    {
        "wikipedia":  "drive",
        "https://en.wikipedia.org/wiki/%s":  "http://www.drive.google.com/"
    }
]
Run Code Online (Sandbox Code Playgroud)

csv powershell json

2
推荐指数
1
解决办法
2万
查看次数

Powershell xml访问密钥对值

我有以下格式的示例 xml 文件。如何使用 Powershell 直接访问键的值?

例如: $xml.array.dict.key.name -> 鲍勃、凯特、约翰

$xml = @'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <dict>
        <key>name</key>
        <string>bob</string>
        <key>age</key>
        <string>35</string>
        <key>gender</key>
        <string>male</string>
    </dict>
    <dict>
        <key>name</key>
        <string>kate</string>
        <key>age</key>
        <string>12</string>
        <key>gender</key>
        <string>female</string>
    </dict>
    <dict>
        <key>name</key>
        <string>john</string>
        <key>age</key>
        <string>57</string>
        <key>gender</key>
        <string>male</string>
    </dict>
</array>
</plist>
'@
Run Code Online (Sandbox Code Playgroud)

如何将 xml 转换为 Powershell 对象,如下所示?

输出

name   age   gender
---    --    -----
bob    35    male
kate   12    female
john   57    male
Run Code Online (Sandbox Code Playgroud)

这是我尝试过的。

$xmldata = [xml]$xml
$xmldict = $xmldata.plist.array.dict …
Run Code Online (Sandbox Code Playgroud)

xml powershell plist

2
推荐指数
1
解决办法
2135
查看次数

使用折叠操作的Haskell树

给定使用折叠的定义,我将如何编写一个contains平衡函数。

data Tree a = Tree a [Tree a]

treeFold :: (a -> [b] -> b) -> Tree a -> b
treeContains :: Eq a => a -> Tree a -> Bool
treeBalanced :: Tree a -> Bool
Run Code Online (Sandbox Code Playgroud)

请注意,在上面的定义中,不允许有空树,并且叶是具有空子树列表的树。

一个包含函数确定树是否包含给定的标签。

一个平衡的功能确定树是否是平衡的。

如果一棵树的子树的高度最大相差一,则该树是平衡的。

到目前为止,我已经包含了contains函数。

treeContains :: Eq a => a -> Tree a -> Bool
treeContains a = treeFold (\x y -> if a == x then True else ...)
Run Code Online (Sandbox Code Playgroud)

那么,您如何做其他部分呢?

任何帮助将不胜感激。

tree haskell fold

0
推荐指数
1
解决办法
731
查看次数

使用 Powershell 从给定的 url 获取网站元数据,例如标题、描述

如何使用 Powershell 从给定 URL 检索网站元数据,例如标题、描述、关键字?

例如:给定以下网址

输入: www.amazon.com

输出

title: "Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more",
description: "Online shopping from the earth's biggest selection of books, magazines, music, DVDs, videos, electronics, computers, software, apparel & accessories, shoes, jewelry, tools & hardware, housewares, furniture, sporting goods, beauty & personal care, broadband & dsl, gourmet food & just about anything else.",
keyword: "Amazon, Amazon.com, Books, Online Shopping, Book Store, Magazine, Subscription, Music, CDs, DVDs, Videos, Electronics, Video …
Run Code Online (Sandbox Code Playgroud)

html url powershell metadata

0
推荐指数
1
解决办法
9475
查看次数