我是第一次使用Google App Script.我在Google Doc电子表格中使用它.
我正在尝试非常简单的功能,只是为了学习基础知识.例如,这有效:
function test_hello() {
return 'hello';
}
Run Code Online (Sandbox Code Playgroud)
但是我对这个简单的问题感到困惑:
function test_today() {
return today();
}
Run Code Online (Sandbox Code Playgroud)
#ERROR!无论我在哪里使用它都能成为现实.当我把光标放在它上面时,它说:
error : ReferenceError: "today" is not defined.
Run Code Online (Sandbox Code Playgroud)
虽然该today()功能在电子表格中直接使用时有效.
这是否意味着在脚本中,我不能使用电子表格内置函数?这周围有什么优雅的方式吗?
一些电子表格函数对我来说非常有用(weekday()例如我喜欢).
一种不优雅的方式可能是创建列来计算我需要的中间值,并且可以使用电子表格函数来计算.但我宁愿避免这些肮脏和笨重的事情.
我正在寻找一个命令行电子表格,到目前为止,sc是我最好的发现(我在这条消息的末尾解释了原因).
但缺乏撤销功能正在扼杀我.你如何应对缺乏这个重要的缺失功能? 现在,当我犯错误时,我要么必须手动纠正它; 或者我必须关闭文件而不保存,重新打开它,并重新做所有最近的更改 - 这是一个痛苦; 事实上,它让我只想不使用sc,这是一个耻辱,因为它是唯一似乎做我想做的其他事情的电子表格.
我想出了一个不稳定的解决方案(尚未尝试过):由于F键是可编程的,我可以让其中一个在Git中提交我的电子表格,另一个"撤消"我最近的更改,通过反转到上次提交.也许还有一个要重做.那不太理想,真的......所以我会感激任何更好的主意.
哦,还!sc的另一个缺失特征是社区.没有邮件列表(也没有IRC频道).如果周围有人使用sc,我可能会建立一个邮件列表,以便我们可以交换问题和想法.任何接受者?
附录:为什么sc是迄今为止最好的命令行电子表格:
这里有关于sc的更多信息:
这是Undo功能的Github问题.它被标记为"将需要补丁",并且讨论了可以实现该功能的不同方式.
PS:你可能想要看的另一个命令行电子表格是茶壶,它看起来也很棒(而且还缺少撤销功能).实际上它有sc缺乏的优秀功能,但我个人会用sc来表示Vim键绑定,颜色以及我可以用任何语言编写函数的事实.
PPS:我没有足够的声誉用标签"sc"发布此消息,因此我将其标记为Vim,因为Vim用户可能会对此电子表格感兴趣.
我已经设置了一台Vagrant机器,并为它创建了一个基本的Ansible剧本.当我跑步时,一切都按预期工作
vm-abla> vagrant provision
Run Code Online (Sandbox Code Playgroud)
但是我不能用Ansible向机器发送ad-hoc命令,为什么会这样?我强调了我认为可能表明原因的界限.
vm-abla> ansible jon -i provisioning/hosts -a "echo 'TEST'" -vvvv
<192.168.33.2> ESTABLISH CONNECTION FOR USER: user
<192.168.33.2> REMOTE_MODULE command echo 'TEST'
<192.168.33.2> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/user/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', '192.168.33.2', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1394126994.26-73015876561126 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1394126994.26-73015876561126 && echo $HOME/.ansible/tmp/ansible-tmp-1394126994.26-73015876561126'"]
192.168.33.2 | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_6.0p1 Debian-4, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration …Run Code Online (Sandbox Code Playgroud) 我不能让最简单的指令在我的AngularJS + Coffeescript项目中起作用.
我在directives.coffee中有这个代码:
'use strict'
app_name = "myApp"
app = angular.module "#{app_name}.directives", []
# Directive to include the version number of my project
app.directive 'appVersion', [
'version', (version) ->
(scope, element, attrs) ->
element.text version
]
# Hello world directive
app.directive 'hello', () ->
restict: 'E'
template: '<div>Hello World</div>'
Run Code Online (Sandbox Code Playgroud)
在我的模板中,当我这样做时
<span app-version></span>
<hello></hello>
Run Code Online (Sandbox Code Playgroud)
然后显示版本号(0.1),表明第一个指令正常工作,但标签不会被任何东西取代.
知道我做错了什么吗?
我也试过这个,但也没用:
# Hello world directive
app.directive 'hello', ->
class Habit
constructor: ->
restict: 'E'
template: '<div>Hello World</div>'
Run Code Online (Sandbox Code Playgroud) 这是我可以做的最简单的例子:
(defmacro printer [& forms]
`(println ~@forms))
(defmacro adder [s]
`(inc ~s))
Run Code Online (Sandbox Code Playgroud)
它们可以按预期使用:
(printer "haha")
=> "haha"
(adder 1)
=> 2
Run Code Online (Sandbox Code Playgroud)
我可以macroexpand让他们看看宏做了什么:
(macroexpand '(printer 1))
=> (clojure.core/println 1)
(macroexpand '(adder 1))
=> (clojure.core/inc 1)
Run Code Online (Sandbox Code Playgroud)
但是当它们嵌套时我得不到我想要的东西:
(macroexpand '(printer (adder 1)))
=> (clojure.core.println (adder 1))
Run Code Online (Sandbox Code Playgroud)
我希望得到
=> (clojure.core.println (clojure.core/inc 1))
Run Code Online (Sandbox Code Playgroud)
有没有办法扩展嵌套宏?这对于调试特定的bug有很大帮助.
angularjs ×1
ansible ×1
clojure ×1
coffeescript ×1
command-line ×1
javascript ×1
macros ×1
sc ×1
spreadsheet ×1
ssh ×1
undo ×1
vagrant ×1