//main code  public static void main(String[] args) {  //initiate game board  initGame();     //start the game     do {         PlayerMove(Cplayer);         updategame(Cplayer, crow, ccol);         printboard();         //game over message         if (currentstate == you_win){             System.out.println("'X' Won!!");             else if (currentstate == comp_win)                 System.out.println("'O' won!!");                 else if (currentstate == draw)                 System.out.println("It's a Draw :(");         }
I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug.  Is == bad? When should it and should it not be used? What's the difference?
How do I run .sh scripts? Whenever I open a .sh file, it opens it in gedit instead of the terminal. I can't find any option similar to Right Click → Open With → Other Application... → Terminal.  How do I open this file in the terminal? Windows 7 Taskbar Icon Highlight Sticks After running Win 7 for some unknown period of time, the taskbar icon highlight starts to stick (video demo here: ). If I restart or kill explorer.exe and relaunch, it goes away.  Any idea what might be causing this? Google Drive storage mismatch What kinds of desktop environments and shells are available? Determine number of pages in a PDF file To consume REST services there is a lot of boilerplate code needed:   Build Apex Objects to model the responses Code to deserialize REST responses to those classes Handling of HTTP requests, responses and errors ...   Did anyone come up with patterns or best practices codified into an open source library or framework that one could just reuse in a similar project without reinventing the callout-wheel over an over again?  Like the zillions of trigger-frameworks that exist as repos on Github... How can I use the MS JDBC driver with MS SQL Server 2008 Express? My configuration:     windows XP SP3 JDBC 2005 MS SQL Server 2008 Express, exposed via tcp/ip on port 1433 sqljdbc.jar in class path    I tried:  try {     Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();     con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433/SQLEXPRESS2008;databaseName=Test;selectMethod=cursor", "sa", ""); } catch (Exception e) {     e.printStackTrace(); }   But it always throws an exception:  java.sql.SQLException: No suitable driver   I also tried the following urls:  localhost:1433/SQLEXPRESS2008  localhost/SQLEXPRESS2008  localhost   Same results.  Any help? How to make a Rigid Body fall off a conveyor belt? I've created conveyor belt and and two objects with rigid body physics. But the first object won't fall and second object falls backwards.  How can I fix it? Convergence in Probability How small a quantity should be added to x to avoid taking the log of zero? I have analysed my data as they are. Now I want to look at my analyses after taking the log of all variables. Many variables contain many zeros. Therefore I add a small quantity to avoid taking the log of zero.   So far I've added 10^-10, without any rationale really, just because I felt like adding a very small quantity would be advisable to minimize the effect of my arbitrarily chosen quantity. But some variables contain mostly zeros, and therefore when logged mostly -23.02. The range of the ranges of my variables is 1.33-8819.21, and the frequency of zeroes also varies dramatically. Therefore my personal choice of "small quantity" affects the variables very differently. It is clear now that 10^-10 is a completely unacceptable choice, as most of the variance in all the variables then comes from this arbitrary "small quantity".  I wonder what would be a more correct way of doing this.  Maybe it's better to derive the quantity from each variables individual distribution? Are there any guidelines about how big this "small quantity" should be?  My analyses are mostly simple cox models with each variable and age/sex as IVs. The variables are the concentrations of various blood lipids, with often considerable coefficients of variation.  Edit: Adding the smallest non-zero value of the variable seems practical for my data. But maybe there is a general solution?  Edit 2: As the zeros merely indicate concentrations below the detection limit, maybe setting them to (detection limit)/2 would be appropriate? Proving trigonometric equation $\cos(36^\circ) - \cos(72^\circ) = 1/2$ Please help me to prove this trigonometric equation.  $\cos \left( 36^\circ \right)-\cos \left( 72^\circ \right) = \frac{1}{2}$  Thank you. Stealing and reattaching a running process It's sunday and I left an instance of R running in the office. The script finished running, and I would like to save my workspace without going to the office. I can ssh to the computer, but I have not run the program into screen.  Is there a way, over ssh, to disown the process (I don't have access to jobsid of the terminal the program is running on!) and reattach it with say, reptyr? Reptyr and reptyr -T don't work without previously disowning the process  28845 3diag       20   0  139.3m  10.4m   0.0  0.1   0:12.06 S  `- urxvtd                                                                                        5327 3diag       20   0   16.4m   4.6m   0.0  0.1   0:00.02 S      `- bash                                                                                      5335 3diag       20   0 3499.3m 3.244g   0.0 43.3 171:57.89 S          `- R    The unique part of my question is that I explicitly require to detach a program without having access to the terminal in which it was created. How do I create bookmarks with pdfLaTeX? I'm using MiKTeX and using pdfLaTeX. I can generate the PDF, but there are no bookmarks. In the .tex-file it is using:  \chapter \section \subsection   (with labels)  I originally used make with sphinx to output LaTeX. It must work somewhat or I wouldn't get the PDF. When I say bookmarks, I mean when you are in Acrobat and the left side has the Bookmarks panel.  I am reading   But I am not sure where to apply this.  EDIT:  I applied this, \usepackage{bookmark}, and got bookmarks, but I never get the subsection bookmarks. How can I make a PATCH HTTP Callout from Apex? I need to make a PATCH http request.  I made the rather incredible discovery today that I can't set an HttpRequest to use the PATCH method, as when sending the request I get a callout exception:     System.CalloutException "Invalid HTTP method: PATCH"   The work around I've found on Stack Exchange and elsewhere is only applicable to a Salesforce Rest API request:    This is therefore not helpful to me as I'm calling out to a third party.  By what manner of magic can I send a PATCH request from Salesforce?  The only work around I can think of is to not do it from Apex - this is not an option. By just typing some commands, how can Ubuntu be uninstalled? I don't want to install Windows or anything, leaving my PC without an OS.  Would this command work?  sudo rm -rf / How can I sum two values and store the result in other variable? How can I download an APK file from the Play Store? What is the difference between Affection and Friendship, if any? I've risen Pokemon Amie Affection to 5 hearts on my Riolo in the hopes that it will evolve as soon as it levels up, but I'm not certain that this is the same thing as friendship, and I'd like to not waste a level.  My question is this: What is the difference between Pokemon Amie Affection and the Friendship stat? First, my apologies if this has already been asked/answered.  I wasn't able to find this question via search.  My question comes from Rudin's "Principles of Mathematical Analysis," or "Baby Rudin," Ch 1, Example 1.1 on p. 2.  In the second version of the proof, showing that sets A and B do not have greatest or lowest elements respectively, he presents a seemingly arbitrary assignment of a number $q$ that satisfies equations (3) and (4), plus other conditions needed to show that $q$ is the right number for the proof.  As an exercise, I tried to derive his choice of $q$ so that I may learn more about the problem.  If we write equations (3) as $q = p - (p^2 - 2)x$, we can write (4) as   $$ q^2 - 2 = (p^2 - 2)[1 - 2px + (p^2 - 2)x^2]. $$  Here, we need a rational $x &gt; 0$, chosen such that the expression in $[...]$ is positive.  Using the quadratic formula and the sign of $(p^2 - 2)$, it can be shown that we need   $$ x \in \left(0, \frac{1}{p + \sqrt{2}}\right) \mbox{ for } p \in A, $$  or, for $p \in B$, $x &lt; 1/\left(p + \sqrt{2}\right)$ or $x &gt; 1/\left(p - \sqrt{2}\right)$.  Notice that there are MANY solutions to these equations! The easiest to see, perhaps, is letting $x = 1/(p + n)$ for $n \geq 2$.  Notice that Rudin chooses $n = 2$ for his answer, but it checks out easily for other $n$.  The Question:  Why does Rudin choose $x = 1/(p + 2)$ specifically?  Is it just to make the expressions work out clearly algebraically?  Why doesn't he comment on his particular choice or the nature of the set of solutions that will work for the proof?  Is there a simpler derivation for the number $q$ that I am missing? Documents with typical LaTeX errors I am giving a LaTeX course and have the idea to let the students find and solve problems within a few documents. Basically they shall learn how to create minimal examples and read error messages.  However, currently I have no document with 'typical' errors around.  If someone has such examples from him- or herself or within this forum I would like to have the code or link. It does not matter if its short or long. It should just be enough to let the students play with it for some minutes.