I need to lock a file in unix/linux OS. I have googled and read about java.nio.channels Filelock and Reentrant File Lock . But both works in Windows but not in unix. Is there any other way of implementing a lock on file in unix? Any sample code would be highly appreciated.  Thanks, Vignesh
I have a Java process that opens a file using a FileReader. How can I prevent another (Java) process from opening this file, or at least notify that second process that the file is already opened? Does this automatically make the second process get an exception if the file is open (which solves my problem) or do I have to explicitly open it in the first process with some sort of flag or argument? To clarify: I have a Java app that lists a folder and opens each file in the listing for processing it. It processes each file after the other. The processing of each file consists of reading it and doing some calculations based on the contents and it takes about 2 minutes. I also have another Java app that does the same thing but instead writes on the file. What I want is to be able to run these apps at the same time so the scenario goes like this. ReadApp lists the folder and finds files A, B, C. It opens file A and starts the reading. WriteApp lists the folder and finds files A, B, C. It opens file A, sees that is is open (by an exception or whatever way) and goes to file B. ReadApp finishes file A and continues to B. It sees that it is open and continues to C. It is crucial that WriteApp doesn't write while ReadApp is reading the same file or vice versa. They are different processes.
Can steam create an overview of all my achievements? I play several games on Steam and I love the achievement system. It would be great to get an overview of all the achievements ever gained in Steam games. Does Steam support this? I haven't found such an overview.  If such a feature does not exist, I would already be happy with an easy way to calculate the sum of all my achievements automatically.  Edit: I stumbled upon an interesting website called  today. Unfortunately it only works for XBox-Achievements. Does anyone know of a similar service for Steam? This would solve my question right away. Implementing my own solution based on the links posted in the answers didn't work because the APIs are not sufficient for my needs. Trying to find the original story (I read it in Russian translation, original was most likely English unless it was Lem).  The story plot had artificial birds designed to serve as cops. The birds started attacking humans who were percieved as being aggressive towards anything alive. So they created more advanced birds to protect against the first ones. This worked for a while until the second kind started attacking humans as well. It ended with the idea that they would need another generation to attack the second-generation birds.  The story wasn't very long. I read it a while back (mid-1980s, which means the original was written even earlier, probably before 1980).  Despite a somewhat Asimov-like "misbehaving robots" topic, I'm pretty sure it wasn't Asimov. Is there a way to draw a Voronoi diagram with pgfplots? I want to draw a voronoi diagram with pgfplots, but sadly I cannot get it the way it should look like. I used the Matlab command to get the x and y coordinates and saved them as a dat-file. In that file I stored the x coordinates in the first column and the y coordinates in the second column.      Does anyone have an idea, how it could work?  Minimal Example of the Code:  \documentclass{standalone}  \usepackage{amsmath,amsfonts,amssymb}  \usepackage{mathtools}  \usepackage[ngerman]{babel}  \usepackage[utf8]{inputenc}  \usepackage{graphicx}  \usepackage[svgnames]{xcolor}  \usepackage{pgfplots} \pgfplotsset{compat=newest}  \usepackage{tikz}  \usetikzlibrary{positioning,fit,calc,shapes,arrows,external,3d,patterns,spy}  \usepackage{filecontents}  \begin{document}  \begin{filecontents*}{data.dat}   -7.9265104e+00   3.6503989e-01    4.3133971e-01   9.4062409e-01   -7.9265104e+00   3.6503989e-01    6.3976919e-02   5.4947497e-01    6.3976919e-02   5.4947497e-01    3.0293735e-01   6.5037024e-01    3.6748619e-01   9.5786833e-02    6.3976919e-02   5.4947497e-01    3.0293735e-01   6.5037024e-01    4.0645496e-01   8.2958752e-01    4.9066479e-01   4.4410036e-01    3.0293735e-01   6.5037024e-01    3.6748619e-01   9.5786833e-02    4.9244296e-01   2.3488102e-01    4.9244296e-01   2.3488102e-01    4.9066479e-01   4.4410036e-01    4.9066479e-01   4.4410036e-01    7.3082954e-01   5.1825327e-01    1.8829507e+00   1.7053562e-01    4.9244296e-01   2.3488102e-01    4.3133971e-01   9.4062409e-01    8.7230061e-01   2.0371867e+00    4.0645496e-01   8.2958752e-01    4.3133971e-01   9.4062409e-01    6.6251849e-01   6.4842135e-01    4.0645496e-01   8.2958752e-01    6.9696115e-01   6.8938388e-01    8.7230061e-01   2.0371867e+00    7.3082954e-01   5.1825327e-01    6.6251849e-01   6.4842135e-01    1.8829507e+00   1.7053562e-01    7.3082954e-01   5.1825327e-01    6.6251849e-01   6.4842135e-01    6.9696115e-01   6.8938388e-01   -7.9265104e+00   3.6503989e-01   -1.7371176e+01   8.6111447e-02    3.6748619e-01   9.5786833e-02   -6.0998602e-02  -1.3709259e+00    1.8829507e+00   1.7053562e-01    4.4291165e+00  -2.9045575e-01    8.7230061e-01   2.0371867e+00    1.8287612e+00   4.5227847e+00    6.9696115e-01   6.8938388e-01    1.9370861e+00   1.3452721e+00 \end{filecontents*}  \begin{tikzpicture} \begin{axis}[x=3cm, y=3cm, z=0cm, view={0}{90}] \addplot3 [color=blue, samples y=0] file {voronoi.dat};  \end{axis} \end{tikzpicture}  \end{document}   Thanks for your help!! The Monty Hall Problem - where does our intuition fail us? How do I jump to the next or previous word with CTRL + arrow keys in a console? In terminal emulation applications, pressing CTRL + Left / Right arrows jumps from one word to the previous or next one. Is it possible to have the same functionality in a Linux console, whether it is in text or in framebuffer modes?  In my configuration, the CTRL + arrow keys are transformed into escaped character sequences and not interpreted. How can I use 3rd party libraries on QGIS plugins on Windows?   I've developed a plugin that uses rasterio and numpy for a customer, but he's having problems installing rasterio and numpy.  Actually rasterio and numpy were installed in it's main system Python (C:\Python27), but I need QGIS Python to recognize it. Uploading video to youtube in right format PC won't boot (Asus P5K pro mainboard) No beeps, no screen output What are preimage resistance and collision resistance, and how can the lack thereof be exploited? What is "preimage resistance", and how can the lack thereof be exploited? How is this different from collision resistance, and are there any known preimage attacks that would be considered feasible? What is the measure of the set of numbers in $[0,1]$ whose decimal expansions do not contain $5$? How to fix TikZ corners in 3D Am trying to draw a simple rectangle and there seems to be minor issue with two of the endpoints (f and d in the following). I tried line cap=rect as suggested by  but that did not seem to work.  The resulting image:    \documentclass{standalone} \setlength\PreviewBorder{5pt}%  \usepackage{tikz}  \newcommand*{\Width}{2.0} \newcommand*{\Height}{3.0} \newcommand*{\Depth}{1.0}  \begin{document} \begin{tikzpicture}%     \coordinate (A) at ( 0,       0,     \Depth);%     \coordinate (B) at (\Height,  0,     \Depth);%     \coordinate (C) at (\Height,  0,      0);%     \coordinate (D) at (\Height, \Width,  0);%     \coordinate (E) at ( 0,      \Width,  0);%     \coordinate (F) at ( 0,      \Width, \Depth);%     \coordinate (G) at (\Height, \Width, \Depth);%     \coordinate (H) at ( 0,       0,      0);%     %     \draw [blue, ultra thick,line cap=rect]%         (A) -- (B) -- (C) -- (D) -- (E) -- (F) -- cycle;%     \draw [blue, ultra thick,line cap=rect]%         (B) -- (G) -- (F) -- (E) -- (D) -- (G) -- cycle;%      \path (D)  [right] node {$d$};% Problem Point 1     \path (F)  [left ] node {$f$};% Problem Point 2 \end{tikzpicture}% \end{document}   This problem about  seems related, but I do not understand how to adapt that to my problem. How to add a space between a string for every 5th letter? Where can I see my flag count / history? Is there a section or page that lists my flag count and / or history? Can the graph of a bounded function ever have an unbounded derivative? Converse of Schur's Lemma in finite dimensional vector spaces I am trying to prove (or disprove) the converse of Schur's Lemma in finite dimensional vector spaces. I am not sure if it holds in this case, but I have tried to apply the idea that proves it in representation theory (see for example Theorem 4.3  that uses Maschke's theorem or in questions  and ).  The converse of Schur's Lemma in finite dimensional vector spaces is:     Let $V$ be a finite dimensional vector space over the complex numbers. Let $S$ be a set of endomorphisms of $V$ and assume that every endomorphism $A$ of $V$ such that $$AB=BA\text{ for all }B\in S$$ is of the form $\lambda I, \ \lambda\in\mathbb{C}$. Then $V$ is a simple $S$-space.   (*an endomorphism of $V$ is a linear operator from $V$ to $V$  *$V$ is a simple $S$-space if the only $S$-invariant subspaces of $V$ are $V$ itself and the zero subspace)  What I've tried so far:  Assume to the contrary that $V$ is not a simple $S-$space. Then, there exists a subspace $W$ of $V$ such that $W\not =\{0\}$, $W\not= V$ and $W$ is $S$-invariant. Let $W'=V\setminus W$. Then, since $V$ is finite, we can easily prove that $V=W\oplus W'$ (this is my attempt to translate Maschke's theorem in vector spaces). Consequently, for every $v\in V$, there exists unique $w\in W$ and $w'\in W'$, such that $v=w+w'$. Define the projection $P:V\rightarrow V$ by $Pv=w$ for every $v\in V$.   What is left to prove is that $PB=BP$ for all $B\in S$. Then $P$ is clearly not a scalar and thus we have the contradiction we are looking for.  There is a difficulty in showing that $PB=BP$ for all $B\in S$, because $W'$ might be $S$-invariant or not. More precisely:   Let $v\in V=W\oplus W'$ and $v\not =0_V$.  If $v\in W$ then $Bv\in W$ because $W$ is $S$-invariant, therefore: $PBv=Bv$ and $BPv=Bv$.  If $v\in W'$ then $Pv=0$, hence $BPv=B\cdot 0=0$, and  (i) if $Bv\in W'$ then $PBv=0$.  (ii) if $Bv\in W$ then $PBv=Bv$ and this is where the problem occurs.  Any hints, ideas or counterexamples would be very helpful. What's the Pythonic way to combine two sequences into a dictionary? Is there a more concise way of doing this in Python?:  def toDict(keys, values):   d = dict()   for k,v in zip(keys, values):     d[k] = v    return d 403 error after upgrading to apache2.4 After upgrading from Ubuntu 13.04 server, the www pages won't display themselves.     Error 403 Forbidden You don't have permission to access / on this server.   I've changed access control saves from apache2.2 to apache2.4, but that didn't work. What else could I do? How do you teleport a certain player to spawn after they win a 1v1 I managed a KitPvP server in Minecraft and everything works fine except when players wants to duel each other. They get sent to a room where they will be dueling. The main problem is when the winner wins, I have no idea how to teleport them back to spawn. Sci-fi novel involving living forever through teleporter copies In Star Trek TOS, we see the Defiant disappear to unknown parts  ('The Tholian Web'), and Star Trek: Enterprise revealed that the Defiant went back in time to the mirror universe ('In a Mirror Darkly', parts 1 &amp; 2).   Because of this, one might wonder why (in-universe) the mirror universe didn't obtain (and maintain) technological superiority over the main timeline. (Granted, the out of universe answer is that TOS depicted the two universes as having essentially the same level of tech)  So does any work (whether STO, or a pocket books work) address why the mirror universe didn't simply leap frog the main universe's technology?   (Or to put it another way, why did the mirror universe's technology appear to stagnate for a century after obtaining access to the Defiant's advanced technology?)