I am trying to identify the MIME type using JAVA program, based on content.   For example:   I have a file abc.exe, i have renamed it to abc.xls and try to find the MIME type for the file, It supposed to show 'Application' But it showed as 'Excel' type. Can someone help me on finding the actual file type based on content?
How do you get a Media Type (MIME type) from a file using Java?  So far I've tried JMimeMagic &amp; Mime-Util. The first gave me memory exceptions, the second doesn't close its streams properly. How would you probe the file to determine its actual type (not merely based on the extension)?
Is ‘half half’ ambiguous? 50-50  Ex) There are half half milk and water. = there are 50:50 milk and water.  1/4  Ex) There is half half water. = there is 1/4 water. Is it right? Why is `enjoy to [verb]` incorrect I can say:     I love to read. I hate to read.   But it must be:     I enjoy to read. I enjoy reading.   What is enjoy so different? Interpretation of ROC curve primes whose difference is a multiple of $n$ Minecraft's got an "Open to LAN" feature, which can be used to set up a local server when two computers running Minecraft are on the same network. Some young relatives of mine use this to play together whenever they're in the same house, but they'd like to be able to play together from their respective residences.  A server is not optimal because it's a bit complex. I've tried using Tunngle to spoof that the computers are on the same connection to no avail.  How can I convince Minecraft's "Open to LAN" that their two separate computers are on the same network? Migrate from a virtual machine (VM) to a physical system Finding the solution of the congruence $4x\equiv16\pmod{26}$ Solve the congruence   $$4x\equiv16\mod{26}.$$  How do I find the solution to this? I have tried by the euclidean algorithm but the gcd is not $1$ so it doesn't work.  $$\begin{align} 26&amp;=&amp;6&amp;\times4&amp;+2\\ 4&amp;=&amp;2&amp;\times2&amp;+0 \end{align}$$  Note: I understand we can see that $4$ and $17$ are solutions but how would I work this out algorithmically? split file lines based on first field I have file with content like below and want to convert my output like below   Input  1,a,b,c 2,b,c 3,e,f 4,l  Required output  1,a 1,b 1,c 2,b 2,c 3,e 3,f 4,l    Values on first field is unique and no duplicate lines for 1st field in the input.  I am new to scripting and not sure how can we do this. Creating volumetric lighting (crepuscular rays) in Cycles (a.k.a. "god rays" and many other names) can be created in Blender Internal by checking the Halo checkbox in the lamp properties box.  How can I create a similar effect using Cycles? How to find out why "context is incorrect"? I have been trying to write my first addon for Blender over the last couple of days. One error I came across quite often is the context is incorrect error for an operation of bpy.ops.  I learned that one can ask the poll function of an operator if the context is correct, but this does not tell why the context is correct/incorrect. What would be the best way to figure that out? Only way I could think of is to look into the code of the poll function. If that is the best way, what is the fastest way to find the appropriate piece of code? Using while loop to ssh to multiple servers I have a file servers.txt, with list of servers:  server1.mydomain.com server2.mydomain.com server3.mydomain.com   when I read the file line by line with while and echo each line, all works as expected. All lines are printed.  $ while read HOST ; do echo $HOST ; done &lt; servers.txt server1.mydomain.com server2.mydomain.com server3.mydomain.com   However, when I want to ssh to all servers and execute a command, suddenly my while loop stops working:  $ while read HOST ; do ssh $HOST "uname -a" ; done &lt; servers.txt Linux server1 2.6.30.4-1 #1 SMP Wed Aug 12 19:55:12 EDT 2009 i686 GNU/Linux   This only connects to the first server in the list, not to all of them. I don't understand what is happening here. Can somebody please explain?  This is even stranger, since using for loop works fine:  $ for HOST in $(cat servers.txt ) ; do ssh $HOST "uname -a" ; done Linux server1 2.6.30.4-1 #1 SMP Wed Aug 12 19:55:12 EDT 2009 i686 GNU/Linux Linux server2 2.6.30.4-1 #1 SMP Wed Aug 12 19:55:12 EDT 2009 i686 GNU/Linux Linux server3 2.6.30.4-1 #1 SMP Wed Aug 12 19:55:12 EDT 2009 i686 GNU/Linux   It must be something specific to ssh, because other commands work fine, such as ping:  $ while read HOST ; do ping -c 1 $HOST ; done &lt; servers.txt Evaluation of $ \sum_{k=0}^n \cos k\theta $ I just wanted to evaluate  $$ \sum_{k=0}^n \cos k\theta $$  and I know that it should give  $$  \cos\left(\frac{n\theta}{2}\right)\frac{\sin\left(\frac{(n+1)\theta}{2}\right)}{\sin(\theta / 2)}   $$  I tried to start by writing the sum as  $$ 1 + \cos\theta + \cos 2\theta + \cdots  + \cos n\theta $$  and expand each cosine by its series representation. But this soon looked not very helpful so I need some clue about how this partial sum is calculated more efficiently ... Using the same variable as a fixed and random effect in Mixed Effect Models Screen Resolution Problem with Ubuntu 14.04 and VirtualBox How to manipulate 2D plots? How do I block unwanted callers without jailbreaking? Make IN clause behave like AND clause I've asked the same question on , but got no answer, so that's why I'm asking it here (I've read that simple sql questions should be asked at SO, but I have no choice).  Suppose I have 3 tables: posts, post_categories and categories. I'm implementing some kind of page with filters where I can filter posts by categories. User can select multiple categories. When he selects more than one, they should be summed. I can't get it working. What I have now is simple IN() SQL clause:  SELECT posts.id, post_categories.category_id FROM posts  JOIN post_categories ON posts.id = post_categories.post_id  WHERE post_categories.category_id IN (1,2,3) LIMIT 10;   But it is not matching all ids, it is OR and I need AND. What I need here is to find all posts that have categories with id=1 AND id=2 AND id=3, but instead this query returns posts that have at least one category from the IN() list. It's so cool that the notification reminds you of the colour of badge you've earned. But I am a little puzzled by the symbols:      Is it feasible to use the symbol from the earned site? At the moment it uses the symbol from the site I happen to be on (as you can see by looking to the left of the dropdown in each case.) Are global variables thread-safe in Flask? How do I share data between requests? Understanding relation between Quotient Space and $S^1$ There is this example at the Wikipedia article on Quotient spaces (QS):     Consider the set $X = \mathbb{R}$ of all real numbers with the ordinary topology, and write $x \sim y$ if and only if $x−y$ is an integer. Then the quotient space $X/\sim$ is homeomorphic to the unit circle $S^1$ via the homeomorphism which sends the equivalence class of $x$ to $\exp(2πix)$.   I understand relations, equivalence relation and equivalence class but quotient space is still too abstract for me. This seems like a simple enough example to begin with.  I understand (sort of) the definition but I can't visualize. And by this example and others, there is a lot of visualizing going on here! torus, circles etc.