所以我需要在用户给出(或拒绝)使用麦克风的权限后调用某个函数.
我已经看到了这个:
[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
if (granted) {
// Microphone enabled code
[self someFunction];
}
else {
// Microphone disabled code
}
}];
Run Code Online (Sandbox Code Playgroud)
但是,这仅用于检测当前状态.
如果当前状态为"no"并且弹出窗口显示且用户提供权限 - 则不会调用该函数.那是因为在执行此操作的那一刻,权限是"否",直到我们下次运行代码时才会调用该函数.
我想要做的是在用户按下"允许"或"拒绝"后调用一个函数.
谁知道怎么做?
编辑:忘了提它它必须是iOS 7.0兼容的解决方案.
有没有办法采用像下面这样的有效 JSON 模式并将其转换为猫鼬模式?
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "some desc",
"title": "Product",
"type": "object",
"properties": {
"endpoints": {
"type": "array",
"items": {
"type": "string"
}
},
"poi": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location_name": {
"type": "string"
},
"distance": {
"type": "string"
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这对我来说似乎非常基本和简单,但我没有在网上找到任何东西。
有很多关于如何获取 JSON 模式的示例,还有很多如何从这样的对象创建 mongoose 模式的示例:
const newSchema = new mongoose.Schema({ name: String });
如果我尝试直接放置 JSON 模式,则会出现错误
node_modules/mongoose/lib/schema.js:674
throw new TypeError('Undefined type `' + name + '` at `' + …Run Code Online (Sandbox Code Playgroud) 我每秒只能用这个模型进行 2-3 次预测,速度非常慢。使用LinearRegression模型时,我可以轻松实现 40 倍的加速。
我正在使用scikit-learnpython 包和一个非常简单的数据集,其中包含 3 列(day、hour和result),所以基本上有 2 个功能。
day和hour是分类变量。
自然有7类day和24hour类。
训练样本相对较小(cca 5000 个样本)。
训练它只需要一露秒。
但当我继续预测某事时,速度就非常慢。
所以我的问题是:这是基本特征吗?RandomForrestRegressor或者我实际上可以对此做些什么?
from sklearn.ensemble import RandomForestRegressor
model = RandomForestRegressor(n_estimators=100,
max_features='auto',
oob_score=True,
n_jobs=-1,
random_state=42,
min_samples_leaf=2)
Run Code Online (Sandbox Code Playgroud) 我使用PostgreSQL 9.4我有一个名为表列timerange,并希望写一个SELECT查询将返回的时间范围在两个单独的列time_start和time_end.我试图像数组一样处理它,但它不起作用:
select *, timerange[0] as t_start from schedules;
当前表格:
| id | - - - - - - - - - - -时间范围 - - - - - - - - - - - - - - ----------- |
| ---- | -------------------------------------------- ------------------------------ |
| 1 | ["2017-05-05 19:00:00 + 02","2017-05-05 21:00:00 + 02")|
| 2 | ["2017-05-05 19:00:00 + 02","2017-05-05 21:00:00 + 02")|
所需表格:
| id | -------- -------------- …
date-range ×1
datetime ×1
ios ×1
jsonschema ×1
microphone ×1
mongoose ×1
node.js ×1
objective-c ×1
permissions ×1
postgresql ×1
python ×1
schema ×1
scikit-learn ×1
sql ×1