在Stoyan Stefanov的伟大着作"JavaScript Patterns"的第101页,他解释了沙盒模式.我很喜欢他的书,但我真的很想念一些现实生活中的例子,然后才能更好地理解他所谈论的内容. 像沙盒模式!
我正在寻找一个真实的工作实现,比如复制和粘贴起点,只是一个简单的例子,可以完全理解它.
有没有?
我试着按照这个教程:http: //docs.phonegap.com/en/2.7.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android
并得到以下错误:
05-08 15:35:59.845: E/dalvikvm(307): Could not find class 'android.webkit.WebResourceResponse', referenced from method org.apache.cordova.CordovaWebViewClient.getWhitelistResponse
Run Code Online (Sandbox Code Playgroud)
这里有一个人解释错误:https://issues.apache.org/jira/browse/CB-3041
This is a known issue. Because Android 2.3 does not have android.webkit.WebResourceResponse, this code is considered dead by Android 2.3's Dalvik. This means your whitelisting doesn't work properly like it does on Android 4.x, as per CB-2099. I'm going to keep this open, but lower the priority, since we know what causes it and it's an easy "First Bug" …Run Code Online (Sandbox Code Playgroud) 在shell上手动运行时工作得很好,但是当我设置一个cronjob在重启时运行它时,我得到"错误的变量名称".
#! /bin/sh
# /etc/init.d/duplicityCleanUp
export PASSPHRASE=foo
duplicity remove-older-than 30D --force --gio smb://remote/archiv/
duplicity remove-all-but-n-full 1 --force --gio smb://remote/archiv/
unset PASSPHRASE
Run Code Online (Sandbox Code Playgroud) 使用带有梨标准的codeniffer.我得到了超过20tsd错误导致行缩进.我使用制表位来缩进.我试图禁用该检查,但我失败了.
我从pearset标准的ruleset.xml中删除了通用标准的最后一条规则.然而,缩进仍被视为错误.
如何完全取消梨标准的缩进检查?
我想为Eclipse创建一个Google Closure Compiler插件.我已经有一个弹出菜单项,可以将JavaScript文件编译为其缩小版本.但是,如果每次保存*.js缩小版本都会自动生成,那将非常有用.我读/听过自然和建设者,延伸点和IResourceChangeListener.但我没有设法弄清楚我应该使用什么,特别是如何使它工作.
是否有一个插件的工作示例执行"相同类型的事情"所以我可以从那个或教程编写这样的?
在下面的答案中,我搜索了使用该项目的项目,IResourceChangeListener并提出了以下代码:
清单:http://codepaste.net/3yahwe
plugin.xml:http://codepaste.net/qek3rw
激活者:http://codepaste.net/s7xowm
DummyStartup:http://codepaste.net/rkub82
MinifiedJavascriptUpdater:http://codepaste.net/koweuh
有在MinifiedJavascriptUpdater.java保存用于该代码IResourceChangeListener的resourceChanged()功能从未达到.
我创建了一个eclipse插件,它将挂钩到save操作,用goolge闭包编译器创建一个缩小的javascript文件.见下面的文件.直到日食3.7.2才有效.不幸的是现在在eclipse 4.2.1中,它似乎有时会产生无限循环.作业"compile .min.js"(ResourceChangedListener.java中的第64行)似乎是原因.这导致了workspaced开始反复构建的情况.我想这是因为该作业创建或更改了再次触发工作区构建的文件,这又触发了触发构建的作业等等.但我无法弄清楚如何防止这种情况.
// Activator.java
package closure_compiler_save;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "closure-compiler-save"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
Activator.plugin = this;
ResourceChangedListener listener = new ResourceChangedListener();
ResourcesPlugin.getWorkspace().addResourceChangeListener(listener);
}
@Override
public …Run Code Online (Sandbox Code Playgroud) 我正在测试的类在更深的地方使用Redis:
<?php
class Publisher {
function publish($message) {
Redis::publish($message);
}
}
class Foo {
public function publishMessage() {
$message = $this->generateMessage();
$this->publish($message);
}
private function publish($message) {
$this->getPublisher()->publish($message);
}
// below just for testing
private $publisher;
public function getPublisher() {
if(empty($this->publisher) {
return new Publisher();
}
return $this->publisher;
}
public function setPublisher($publisher) {
$this->publisher = $publisher;
}
}
Run Code Online (Sandbox Code Playgroud)
现在我不知道该如何测试。当然,我不想测试Redis。我真正需要测试的是发送给Redis的消息是否符合我的期望。(我认为)我可以编写一个返回消息并公开的函数。但是我不喜欢那个主意。在此示例中,我可以设置发布者,因此在测试时我可以返回另一个发布者类。与其发送消息,不如将其保存在内部,以便稍后声明。
class Publisher {
public $message;
function publish($message) {
$this->message = $message;
}
}
Run Code Online (Sandbox Code Playgroud)
但是然后我不知道如何模拟Publisher类来更改方法。否则我将不得不继承Publisher类。同样,通过这种方式,我的测试类必须包含仅用于测试的代码。我也不喜欢。
我该如何正确测试?存在用于Redis的模拟库,但不支持发布。
假设我的 OpenAPI 定义有两个服务器。两者共享相同的变量。因此我想引用这些变量以防止重复代码。
实际上,我将 OpenAPI 分成文件并将其与swagger-cli bundle. 这就是它创建的:
openapi: 3.0.2
info:
title: My API
description: 'some description'
version: 1.0.0
servers:
- url: 'https://stage-api.domain.com/foo/{v1}/{v2}/{v3}'
description: Staging API server for QA
variables:
v1:
description: 'variable 1'
default: 'something'
enum:
- 'foo1'
- 'foo2'
v2:
description: 'variable 2'
default: 'something'
enum:
- 'foo1'
- 'foo2'
v3:
description: 'variable 3'
default: 'something'
enum:
- 'foo1'
- 'foo2'
- url: 'https://api.domain.com/foo/{v1}/{v2}/{v3}'
description: PRODUCTION API server
variables:
region:
$ref: '#/servers/0/variables/v1'
brand:
$ref: '#/servers/0/variables/v2'
locale: …Run Code Online (Sandbox Code Playgroud) 使用下面的原型代码,我将许多功能逐步添加到 osm 中。我正在加载大约 8500 个多边形特征。其中一些有很多坐标,所以总共大约有 150MB 的文本数据。一一加载它们会导致浏览器崩溃。分块加载它是有效的,但它也不快。特别是如果您想在加载完成后滚动或缩放。我有点不好意思一次性加载所有内容,因为这是 150MB 的数据。
我有哪些选择可以改善体验?需要明确的是:我不是在谈论加载本身。我在谈论具有特征的地图的渲染。
这是代码存根:
addToMap = function (id, totalCount) {
var idTo = id+99;
jQuery.get('getData.php', {id: id, idTo: idTo}, function (result) {
var geojson;
function onEachFeature(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
click: zoomToFeature
});
}
function resetHighlight(e) {
geojson.resetStyle(e.target);
info.update();
}
geojson = L.geoJson(result, {
style: getStyle,
onEachFeature: onEachFeature
}).addTo(map);
if (id < totalCount) {
jQuery('#count').html(idTo+' of '+totalCount);
addToMap(idTo+1, totalCount);
} else {
jQuery('#loader').remove();
}
}, 'json');
}
Run Code Online (Sandbox Code Playgroud) 我想用字符串键重写数组"foo"的数字键.该关系保存在另一个数组"bar"中.
$foo = array(
1 => 'foo',
2 => 'bar',
...
);
$bar = array(
1 => 'abc',
2 => 'xyz',
...
);
$result = array(
'abc' => 'foo',
'xyz' => 'bar',
...
);
Run Code Online (Sandbox Code Playgroud)
实现这一结果的最快方法是什么?
当您查看"aaaaa"时,会显示一个叠加层,当您尝试从叠加层中的选择中选择某些内容时.我怎么做到这一点?
只有在保留实际覆盖区域时才应关闭叠加层.
谢谢!
我正在尝试从 Maria 数据库中的 laravel 迁移创建此过程(来源: https: //mariadb.com/resources/blog/automatic-partition-maintenance-mariadb ):
DELIMITER $$
CREATE PROCEDURE db1.create_new_partitions(p_schema varchar(64), p_table varchar(64), p_months_to_add int)
LANGUAGE SQL
NOT DETERMINISTIC
SQL SECURITY INVOKER
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE current_partition_name varchar(64);
DECLARE current_partition_ts int;
-- We'll use this cursor later to check
-- whether a particular already exists.
-- @partition_name_to_add will be
-- set later.
DECLARE cur1 CURSOR FOR
SELECT partition_name
FROM information_schema.partitions
WHERE TABLE_SCHEMA = p_schema
AND TABLE_NAME = p_table
AND PARTITION_NAME != 'p_first'
AND PARTITION_NAME …Run Code Online (Sandbox Code Playgroud) wget https://some.url/with/a/file.txt
Run Code Online (Sandbox Code Playgroud)
No such file or directory尽管file.txt存在于该位置,但仍会返回(可通过浏览器下载)。运行命令的用户也可以写入保存到的目录。
eclipse ×3
javascript ×3
php ×3
java ×2
android ×1
arrays ×1
bash ×1
codesniffer ×1
cordova ×1
cron ×1
curl ×1
download ×1
file ×1
indentation ×1
jquery ×1
laravel ×1
laravel-5.5 ×1
leaflet ×1
line ×1
mariadb ×1
mocking ×1
mouseevent ×1
mysql ×1
openapi ×1
pear ×1
performance ×1
phpunit ×1
plugins ×1
redis ×1
sandbox ×1
save ×1
sorting ×1
sql ×1
swagger ×1
ubuntu ×1
unit-testing ×1
wget ×1