got null when creating bitmap from byte array

Uncategorized
Question: I create a main HASHMAP repo for caching user images that comes from the server. this cache is static. this cache saves user id as a key and byte array as a value. private static HashMap sDrawables; public static HashMap getMapInstance (){ if (sDrawables == null) sDrawables = new HashMap(); return sDrawables; } I use of AsyncTask for downloading images from the server and put this id and images array on hashmap and after this, I put this map to my main static hashmap:for (Map.Entry entry : drawables.entrySet()) { ImgFactory.getMapInstance().put(entry.getKey(), entry.getValue()); } On the place that I want to set this user image to my imageview, I send user Id to the main hashmap and after finding it I get its value and I convert this value to a…
Read More

how to register aws ec2 instance launch API in TFS service endpoint?

Uncategorized
Question: My requirement is, need to launch an AWS EC2 Instance through REST API while TFS running. For that I need to register the API in TFS as Generic Service Endpoint. I am not aware how to add the API endpoint because the endpoint contains many header values and signatures. I hope we can pass the Signature in token. But what need to pass for UserName? Could anyone know how to register the AWS REST API in TFS service Endpoint.? Answer: Read more
Read More

Flask library is no longer accessible from http even though the py is still alive and working

Uncategorized
Question: Im using the flask library with python to create a web interface. The py is supposed to be running indefinitely (it get data every 30 min from the DB , do some operations and send the dataframe as json on a certain myroute) Im using:if __name__ == '__main__':app.run(host = '0.0.0.0', port = 5055, debug=True) The problem is that after a while , if I run http://myapp:5055/myroute I will get a ERR_CONNECTION_REFUSED. if I run lsof -i tcp:5055 shows that no app is using this port. However the .py logs that I have in the code are indicating that the code is working fine (its fetching data and adjusting it) Any clue on how to debug further? Answer: Read more
Read More

gcc: command not found but already installed

Uncategorized
Question: k@k-Inspiron-5537:~$ sudo apt-get install gcc [sudo] password for k: Reading package lists... Done Building dependency tree Reading state information... Done gcc is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 291 not upgraded. 1 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] y Setting up matlab-support (0.0.19) ... No default Matlab path found. Exiting. dpkg: error processing package matlab-support (--configure):subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing:matlab-support E: Sub-process /usr/bin/dpkg returned an error code (1) k@k-Inspiron-5537:~$ gcc -v The program 'gcc' is currently not installed. You can install it by typing:sudo apt-get install gcc Any idea ?? Answer: Matlab-support requires matlab to be…
Read More

Unable to get property ‘0’ of undefined or null reference JavaScript Internet Explorer

Uncategorized
Question: JavaScript Code function update() { var newAmt = 0; var newtable = document.getElementById("tbl"); for ( var i = 0; i < newtable.rows.length; i++) { innerTable = newtable.rows[i].cells[0].childNodes[0]; if ( (innerTable.rows[0].cells[5].childNodes[0].value != "") && !(isNotNumber(innerTable.rows[0].cells[5].childNodes[0].value))) { newAmt = newAmt + parseFloat(innerTable.rows[0].cells[5].childNodes[0].value); } } innerTable.rows[0] is throwing exception as Unable to get property '0' of undefined or null reference in Internet Explorer But same piece of code is working perfectly in eclipse web browser HTML Stuck in this one from past two days. Completely fed up some one help me Thanks in Advance Answer: Have a try at this much simpler an unobtrusive code Note I removed the inline event handler function isNumber(n) { return !isNaN(parseFloat(n)) && isFinite(n); } var fields, newAmt=0; window.onload = function() { fields = document.querySelectorAll("[name=Amt]"); for (var…
Read More

Forbidden ec2 subnets but not cloudfront in apache deny

Uncategorized
Question: I am trying to forbidden access from all ec2 subnets in apache but it is not working. when I added ec2 subnets on apache deny config it will block access from all ips. What I am trying to do is block access from ec2 subnets but not for cloudfront which allowed in apache. Can anyone help me in this. Apache version is 2.4 Order Allow,Deny Allow from all Deny from ec2 subnets Answer: Read more
Read More

JavaScript: How to filter data in dictionary

javascript
Question: I have following object in JS:[ { "financial_year":1, "mainline_revenue":18743.0, "regional_revenue":2914.0, "other_revenue":3198.0, "non_operating_items":-1983.0 }, { "financial_year":2, "mainline_revenue":20218.0, "regional_revenue":3131.0, "other_revenue":3394.0, "non_operating_items":-3233.0 }, { "financial_year":3, "mainline_revenue":30802.0, "regional_revenue":6322.0, "other_revenue":5526.0, "non_operating_items":-1367.0 } ] financial_year is the unique identifier which I want to use to filter data. How can I filter data where for example financial_year is 2 and put the other values in an array? Answer: You can use the filter method on arrays. filter takes a callback which returns true or false (more accurately, a truthy or falsey value). If it returns true, that object is included in the resulting array. let input = [ { "financial_year":1, "mainline_revenue":18743.0, "regional_revenue":2914.0, "other_revenue":3198.0, "non_operating_items":-1983.0 }, { "financial_year":2, "mainline_revenue":20218.0, "regional_revenue":3131.0, "other_revenue":3394.0, "non_operating_items":-3233.0 }, { "financial_year":3, "mainline_revenue":30802.0, "regional_revenue":6322.0, "other_revenue":5526.0, "non_operating_items":-1367.0 } ]; let output = input.filter((obj) => obj.financial_year…
Read More

Angular 2 Cannot Read Property of Undefined (Function Name) [duplicate]

Uncategorized
Question: This question already has an answer here:How to access the correct `this` inside a callback? 4 answers Component:import { Component, OnInit } from '@angular/core'; import { HttpClient } from '@angular/common/http'; @Component({ selector: 'app-ore-table', templateUrl: './ore-table.component.html', styleUrls: ['./ore-table.component.less'] }) export class OreTableComponent implements OnInit { ores = '../assets/json/ores.json'; prices = 'https://esi.tech.ccp.is/latest/markets/prices/?datasource=tranquility'; oreArray: any; pricesArray: any; joinedArray: any; constructor(private http: HttpClient) { } getOres() { this.http.get(this.ores).subscribe(data => { this.oreArray = data; this.getPrices(); }); } getPrices() { this.http.get(this.prices).subscribe(data => { this.pricesArray = data; this.joinPrices(); }); } joinPrices() { this.oreArray.forEach(function(data) { const matchingPrice = this.getMatchingPrice(data); }); } getMatchingPrice(data) { for (let i = 0; i < this.pricesArray.length; i++) { if (this.pricesArray[i].type_id === data.id) { return this.pricesArray[i]; } } return false; } ngOnInit() { this.getOres(); } } Not sure what is going on here.…
Read More

CodeFight firstDuplicate interview challenge

Uncategorized
Question: As per problem statement: Write a solution with O(n) time complexity and O(1) additional space complexity. Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 duplicated numbers, return the number for which the second occurrence has a smaller index than the second occurrence of the other number does. If there are no such elements, return -1 I followed my code according to constraints and still I'm getting time complexity error. Here's my solution:int firstDuplicate(std::vector a) { long long int n = a.size(); int cnt=0; for(long long int i=0;i
Read More

Swagger: java.text.parseexception: Unparseable date

Uncategorized
Question: I'm using Swagger to define API specifications for my android project. My JSON data returns one of the parameter 'creationDate'. It's value is 2017-08-14To2:42:59.528Z However when it passes through APIInvoker method in Swagger module, it gave me the below error. java.text.parseexception:unparseable date "2017-08-14To2:42:59.528Z" When I debugged the code further, I found that it is failing in DefaultDateTypeAdapter.java class. It is unable to parse through any of the 3 formats in deserializeToDate method. private Date deserializeToDate(JsonElement json) { synchronized (localFormat) { try { return localFormat.parse(json.getAsString()); } catch (ParseException ignored) { } try { return enUsFormat.parse(json.getAsString()); } catch (ParseException ignored) { } try { return iso8601Format.parse(json.getAsString()); } catch (ParseException e) { throw new JsonSyntaxException(json.getAsString(), e); } } } Does anyone know how to solve this error? Note: The images are posted…
Read More