如何从函数内部调用函数,使其变为递归?这是我的代码,我添加了一个注释,我想开始递归:
$('a.previous-photos, a.next-photos').click(function() {
var id = $('#media-photo img').attr('id');
var href = $(this).attr('href');
href = href.split('/');
var p = href[href.length - 1];
var url = '/view/album-photos/id/' + id + '/p/' + p;
$.get(url, function(data) {
$('.box-content2').replaceWith('<div class="box-content2"' + data + '</div>');
});
// here I want to call the function again
return false;
});
Run Code Online (Sandbox Code Playgroud) 解决了:
此URI有效:
/controller/action?ret=%2F
Run Code Online (Sandbox Code Playgroud)
我想将另外的"/"参数传递给控制器操作.所以我这样做了:
$par1 = urlencode('/');
$this->_redirect('/controller/action/par1/' . $par1);
Run Code Online (Sandbox Code Playgroud)
但我收到此错误消息:
Not Found
The requested URL /controller/action/ret// was not found on this server.
Run Code Online (Sandbox Code Playgroud)
当我在没有任何参数或参数"aaa"的情况下调用控制器动作时,它可以工作.这些URI有效:
/controller/action
/controller/action/par1/aaa
/controller/action/par1/jfhsdajkhfui454fs
/controller/action/par1
/controller/action/par1/
Run Code Online (Sandbox Code Playgroud)
您可以将http://example.com放在上面的所有相对URI之前,它们是相同的.
我需要在Silverlight应用程序中显示一些基本的HTML(只是一些段落,无序列表和超链接).我该怎么办呢?
使用哪种控件?
EDIT2:
新训练集......
输入:
[
[0.0, 0.0],
[0.0, 1.0],
[0.0, 2.0],
[0.0, 3.0],
[0.0, 4.0],
[1.0, 0.0],
[1.0, 1.0],
[1.0, 2.0],
[1.0, 3.0],
[1.0, 4.0],
[2.0, 0.0],
[2.0, 1.0],
[2.0, 2.0],
[2.0, 3.0],
[2.0, 4.0],
[3.0, 0.0],
[3.0, 1.0],
[3.0, 2.0],
[3.0, 3.0],
[3.0, 4.0],
[4.0, 0.0],
[4.0, 1.0],
[4.0, 2.0],
[4.0, 3.0],
[4.0, 4.0]
]
Run Code Online (Sandbox Code Playgroud)
输出:
[
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[0.0],
[1.0],
[1.0],
[0.0],
[0.0],
[0.0], …Run Code Online (Sandbox Code Playgroud) Python中哪种压缩方法具有最佳压缩率?
常用的zlib.compress()是最好的还是有更好的选择?我需要获得最佳的压缩比.
我正在压缩字符串并通过UDP发送它们.压缩的典型字符串大约有1,700,000个字节.
它有效,但有点问题.当有多个小的可放置区域彼此靠近(15x15px)并且我想在正确的容器中丢弃150x150px可拖动项目时,很难做到正确.
有没有办法让可拖动项目在当前光标位置下降?
然后,我可以使用cursorAt将光标指定为可拖动项目之外,并且很容易"瞄准"它以纠正可放置区域.
是否有比JPEG更快但仍受到良好支持的压缩算法?我知道jpeg2000,但据我所知,它并没有那么快.
编辑:用于压缩.
Edit2:它应该在Linux 32位上运行,理想情况下它应该是C或C++.
所以我在Zend Framework 2中使用了根据Jason Grimes的turorial(http://www.jasongrimes.org/2012/01/using-doctrine-2-in-zend-framework-2/)配置的Doctrine 2模块.
有时我会不断收到此错误:
Your proxy directory must be writable.
Run Code Online (Sandbox Code Playgroud)
如何设置代理目录?
这是我在module.config.php中的Doctrine配置:
'doctrine' => array(
'driver' => array(
__NAMESPACE__ . '_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity')
),
'orm_default' => array(
'drivers' => array(
__NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver'
),
),
),
),
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Behat进行BDD测试.在Jenkins上运行构建时,我希望Behat在Web服务器中打开PHP的构建,然后在运行测试后关闭它.怎么做?
基本上我需要运行:
php -S localhost:8000
Run Code Online (Sandbox Code Playgroud)
在我的BDD测试中,我试过:
/**
* @Given /^I call "([^"]*)" with email and password$/
*/
public function iCallWithPostData($uri)
{
echo exec('php -S localhost:8000');
$client = new Guzzle\Service\Client();
$request = $client->post('http://localhost:8000' . $uri, array(), '{"email":"a","password":"a"}')->send();
$this->response = $request->getBody(true);
}
Run Code Online (Sandbox Code Playgroud)
但是当运行Behat时它会被卡住而没有任何消息.
假设我在S3上有不同大小的图像:
137ff24f-02c9-4656-9d77-5e761d76a273.webp
137ff24f-02c9-4656-9d77-5e761d76a273_500_300.webp
137ff24f-02c9-4656-9d77-5e761d76a273_400_280.webp
Run Code Online (Sandbox Code Playgroud)
我使用boto删除单个文件:
bucket = get_s3_bucket()
s3_key = Key(bucket)
s3_key.key = '137ff24f-02c9-4656-9d77-5e761d76a273.webp'
bucket.delete_key(s3_key)
Run Code Online (Sandbox Code Playgroud)
但是我想删除所有以137ff24f-02c9-4656-9d77-5e761d76a273开头的密钥.
请记住,存储桶中可能有数百个文件,因此我不想迭代所有文件.有没有办法只删除以某些字符串开头的文件?
也许一些正则表达式删除功能.
php ×3
python ×3
compression ×2
jquery ×2
algorithm ×1
amazon-s3 ×1
behat ×1
boto ×1
c ×1
c++ ×1
doctrine-orm ×1
javascript ×1
jenkins ×1
jquery-ui ×1
math ×1
silverlight ×1