如何获取存储在变量中的字符串的长度并将其分配给另一个变量?
myvar="some string"
echo ${#myvar}
# 11
Run Code Online (Sandbox Code Playgroud)
如何将另一个变量设置为输出11?
*/20 * * * *
确保它每20分钟运行一次,我希望每隔20分钟运行一次任务,从小时开始5点开始,这可能与Cron有关吗?可不可能是:
5/20 * * * * ?
我试图建立一个GitHub的jQuery的UI库使用grunt,但运行后npm install我还是根据无法运行该命令自述文件.它只是给出No command 'grunt' found:
james@ubuntu:~/Documents/projects/ad2/lib/jquery-ui$ grunt build
No command 'grunt' found, did you mean:
Command 'grun' from package 'grun' (universe)
grunt: command not found
james@ubuntu:~/Documents/projects/ad2/lib/jquery-ui$ npm ls
jquery-ui@1.9.0pre /home/james/Documents/projects/ad2/lib/jquery-ui
??? grunt@0.3.9
? ??? async@0.1.18
? ??? colors@0.6.0-1
? ??? connect@1.8.7
? ? ??? formidable@1.0.9
? ? ??? mime@1.2.5
? ? ??? qs@0.5.0
? ??? dateformat@1.0.2-1.2.3
? ??? glob-whatev@0.1.6
? ? ??? minimatch@0.2.4
? ? ??? lru-cache@1.0.6
? ??? gzip-js@0.3.1 …Run Code Online (Sandbox Code Playgroud) function sayName(params: {firstName: string; lastName?: string}) {
params.lastName = params.lastName || 'smith'; // <<-- any better alternative to this?
var name = params.firstName + params.lastName
alert(name);
}
sayName({firstName: 'bob'});
Run Code Online (Sandbox Code Playgroud)
我曾经想象过这样的事情可能有用:
function sayName(params: {firstName: string; lastName: string = 'smith'}) {
Run Code Online (Sandbox Code Playgroud)
显然,如果这些是明确的论据,你可以这样做:
function sayName(firstName: string, lastName = 'smith') {
var name = firstName + lastName;
alert(name);
}
sayName('bob');
Run Code Online (Sandbox Code Playgroud)
在coffeescript中,您可以访问条件存在运算符,因此可以执行以下操作:
param.lastName ?= 'smith'
Run Code Online (Sandbox Code Playgroud)
哪个编译成javascript:
if (param.lastName == null) {
param.lastName = 'smith';
}
Run Code Online (Sandbox Code Playgroud) Visual Studio代码(版本0.10.11,在OSX上)不刷新文件夹中的文件.有没有办法强迫它刷新.目前我必须关闭并重新打开整个程序.
有了这个页面:
<!DOCTYPE html>
<html>
<head>
<script>
"use strict";
var foo = 2;
delete foo;
</script>
</head>
<body></body>
</html>
Run Code Online (Sandbox Code Playgroud)
Firebug控制台给出:
applying the 'delete' operator to an unqualified name is deprecated
>>> foo
ReferenceError: foo is not defined
foo
Run Code Online (Sandbox Code Playgroud)
但是这很成功:
>>> var bar = 2;
undefined
>>> delete bar;
true
Run Code Online (Sandbox Code Playgroud)
即使您注释掉delete foo;脚本没有中断,删除bar仍然是成功的,尽管它"是Global对象的属性,因为它是通过变量声明创建的,因此具有DontDelete属性 ":
>>> foo
2
>>> delete foo
false
>>> var bar = 2;
undefined
>>> delete bar
true
Run Code Online (Sandbox Code Playgroud)
是否可以启用"严格模式"; 在FireBug和Chrome的控制台?
目前我收到以下错误:
PGError(致命:用户"postgres"的密码验证失败):
当我的应用程序尝试访问数据库时.
我希望测试我的针对postgres的SQL调用,因为我的应用程序经常在Heroku上推送到生产时因为postgres的更严格的要求(我认为这可能是一个健康的东西)而不是sqlite 3.所以我对此有类似的请求如果没有过时的教程,请安装postgres,以便在windows(7)上使用ruby on rails.我认为这是一个快速的20分钟下载和安装,但2小时后,我不认为我非常接近.到目前为止,我已经:
从这里下载并安装Postgres版本8.4.8-1
设置我的环境变量,使Path(for User)为: C:\Ruby192\bin;C:\Program Files (x86)\PostgreSQL\8.4\bin
的Gemfile:
Run Code Online (Sandbox Code Playgroud)gem 'pg', '0.11.0' # instead of gem 'sqlite3', '1.3.3'
跑了bundle install我的Rails应用程序看似成功,但还没有找到简单的方法来验证安装呢.
按照此处的建议设置database.yml :
development:
adapter: postgresql
database: db/development
username: postgres
password: secret
host: localhost
encoding: UTF8
pool: 5
timeout: 5000
Run Code Online (Sandbox Code Playgroud)
我知道我需要为Postgres设置一个用户名和密码,也可以启动postgres服务器,连接到它(?)并输入我的本地IP地址我将连接到它上面的某个配置文件,然后编辑'C:\ Program Files(x86)\ PostgreSQL\8.4\data'等中的其他.conf文件之一...
我认为Rails让我变得柔软,我是在思考问题还是设置起来实际上相当棘手,我应该回到Sqlite3,为此还有非常有用的SQLite Manager,Firefox插件?
我还在寻找一个初学者指南,安装和使用的Postgres的轨道,但到目前为止只得到了大部分的东西,我看糊涂/试过下面像这个,这个,这个,这个,这个(雪豹)这(linux).
任何指针都将非常感激.谢谢!
詹姆士
我们运行了etsy/statsd节点应用程序,每10秒将统计信息刷新为碳/低语.如果发送100个增量(计数),在前10秒内,石墨会正确显示它们,如:
localhost:3000/render?from=-20min&target=stats_counts.test.count&format=json
[{"target": "stats_counts.test.count", "datapoints": [
[0.0, 1372951380], [0.0, 1372951440], ...
[0.0, 1372952460], [100.0, 1372952520]]}]
Run Code Online (Sandbox Code Playgroud)
然而,10秒后,这个数字下降到0,null和33.3.最终,它在初始增量数的1/6处稳定,在这种情况下16.6.
/opt/graphite/conf/storage-schemas.conf 是:
[sixty_secs_for_1_days_then_15m_for_a_month]
pattern = .*
retentions = 10s:10m,1m:1d,15m:30d
Run Code Online (Sandbox Code Playgroud)
我想获得准确的计数,石墨是否平均了60秒窗口的数据而不是总结它?使用积分函数,经过一段时间后,显然给出:
localhost:3000/render?from=-20min&target=integral(stats_counts.test.count)&format=json
[{"target": "stats_counts.test.count", "datapoints": [
[0.0, 1372951380], [16.6, 1372951440], ...
[16.6, 1372952460], [16.6, 1372952520]]}]
Run Code Online (Sandbox Code Playgroud) 我目前有:
Range("Z1").Interior.Color = RGB(255, 255, 255)
Run Code Online (Sandbox Code Playgroud)
但这消灭了细胞的边界.相反,我只想将范围内的单元格透明度设置为1.0. 文档似乎暗示它不存在(?).
谢谢!
这一定非常简单,但完全是空白.我可以通过使用ls -la看到文件的权限,它可以提供类似的东西:
-rwxr-xr-x 1 james staff 68 8 Feb 13:33 basic.sh*
-rw-r--r-- 1 james staff 68 8 Feb 13:33 otherFile.sh*
Run Code Online (Sandbox Code Playgroud)
如何翻译成若干为使用chmod像chmod 755 otherFile.sh(与做出来的手工转换).
bash ×1
build ×1
cell ×1
console ×1
cron ×1
excel ×1
excel-2007 ×1
graphite ×1
install ×1
javascript ×1
macos ×1
node.js ×1
npm ×1
package ×1
posix ×1
postgresql ×1
statsd ×1
strict-mode ×1
transparency ×1
typescript ×1
variables ×1
vba ×1
windows ×1