我花了一个下午的时间寻找世界上最重要城市的开放数据库,
其中大部分是高级的,花费400美元,但由于我正在开发一个开源项目,我想使用开放数据,是否有可以下载重要城市名称的地方?
我找到了开放的街道地图,但它是16gb的节点关系等东西,但我只需要城市名称和坐标,
非常感谢你,
G
我为facebook写了一个发送数据的插件testing-fb.local.如果用户已登录,则请求将通过.
这是工作流程:
testing-fb.local$.ajax()从Chrome扩展程序中触发
chrome.webRequest.onBeforeSendHeaderschrome.cookies.getSet-Cookies要发送的标头请求通过.
我写了这部分代码,应该是这样的:
function getCookies (callback) {
chrome.cookies.get({url:"https://testing-fb.local", name: "connect.sid"}, function(a){
return callback(a)
})
}
chrome.webRequest.onBeforeSendHeaders.addListener(
function(details) {
getCookies(function(a){
// Here something happens
})
},
{urls: ["https://testing-fb.local/*"]},
['blocking']);
Run Code Online (Sandbox Code Playgroud)
这是我的manifest.json:
{
"name": "test-fb",
"version": "1.0",
"manifest_version": 1,
"description": "testing",
"permissions": [
"cookies",
"webRequest",
"tabs",
"http://*/*",
"https://*/*"
],
"background": {
"scripts": ["background.js"]
},
"content_scripts": [
{
"matches": ["http://*.facebook.com/*", "https://*.facebook.com/*"],
"exclude_matches" : [
"*://*.facebook.com/ajax/*",
"*://*.channel.facebook.tld/*", …Run Code Online (Sandbox Code Playgroud) 我不确定在对象数组中使用indexOf
不起作用的代码是:
if (res.locals.company.companies.indexOf(req.query.companyId) >= 0) return next()
Run Code Online (Sandbox Code Playgroud)
if条件总是返回false.
我也在控制台测试过它实际上是错误的:
>> var zio = { __v: 1,
_id: '50bc0238049a1ff10b000001',
companies:
[ { _id: '50bc01938f164ee80b000001', name: 'Test' },
{ _id: '50bc01ac4e860ee90b000001', name: 'zio' } ],
}
>> zio.companies.indexOf("50bc01938f164ee80b000001")
-1
Run Code Online (Sandbox Code Playgroud)
而它应该是真的.
我应该使用任何神秘的下划线实用程序吗?
更新/澄清:我的目的是检查其中一个ID中是否存在50bc01938f164ee80b000001,我不需要知道它实际上在哪里.这非常重要!
Nodejs的解决方案或提示会很棒!
如何减少/简化此代码(或通常,具有多个输入的代码)?
do
sex <- askSex
name <- askName
sayHello sex name
Run Code Online (Sandbox Code Playgroud)
在这种情况下已经非常短,但当它达到多个输入时,它看起来很乱.有什么方法可以做以下事情:
sayHello askSex askName
Run Code Online (Sandbox Code Playgroud)
?
这是我的问题.我没有在使用express的情况下在节点中写东西,所以我发现很难用基本API创建服务器.
基本上我在互联网上找到的是:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
Run Code Online (Sandbox Code Playgroud)
但是我没有看到如何实现/index.html和/ getData.这段代码将在Raspberry派上运行,这就是我不应该使用库的原因.基本上我没有太多空间.
非常感谢,h
我有两个指令:
app.directive('uiElement', function () {
return {
restrict: 'A',
replace: true,
scope: {element: "=uiElement", search: "=search"},
templateUrl: "/views/uiElement.html",
link: function (scope, elem, attrs) {
scope.isImage = function () {
return (scope.element.type === 'image/png' || scope.element.type === 'image/jpeg');
};
scope.isList = function () {
return (scope.element.type === 'text/list');
};
scope.isTodo = function () {
return (scope.element.type === 'text/todo');
};
}
};
});
Run Code Online (Sandbox Code Playgroud)
以及相关的模板:
<article class="uiElement" ng-class="{typeImage: isImage(), typeList:isList(), typeTodo:isTodo()}" ng-switch on="element.type">
<div><div class="inside" ng-switch-when="image/png">
<i ui-image="element"></i>
</div></div>
<div><div class="inside" ng-switch-when="image/jpeg">
<i …Run Code Online (Sandbox Code Playgroud) 这是我的代码:
// assuming HashMap<String, Integer> hashmap
double sum = hashmap.values().stream()
.reduce(.0, (i, v) -> i + Math.pow(v,2) + 0.5 );
Run Code Online (Sandbox Code Playgroud)
在这种情况下,reduce应该采用(Integer i)和(double v)并将它们相加并将此reduce作为double返回.
相反,我得到这个错误:
- The method reduce(Integer, BinaryOperator<Integer>) in the type Stream<Integer> is not applicable for the arguments (double, (<no type> i, <no type> v) -> {})
- Type mismatch: cannot convert from double to Integer
Run Code Online (Sandbox Code Playgroud)
降低,
但是,这个修复:
// assuming HashMap<String, Integer> hashmap
double sum = hashmap.values().stream()
.map((t)->(double)t)
.reduce(.0, (i, v) -> i + Math.pow(v,2) + 0.5 );
Run Code Online (Sandbox Code Playgroud)
这样做有更优雅的方式吗?
我想有一个函数检查列表是否只包含偶数; 如果是这样,它应该返回True,否则 - False.
功能我想用的map/ filter/ foldr,可能没有length.
这是我的尝试:
ListOfeven :: [Integral] -> Bool
ListOfeven xs =
| foldr (+) True filter odd xs < 0 = True
| otherwise = False
Run Code Online (Sandbox Code Playgroud)
我很确定有一种更清洁的方式......不存在吗?:)
我无法使用角度js打印fb名称.我不确定出了什么问题.在下面的代码中,"no_name"被打印出来.JSON警报正确显示.
I have this view code trying to print l from the scope
<div ng-controller="TestCtrl">
{{n}}
</div>
This is the controller code:
function TestCtrl($scope){
$scope.n="no_name";// default value
FB.login(function(response) {// fb login as soon as the ui loads
if (response.authResponse) {
FB.api('/me', function(response) {
alert(JSON.stringify(response));
$scope.n=response.name;
});
} else {
//do nothing..
}
});
}
Run Code Online (Sandbox Code Playgroud) 在我的班上我定义:
private ArrayList<BlockObject> blocks;
Run Code Online (Sandbox Code Playgroud)
然后:
blocks.add(new BlockObject(x, y));
Run Code Online (Sandbox Code Playgroud)
但是我得到了这个错误
02-22 17:06:52.672: E/AndroidRuntime(479): Caused by: java.lang.NullPointerException
02-22 17:06:52.672: E/AndroidRuntime(479): at com.comp1008.hhh.uuu.Scenario.blocks(Scenario.java:41)
Run Code Online (Sandbox Code Playgroud)
有什么建议吗?