我的项目需要几个符号链接.
来自src/openlayers,文件夹img和theme必须符号链接contrib/openlayers.该contrib/openlayers文件夹也应自动创建.
.PHONY: run
run: contrib/openlayers/theme contrib/openlayers/img
../bin/pserve development.ini --reload
contrib/openlayers/theme:
ln -s src/openlayers/theme $@
contrib/openlayers/img:
ln -s src/openlayers/img $@
Run Code Online (Sandbox Code Playgroud)
但是这条规则每次都试图创建符号链接.(我把-f旗帜放到了ln,所以每次都会重新创建符号链接.)
我有一个与我一起观看的Sphinx文档的文件夹inotifywait(来自inotify-tools).该脚本重新构建html&singlehtml并刷新Chrome.
#!/bin/sh
inotifywait -mr source --exclude _build -e close_write -e create -e delete -e move | while read file event; do
make html singlehtml
xdotool search --name Chromium key --window %@ F5
done
Run Code Online (Sandbox Code Playgroud)
保存单个文件时,此工作正常.但是,当我hg update使用旧版本或粘贴文件source夹中的多个文件时,它会为每个文件触发脚本.
是否有一个简单的解决方法(没有编写自定义python脚本 - 我可以这样做)让它在启动脚本之前等待几分之一秒?
我需要补丁os.listdir和其他os函数来测试我的Python函数.但是当它们被修补时,import声明失败了.是否可以仅在单个模块(真实模块)中修补此功能,并使tests.py正常工作?
这是一个打破的例子import:
import os
from mock import patch
# when both isdir and isfile are patched
# the function crashes
@patch('os.path.isdir', return_value=False)
@patch('os.path.isfile', return_value=False)
def test(*args):
import ipdb; ipdb.set_trace()
real_function(some_arguments)
pass
test()
Run Code Online (Sandbox Code Playgroud)
我想看real_function一个修补os.path,并测试看看正常的功能.
我在服务器端使用node.js,express.js和jade.我编写了一个小的包装函数来填充客户端的jade模板.我想我会在客户端使用requireJS和jQuery,但还没有决定.现在,我必须多次完成的任务是
注意:有大量的模板引擎,我的问题不是关于模板引擎,而是关于简单的工作流程.
我必须这样做:
var get_data = function (tpl) {
$.get(url, function(data) {
$('#target_element').html(jade.render(tpl, {locals: data}));
});
};
if (!'template_name' in _cache) {
$.get('template_name', function(tpl) {
_cache['template_name'] = tpl;
get_data(tpl);
});
}
else {
get_data(_cache['template_name']);
}
Run Code Online (Sandbox Code Playgroud)
(在这个例子中,模板和数据是同步获取的,这不太好)
我想要这样的代码:
render_template('template_name', 'url?arguments=values', {replace: '#element_id'});
Run Code Online (Sandbox Code Playgroud)
(它与MongoDB语法类似)
是否有一个简单的框架或jquery模块来完成这项工作?
我有一个想法在Node中将代码存储为列表(数组)并执行它们,但这比我想象的要难:如果我在开头或结尾创建一个带有函数的列表,.pop或者.shift删除但省略它并返回下一个要素:
> l = [1, 75, 84, function() { console.log('aseuht') }]
[ 1, 75, 84, [Function] ]
> l.pop()
84
> l
[ 1, 75 ]
Run Code Online (Sandbox Code Playgroud)
我在Node v0.4.9中注意到了这一点,但它仍然存在于0.6.10中.
有解决方法吗?
更新2:该错误仅存在于我的shell中,当我从独立脚本运行这些命令时,它可以正常工作.所以这只是一个shell问题.
如果我猴子修补一个模块:
# mokeypatch.py
import other_module
def replacement(*args, **kwargs):
pass
other_module.some_func = replacement
Run Code Online (Sandbox Code Playgroud)
这会影响直接导入的模块some_func,还是取决于导入的顺序?如果第三个模块是这样的:
# third_module.py
from other_module import some_func
Run Code Online (Sandbox Code Playgroud)
首先,运行此代码,然后运行我们的猴子补丁。会third_module.some_func是旧的吗?
这可不是说笑.我想看看我是否遗漏了什么.在官方文档中,我只看到描述和声明该框架已有详细记录.我想知道这个优秀的文档在哪里?
我需要编写一个简单的演示电子商店,其中包含一个简单的产品列表并与ipayment.de集成.清单,我可以轻松完成.但是,我在哪里阅读如何将ipayment表单与商店集成?
我有一个显示在页面中的模式小部件,当我在 IE11 中打开它时,它部分损坏,但是一旦我调整窗口大小或打开开发人员工具,一切都会得到修复。
似乎应用了一些媒体查询,就像在大屏幕中使用了一些非常小的屏幕规则。但并非所有元素都是如此。
我究竟做错了什么?
我在查询中遇到问题,其中一个 CTE 没有返回任何行。但这很难注意到,并且调试了很长一段时间。
是否可以在不注释掉主查询的情况下输出 Postgres 中的所有 CTE?
create or replace function generate_grid(
poly geometry, step double precision)
returns setof geometry as
$$ */
with
initial as (select st_xmin(poly) x0, st_ymin(poly) y0),
...(another 3 CTE skipped here)...
grid as (select point from points where st_intersects(point, poly)),
centroid as (select st_centroid(poly) point from grid where (select count(*)=0 from grid))
select * from grid
union all
select * from centroid;
$$ language sql;
Run Code Online (Sandbox Code Playgroud)
在示例中,CTEcentroid被逐步添加到之前运行良好的功能中。如果为空,它应该返回行grid。错误(我已修复)是它没有,因为它是从空的 CTE 中选择的 …
我在 makefile 中有一系列模式依赖项,最后它们应该放在一个文件中,例如:*.x-> *.y->onefile.z
所以我制作了这样的文件:
$ touch a.x b.x
Run Code Online (Sandbox Code Playgroud)
和规则:
%.y: %.x some-other-script
touch $@
onefile.z: %.y second-other-script
touch $@
Run Code Online (Sandbox Code Playgroud)
该规则不起作用:
$ make onefile.z
make: *** No rule to make target '%.y', needed by 'onefile.z'. Stop.
Run Code Online (Sandbox Code Playgroud)
使用通配符:
%.y: %.x some-other-script
touch $@
z: $(wildcard *.y) second-other-script
touch $@
Run Code Online (Sandbox Code Playgroud)
这也不起作用:它发现没有*.y文件并继续onefile.z跳过第一条规则。
$ make onefile.z
touch onefile.z
$ ls
a.x b.x onefile.z Makefile
Run Code Online (Sandbox Code Playgroud)
我可能可以将两个规则合并为一个,但在实际应用中,步骤更多,有些是通过 HTTP 发出请求,需要很长时间,而且实际上不应该无缘无故地重复。
有没有办法建立这样的依赖关系?
javascript ×2
makefile ×2
python ×2
css ×1
django ×1
gnu-make ×1
import ×1
inotify ×1
namespaces ×1
node.js ×1
postgresql ×1
pug ×1
python-mock ×1
satchless ×1
shell ×1
sql ×1
symlink ×1
templates ×1
unit-testing ×1