How can I randomly choose a number from a list of given numbers in Java?  I have only these 5 numbers: 1000, 2000, 3000, 4000, 5000  Now I have to select any one number from this set of numbers randomly.  My code to try this  int ar[] = new int[4]; ar[0] = 1000; ar[1] = 2000; ar[2] = 3000; ar[4] = 4000;  int randomArrayIndex = num.nextInt(ar.length);
How do I generate a random int value in a specific range? I have tried the following, but those do not work: Attempt 1: randomNum = minimum + (int)(Math.random() * maximum);  Bug: randomNum can be bigger than maximum. Attempt 2: Random rn = new Random(); int n = maximum - minimum + 1; int i = rn.nextInt() % n; randomNum =  minimum + i;  Bug: randomNum can be smaller than minimum.
I'm confused with using single or double brackets. Look at this code:  dir="/home/mazimi/VirtualBox VMs"  if [[ -d ${dir} ]]; then     echo "yep" fi   It works perfectly although the string contains a space. But when I change it to single bracket:  dir="/home/mazimi/VirtualBox VMs"  if [ -d ${dir} ]; then     echo "yep" fi   It says:  ./script.sh: line 5: [: /home/mazimi/VirtualBox: binary operator expected   When I change it to:  dir="/home/mazimi/VirtualBox VMs"  if [ -d "${dir}" ]; then     echo "yep" fi   It works fine. Can someone explain what is happening? When should I assign double quotes around variables like "${var}" to prevent problems caused by spaces? Parse and Extract Attributes from JSON I'm having problems with a WFS GetFeature request. I'm using OpenLayers with an OSM map as base layers which use the Google projection. Overlaying the layer with WMS works perfect. When I do a request to return all features within the bounds of a polygon, no features are found.  My layer uses EPSG:28992. the base layer uses: EPSG:900913  My layer configuration in GeoServer:    When I set the declared SRS to EPSG:900913 and set "SRS handling" to "Reproject native to declared" it works fine, but I need OpenLayers to reproject it, not GeoServer.  Below is an example request I would do. I think the problem is that GeoServer does not convert the spatial filter to the native SRS.  http://mydomain.com/wfs?request=GetFeature&amp;version=1.1.0&amp; srsName=epsg:28992&amp; typeName=Namespace:Layer1&amp; propertyName=(*)&amp; CQL_FILTER=year = 2011 and INTERSECTS(geometry,POLYGON((565585.61613069 6816272.786200799,565585.61613069 6817032.3791692,564362.62367835 6817032.3791692,564362.62367835 6816272.786200799,565585.61613069 6816272.786200799)))&amp; outputFormat=GMl2&amp;   Update  I just tried re-projecting some points from OpenLayers (EPSG:900913) via proj4js to EPSG:28992 (PostgreSQL and GeoServer). I took 3 points and  compared them. They all showed an offset.   Converted: POINT(233492,24349424947 582191,0681508556)  In Database: POINT(233530,852147064 582315,680920578)  Difference x: 38,60865281453 Difference y: 124,6127697224 Converted: POINT(133459,1980658749 455770,7481867363)  In Database: POINT(133486,356985081 455879,67223342)  Difference x: 27,1589192061 Difference y: 108,9240466837 Converted: POINT(176920,43262818802 317930,36182729155)  In Database: POINT(176954,154083767 318023,515324756)  Difference x: 33,72145557898 Difference y: 93,15349746445   If the offset was constant I could correct it. Now I'm not sure if the offset is caused by GeSserver or by proj4js. I'm guessing proj4js since the WMS layer does not show any offset. Do "owed" and "due" mean the opposite? Flying with a desktop computer (as checked luggage) On an upcoming trip, I will be taking a desktop computer and monitor as checked luggage (on a United/Continental flight). What should I be aware of when doing this? What needs to be done to properly protect all the components? Are there any airline policies I should be aware of? Is there any cryptographic algorithm immune to side channel attacks based on scan chain? In VLSI point of view. Adding my launcher to the Unity Launcher automatically. How? Assume there is a public-key encryption scheme $(KeyGen, Enc, Dec)$ with perfect correctness (i.e., for all messages M and valid key-pairs (PK,SK), we have $Dec_{SK}(Enc_{PK}(M))=M$).  Will there always be a function $A$ such that for all messages M and valid public-keys PK, $A_{PK}(Enc_{PK}(M))=M$?  In other words, can a computationally unbounded adversary decrypt the message, having only the public key? Group of even order contains an element of order 2 filling area between 2 functions, with shading When solving this issue (  ), I did a function so that the plugin would auto-hide from all users except one (me:).  The flaw is that it only auto-hides when active.  At first, it was a mu-plugin, but I had to enable/disable it manually. It really doesn't need to run all the time, as it may slow the site (?) or even contain some sensitive manipulation of the site's language (another question mark).  But mainly the motivation is that I don't want the client activating/deactivating/deleting this plugin (is for my own use), and don't want it cluttering her own plugins list.  So, decided to split the functions in two plugins:   One is a Must-Use used to hide the regular one.  The other will be activated/deactivated upon necessity and is the one from the above linked issue.   But now I run into another question: how to hide one plugin from the Must-Use listing? How did the Swooping Evil Venom infused rain affect the magical community? I didn't see any wizards drenched in the rain at the end of Fantastic Beasts and Where to Find Them (don't recall, actually). But would the rain equally affect the wizards as it did no-maj's?   This event is something that doesn't necessarily need to be forgotten by the Wizarding community. How would they avoid being obliviated by the rain?  (They could avoid the rain by Apparating, but what about the showers and drinking water?)  This question is picking at my brain. I am attempting to set a value in a textarea field using jquery with the following code:  $("textarea#ExampleMessage").attr("value", result.exampleMessage);   The issue is, once this code executes, it is not altering the text in the textarea?  However when performing an alert($("textarea#ExampleMessage").attr("value")) the newly set value is returned? I'm trying to solve this problem from Hatcher 3.3.24.  Let $M$ be a closed connected 3-manifold, and write $H_1(M, \mathbb{Z})$ as $\mathbb{Z^r} \oplus T$ where $T$ is torsion. Show that $H_2(M, \mathbb{Z})$ is $\mathbb{Z^r}$ if $M$ is orientable or $\mathbb{Z^{r-1}} \oplus \mathbb{Z_2}$ if $M$ is not orientable. In particular $r \geq 1$ if $M$ is not orientable. Using exercise 6 construct examples showing there are no other restrictions on the homology groups of closed 3-manifolds. (In the nonorientable case consider the manifold $N$ obtained from $S^2 \times I$ by identifying $S^2 \times \{0\}$ with $S^2 \times \{1\}$ via a reflection of $S^2$.)  I think I've solved the first part, here's my proof:   First note the following theorem: If $M$ is a closed connected and orientable n-manifold then $H_n(M, \mathbb{Z}) = \mathbb{Z}$ and $Tors(H_{n-1}(M, \mathbb{Z})) = 0$. If nonorientable, then $H_n(M, \mathbb{Z}) = 0$, $Tors(H_{n-1}(M, \mathbb{Z})) = \mathbb{Z_2}$.  Now note by Poincare duality and UCT we have that $H_2(M) \cong H^1(M) \cong \mathbb{Z^r} \oplus T_0 \cong \mathbb{Z^r}$.   In the nonorientable case consider the exact sequence:  $0 \longrightarrow H_2(M) \longrightarrow H_1(M) \longrightarrow H_0(M) \longrightarrow 0$  But we know $H_1(M) = \mathbb{Z^r} \oplus Z_2$ from the earlier theorem and $H_0(M) = \mathbb{Z}$.   Therefore $H_2(M) \cong ker(\mathbb{Z^r} \oplus Z_2 \rightarrow \mathbb{Z}) \cong \mathbb{Z^{r-1}} \oplus \mathbb{Z_2}$.   For the rest of the question I'm quite lost. I'm attempting to install Ubuntu 14.04.1 (the only version I have handy) onto my old Compaq Presario R3000 (this Ubuntu was recommended for this computer). The installation has stalled at about 60% and hasn't moved in an hour.  The message at the bottom says: Configuring bcmwl-kernal-source (i386).  I have no experience with Ubuntu (or with Linux, for that matter), coming from a strictly-Windows background). Can anyone offer some advice? Prove that for every odd integer n, there is a group... Prove that for every odd integer n, there is a group with exactly n elements of order 2.  I am new to abstract algebra and proofs in general. Proving existence is difficult for me, but I will show what I have.  $$n = 2k + 1$$ $$k \in \mathbb{Z^+}$$  $$\exists G \supset H = (a_1 , a_2 , ..., a_n, e)$$  $$s.t. |a_1| = |a_2| = ... = |a_n| = 2$$  My instinct is to use Lagrange's Theorem, although I would like to try another method to prove this as we have not gone over cosets in class yet. If someone could just give me a hint of how to start, it would be very beneficial. Thank you. Where are the review queue counters? The review queue counters have disappeared:        Where are they?  When I did screenshot the Close Votes queue was not empty, if someone think so. Formula label outside of formula Diagnostics for logistic regression? I've been told that when "the" is proceeded by a vowel sound, like "apple" or "hour", it's pronounced as "thee" and not as "thu".  But after listening to a couple of songs, I noticed that sometimes this "rule" is not followed. Take for example the two Katy Perry's songs, "Roar" and "The one that got away". In the first she sings "I got thee eye of thu tiger", but in the second she sings "Thu one that got away".  I don't know if it was sang this way to better suit the song melody (I understand nothing about those techniques), but I got confused. What's the correct pronunciation?  Thanks in advance.