Questions

Is there functionality to generate a random character in Java?

Does Java have any functionality to generate random characters or strings? Or must one simply pick a random integer and convert that integer's ascii code to a character?

13 Apr at 03:45

Mockito - NullpointerException when stubbing Method

So I started writing tests for our Java-Spring-project. What I use is JUnit and Mockito. It's said, that when I use the when()...thenReturn() option I can mock services, without simulating them or s...

14 Oct at 19:35

How do you specify the Java compiler version in a pom.xml file?

I wrote some Maven code in Netbeans that has approximately more than 2000 lines. When I compile it on Netbeans, everything is fine, but if I want to run it on command line, I will get these errors: ``...

16 Dec at 09:21

Using Python String Formatting with Lists

I construct a string `s` in Python 2.6.5 which will have a varying number of `%s` tokens, which match the number of entries in list `x`. I need to write out a formatted string. The following doesn't w...

How to replace list item in best way

``` if (listofelements.Contains(valueFieldValue.ToString())) { listofelements[listofelements.IndexOf(valueFieldValue.ToString())] = value.ToString(); } ``` I have replaced like above. Is there ...

10 Sep at 20:7

How do you tell if a string contains another string in POSIX sh?

I want to write a Unix shell script that will do various logic if there is a string inside of another string. For example, if I am in a certain folder, branch off. Could someone please tell me how to ...

15 Aug at 07:9

How to add items to a spinner in Android?

How to add items to a spinner?

9 Dec at 09:7

Does Internet Explorer 8 support HTML 5?

Is there any HTML5 support in IE8? Is it on the IE8 roadmap?

Maven error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher

I have installed a latest `maven-3.0.4` on : The installation details are as follows: Installation Path : ``` C:\apache-maven-3.0.4 ``` Environment Variables are: ``` M2_HOME C:\apache-maven-3.0.4\ap...

17 Dec at 05:18

How do you specifically order ggplot2 x axis instead of alphabetical order?

I'm trying to make a `heatmap` using `ggplot2` using the `geom_tiles` function here is my code below: ``` p<-ggplot(data,aes(Treatment,organisms))+geom_tile(aes(fill=S))+ scale_fill_gradient(low = ...

22 Jul at 17:6

How to create a directory and give permission in single command

How to create a directory and give permission in single command in Linux? I have to create lots of folder with full permission `777`. ### Commands ``` mkdir path/foldername chmod 777 path/foldernam...

20 Jun at 09:12

How to replace part of string by position?

I have this string: `ABCDEFGHIJ` I need to replace from position 4 to position 5 with the string `ZX` It will look like this: `ABCZXFGHIJ` But not to use with `string.replace("DE","ZX")` - I need t...

31 Aug at 22:21

Changing EditText bottom line color with appcompat v7

I am using appcompat v7 to get the look consistent on Android 5 and less. It works rather well. However I cannot figure out how to change the bottom line color and the accent color for EditTexts. Is i...

How to read/write from/to a file using Go

I've been trying to learn Go on my own, but I've been stumped on trying read from and write to ordinary files. I can get as far as `inFile, _ := os.Open(INFILE, 0, 0)`, but actually getting the conten...

14 May at 21:48

Send message to specific client with socket.io and node.js

I'm working with socket.io and node.js and until now it seems pretty good, but I don't know how to send a message from the server to an specific client, something like this: ``` client.send(message, ...

PHP: How to check if image file exists?

I need to see if a specific image exists on my cdn. I've tried the following and it doesn't work: ``` if (file_exists(http://www.example.com/images/$filename)) { echo "The file exists"; } else {...

17 Sep at 20:32

How to allow only integers in a textbox?

In my form I want to allow typing of integer values only in a textbox. How to do that?

17 Apr at 12:41

MySQL: Cloning a MySQL database on the same MySql instance

I would like to write a script which copies my current database `sitedb1` to `sitedb2` on the same mysql database instance. I know I can dump the sitedb1 to a sql script: ``` mysqldump -u root -p sit...

25 Jan at 18:34

How to define Gradle's home in IDEA?

I am trying to import a Gradle project into IntelliJ, and when I get to the `Gradle Home` textbox, it is not automatically populated, nor will typing in the path of `Gradle Home` result in a valid loc...

2 Jan at 08:34

Matplotlib scatter plot legend

I created a 4D scatter plot graph to represent different temperatures in a specific area. When I create the legend, the legend shows the correct symbol and color but adds a line through it. The code I...

reducing number of plot ticks

I have too many ticks on my graph and they are running into each other. How can I reduce the number of ticks? For example, I have ticks: ``` 1E-6, 1E-5, 1E-4, ... 1E6, 1E7 ``` And I only want: ...

13 Feb at 00:3

Format date and Subtract days using Moment.js

I would like a variable to hold yesterday's date in the format `DD-MM-YYYY` using Moment.js. So if today is 15-04-2015, I would like to subtract a day and have 14-4-2015. I've tried a few combination...

6 Mar at 07:11

Pure Javascript listen to input value change

Is there any way I can create a constant function that listens to an input, so when that input value changes, something is triggered immediately? I am looking for something using pure javascript, no ...

5 Jan at 05:44

How can I enable or disable the GPS programmatically on Android?

I know that the question about turning on/off GPS programatically on android [has](https://stackoverflow.com/questions/3745884/how-to-enable-the-gps-setting-automatic) [been](https://stackoverflow.com...

23 May at 12:10

how to add a jpg image in Latex

I want to insert a .jpg image(that is in my current folder, where the .tex file is) after a paragraph. How can I do it in Latex? What should I include / what commands should I use?

15 Sep at 16:36