我需要找到所有值相等的数组.最快的方法是什么?我应该遍历它并只是比较值吗?
['a', 'a', 'a', 'a'] // true
['a', 'a', 'b', 'a'] // false
Run Code Online (Sandbox Code Playgroud) Facebook最近推出了Instagram Graph API,它允许从连接到Facebook公司页面的Instagram页面获取数据,Instagram.com/ developers说:
在Instagram的图形API是目前提供给所有开发.
对于非商业Instagram帐户,请继续使用现有的Instagram API.
因此,例如,如果我的公司有帐户instagram.com/my_first_company,我只能检索其Feed而不是其他人.
从旧的API文档中,使用旧的Instagram API来检索public_content权限(访问任何Feed)也不再是一个选项:
public_content - 代表用户阅读任何公开的个人资料信息和媒体(不再接受申请)
public_content权限的现有工具会发生什么?(例如,有各种CMS的插件,可以显示最近的Instagram照片)public_content(访问任何Feed)(除了获取Instagram网站的HTML页面)?UPD.似乎有一个?__a=1端点允许访问任何没有任何令牌的公共源的近期照片.但这不是官方的,没有人知道Instagram何时/是否会关闭它.如果你这样做 - 请告诉我.
UPD 2. Instagram删除了?__a=1端点,不确定多久,可能永远.目前访问Instagram Feed的唯一方法是废弃instagram.com网站,这是一个恐怖.
我有一个像这样的结构:
folder/
folder/subfolder/
Run Code Online (Sandbox Code Playgroud)
我想从文件夹/中排除所有内容,除了文件夹/子文件夹/.
我有什么办法和杰基尔这样做吗?我尝试了几种组合,但都不起作用,例如:
exclude: ["folder"]
include: ["folder/subfolder"]
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
以这种方式编写插件是好事还是坏事(使用类和原型),这些代码有什么不妥之处?
function PluginName(jqueryObject, options) {
}
PluginName.prototype = {
publicMethod:function() {
},
_privateMethod:function() {
}
}
// Initializing
var myPluginInstance = new PluginName($(".mySelector"), {myOption:1});
myPluginInstance.publicMethod();
Run Code Online (Sandbox Code Playgroud) 据我所知,使用translate3d()时启用了iOS设备上的硬件加速.那么为什么对jsperf的这个测试显示使用css left/top更快?
我知道要通过管理员启用日志记录,您可以执行以下操作:
系统>配置>高级>开发人员>日志设置>启用
但有没有办法通过数据库启用它?因为我无权访问管理员.
有一个包含许多小行和列的网格,如下所示:
项目将被放置在其中,例如:
网格是用类似的东西创建的:
grid-template-rows: repeat(auto-fill, 10px);
grid-template-columns: repeat(auto-fill, 10px);
Run Code Online (Sandbox Code Playgroud)
问题
repeat(auto-fill, 10px)?也许应该使用百分比来代替 ( repeat(auto-fill, 1%)),或者用什么来代替auto-fill?或者最好通过 JavaScript 执行此操作(高度到容器,左/上到项目)?
我试图通过缓冲区将图像数据从Jimp图像对象传递到 Tesseract (ocr lib):
image.getBufferAsync('image/png').then((buffer) => {
// Buffer here is <Buffer 12 34 56 ...
const worker = new TesseractWorker();
worker.recognize(buffer)
.then((result) => { console.log('result', result.text); });
});
Run Code Online (Sandbox Code Playgroud)
Teserract 抛出一个错误,表示它需要 Uint8Array 而不是 buffer
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received <Buffer 89 50 4e 47...
Run Code Online (Sandbox Code Playgroud)
所以我尝试将 buffer 转换为 Uint8Array:
buffer = new Uint8Array(buffer);
Run Code Online (Sandbox Code Playgroud)
但我收到另一个错误:
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received …Run Code Online (Sandbox Code Playgroud) 有一个基本的 Formik 形式:
<Formik
initialValues={{ email: '', color: 'red', firstName: '' }}
onSubmit={(values, actions) => {
setTimeout(() => {
alert(JSON.stringify(values, null, 2));
actions.setSubmitting(false);
}, 1000);
}}
render={props => (
<form onSubmit={props.handleSubmit}>
<Field type="email" name="email" placeholder="Email" />
<div>other inputs ... </div>
<button type="submit">Submit</button>
</form>
)}
/>
Run Code Online (Sandbox Code Playgroud)
当其中的任何输入发生更改(不是提交,而是更改)时 - 我需要更新<Formik />. “外部”组件应该接收所有表单数据。
有没有什么方法可以做到这一点,而无需为表单的每个单独输入添加单独的更改处理程序?或者解决方案是尝试将“外部”组件插入其中<Formik />?
我有一个水平滚动元素(带有overflow-x:scroll),其中包含包含弹性项目的弹性容器。我正在尝试将背景应用于柔性容器。
但正如您在下面的示例中看到的(尝试向左/向右滚动),背景仅应用于视口的可见部分(橙色)。有没有什么方法可以将其扩展到全宽,而不必为每个颜色着色.item?
.list-container {
width: 100%;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
background: tomato;
margin-bottom: 10px;
}
.item {
flex: 0 0 100px;
height: 100px;
margin-right: 10px;
background-color: skyblue;
opacity: 0.6;
}
.crop-container {
width: 300px;
overflow-x: scroll;
}
.item:first-child {
margin-left: 10px;
}
.item:last-child {
margin-right: 10px;
}Run Code Online (Sandbox Code Playgroud)
<div class='crop-container'>
<div class='list-container'>
<div class='item'></div>
<div class='item'></div>
<div class='item'></div>
<div class='item'></div>
<div class='item'></div>
<div class='item'></div>
<div class='item'></div>
</div>
<div class='list-container'>
<div class='item'></div>
<div class='item'></div>
<div class='item'></div> …Run Code Online (Sandbox Code Playgroud)