Twitter Rate Limit json - twitter

I am still relatively new to Twitter development. so this is probably a stupid question.
I am looking at a Twitter API library, and they have rate limit defined in the resource file
<data name="QueryRateLimit" xml:space="preserve">
<value>https://api.twitter.com/1.1/application/rate_limit_status.json</value>
what exactly does https://api.twitter.com/1.1/application/rate_limit_status.json do and what is it used for in the application?
Because if you just open a browser, and copy and past this link, you get authentication error, as expected. But if your request is authenticated, does that mean the json will return a certain set of values map to the rate limit of the session?
All tips and help are greatly appreciated.
Thanks
What

According to the documentation you will get something like this:
{
"rate_limit_context": {
"access_token": "119476949-oYGCs2M5duG5QalbOAK2YUZh8zG3ur7DPYo5qIFN"
},
"resources": {
"help": {
"/help/privacy": {
"remaining": 15,
"reset": 1346439527,
"limit": 15
},
"/help/configuration": {
"remaining": 15,
"reset": 1346439527,
"limit": 15
},
"/help/tos": {
"remaining": 15,
"reset": 1346439527,
"limit": 15
},
"/help/languages": {
"remaining": 15,
"reset": 1346439527,
"limit": 15
}
},
"statuses": {
"/statuses/oembed": {
"remaining": 180,
"reset": 1346439527,
"limit": 180
},
"/statuses/user_timeline": {
"remaining": 180,
"reset": 1346439527,
"limit": 180
},
"/statuses/mentions_timeline": {
"remaining": 15,
"reset": 1346439527,
"limit": 15
},
"/statuses/home_timeline": {
"remaining": 15,
"reset": 1346439527,
"limit": 15
},
"/statuses/show/:id": {
"remaining": 180,
"reset": 1346439527,
"limit": 180
},
"/statuses/retweets/:id": {
"remaining": 15,
"reset": 1346439527,
"limit": 15
}
},
"users": {
"/users/show": {
"remaining": 180,
"reset": 1346439527,
"limit": 180
},
"/users/search": {
"remaining": 180,
"reset": 1346439527,
"limit": 180
},
"/users/suggestions": {
"remaining": 15,
"reset": 1346439527,
"limit": 15
},
"/users/contributors": {
"remaining": 15,
"reset": 1346439527,
"limit": 15
},
"/users/suggestions/:slug/members": {
"remaining": 15,
"reset": 1346439527,
"limit": 15
},
"/users/suggestions/:slug": {
"remaining": 15,
"reset": 1346439527,
"limit": 15
},
"/users/contributees": {
"remaining": 15,
"reset": 1346439527,
"limit": 15
},
"/users/lookup": {
"remaining": 180,
"reset": 1346439527,
"limit": 180
}
},
"search": {
"/search/tweets": {
"remaining": 180,
"reset": 1346439527,
"limit": 180
}
}
}
}

Related

Detox: iOS unable to Match className

In Detox I setup an expectation by label for 'SIGN IN', which returns 'Multiple Elements Found...'. However, when I try to filter it out by type I get the following error
DetoxRuntimeError: Test Failed: No elements found for “MATCHER(class ⊇
“RCTTextView”)”
Below is the elements I get when I use by.label('SIGN IN').getAttributes(). Even thought one of the elements contains RCTTextView it still can't be found.
{
"elements": [
{
"layer": "<CALayer: 0x600002d5c0c0>",
"hittable": true,
"elementSafeBounds": {
"y": 0,
"x": 0,
"width": 339,
"height": 39.5
},
"enabled": true,
"activationPoint": {
"x": 169.5,
"y": 19.75
},
"elementFrame": {
"y": 331.5,
"x": 18,
"width": 339,
"height": 39.5
},
"visible": true,
"label": "SIGN IN",
"className": "RCTView",
"safeAreaInsets": {
"right": 0,
"top": 0,
"left": 0,
"bottom": 0
},
"frame": {
"y": 351.5,
"x": 18,
"width": 339,
"height": 39.5
},
"normalizedActivationPoint": {
"x": 0.5,
"y": 0.5
},
"elementBounds": {
"y": 0,
"x": 0,
"width": 339,
"height": 39.5
}
},
{
"safeAreaInsets": {
"right": 0,
"top": 0,
"left": 0,
"bottom": 0
},
"enabled": true,
"visible": true,
"frame": {
"y": 351.5,
"x": 18,
"width": 339,
"height": 39.5
},
"elementBounds": {
"y": 0,
"x": 0,
"width": 339,
"height": 39.5
},
"elementFrame": {
"y": 0,
"x": 0,
"width": 339,
"height": 39.5
},
"layer": "<CALayer: 0x600002d5c5e0>",
"className": "RCTView",
"label": "SIGN IN",
"activationPoint": {
"x": 169.5,
"y": 19.75
},
"normalizedActivationPoint": {
"x": 0.5,
"y": 0.5
},
"hittable": true,
"elementSafeBounds": {
"y": 0,
"x": 0,
"width": 339,
"height": 39.5
}
},
{
"visible": true,
"frame": {
"y": 351.5,
"x": 18,
"width": 339,
"height": 39.5
},
"activationPoint": {
"x": 169.5,
"y": 19.75
},
"enabled": true,
"elementSafeBounds": {
"y": 0,
"x": 0,
"width": 339,
"height": 39.5
},
"hittable": true,
"label": "SIGN IN",
"normalizedActivationPoint": {
"x": 0.5,
"y": 0.5
},
"layer": "<CALayer: 0x600002d5cc80>",
"safeAreaInsets": {
"right": 0,
"top": 0,
"left": 0,
"bottom": 0
},
"elementBounds": {
"y": 0,
"x": 0,
"width": 339,
"height": 39.5
},
"className": "RCTView",
"elementFrame": {
"y": 0,
"x": 0,
"width": 339,
"height": 39.5
}
},
{
"enabled": true,
"visible": true,
"label": "SIGN IN",
"normalizedActivationPoint": {
"x": 0.5,
"y": 0.5
},
"frame": {
"y": 359.5,
"x": 155.5,
"width": 64,
"height": 24
},
"elementFrame": {
"y": 8,
"x": 137.5,
"width": 64,
"height": 24
},
"elementBounds": {
"y": 0,
"x": 0,
"width": 64,
"height": 24
},
"safeAreaInsets": {
"right": 0,
"top": 0,
"left": 0,
"bottom": 0
},
"className": "RCTTextView",
"activationPoint": {
"x": 32,
"y": 12
},
"elementSafeBounds": {
"y": 0,
"x": 0,
"width": 64,
"height": 24
},
"layer": "<CALayer: 0x600002c925c0>",
"hittable": true
}
]
}
What should I look into in order to fix the element type matcher?

Highchart-export-server not showing plot band correctly on chart

Plot bands in highchart export server is not working properly. I want the output same as shown in jsfiddle below.
I want the color plot band to show on y axis with width 20.
This is expected output: https://jsfiddle.net/vc6r8y3n/
Attached image is actual output when we use high-chart export server.
but when I tried same JavaScript json object on
http://export.highcharts.com/
its giving me image with plot band color spread on whole chart. its not considering width for 'y' or 'x' axis in export server. I gave attached image of export chart.
Why highchart behaving differently in both the cases.
Highchart JSON is same as in JSfiddle.
Actual image.
Expected is what it display in Jsfiddle. https://jsfiddle.net/vc6r8y3n/
{
"chart": {
"height": 350,
"width": 600,
"style": {
"fontFamily": "\"Arial\", sans-serif",
"fontSize": "16px"
},
"backgroundColor": "transparent"
},
"title": {
"text": null
},
"credits": {
"enabled": false
},
"legend": {
"align": "center",
"layout": "horizontal",
"verticalAlign": "bottom",
"symbolHeight": 5,
"symbolWidth": 5,
"symbolRadius": 0,
"itemDistance": 10,
"itemStyle": {
"fontSize": "5px",
"fontWeight": "bold",
"fontFamily": "\"Arial\", sans-serif"
},
"borderWidth": 0,
"padding": 0,
"margin": 5
},
"xAxis": {
"categories": [
"Sep-2020",
"Oct-2020",
"Nov-2020",
"Dec-2020",
"Jan-2021",
"Feb-2021"
],
"labels": {
"style": {
"fontSize": "4px",
"fontFamily": "\"Arial\", sans-serif",
"color": "#000"
},
"y": 5
},
"gridLineColor": "transparent",
"gridLineWidth": 0,
"minorGridLineWidth": 0,
"lineColor": "#9A9A9A",
"zIndex": 9999999
},
"yAxis": [
{
"title": {
"text": ""
},
"min": 0,
"max": 100,
"tickInterval": 20,
"plotBands": [
{
"color": "rgb(204,0,0)",
"from": 0,
"to": 30.99,
"zIndex": 3
},
{
"color": "rgb(226,113,113)",
"from": 31,
"to": 44.99,
"zIndex": 3
},
{
"color": "rgb(247,209,34)",
"from": 45,
"to": 54.99,
"zIndex": 3
},
{
"color": "rgb(136,207,136)",
"from": 55,
"to": 68.99,
"zIndex": 3
},
{
"color": "rgb(68,180,68)",
"from": 69,
"to": 87.99,
"zIndex": 3
},
{
"color": "rgb(0,153,0)",
"from": 88,
"to": 100,
"zIndex": 3
}
],
"width": 20
}
],
"plotOptions": {
"column": {
"dataLabels": {
"enabled": true
}
}
},
"series": [
{
"name": "Line1",
"type": "column",
"data": [
{
"y": 61,
"color": "#5b9bd5"
},
{
"y": 41,
"color": "#5b9bd5"
},
{
"y": 21,
"color": "#5b9bd5"
},
{
"y": 81,
"color": "#5b9bd5"
},
{
"y": 31,
"color": "#5b9bd5"
},
{
"y": 71,
"color": "#5b9bd5"
}
],
"color": "#5b9bd5",
"showInLegend": true
},
{
"name": "Line 2",
"type": "column",
"data": [
null,
null,
null,
null,
null,
1
],
"color": "#00B050"
},
{
"name": "Line 3",
"type": "spline",
"data": [
null,
{
"y": 45
},
{
"y": 38
},
{
"y": 32
},
{
"y": 40
},
{
"y": 48
}
],
"color": "#9A0229"
}
]
}
enter image description here

JSON decoding in Flutter

I am currently working on a health application and i don't know how to decode this sample json using flutter. I want to extract "heartRateZones" list.
{
"activities-heart": [{
"dateTime": "2015-08-04",
"value": {
"customHeartRateZones": [],
"heartRateZones": [{
"caloriesOut": 740.15264,
"max": 94,
"min": 30,
"minutes": 593,
"name": "Out of Range"
}, {
"caloriesOut": 249.66204,
"max": 132,
"min": 94,
"minutes": 46,
"name": "Fat Burn"
}, {
"caloriesOut": 0,
"max": 160,
"min": 132,
"minutes": 0,
"name": "Cardio"
}, {
"caloriesOut": 0,
"max": 220,
"min": 160,
"minutes": 0,
"name": "Peak"
}],
"restingHeartRate": 68
}
}]
}
Please Help...
JSON is hosted at https://api.myjson.com/bins/g05ga .
According to the documentation, you should use json.decode and you will be able to extract what you want.
You can then use it somehow like this activities-heart.value.heartRateZones

Find minimum weighted spanning tree in Neo4j graph

I have drawn a graph in neo4j which have following nodes:
Driver
School
Students
Which have following conditions:
A driver is connected to all students by 'connects' relationship with 'distance' as attribute
Each Student is connected to each other by same 'connects' relationship with same 'distance' attribute
Each Student is also connected on one School by same 'connects' relationship with same 'distance' attribute
Now I want to get the minimum path that driver will cover to reach to school with N number students. For that, I am using neo4j predefined procedures(Algorithms):
MATCH (n:Driver{name:"Driver2"}),(s:student),(sc:school),(n)-[c:connects]->
(s),(s)-[d:connects]->(sc) CALL
algo.spanningTree.minimum('students','connects','distance',ID(n)) YIELD
loadMillis, computeMillis, writeMillis, effectiveNodeCount
RETURN loadMillis, computeMillis, writeMillis, effectiveNodeCount
which gives result like this:
[
{
"keys": [
"loadMillis",
"computeMillis",
"writeMillis",
"effectiveNodeCount"
],
"length": 4,
"_fields": [
{
"low": 5,
"high": 0
},
{
"low": 1,
"high": 0
},
{
"low": 0,
"high": 0
},
{
"low": 1,
"high": 0
}
],
"_fieldLookup": {
"loadMillis": 0,
"computeMillis": 1,
"writeMillis": 2,
"effectiveNodeCount": 3
}
},
{
"keys": [
"loadMillis",
"computeMillis",
"writeMillis",
"effectiveNodeCount"
],
"length": 4,
"_fields": [
{
"low": 5,
"high": 0
},
{
"low": 0,
"high": 0
},
{
"low": 0,
"high": 0
},
{
"low": 1,
"high": 0
}
],
"_fieldLookup": {
"loadMillis": 0,
"computeMillis": 1,
"writeMillis": 2,
"effectiveNodeCount": 3
}
},
{
"keys": [
"loadMillis",
"computeMillis",
"writeMillis",
"effectiveNodeCount"
],
"length": 4,
"_fields": [
{
"low": 4,
"high": 0
},
{
"low": 0,
"high": 0
},
{
"low": 0,
"high": 0
},
{
"low": 1,
"high": 0
}
],
"_fieldLookup": {
"loadMillis": 0,
"computeMillis": 1,
"writeMillis": 2,
"effectiveNodeCount": 3
}
},
{
"keys": [
"loadMillis",
"computeMillis",
"writeMillis",
"effectiveNodeCount"
],
"length": 4,
"_fields": [
{
"low": 4,
"high": 0
},
{
"low": 0,
"high": 0
},
{
"low": 0,
"high": 0
},
{
"low": 1,
"high": 0
}
],
"_fieldLookup": {
"loadMillis": 0,
"computeMillis": 1,
"writeMillis": 2,
"effectiveNodeCount": 3
}
}
]
MY QUESTION IS: How to interpret this data? and if it not the right way then which Neo4j procedure(algo) should i use?

Parsing JSON with Ruby on Rails

I suspect this is a fairly basic concept, but two days of trial and error, google searches, and random keyboard mashing have worn me down. I'm attempting to parse JSON returned from a URL, but I'm running into an issue that I suspect is related to the array inside the JSON.
What am I doing wrong?
JSON:
{
"HotelInformationResponse": {
"#hotelId": "106347",
"customerSessionId": "0ABAA83F-4430-B291-3432-E0A2DC790CA0",
"HotelImages": {
"#size": "16",
"HotelImage": [
{
"hotelImageId": 4694179,
"name": "",
"category": 1,
"type": 0,
"caption": "Exterior",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_44_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_44_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694182,
"name": "",
"category": 2,
"type": 0,
"caption": "Lobby",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_47_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_47_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694171,
"name": "",
"category": 2,
"type": 0,
"caption": "Lobby",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_36_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_36_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694174,
"name": "",
"category": 2,
"type": 0,
"caption": "Lobby",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_39_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_39_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694168,
"name": "",
"category": 3,
"type": 0,
"caption": "Guest Room",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_33_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_33_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694173,
"name": "",
"category": 3,
"type": 0,
"caption": "Guest Room",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_38_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_38_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694177,
"name": "",
"category": 3,
"type": 0,
"caption": "Guest Room",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_42_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_42_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694165,
"name": "",
"category": 10,
"type": 0,
"caption": "Restaurant",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_30_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_30_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694166,
"name": "",
"category": 10,
"type": 0,
"caption": "Restaurant",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_31_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_31_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 6601500,
"name": "",
"category": 11,
"type": 0,
"caption": "Interior",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_56_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_56_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694176,
"name": "",
"category": 12,
"type": 0,
"caption": "Pool",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_41_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_41_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694170,
"name": "",
"category": 12,
"type": 0,
"caption": "Pool",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_35_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_35_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694172,
"name": "",
"category": 12,
"type": 0,
"caption": "Pool",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_37_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_37_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694180,
"name": "",
"category": 21,
"type": 0,
"caption": "Lounge/Bar",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_45_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_45_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694181,
"name": "",
"category": 21,
"type": 0,
"caption": "Lounge/Bar",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_46_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_46_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
},
{
"hotelImageId": 4694175,
"name": "",
"category": 38,
"type": 0,
"caption": "Suite",
"url": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_40_b.jpg",
"thumbnailUrl": "http://images.travelnow.com/hotels/1000000/10000/5900/5900/5900_40_t.jpg",
"supplierId": 13,
"width": 350,
"height": 350,
"byteSize": 0
}
]
}
}
}
My simplified code:
api = Expedia::Api.new
response = api.get_information({:hotelId => '106347'})
data = response.body
parsed = JSON.parse(data.to_json)
thumbnail = parsed['HotelInformationResponse']['HotelImages']['HotelImage']['thumbNailUrl']
This returns an error "no implicit conversion of String into Integer" at the thumbnail line. I understand that the JSON lists more then one 'thumbNailUrl', and I need to specify with I'm requesting, but I'm not sure how. I would just like to retrieve the first 'thumbNailUrl'.
Incidentally, the EAN API gem I'm using is located here: https://github.com/zaidakram/expedia
This line parsed['HotelInformationResponse']['HotelImages'] gives you an Array of Hash. So you need to access each Hash inside the array by index(s). Thus you need to go as below :-
parsed['HotelInformationResponse']['HotelImages']['HotelImage'][0]['thumbnailUrl']
If you want to get all thumbnails then, iterate over it as
thumbnails = parsed['HotelInformationResponse']['HotelImages']['HotelImage'].map do |hash|
hash[thumbnailUrl]
end
To get the first hotel image you can do:
thumbnail = parsed['HotelInformationResponse']['HotelImages']['HotelImage'][0]['thumbNailUrl']
If you wanted to get all the thumbnails you can do something like:
thumbnails = []
parsed['HotelInformationResponse']['HotelImages']['HotelImage'].each { |thumbnail| thumbnails << thumbnail['thumNailUrl'] }

Resources