Electron.screen.getPrimaryDisplay() method incorrect [OSX] - electron

Im currently using a 2021 Macbook pro which has the screen resolution of 3456x2234.
When i run the following command:
Electron.screen.getPrimaryDisplay()}
I get the following response:
{
"id": 1,
"bounds": {
"x": 0,
"y": 0,
"width": 2056,
"height": 1329
},
"workArea": {
"x": 34,
"y": 44,
"width": 2022,
"height": 1285
},
"accelerometerSupport": "unknown",
"monochrome": false,
"colorDepth": 30,
"colorSpace": "{primaries:BT709, transfer:IEC61966_2_1_HDR, matrix:RGB, range:FULL}",
"depthPerComponent": 10,
"size": {
"width": 2056,
"height": 1329
},
"displayFrequency": 120,
"workAreaSize": {
"width": 2022,
"height": 1285
},
"scaleFactor": 2,
"rotation": 0,
"internal": true,
"touchSupport": "unknown"
}
Im expecting the size.width and size.height to match 3456x2234 however they don't. Whats happening here and how can i get the correct screen resolution on OSX?
Thanks

For anyone who stumbles here i worked out i had the display set as 'scaled - more space'. If i change display to be 'default' the reported values are as expected (times by scaleFactor) to get the real display resolution.

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?

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

YouTube API thumbnail urls not resolving

I am hoping this is a one off, but today I came across a video that reports the following when calling the "Videos: list" endpoint by a videoId:
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/**uEGlS01**/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/**uEGlS01**/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/**uEGlS01**/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/**uEGlS01**/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/**uEGlS01**/maxresdefault.jpg",
"width": 1280,
"height": 720
}
}
... but neither the "maxres" or "standard" urls render an image (they 404 and render the nasty YouTube default grey image). Usually when those sizes were not available, those objects were not in the array.
Can anyone shed some light on this?
EDIT **
I should mention that the remainder of the thumb urls work as expected and embedding of the video fails to render a poster image with the exception of Chrome on desktop (which uses WEBP)

Facebook Graph API get photos returns with duplicated size.? Can I reduct the return?

How should I removed the duplicated size photos?
I just want one size for each photo.
But it returns images array and each array is one image with different sizes.
The service I'm calling is:
{user-id}/photos/uploaded?fields=images
returns:
"data": [
{
"images": [
{
"height": 960,
"source": "https://scontent.xx.fbcdn.net/hphotos-ash2/v/t1.0-9/10734238_10204858324278565_766379049543592577_n.jpg?oh=6ece9809697d2ca4019087d2173702d3&oe=56D2FB6C",
"width": 720
},
{
"height": 800,
"source": "https://fbcdn-photos-c-a.akamaihd.net/hphotos-ak-ash2/v/t1.0-0/p600x600/10734238_10204858324278565_766379049543592577_n.jpg?oh=8aabb9ba4538fdcf853b8c9107601f15&oe=56941F5E&__gda__=1455658621_d167345958233195768c68333d481f1a",
"width": 600
},
{
"height": 640,
"source": "https://fbcdn-photos-c-a.akamaihd.net/hphotos-ak-ash2/v/t1.0-0/p480x480/10734238_10204858324278565_766379049543592577_n.jpg?oh=2810aba0ea4eda0ee5ff73b5df75a70c&oe=56C3DF77&__gda__=1452026196_7d112ea2ad4fa41b108a883a27819241",
"width": 480
},

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