我需要我的脚本能够接受带有空格字符的参数.例如,如果我有一个如下脚本:
for SOME_VAR in $@
do
echo "$SOME_VAR"
cd "$SOME_VAR"
done;
Run Code Online (Sandbox Code Playgroud)
如果我将参数传递给脚本(假设它被调用foo.sh
)
sh foo.sh "Hello world"
Run Code Online (Sandbox Code Playgroud)
我期待脚本打印Hello world
并将目录更改为Hello world
.但我收到此错误消息:
hello
cd: 5: can't cd to hello
world
cd: 5: can't cd to world
Run Code Online (Sandbox Code Playgroud)
我究竟如何将带有空格字符的参数传递给shell脚本中的命令?
我正在尝试编写一个简短的脚本来通过clojure聚集我的数据(尽管调用Mahout类).我有这种格式的输入数据(这是PHP脚本的输出)
format: (tag) (image) (frequency)
tag_sit image_a 0
tag_sit image_b 1
tag_lorem image_a 1
tag_lorem image_b 0
tag_dolor image_a 0
tag_dolor image_b 1
tag_ipsum image_a 1
tag_ipsum image_b 1
tag_amit image_a 1
tag_amit image_b 0
... (more)
Run Code Online (Sandbox Code Playgroud)
然后我使用这个脚本(clojure)将它们写入SequenceFile
#!./bin/clj
(ns sensei.sequence.core)
(require 'clojure.string)
(require 'clojure.java.io)
(import org.apache.hadoop.conf.Configuration)
(import org.apache.hadoop.fs.FileSystem)
(import org.apache.hadoop.fs.Path)
(import org.apache.hadoop.io.SequenceFile)
(import org.apache.hadoop.io.Text)
(import org.apache.mahout.math.VectorWritable)
(import org.apache.mahout.math.SequentialAccessSparseVector)
(with-open [reader (clojure.java.io/reader *in*)]
(let [hadoop_configuration ((fn []
(let [conf (new Configuration)]
(. conf set "fs.default.name" "hdfs://localhost:9000/")
conf)))
hadoop_fs …
Run Code Online (Sandbox Code Playgroud) 是否有替代mysql_insert_id()
PostgreSQL的PHP函数?大多数框架通过查找ID中使用的序列的当前值来部分解决问题.但是,有时主键不是串行列....
我知道HTTP PUT是一个幂等请求,根据定义(引自rfc)将某些内容存储在特定的URI中
The PUT method requests that the enclosed entity be stored under the supplied Request-URI.
Run Code Online (Sandbox Code Playgroud)
但是"封闭实体"的定义是什么?我似乎无法发送表单数据(例如HTTP POST请求).如何通过JSON/XML或其他序列化格式发送实体的表示?
简而言之,如何将HTTP PUT请求发送到特定URI的存储/更新信息呢?
我有以下字符串:
"hello.world.foo.bar"
我想拆分(使用"."
as分隔符,只想从头到尾获得两个元素),如下所示:
["hello.world.foo", "bar"]
我怎么能做到这一点?到底存在限制?
我有一个启用了restful的Web服务站点,因此其他网站/ ajax脚本可以调用该站点来获取/设置数据.但是,每当Web服务站点以某种方式返回PHP致命错误时,返回的HTTP状态为200而不是500.是否有办法修复它,以便每当发生致命错误时,返回500而不是200?或者,如果不可能,我如何更改我的客户端以识别Web服务返回的致命错误?
在Kohana/CodeIgniter中,我可以使用以下格式的URL:
http://www.name.tld/controller_name/method_name/parameter_1/parameter_2/parameter_3 ...
Run Code Online (Sandbox Code Playgroud)
然后按如下方式读取控制器中的参数:
class MyController
{
public function method_name($param_A, $param_B, $param_C ...)
{
// ... code
}
}
Run Code Online (Sandbox Code Playgroud)
你如何在Zend框架中实现这一目标?
我需要从html文件生成一个insert语句列表(对于postgresql),是否有可用于python的库来帮助我正确转义并引用名称/值?在PHP中,我使用PDO进行转义和引用,是否有任何等效的python库?
编辑:我需要生成一个带有sql语句的文件,以便以后执行
这实际上是关于ES6中面向对象模型的问题.但是,我将使用创建新的自定义元素作为示例.
因此,创建一个新的自定义元素的新的和有光泽的(截至今天)方法是根据MDN,Google,当然还有规范customElements.define()
来获取标签name
,a constructor
和options
(这是可选的).列出的所有文档都使用新关键字的变体.class
constructor
假设我不喜欢新的class
语法,并且考虑到大多数情况下class
是一个合成糖(根据本教程).该规范甚至具体说明了这一点
无参数调用
super()
必须是构造函数体中的第一个语句,以便在运行任何其他代码之前建立正确的原型链和此值.
通过阅读教程,我出来了,试试是否有可能(也修改和重新学习Javascript的对象模型).
var _extends = function(_parent) {
var _result = function() {
_parent.call(this);
};
_result.prototype = Object.create(_parent.prototype);
Object.defineProperty(_result.constructor, 'constructor', {
enumerable: false,
writeable: true,
value: _result
});
return _result;
};
customElements.define('foo-bar', _extends(HTMLElement));
console.log(document.createElement('foo-bar'));
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误
错误:正在构造的自定义元素未注册
customElements
.
所以我的问题是,是否可以不使用class
关键字(也new
可能没有)?如果答案是否定的,我是否应该坚持class
使用关键字而不是Object.create
在将来编写新的Javascript代码时使用?