android largeheap equated to true based on devices

Uncategorized
Question: I want to add in my manifest android_largeheap="true" based on some devices. Mostly devices running probably os 5.1 and below.Because alot of my clients are using samsung s3 , chinese , indian , pakistani phones.And I am getting lots of crashes in my firebase console. However this issue is not faced on top notch devices like google pixel samsung s8 etc. How can I detect which devices i run largeheap, and how i run it on those devices only? I do not want to run it on devices i dont need to. Answer: Well, you can't set this flag depending on the device. That's the true. But you can set it depending on OS version, screen size and etc. Check this answer to see how it can be done.…
Read More

What is a NullPointerException, and how do I fix it?

Uncategorized
Question: What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? Answer: When you declare a reference variable (i.e. an object) you are really creating a pointer to an object. Consider the following code where you declare a variable of primitive type int:int x; x = 10; In this example the variable x is an int and Java will initialize it to 0 for you. When you assign it to 10 in the second line your value 10 is written into the memory location pointed to by x. But, when you try to declare a reference type something different happens. Take the following code:Integer num; num = new…
Read More

Timout expired issue in database in C# and SQL Server 2012

sql-server
Question: Right now I am facing time out issue in my web application when database perform update / insert operations on multiple tables. Database size is 80 GB and I am wanting to resolve this time out issue from application level. Can any one please help me to sort out this issue basis of below point - Create new indexing in already running database Thanks SS Answer: MS SQL comes with a default setting of 30 seconds to timeout a transaction. Adding an index to a 80GB database might take more then that. To increate the timeout value, go to: Tools > Options > Designers > Table and Database Designers And increase its value. Read more
Read More

App Crashes When Saving Shared Preference for a CustomView [duplicate]

Uncategorized
Question: This question is an exact duplicate of:App Crashes When Trying to save position of custom view as SharedPreference Trying to implement a movable custom view like a crop view to specify the area of detection in a motion detection application. The bitmaps for the motion detection should be created according to the height and width of the custom view as the user sets it. The view is inflating properly, but the app crashes as soon as custom view is moved. Whether it has something to do with the way the state of box is saved as preference when it is moved? What are the changes should be made in the code? Logcat 08-15 10:34:00.166 5884-6969/com.md.areadectest I/MotionDetectionActivity: Saving.. previous=android.graphics.Bitmap@e8b4fcb original=android.graphics.Bitmap@5a303a8 bitmap=android.graphics.Bitmap@d75eec1 08-15 10:34:00.279 5884-5884/com.md.areadectest D/ViewRootImpl@47122fb[MotionDetectionActivity]: ViewPostImeInputStage processPointer 1 08-15 10:34:00.284…
Read More

How to make javascript dynamic?

Uncategorized
Question: I want to move document.getElementById("b") checked in a loop.Is it possible? then how can I make it happen.Please help me in this. " onClick="changeSrc()"> " style="border: 1px solid #ccc;" class="img-responsive" src=""> I want to repeat it in a loop ,as fradio0 i.e $front will increment ,javascript also repeat in a loop to match each. Thanks in advance Answer: You can pass parameters with your id for example:" onClick="changeSrc()"> and use it on script like Read more
Read More

Resize WebPage to view all Elements without ScrollBars

html
Question: How can I make the contents in my web page to be automatically resized so that at each resize level I can see all the contents of the webpage at once without using the scroll-bars. Is there a way with Bootstrap too? Answer: If you create this css class and add it over all of your elements it should work: CSS: .height-responsive { width: auto; display:block; height: 100%; } HTML: //your code Read more
Read More

Php log and floor function strange behavior

Uncategorized
Question: My problem is the following: log(1000,10) returns 3, but floor(log(1000,10)) returns 2. How to fix this issue? My phpversion is 5.6.30-0+deb8u1. Answer: From a 13 year old comment at the PHP:log documentation:$val = 1000000 $val2 = floor(log($val,10)) // gives a value of 5 for $val2 and not 6 as expected. $val2 = floor(log10($val)) // gives the correct value. So you should use floor(log10(1000); While I'm certainly no expert, I think the different outcome in PHP5 and PHP7 (as pointed out in the comments on your question) has to do with scalar type declaration, a new feature in PHP 7 (try playing with strict mode to find out more, eg. https://3v4l.org/KVCol). Read more
Read More

How to move elasticsearch index to a specified path within a cluster

Uncategorized
Question: I have a cluster with 3 nodes and 6 indices and have some problems with the storage on all cluster. The elasticsearch indices are in /mnt. To solve this I've added/mounted a new storage on each node. Currently I want to move the biggest index to this new storage (separate mount point) within the cluster, in order avoid ES to reach out the storage limit. How should I re-route only one index within cluster from /mnt/elasticsearch/data to /new_storage? Or, in other words, how to move the index from one path to another path within the cluster? Answer: Read more
Read More

Creating a simple chat bot framework (state machine) in Django [on hold]

Uncategorized
Question: Editing completely for narrowing down: How to represent the state-machine of the chat bot inside Django:Should I store all it's states, transitions, actions and conditions inside models? Or should i just represent them using dictionaries and other data structures and calculate the response on every request (based on the state of the conversation with the specific user that sent the request which will have to be stored inside database)? If this then how? Or is there any better way to represent this state machine? for example using a class based representation like dropbox's securitybot. (The problem with this is that it loads all of the state machine from dictionaries when the class is instantiated. This is inside a main loop so instantiating it once for every user works but…
Read More

Tips about sending real-time data to a web-page running on remote server

node.js
Question: I have a Python program running on a Raspberry Pi, it collects readings from peripheral sensors. I went through a tutorial about Node.JS and I've been searching for a long time but yet no luck to figure out: How to send those readings to a very simple web page running on a remote server like 000webhost using Node.JS every some interval time? I know it's a very general question, but please indeed I need some help with some tips. Answer: Read more
Read More

iOS – Shortcut for jumping to definition in Xcode 9?

Uncategorized
Question: In previous Xcode version , I could jump to definition with simple Cmd + click on that method/variable . But in Xcode 9, I feel uncomfortable to jump to definition . Does anyone has a better solution for jumping to definition in Xcode 9 ? I am tired of selecting options from dropdown list. Thanks in advance. Answer: Ashish and Ghulam's answers were great but it still kinda bugged me that things had changed and I couldn't jump to definition as before. Then I found this... Xcode9Beta2-Preferences->Navigation->Command-click on Code:->Jump To Definition: Read more
Read More

C – fopen_s cannot write to a file made by CreateFile

Uncategorized
Question: I have a main.c function and a subfunction that is called within it. In the subfunction I have used CreateFile to make a file. I then use CloseHandle to close the handle to that file. When I use fopen_s after that (within the subfunction) it works with both read and write modes. But if I use fopen_s in the main function afterwards, I can only open with read access, or else I get error code 13 - permission denied. The parameters of my CreateFile function are as follows:hAppend = CreateFile(centralDataFilepath, // open central data file FILE_APPEND_DATA, // open for writing FILE_SHARE_READ|FILE_SHARE_WRITE, // allow multiple readers NULL, // no security OPEN_ALWAYS, // open or create FILE_ATTRIBUTE_NORMAL, // normal file NULL); // no attr. template And I use fopen_s as follows:FILE…
Read More