java.concurrent.ReentrantLock - why we want to acquire the same lock multiple times
Why use a ReentrantLock if one can use synchronized(this)?
How can I use sed to replace a multi-line string? I've noticed that, if I add \n to a pattern for substituting using sed, it does not match. Example:  $ cat &gt; alpha.txt This is a test Please do not be alarmed  $ sed -i'.original' 's/a test\nPlease do not/not a test\nBe/' alpha.txt  $ diff alpha.txt{,.original}  $ # No differences printed out   How can I get this to work? $\sum_{1}^{n}\left ( a_{i}b_{i} \right )\geq \prod_{1}^{n}\left ( a_{i}^{b_{i}} \right )$ Let $a,b,c,x,y,z&gt;0$ and $x+ y+ z= 1$. Show that $$ax+ by+ cz\geq  a^{x}.b^{y}.c^{z}$$ I have found the generalization of this inequality: For 2 sets of numbers $\left \{ a_{i} \right \}, \left \{ b_{i} \right \}&gt; 0$ and $\sum_{1}^{n}b_{i}= 1$, we have: $$\sum_{1}^{n}\left ( a_{i}b_{i} \right )\geq  \prod_{1}^{n}\left ( a_{i}^{b_{i}} \right )$$ First solution Simply compare the logs: as the natural logarithm is a concave function, one has $$\ln\bigl(a^x b^y c^z)=x\ln a+y\ln b+z\ln c\le \ln(ax+by+cz)$$ for all non-negative $x,y,z$ such that $x+y+z=1$. How about another solution? I really hope to see that. Thanks! Bake Simple Deform animation into mesh for Unity3D export? I'm trying to use a .blend file with a keyframe animation on the angle of a Simple Deform modifier in Unity3D. Unity3D however does not know how to handle modifiers and hence cannot play the animation.  How can I bake/save the animation to the .blend file so that Unity3D can play it? How do I close a terminal without saving the history? More than once I've accidentally run a number of commands and polluted my bash history. How do I close my terminal without saving my bash history? I'm using Fedora. Are there rules for using manacles in combat? I can't quite find in the PHB or DMG how to slap manacles onto someone during combat. PHB 152 describes how to break out of mundane manacles, while DMG 165 shows how Dimensional Shackles work (they are essentially magic manacles -- use 1 action to bind an Incapacitated target).  Is there an official rule on how to use manacles in combat, or do we have to use house rules? I have just migrated from Windows environment. I have installed Python 3.2 in a separate directory. How can I get the python installation path in Ubuntu shell?  Is there any way I can let the shell know/choose at runtime which python version is to be used for further code execution?  Are there any environment variables and search path kind of things in Ubuntu Linux as well? Greatest comeback in 2nd leg match Why doesn't the Java SDK installer set JAVA_HOME? I always wondered why I have to manually set the JAVA_HOME environment variable after installing the Java SDK.     JAVA_HOME=c:\Program Files\Java\jdk1.6.0_12   Visual Studio at least provides a batch file to set these kind of environment variables:     call "c:\Program Files\Microsoft Visual   Studio 9.0\VC\vcvarsall.bat"   Does Java have something similar? I'm trying to make a build script that should simply work after installing the Java SDK. I don't want people to mess with environment variables on their PC. The vast majority of intelligent species in the Star Trek universe are bipedal, humanoid creatures.  From the lot I've seen of TOS, TNG, DS9, Voyager, Enterprise, and the movies, it seems that this coincidence goes largely unquestioned.  Metaknowledge grants that it is much easier to have human actors portray human-like beings, and so this was probably done due to budgetary/technological limitations.  However, I'm wondering if an in-universe reason for this was ever given or explored? I've been using Texmaker for ~5 years now and prefer it over other editors because of its flexibility.   Is there a way to auto-indent LaTeX code in TeXmaker so that the code becomes more manageable ? How do I time a method's execution in Java? How to cluster time series? I have a question about cluster analysis. There are 3000 companies, which have to be clustered according to their power usage over 5 years. Each company has values for every hour during 5 years. I would like to find out if some companies have the same pattern in usage power over the time period. The results should be used for daily prediction of power usage. If you have some ideas how to cluster time series in SPSS, please share with me. What is the chance that at least two people were born on the same day   of the week if there are 3 people in the room?   I'm wondering if my solution is accurate, as my answer was different than the solution I found:  Probability that there are at least 2 people in the room born on the same day = 1 - (No one was born on the same day) - (Exactly one person was born on the same day)  There are (3 choose 2) different pairs of couples. Each couple has the same birthday as another couple with the chances of 1/7 and different with chances 6/7. Thus:  $$1 – (6/7)^3 – 3(1/7)(6/7)^2 = 0.0553$$  Thanks for any help! Get list of ALL offers from Amazon Product Advertising API Singular to plural noun Many nouns that end in ‑f are made plural by changing the ‑f to ‑v‑ and adding ‑es.  +----------+-----------+ | Singular |   Plural  | +----------+-----------+ |  half    |  halves   | |  leaf    |  leaves   | |  shelf   |  shelves  | +----------+-----------+     But some nouns that end in ‑f are made plural simply by adding ‑s.  +----------+-----------+ | Singular |   Plural  | +----------+-----------+ |  chief   |  chiefs   | |  roof    |  roofs    | |  cliff   |  cliffs   | +----------+-----------+   Some nouns that end in ‑f can be made plural in two ways, either by adding ‑s or ‑ves:   +----------+--------------------+ | Singular |      Plural        | +----------+--------------------+ |  scarf   |  scarfs or scarves | |  hoof    |  hoofs or hooves   | |  dwarf   |  dwarfs or dwarves | |  wharf   |  wharfs or wharves | +----------+--------------------+   Now my question is how to determine whether to use only ‑s or to change the ‑f to ‑v‑ and add ‑es? I have encountered this question while tring to figure out why every sequential space $X$, is a quotient spaces of a metric space. If I understand correctly, given a sequential space, every sequence (including it's limit) can be identified with the space $Y=\{0\} \cup \{\frac1{n+1}|n \in N\}$. So The space $X$ can viewed as a quotient space of $\bigoplus_{(x_n) \in C} \{(x_n) \} \times Y$ where $C$ is the set of all converges sequences in $X$. My question is, How can I show that this space is metrizable?  Thank you! Shir What good CAD programs are available? I would like to count subgroups of each order (2, 3, 4, 6, 8, 12) of $S_4$, and, hopefully, convince others that I counted them correctly.  In order to do this by hand in the term exam, I need a clever way to do this because there can be as many subgroups of a group of order 24 as $2^{23}$.  Do you know how to do this?   (I would be most grateful if you could tell me what part of the answer to the old question answers my question before voting to close.) How can I install the latest Netbeans? In Ubuntu Software Center the Netbeans version is netbeans 7.0.1+dfsg1-5ubuntu2 but Netbeans 8.1 is available in the Netbeans website. Why is energy in a wave proportional to amplitude squared?