该pod命令是否支持在给定项目中列出已安装的CococaPods的选项?pod list似乎显示所有已发布的pod 的列表.我在文档中查看过,但找不到这样做的方法.
我有一些像这样的结构化JSON数据.让我们假设这是可以互换的,通过JSON.parse():
[
{
"title": "pineapple",
"uid": "ab982d34c98f"
},
{
"title": "carrots",
"uid": "6f12e6ba45ec"
}
]
Run Code Online (Sandbox Code Playgroud)
我需要它看起来像这样,重新映射title到name,并uid以id与结果:
[
{
"name": "pineapple",
"id": "ab982d34c98f"
},
{
"name": "carrots",
"id": "6f12e6ba45ec"
}
]
Run Code Online (Sandbox Code Playgroud)
最明显的做法是这样的:
str = '[{"title": "pineapple","uid": "ab982d34c98f"},{"title": "carrots", "uid": "6f12e6ba45ec"}]';
var arr = JSON.parse(str);
for (var i = 0; i<arr.length; i++) {
arr[i].name = arr[i].title;
arr[i].id = arr[i].uid;
delete arr[i].title;
delete arr[i].uid;
}
Run Code Online (Sandbox Code Playgroud)
str = '[{"title": "pineapple","uid": "ab982d34c98f"},{"title": "carrots", "uid": "6f12e6ba45ec"}]'; …Run Code Online (Sandbox Code Playgroud)没有丝毫想到为什么会发生这种情况......
我相应地设置了一张桌子:
CREATE TABLE raw (
id SERIAL,
regtime float NOT NULL,
time float NOT NULL,
source varchar(15),
sourceport INTEGER,
destination varchar(15),
destport INTEGER,
blocked boolean
); ... + index and grants
Run Code Online (Sandbox Code Playgroud)
我已成功使用此表一段时间了,突然之后,以下插入不再有效..
INSERT INTO raw(
time, regtime, blocked, destport, sourceport, source, destination
) VALUES (
1403184512.2283964, 1403184662.118, False, 2, 3, '192.168.0.1', '192.168.0.2'
);
Run Code Online (Sandbox Code Playgroud)
错误是: ERROR: integer out of range
我的意思是comon ...甚至不确定从哪里开始调试这个..我不是没有磁盘空间而且错误本身有点谨慎..
如何将CGRect的大小增加一定的百分比值?我应该用某种形式CGRectInset来做吗?
例:
假设我有一个CGRect: {10, 10, 110, 110}
我想将它的大小(保持相同的中心点)增加20%:
{0, 0, 120, 120}
我在响应正文中遵循JSON格式
[
{
"Name" : "Prashant",
"City" : "Sydney"
},
{
"Name" : "Yogi",
"City" : "London"
}
]
Run Code Online (Sandbox Code Playgroud)
检查此数组是否有任何记录的更好方法是什么?如果是,则为第一个数组索引提供"名称".我正在为jMeter使用jp @ gc JSON提取器插件.
是否可以使用插件解析它或我需要使用正则表达式吗?
我需要创建一个代理从端口A到端口B的请求的应用程序.例如,如果用户在端口3000上连接,他将被路由(在引擎盖下)到端口3001,因此"原始"应用程序将在端口3001上运行但在客户端(浏览器)中,用户将输入端口3000.不重定向...
http://example.com:3000/foo/bar
将创建一个侦听端口3001的新服务器,所有呼叫实际上都是使用新服务器和新端口运行的端口3000.由于端口3000实际被占用,我的反向代理应用程序?我该怎么测试呢......
有没有办法测试这个以验证这是否有效,例如通过单元测试?
我发现这个模块https://github.com/nodejitsu/node-http-proxy可能会有所帮助.
function getCookies(){
request('http://google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(response.headers);
}
})
}
Run Code Online (Sandbox Code Playgroud)
结果
{ date: 'Fri, 11 Dec 2015 07:15:50 GMT',
expires: '-1',
'cache-control': 'private, max-age=0',
'content-type': 'text/html; charset=EUC-KR',
p3p: 'CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."',
server: 'gws',
'x-xss-protection': '1; mode=block',
'x-frame-options': 'SAMEORIGIN',
'set-cookie':
[ 'PREF=ID=1111111111111111:FF=0:TM=1449818150:LM=1449818150:V=1:S=Q3BB20FA6TkaZymd; expires=Thu, 31-Dec-2015 16:02:17 GMT; path=/; domain=.google.co.kr',
'NID=74=hnriWxk7N9jHtP5W0qgaxrwD1YuNKOmJg748ucxWilu9jaqHJVovfkYdvMr0tlp-VToID5cdTNDSXNXqr4M8umJ9traab67x2xZKfu3hJbsBRXeVvyiCOcwZ8bkXNcU4; expires=Sat, 11-Jun-2016 07:15:50 GMT; path=/; domain=.google.co.kr; HttpOnly' ],
'accept-ranges': 'none',
vary: 'Accept-Encoding',
connection: 'close' } …Run Code Online (Sandbox Code Playgroud) 我认为自己善于理解正则表达式; 这是第一次,我被困了,最后20分钟的谷歌搜索/搜索SO的答案没有产生任何结果.
考虑字符串:
var string = "Friends of mine are from France and they love to frolic."
Run Code Online (Sandbox Code Playgroud)
我想替换或捕获(或做某事)每次出现"fr"(不区分大小写).
我可以使用,简单地说:
var replaced = string.replace(/fr/gi);
Run Code Online (Sandbox Code Playgroud)
但是,如果我想忽略第一次出现的"fr"怎么办?通常我会使用积极的lookbehind(例如,(?<=.)fr在php中)来做这个,但我们的朋友javascript不这样做.如果没有安装第三方库,有没有办法确保我的表达式在行首不匹配?
更新:虽然有替换捕获的方法$1,我的特定用例就split()在这里,并且如果我使用类似@Explosion Pills的建议,则需要修复阵列string.replace(/^(fr)|fr/gi, "$1");
我正在使用以下函数从种子点生成指定半径内的随机地理坐标:
function randomGeo(center, radius) {
var y0 = center.latitude;
var x0 = center.longitude;
var rd = radius / 111300;
var u = Math.random();
var v = Math.random();
var w = rd * Math.sqrt(u);
var t = 2 * Math.PI * v;
var x = w * Math.cos(t);
var y = w * Math.sin(t);
var xp = x / Math.cos(y0);
return {
'latitude': y + y0,
'longitude': xp + x0
};
}
Run Code Online (Sandbox Code Playgroud)
我使用2000米半径和以下种子点在循环中多次执行此操作:
location: { // Oxford
latitude: 51.73213,
longitude: -1.20631 …Run Code Online (Sandbox Code Playgroud) javascript ×4
ios ×2
json ×2
node.js ×2
regex ×2
arrays ×1
cgrect ×1
cocoapods ×1
cookies ×1
express ×1
geolocation ×1
integer ×1
jmeter ×1
node-request ×1
objective-c ×1
parsing ×1
postgresql ×1
swift ×1
xcode7 ×1