我目前正在阅读Adam Freeman撰写的"Pro AngularJS".通过这些示例,他让读者使用Angular(当然)和Deployd服务器资源创建了一个体育商店应用程序.Deployd资源设置为返回要填充到模型中的JSON数据.我正在使用NodeJS来运行我的服务器.它目前在端口5000(http://localhost:5000/sportsstore/app.html)上设置.Deployd资源在端口5500(http://localhost:5500/products)上运行.点击Deployd时,响应如下:
[
{ "name": "Kayak", "description": "A boat for one person", "category": "Watersports", "price": 275, "id": "a1c999fc248b2959" },
{ "name": "Lifejacket", "description": "Protective and fashionable", "category": "Watersports", "price": 48.95, "id": "61303717cfad182e" },
{ "name": "Soccer Ball", "description": "FIFA-approved size and weight", "category": "Soccer", "price": 19.5, "id": "0fb5f67bdcbd992f" },
{ "name": "Corner Flags", "description": "Give your playing field a professional touch", "category": "Soccer", "price": 34.95, "id": "24385d315dd388b4" },
{ "name": "Stadium", "description": "Flat-packed 35,000-seat stadium", …Run Code Online (Sandbox Code Playgroud) 我有一段 PowerShell 代码,它从 Azure 读取项目列表,并将它们格式化为一个表格供用户选择:
if ($SubscriptionArray.Count -eq 1) {
$SelectedSub = 1
}
# Get SubscriptionID if one isn't provided
while ($SelectedSub -gt $SubscriptionArray.Count -or $SelectedSub -lt 1) {
Write-host "Please select a subscription from the list below"
$SubscriptionArray | Select-Object "#", Id, Name | Format-Table
try {
$SelectedSub = Read-Host "Please enter a selection from 1 to $($SubscriptionArray.count)"
}
catch {
Write-Warning -Message 'Invalid option, please try again.'
}
}
Run Code Online (Sandbox Code Playgroud)
在脚本的主要区域中执行时,会输出预期的结果:
我想多次使用这个逻辑,因此将它移到一个方法中:
function Get-IndexNumberFromArray(
[Parameter(Mandatory = $True)]
[array]$selectArray, …Run Code Online (Sandbox Code Playgroud) 我在文本文件上使用File :: Find和file i/o来解析一系列目录并将内容移动到一个新文件夹中.这是一个简单的脚本(见下文):
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
use File::Copy;
my $dir = "/opt/CollectMinderDocuments/coastalalglive"; #base directory for Coastal documents
#read file that contains a list of closed IDs
open(MYDATA, "Closed.txt");
mkdir("Closed");
while(my $line = <MYDATA>) {
chomp $line;
my $str = "$dir" . "/Account$line";
print "$str\n";
find(\&move_documents, $str);
}
sub move_documents {
my $smallStr = substr $File::Find::name, 43;
if(-d) {
#system("mkdir ~/Desktop/Closed/$smallStr");
print "I'm here\n";
system("mkdir /opt/CollectMinderDocuments/coastalalglive/Closed/$smallStr");
#print "Made a directory: /opt/CollectMinderDocuments/coastalalglive/Closed/$smallStr\n";
}
else {
print "Now …Run Code Online (Sandbox Code Playgroud) 我可以用一些帮助搞清楚为什么我的游戏不允许我拿起一把剑.出现的错误消息是
回溯(最近一次调用最后一次):文件"",第36行,在文件"",第1行,在NameError中:名称'y'未定义
这是基本游戏,我对此非常新,所以简单的术语会很好.
print 'You enter a Dungeon with three doors. Do you want to enter door #1 door #2 or door #3?'
door = raw_input('> ')
if door == "1":
print 'Theres a dragon eating a human, the dragon is massive and looks terrifying'
print 'what do you want to do?'
print '#1 try to save the human'
print '#2 scream and run around'
dragon = raw_input('> ')
if dragon == "1":
print 'You approach the dragon sneakily. After …Run Code Online (Sandbox Code Playgroud) angularjs ×1
cors ×1
deployd ×1
file ×1
file-find ×1
javascript ×1
perl ×1
powershell ×1
python ×1