在我的OS X中使用swift遇到了这个错误:
"此应用程序正在从后台线程修改自动布局引擎,这可能导致引擎损坏和奇怪的崩溃.这将导致未来版本中的异常."
我有一个我的NSWindow,我正在交换contentView窗口的视图.当我尝试在窗口上执行操作时,或者在向窗口添加窗口时,我收到错误.尝试禁用自动调整大小的东西,我没有任何使用自动布局的东西.有什么想法吗?NSApp.beginSheetsubview
有时它很好,没有任何反应,有时它完全打破了我的UI负担
正确模拟以下示例的最佳方法是什么?
问题是在导入时间之后,foo保持对原始未引用的引用bar.
module.js:
export function bar () {
return 'bar';
}
export function foo () {
return `I am foo. bar is ${bar()}`;
}
Run Code Online (Sandbox Code Playgroud)
module.test.js:
import * as module from '../src/module';
describe('module', () => {
let barSpy;
beforeEach(() => {
barSpy = jest.spyOn(
module,
'bar'
).mockImplementation(jest.fn());
});
afterEach(() => {
barSpy.mockRestore();
});
it('foo', () => {
console.log(jest.isMockFunction(module.bar)); // outputs true
module.bar.mockReturnValue('fake bar');
console.log(module.bar()); // outputs 'fake bar';
expect(module.foo()).toEqual('I am foo. bar is fake bar');
/**
* …Run Code Online (Sandbox Code Playgroud) (这是完整的最小代表:https://github.com/magicmark/jest_question)
鉴于以下应用程序:
SRC/food.js
const Food = {
carbs: "rice",
veg: "green beans",
type: "dinner"
};
export default Food;
Run Code Online (Sandbox Code Playgroud)
SRC/food.js
import Food from "./food";
function formatMeal() {
const { carbs, veg, type } = Food;
if (type === "dinner") {
return `Good evening. Dinner is ${veg} and ${carbs}. Yum!`;
} else if (type === "breakfast") {
return `Good morning. Breakfast is ${veg} and ${carbs}. Yum!`;
} else {
return "No soup for you!";
}
}
export default …Run Code Online (Sandbox Code Playgroud) 这个问题似乎很无辜,因为我们可以阅读https://nodejs.org/api/http.html并发现以下选项:
server.requestTimeout = 1;
server.keepAliveTimeout = 1;
server.timeout = 1;
server.setTimeout(1);
Run Code Online (Sandbox Code Playgroud)
很简单,对吧?没那么快!
超时仅在进程中的请求处理程序接受请求后才开始计数。这很重要,因为在到达该点之前,请求可以在节点中排队的两个地方:
我似乎找不到任何允许我们设置超时的内置 API,这些超时在请求到达套接字时开始计数(我认为这是有道理的,Node 如何知道这种情况何时发生?)即使我们用TIME_SENT标头或允许我们在中间件中“手动”删除旧请求的东西,我们仍然需要等待一段时间才能解除阻塞进程。Node不能在带外为我们做这件事。
但也许我错了?有什么我想念的吗?
我们还有server.maxConnections:https : //nodejs.org/api/net.html#net_server_maxconnections
设置此属性以在服务器的连接数变高时拒绝连接
我们可能首先要设置的原因server.timeout是阻止请求队列在高峰时间建立。设置server.maxConnections也应该实现这个!
使用单个进程,此设置几乎可以满足我们的需求。
使用hello world 服务器(https://i.fluffy.cc/FvGQHxMfKGScFcSkJBw1MRVL7x7hplB3.html),我们可以运行:
for i in `seq 1 10`; do echo "${i}: "; curl localhost:8000 &; done
Run Code Online (Sandbox Code Playgroud)
这是一个与 curl 循环执行相同操作的脚本,但具有更高级的输出:
$ node test.js
?????????????????????????????????????????????????????????????????????????????????????????
? (index) ? success ? output ? timeTaken ?
????????????????????????????????????????????????????????????????????????????????????????? …Run Code Online (Sandbox Code Playgroud) 为了更准确,我理解为什么这在技术上发生 - 因为undefined它不是有效的JSON类型:
var breakfast = {
"cereal" : "fruit loops",
"pastry" : undefined
};
console.log(breakfast);
// -> { cereal: 'fruit loops', pastry: undefined }
console.log(JSON.stringify(breakfast));
// -> {"cereal":"fruit loops"}
Run Code Online (Sandbox Code Playgroud)
我的问题是 - 为什么这被认为是可接受的行为?我有理由想要将undefinedAPI作为API的一部分或其他任何内容传递.这似乎有些危险 - 为什么函数不会引发错误而不是肆无忌惮地在没有警告的情况下更改我的数据?这似乎是JS的一个运行线程.
有一个问题,通过添加空格我得到以下突出显示偏移怪异.这真的是预期的行为吗?
这似乎会影响Chrome/Safari
问题转载于此:https://jsfiddle.net/qsa99cc6/
CSS:
p:first-letter {
text-transform: uppercase;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<p>
highlight me! this won't work because there's whitespace in the <p>
</p>
<p>highlight me! This should work because there isn't</p>
Run Code Online (Sandbox Code Playgroud) 有人可能会想到下面的打印出来a,b,c.
var i, rowName;
for (i = 0; i < 3; i++, rowName = ['a', 'b', 'c'][i]) {
console.log(rowName);
}
Run Code Online (Sandbox Code Playgroud)
相反,但是,它打印出undefined,b,c.为什么?
澄清:我知道如何使这项工作; 我很好奇的是为什么以上不起作用.
尝试设置一个普通的 AWS RDS Aurora Serverless 实例。
现在,我只想直接从我的 PC 连接到它作为健全性检查,但我无法这样做。每次我通过 连接时$ mysql,它都会等待几分钟。然后我得到:
$ mysql -h <MY-DATABASE>.cluster-deadbeef.us-west-1.rds.amazonaws.com -P 3306 -u admin -p
ERROR 2003 (HY000): Can't connect to MySQL server on '<MY-DATABASE>.cluster-deadbeef.us-west-1.rds.amazonaws.com' (60)
Run Code Online (Sandbox Code Playgroud)
(nc也只是超时)
看起来我在某处建立了网络连接,但我不确定在哪里。
这是整个设置(认为我已经包含了所有相关内容?):
数据库实例:
$ aws rds describe-db-clusters --output json | jq '.DBClusters[0] | {AvailabilityZones, DBSubnetGroup, VpcSecurityGroups}'
{
"AvailabilityZones": [
"us-west-1c",
"us-west-1b"
],
"DBSubnetGroup": "default-vpc-0165fd69fae5d2569",
"VpcSecurityGroups": [
{
"VpcSecurityGroupId": "sg-051e6ad0fe8837a56",
"Status": "active"
}
]
}
Run Code Online (Sandbox Code Playgroud)
专有网络:
$ aws ec2 describe-vpcs --output json | jq '.Vpcs[0] | {VpcId, …Run Code Online (Sandbox Code Playgroud)const foo = () => 'foo!';
const doAThing = (
foo = foo
) => {
console.log(foo)
}
doAThing();
Run Code Online (Sandbox Code Playgroud)
给出以下内容:
/private/var/folders/xp/n5tbdrrs761ck82qqychcf61ptmq9d/T/CodeRunner/Untitled.js:4
foo = foo
^
ReferenceError: foo is not defined
at doAThing (/private/var/folders/xp/n5tbdrrs761ck82qqychcf61ptmq9d/T/CodeRunner/Untitled.js:4:8)
at Object.<anonymous> (/private/var/folders/xp/n5tbdrrs761ck82qqychcf61ptmq9d/T/CodeRunner/Untitled.js:9:1)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:423:7)
at startup (bootstrap_node.js:147:9)
Run Code Online (Sandbox Code Playgroud)
(如果我做它_foo = foo然后它工作.)为什么foo没有在我的例子中定义?
javascript ×6
jestjs ×2
amazon-ec2 ×1
amazon-rds ×1
amazon-vpc ×1
autolayout ×1
css ×1
ecmascript-6 ×1
html ×1
json ×1
loops ×1
macos ×1
mocking ×1
node.js ×1
swift ×1
tcp ×1
testing ×1
webkit ×1