我一直想为YEARS寻找解决方案.
由于这个原因,我在操作文件时比使用bash更有效率.
如果我有
file_12390983421
file_12391983421
file_12340983421
file_12390986421
Run Code Online (Sandbox Code Playgroud)
在bash和type file_1-> tab中,它显然列出:
file_12390983421 file_12391983421 file_12340983421 file_12390986421
Run Code Online (Sandbox Code Playgroud)
这是一个可怕的工作和痛苦的工作.
vim中的相同序列将一次循环一个文件.
请有人告诉我如何在bash中执行此操作,或者如果有另一个shell可以执行此操作,我明天会切换.
我确定我的问题是基于对node.js中的异步编程缺乏了解,但是这里有.
例如:我有一个我想要抓取的链接列表.当每个异步请求返回时,我想知道它是用于哪个URL.但是,大概是因为竞争条件,每个请求返回的URL都设置为列表中的最后一个值.
var links = ['http://google.com', 'http://yahoo.com'];
for (link in links) {
var url = links[link];
require('request')(url, function() {
console.log(url);
});
}
Run Code Online (Sandbox Code Playgroud)
预期产量:
http://google.com
http://yahoo.com
Run Code Online (Sandbox Code Playgroud)
实际产量:
http://yahoo.com
http://yahoo.com
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:
PS:对于1.我不想要一个检查回调参数的解决方案,而是一个回调知道变量'从上面'的一般方法.
我有一个深度子文件夹调用objects
文件调用*.object
,我不想跟踪git(Windows).
在.gitignore我尝试了各种组合(例如**/objects/*
或**/objects/*
等)无济于事:每次,当我这样做时,git status
我看到:
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# foo/src/objects/a.object
# foo/src/objects/b.object
Run Code Online (Sandbox Code Playgroud)
只有当我添加*.object
.gitignore时,文件才会从未跟踪的文件列表中消失.我的外卡有什么问题?
此外,何时git update-index
需要,我应该在git rm --cached myfile
什么时候?
rm是否有通配符功能git rm --cached **/foo/*.zip
?
UPDATE:类似地,将所述线.gitignore
以.gitignore
(不总是可取的,但仍然)没有效果.这有点古怪,因为过去可能跟踪过这些文件吗?
运行Chrome 61是应该支持模块加载用import
.
确实,保罗的演示适合我.但是,当我自己尝试时,我得到一个JS错误"意外的令牌导入".Chrome似乎不愿意import
:
的test.html
<!doctype html>
<html>
<body>
<script src="test.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
test.js:
import {hello} from './something.js'
console.log(hello())
Run Code Online (Sandbox Code Playgroud)
something.js
export {hello}
function hello() {
return "hello world"
}
Run Code Online (Sandbox Code Playgroud)
为什么Chrome不理解"导入"
VSCode 的 PowerShell 终端现在提供一种灰色建议,提示您可能想要输入的内容(大概来自历史记录?):
但似乎没有办法真正接受这个建议:按 Tab 键只是执行正常的 PowerShell 自动完成(通常是 cmdlet 或路径)。
这个功能是什么?我如何“制表符”来自动完成显示的命令?
更新:只需按right arrow
键盘即可自动完成。
任何人都知道为什么Safari 5(Windows 7)无法对对象数组进行排序?
var arr = [{a:1},{a:3},{a:2}];
console.log(arr[0].a+','+arr[1].a+','+arr[2].a);
arr.sort(function(a,b){return a.a > b.a;});
console.log(arr[0].a+','+arr[1].a+','+arr[2].a);
Run Code Online (Sandbox Code Playgroud)
控制台结果应该是
1,3,2
1,2,3
Run Code Online (Sandbox Code Playgroud)
这在FF和IE中工作正常,但Safari返回:
1,3,2
1,3,2
Run Code Online (Sandbox Code Playgroud) 我想得到一个Hashtable的JSON表示,如下所示:
@{Path="C:\temp"; Filter="*.js"}
Run Code Online (Sandbox Code Playgroud)
ConvertTo-Json
结果是:
{
"Path": "C:\\temp",
"Filter": "*.js"
}
Run Code Online (Sandbox Code Playgroud)
但是,如果您将JSON字符串转换回来,ConvertFrom-Json
则不会获得HashTable,而是获得PSCustomObject.
那么如何才能可靠地序列化上面的Hashmap呢?
我有一个工作的jQuery移动应用程序,它对$.ajax
静态.json文件做一些简单的请求.一切都很顺利,直到我添加一个清单:只是改变<html>
以<html manifest="myapp.appcache">
打破我的ajax!这是我的清单:
CACHE MANIFEST
CACHE:
jquery.mobile-1.0.1.css
images/ajax-loader.png
images/icons-18-white.png
jquery-1.6.4.js
jquery.mobile-1.0.1.js
Run Code Online (Sandbox Code Playgroud)
我试过添加:
NETWORK:
salesorg.*.json
Run Code Online (Sandbox Code Playgroud)
没有区别.严肃的de ja vu在这里,但我不知道解决方案是什么.
使用jQuery jquery-1.9.1.js和jQueryMobile 1.3.1(Chrome 26/Windows 7)我无法理解为什么这些"click"事件中的一个绑定到#one1会触发而另一个不会:
HTML:
<div data-role="page" id="one" data-theme="a">
<div data-role="header" data-position="inline">
<h1>One</h1>
</div>
<div data-role="content" data-theme="a">
<a href="#" id="one1">[one]</a>
<a href="#two">two</a>
<a href="#three">three</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
<script>
$(document).on( "mobileinit", function() {
$(document).on('click', '#one1', function(e){
console.log('firing');
});
$('#one1').on("click", function() {
console.log('not firing');
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
当我在JSFiddle中运行它时,当没有包含在"mobileinit"事件中时,两个事件都会触发:http: //jsfiddle.net/9NRwa/
我在这里错过了什么?
I've stumbled across an odd situation in PowerShell 5.1 (Windows 10) where ConvertTo-Json
produces {}
instead of null
for an apparently null valued object:
[CmdletBinding()]
param()
function main() {
$foo1 = $null
Write-Verbose ("foo1 null? " + ($null -eq $foo1))
$foo2 = try{1/0}catch{}
Write-Verbose ("foo2 null? " + ($null -eq $foo2))
$foo3 = try{1/0}catch{$null}
return [PSCustomObject]@{"foo1"=$foo1; "foo2" = $foo2; "foo3" = $foo3} | ConvertTo-Json
}
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
main
Run Code Online (Sandbox Code Playgroud)
Running this cmdlet -verbose
shows two apparently $null …
javascript ×3
jquery ×2
json ×2
powershell ×2
ajax ×1
arrays ×1
asynchronous ×1
bash ×1
es6-modules ×1
git ×1
html5 ×1
node.js ×1
null ×1
safari ×1
shell ×1
vim ×1
web-crawler ×1