Questions

How can I override the OnBeforeUnload dialog and replace it with my own?

I need to warn users about unsaved changes before they leave a page (a pretty common problem). ``` window.onbeforeunload = handler ``` This works but it raises a default dialog with an irritating sta...

18 Feb at 07:15

Getting activity from context in android

This one has me stumped. I need to call an activity method from within a custom layout class. The problem with this is that I don't know how to access the activity from within the layout. ## Profil...

Maximum on HTTP header values?

Is there an accepted maximum allowed size for HTTP headers? If so, what is it? If not, is this something that's server specific or is the accepted standard to allow headers of any size?

30 Jun at 10:33

read file from assets

``` public class Utils { public static List<Message> getMessages() { //File file = new File("file:///android_asset/helloworld.txt"); AssetManager assetManager = getAssets(); ...

28 Mar at 08:31

What are the correct version numbers for C#?

What are the correct version numbers for C#? What came out when? Why can't I find any answers about ? This question is primarily to aid those who are searching for an answer using an incorrect versio...

Catch exception and continue try block in Python

Can I return to executing the `try` block after exception occurs? For example: ``` try: do_smth1() except: pass try: do_smth2() except: pass ``` vs. ``` try: do_smth1() do_sm...

27 Mar at 22:10

align text center with android

I know it sounds easy. I need to put a text in center, but when the text is too long it needs to go below, but still align in the center of my xml. Here's my code : ``` <LinearLayout android:la...

18 Oct at 19:46

Checking Maven Version

I have just installed maven. I downloaded distributive, extracted files and set bin value environment variables, but when I type `mvn -version` in CMD I am getting message: > 'mvn' is not recognized...

4 Jan at 09:4

How to define custom exception class in Java, the easiest way?

I'm trying to define my own exception class the easiest way, and this is what I'm getting: ``` public class MyException extends Exception {} public class Foo { public bar() throws MyException { ...

9 Jan at 20:11

Using os.walk() to recursively traverse directories in Python

I want to navigate from the root directory to all other directories within and print the same. Here's my code: ``` #!/usr/bin/python import os import fnmatch for root, dir, files in os.walk("."): ...

7 Aug at 14:40

How does spring.jpa.hibernate.ddl-auto property exactly work in Spring?

I was working on my Spring boot app project and noticed that, sometimes there is a connection time out error to my Database on another server(SQL Server). This happens specially when I try to do some...

foreach for JSON array , syntax

my script is getting some array from php server side script. ``` result = jQuery.parseJSON(result); ``` now I want to check each variable of the array. ``` if (result.a!='') { something.... } if (...

3 Apr at 11:5

Generating random number between 1 and 10 in Bash Shell Script

How would I generate an inclusive random number between 1 to 10 in Bash Shell Script? Would it be `$(RANDOM 1+10)`?

28 Apr at 08:34

How to remove a field completely from a MongoDB document?

``` { name: 'book', tags: { words: ['abc','123'], lat: 33, long: 22 } } ``` Suppose this is a document. How do I remove "`words`" completely from all the documen...

22 Sep at 17:57

Last non-empty cell in a column

Does anyone know the formula to find the value of the last non-empty cell in a column, in Microsoft Excel?

27 Mar at 21:22

How to wait for a JavaScript Promise to resolve before resuming function?

I'm doing some unit testing. The test framework loads a page into an iFrame and then runs assertions against that page. Before each test begins, I create a `Promise` which sets the iFrame's `onload` ...

Why should I use core.autocrlf=true in Git?

I have a Git repository that is accessed from both Windows and OS X, and that I know already contains some files with CRLF line-endings. As far as I can tell, there are two ways to deal with this: 1...

23 May at 12:10

Use jQuery to get the file input's selected filename without the path

I used this: ``` $('input[type=file]').val() ``` to get the file name selected, but it returned the full path, as in "C:\fakepath\filename.doc". The "fakepath" part was actually there - not sure if...

22 Jul at 14:10

Git fatal: protocol 'https' is not supported

I am going through Github's forking guide: [https://guides.github.com/activities/forking/](https://guides.github.com/activities/forking/) and I am trying to clone the repository onto my computer. Howe...

29 Apr at 12:39

Signed versus Unsigned Integers

Am I correct to say the difference between a signed and unsigned integer is: 1. Unsigned can hold a larger positive value and no negative value. 2. Unsigned uses the leading bit as a part of the valu...

5 Feb at 06:30

Do you have to put Task.Run in a method to make it async?

I'm trying to understand async await in the simplest form. I want to create a very simple method that adds two numbers for the sake of this example, granted, it's no processing time at all, it's just...

21 Apr at 08:38

Force page scroll position to top at page refresh in HTML

I am building a website which I am publishing with `div`s. When I refresh the page after it was scrolled to position X, then the page is loaded with the scroll position as X. How can I force the page...

How to insert a text at the beginning of a file?

So far I've been able to find out how to add a line at the beginning of a file but that's not exactly what I want. I'll show it with an example: ``` some text at the beginning ``` ``` <added text> ...

1 Jun at 14:14

How to change the default encoding to UTF-8 for Apache

I am using a hosting company and it will list the files in a directory if the file `index.html` is not there. It uses [ISO 8859-1](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) as the default encoding...

Split a python list into other "sublists" i.e smaller lists

I have a python list which runs into 1000's. Something like: ``` data=["I","am","a","python","programmer".....] ``` where, len(data)= say 1003 I would now like to create a subset of this list (dat...

12 Mar at 16:46