add an image from Database into JTable

Question: i am trying to add an image that is in my database in a column in JTable
with a number and a code special to this image the problem is i got the number and the code but the image doesn't show i don't know why here is my code
String sql="SELECT id,chiffre,image FROM symbolique WHERE id  BETWEEN 200 and 205";
try{
    st=connexion.prepareStatement(sql);
    res=st.executeQuery();
    while(res.next()){
        int j=0;
        String [] code= new String[1000];
        String [] chiffre1=new String[100];
        code [j] = res.getString("id");
        chiffre1[j] = Integer.toString(res.getInt("chiffre"));
        Blob blob = res.getBlob("image");
        is2 = new BufferedInputStream(blob.getBinaryStream());
        Image raw = ImageIO.read(is2);
        ImageIcon icon  =new ImageIcon(raw);
        Object [][] data = new Object[200][100];
        data[j][1]= code [j];
        data[j][2]= chiffre1[j];
        data[j][3]=icon;
        j++;
        String title[] = {"image", "chiffre","code"};
        DefaultTableModel model = new DefaultTableModel(data, title);
        table.setModel(model);
    }
}catch(Exception e){
   JOptionPane.showMessageDialog(null, e);}
}

Answer:
put Icon/ImageIcon to JTable better to the TableModel directly
you have to override getColumnClass for Icon/ImageIcon in XxxTableModel for showing this Object as image in the JTables view
for detailed informations (incl. working code examples) to read official Oracle tutorial - How to use Tables
Comment: i didn't understand how to do this : put Icon/ImageIcon to JTable better to the TableModel directly
Answer: This won't help solve the image problem but right now your code recreates the TableModel for every row in the ResultSet, which means you will only ever see one row of data.

Since you have looping code you need to create an empty DefaultTableModel before the loop starts.
Inside the loop you then use the addRow(...) method to add another row of data to the TableModel for every row in the ResultSet
When you finish the loop then you use the model to create the JTable.

Did you add any debug code? Did you attempt to display the width/height of the image to confirm that you are reading the image properly? Why don't you do a simple test that tries to read and display an image in a JLabel first since using a JTable is more complicated than using a JLabel. Then once you get that working you can apply the knowledge to using a JTable.
Comment: yes i tried it on JLabel and it works properly i can see my image but with JTable it doesn't work i don't know why ? i have to work with JTable because i want to get a number and a code corresponding to the image

add an image from Database into JTable


CryptGenRandom Entropy

Question: CryptGenRandom is a random number generator function in CryptoAPI in Windows. How much entropy has that random number generator ? I have already looked a lot, but I couldn't find it.
Comment: Also see [Cryptanalysis of the Random Number Generator of the Windows Operating System](https://eprint.iacr.org/2007/419.pdf) by Leo Dorrendor.
Answer: The exact algorithm of Windows CryptGenRandom was never published, therefore, some security experts suggest not to use it at all.
Some reverse-engineering and cryptanalysis was made.
A published research (Cryptanalysis of the Windows Random Number Generator - Leo Dorrendorf, 2007) examined Windows 2000 RNG and found a number of
weaknesses in the design and implementation.
The document also describes the entropy collector mechanism of the algorithm (section 4.2.3). The Entropy sources are:
<code>Source                   Bytes requested
CircularHash              256
KSecDD                    256
GetCurrentProcessID()       8
GetCurrentThreadID()        8
GetTickCount()              8
GetLocalTime()             16
QueryPerformanceCounter()  24
GlobalMemoryStatus()       16
GetDiskFreeSpace()         40
GetComputerName()          16
GetUserName()             257
GetCursorPos()              8
GetMessageTime()           16
NTQuerySystemInformation calls:
ProcessorTimes             48
Performance               312
Exception                  16
Lookaside                  32
ProcessorStatistics       up to the remaining length (3584 bytes buffer)
ProcessesAndThreads       up to the remaining length
</code>
Since we are talking about a pseudo-number-generator and not a real-number-generator, you may say that there is no real entropy at all, or count only the sources that you may consider as "entropy" (pseudo-entropy).
I was unable to find information regarding newer versions on Windows.
Comment: what's about Windows Vista/7/8 entropy?
Comment: The research link is bad. Can you adjust?
Comment: A presentation is also available: http://www.wisdom.weizmann.ac.il/~naor/COURSE/PRIVACY/pinkas_prg_insecurity.ppt
Comment: This is a very good answer! I really like your systematic approach. How can you determine the *bytes requested* for each algorithm? The *performance*'s inspection has a very high proportion in the overall entropy (312 bits). Can you explain why?  - - It would love to get your systematic approach also for the image analysis generally because I cannot find any quality preview about any algorithm, etc here http://cs.stackexchange.com/q/4935/10350

CryptGenRandom Entropy


SQL Server, connection pools vs static connection for special cases

Question: I sort of know the answer to this, but cannot really grasp the underlying concept. I know you are always instructed to use connection pooling now. But imagine this scenario.
I need to read data from one database, and one table, multiple times.
Connection pooling is going to inject microseconds of overhead, but why not eliminate that by using a single connection for everything and locking around that?
Since it is one database, with one table. Isn't it pretty unlikely that we will be able to get any performance boost from multithreaded connection pools?
Just hoping for some clarity here. And maybe some simple resources which would explain WHY, connection pooling ALWAYS is better.
Thanks. I know this is not the greatest question, and I appreciate your time. I am specifically in the .net environment, but this is a basic concept across programming correct?
Comment: Side note: one of basic concept across programming is "never guess about performance of particular code - try and measure". And another one less basic - there is no algorithm that is ALWAYS better - even bubble sort can outperform pretty much anything on 3 element list :)
Answer:
With one global connection you need to be prepared to handle spurious connection failues. Those can always happen (network hiccup, ...).
You absolutely do get concurrency when using multiple concurrent statements against a single table. SQL Server does not usually lock tables exclusively (exceedingly rare).
You will forget to use the synchronization protocol somewhere (lock everywhere). You will get it wrong eventually and have to fight races.
If you have a slow runaway query that would block the entire app. It will appear "hung" to browsers.
You serialize all HTTP requests on the global lock. You only use one CPU. You won't scale at all. Your app will not handle burst well.

Having a single global connection is really a bad idea. Why not just use pooling? That saves you the development work of using synchronization. It is even less work.
Of course, pooling is not always better. You can construct pathological cases where it isn't. I never encountered a case where I needed to keep a connection open for longer than the current HTTP request, though.


What's the difference between using the/a/(nothing) in this sentence?

Question: What's the difference between using the/a/(nothing) in this sentence? What's the difference between definite and indefinite article? What about not using them at all - would it be still correct?
"Breaking the/a/(no article) boundaries of fear."
Answer:
Breaking a boundaries doesn't work because a/an can only be used with singular nouns. Boundaries is plural.
Both breaking the boundaries and breaking boundaries are fine, the former implying all the boundaries, and the latter implying some of the boundaries.
Comment: Or one could use singular *boundary* and say either "breaking a boundary" or "breaking the boundary", depending on the metaphor intended.


How important is material thickness in really large cooking pots?

Question: I need a stainless steel pot of 100 liters or maybe even bigger for cooking. They sell at different wall material strength at the wholesale, varying from 0.8mm to 1.6mm (they all have sandwich bottom of course). The thick-walled ones cost twice as much. This seems like it might be a situation where wall thickness is more than just an aesthetic issue, but they are all made by manufacturers for professional cooking equipment. I don't care about aesthetics, but I don't want to spend several hundred euros on a tin can. Does anyone have experience? If I get the cheaper one and actually cook 100 liters of food in it repeatedly, will it just fall apart or deform or require extreme care to maintain?
Comment: I have to ask: what on earth are you making 100 liters of frequently?  Are you cooking for a military division?
Comment: I use a 40 liter pot for brewing beer (in roughly 20-25 liter batches, since there's a need for headspace to avoid boilover, and typically 8 liters boils off to reach that end volume). Brewing larger batches of beer would be a *conceivable* use.
Answer: Firstly, a pot with thicker walls is, without a doubt, more durable. Thin-walled pots can dent more easily and even warp over time, especially if you're planning to cook large quantities often. You want your culinary equipment to withstand the demands of your kitchen.
Now, onto heat distribution - another key factor that's influenced by your pot's thickness. Thin walls can lead to uneven heating, causing hot spots where your food could stick or even burn. A thicker pot, especially one with a sandwiched bottom made of a heat-conductive material like aluminium or copper, helps to distribute the heat more evenly. You don't want your food to cook unevenly, do you?
Stability is another aspect you need to consider. Imagine this - you're carrying a pot full of delicious stew, but the pot is wobbly and unstable. It's a disaster waiting to happen! A thicker pot is generally more stable, reducing the risk of unfortunate kitchen accidents.
Finally, let's talk about longevity. We all want to get the most out of our kitchen investments, right? A pot with thicker walls may cost more upfront, but it's likely to outlast a thinner one, especially under regular, heavy use.
But remember, this doesn't mean a thinner pot will instantly fall apart or deform. It might serve you well, especially if you're not using it heavily or frequently. However, if the kitchen is your battlefield and you're planning to use this pot as your main weapon, investing in a thicker one could be worthwhile.
Answer: If the difference between the two is just the wall thickness, with the bottom thickness being more-or-less the same, then what you're concerned with here is durability, and the ability to move the pot.
A pot that large with < 1mm thick walls is going to be immobile on the stove once filled, and you might even have to worry about it distorting or bloating with the weight.  A pot with thicker walls would be theoretically possible to slide around the stove, and for 2-3 strong people to pick it up.


Stop notifications from a deleted app

Question: I got the app Baby Story for my iPod Touch a while ago, and then decided I didn't like it and deleted it. Part of the reason I got rid of it was because it would pop up random messages with things like, "Your baby is hungary!" The app appears to be completely deleted, and I can't find any reference to it on the iPod anywhere, but I'll still get random notifications with things like, "Your baby is sick." Is there a way, short of reformatting the iPod, to stop these messages?
Answer: Removing an app should disable all of the Push Notifications. Try rebooting your iPod, and making sure that iTunes did not re-install it.
Also, you can try disabling all Notifications, then -re-enabling them.
Maybe post a screenshot of the message. You may have another app installed (mBox for example) that displays messages from apps that send emails as well. (of course this is just a far fetched scenario).
Answer: Try going into the "notifications" settings in your iPod's settings to see if u can the app listed there. If so then just turn off it's notification privileges.
Comment: I looked in there, but I didn't see the app. I thought about reinstalling the app and then trying to turn off the notifications, but I'm afraid I'll just get stuck with twice as many.
Comment: Reinstalling would probably be the way to go. Then you can block the application all together and remove it without a problem. If this doubles the amount of notifications, you should report it as a bug to Apple.
Comment: Thanks for the responses. Apparently, what I needed to do was ask about it here. Since I posted about it I don't think I've had any notifications from the application.
Comment: haha victory! :D

Stop notifications from a deleted app


Help with linux based gaming

Question: I am new to Ubuntu and linux in general. I am an avid gamer that used to play off of steam on windows, and am now finding that steam doesn't work and I cannot play any non- linux games. I am wondering if there is any way to play these games without going back to windows
Comment: Steam works fine on Ubuntu.  If you are having issues, open a terminal window and type `steam`.  Edit your question and include any error messages you get.
Comment: You can install Steam for Windows and use that, but you will not have good performance.
Comment: "non-linux games" already answers your question. If you want "steam doesn't work" provide something for us to help you with.
Comment: when I try to use steam it says im missing libGL.so.1 32-bit libraries
Answer: If the problem is the missing libGL.so.1 32-bit libraries please check this thread:
Trying to install Steam ERROR: You are missing the following 32-bit libraries, and Steam may not run: not
Sees like creating a link is the way to go:
<code>sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib
</code>
Good luck

Help with linux based gaming


Show that it is a stopping time

Question: My task is to describe the following stopping time formally and to prove that it is indeed a stopping time.
Let $A\in \mathcal{B}(\mathbb{R})$ be a fixed set. $(X_t)_{t\ge 0}$ hits A for the first time, leaves A again and hits A for the second time.
I defined the stopping time $\nu = min \{ t\in \mathbb{N} | \exists \tau_1, \tau_2 < t \text{ such that } X_{\tau_1} \in A, X_{\tau_2} \notin A, X_t \in A \}$, where $min\emptyset := \infty$
In order to proof, that it is indeed a stopping time I rewrote $\nu$:
$\{\nu=t\} = \cap_{n=0}^{\tau_1 - 1} \{X_n \notin A\} \cap_{n = \tau_1}^{\tau_2 - 1} \{X_n \in A \} \cap_{n = \tau_2}^{t - 1} \{X_n \notin A \} \cap \{ X_t \in A\}$,
which is "obviously" in $\mathcal{F}^X \subset \mathcal{F}_t$ (the filtration).
My questions are:

Is this a valid definition of a stopping time?
Am I allowed to rewrite the stopping time in terms of the parameters $\tau_1, \tau_2$?

Thank you in advance!
Comment: You seem to have already [asked this question](https://math.stackexchange.com/q/4663360/).  In the future, rather than deleting and reposting, please use the [edit] button to make improvements to your question.
Answer: Don't forget the quantifiers on $\tau_1$ and $\tau_2$ in your definition of $\nu$. Taking them into account you'll have
$$
\{\nu=t\}=\cup_{\tau_1=0}^{t-2}\cup_{\tau_2=\tau_1+1}^{t-1}\left[\cap_{n=0}^{\tau_1 - 1} \{X_n \notin A\} \cap_{n = \tau_1}^{\tau_2 - 1} \{X_n \in A \} \cap_{n = \tau_2}^{t - 1} \{X_n \notin A \} \cap \{ X_t \in A\}\right].
$$
Otherwise, it looks okay.
You could also "modularize" things by checking that if $S$ is a stopping time then so is $T(A,S):=\min\{n>S:X_n\in A\}$.  Your stopping time is the two-fold iteration of this construction:
$$\nu=T(A,T(A^c,T(A))),
$$
where $T(A)$ is just the first time to hit $A$.

Show that it is a stopping time


Does MissingNo exist 'canonically'?

Question: The infamous Pokémon MissingNo is not supposed to exist, it's a programming glitch and was never intended to be in the game. That being said there are no mistakes, just happy accidents, something like that anyway. Is MissingNo acknowledged as existing as part of the lore? I think that would be interesting, personally.
Answer: MissingNo. is not a Pokémon, it's not something that was never intended to be in the game. It is random data found in memory that is misread by the game, which believes a Pokémon should be there.
Nintendo's customer service for the GameBoy has a specific section about MissingNo., which says the following:

MissingNO is a programming quirk, and not a real part of the game. When you get this, your game can perform strangely, and the graphics will often become scrambled. The MissingNO Pokémon is most often found after you perform the Fight Safari Zone Pokémon trick.
To fix the scrambled graphics, try releasing the MissingNo Pokémon. If the problem persists, the only solution is to re-start your game. This means erasing your current game and starting a brand new one.

Even Nintendo calls it just a "programming quirk", it is not an entity whose "canonicity" can be confirmed or denied.
Comment: On a side note, the second paragraph in the quote is actually completely wrong on both counts. Releasing MissingNo. doesn't do anything to fix the graphics, and you don't have to restart your game to fix them either (viewing any non-glitch Pokémon's details or Pokédex entry fixes it).
Comment: It's an entity that exists because of a programming quirk (their PR friendly name for glitch). However, that doesn't mean that they couldn't look at this thing they accidentally created and somehow incorporate it into the lore. It wouldn't be the first time a creative work had a mistake be explained into canon later. It wouldn't be completely like turning a bug into a feature. Kind of like how they had to make up an explanation for why you can hear things in space in Star Wars, it was an oversight that they created new lore to explain.

Does MissingNo exist 'canonically'?


A basic game of Tic-Tac-Toe

Question: import java.util.Scanner;

public class ticTacToe {

    public static Scanner input;

    public static void main(String[] args) {
        input = new Scanner(System.in);
        char p1 = ' ';
        char p2 = ' ';
        boolean gameOver = false;
        char[][] board = new char[3][3];
        int pos1 = 0, pos2 = 0;

        // Welcome the user to the game
        System.out.println("----- Welcome to Tic-Tac-Toe! -----");
        System.out.println("Would you like to play as x's or o's?");
        p1 = input.next().charAt(0);
        System.out.println("Would you like to go first or first?");
        String first = input.next();

        while (checkLetter(p1) == false) {
            System.out.println("Invalid input. Please choose either x or o.");
            p1 = input.next().charAt(0);
        }
        p2 = setCompLetter(p1);

        // game loop
        while (gameOver == false) {
            // Player 1 turn
            player1(p1, p2, board);
            // Check P1 victory
            if (checkP1Victory(board, p1) == true) {
                gameOver = true;
                System.out.println("Player 1 wins");
                break;
            }
            // Player 2 turn
            player2(p1, p2, board);
            // Check p2 victory
            if (checkP2Victory(board, p2) == true) {
                gameOver = true;
                System.out.println("Player 2 wins!");
                break;
            }
            // Check for draw
            if(checkDraw(p1, p2, board) == true){
                System.out.println("It is a draw!");
                break;
            }

        }

    }

    // Checks to see if the user input is valid when they select a letter
    public static boolean checkLetter(char letter) {
        if (letter != 'x' && letter != 'o') {
            return false;
        }
        return true;
    }

    // Sets the computer letter based on the user input
    public static char setCompLetter(char p1) {
        if (p1 == 'x') {
            return 'o';
        } else {
            return 'x';
        }

    }

    // Prints the board to the console
    public static void printBoard(char[][] board) {
        for (int i = 0; i < board.length; i++) {
            for (int j = 0; j < board[i].length; j++) {
                System.out.print("[ " + board[i][j] + " ]");
            }
            System.out.println();
        }
    }

    // Player 1 turn sequence
    public static void player1(char p1, char p2, char[][] board) {
        //System.out.println("Player 1 turn.");
        System.out.println("Enter the position: ");
        int pos1 = input.nextInt();
        int pos2 = input.nextInt();

        // Checks to see if the user entered a position that is in bounds
        while ((pos1 >= 3) || (pos2 >= 3)) {
            System.out.println("Out of bounds index, re-enter a position");
            pos1 = input.nextInt();
            pos2 = input.nextInt();
        }

        // Checks to see if there is an x or o in the position
        while ((board[pos1][pos2] == p1) || (board[pos1][pos2] == p2)) {
            System.out.println("Already something in that position, enter another.");
            pos1 = input.nextInt();
            pos2 = input.nextInt();
        }
        board[pos1][pos2] = p1;
        printBoard(board);
    }

    // Player 2(CPU) sequence
    public static void player2(char p1, char p2, char[][] board) {
        int pos1 = (int) (Math.random() * 3);
        int pos2 = (int) (Math.random() * 3);
        while ((board[pos1][pos2] == p1) || (board[pos1][pos2] == p2)) {
                pos1 = (int) (Math.random() * 3);
                pos2 = (int) (Math.random() * 3);
            }
        board[pos1][pos2] = p2;
        System.out.println("");
        printBoard(board);
    }
    // Checks the p1 victory
    public static boolean checkP1Victory(char[][] board, char p1) {
        // Checks player 1 row victory
        for (int i = 0; i < board.length; i++) {
            if ((board[i][0] == p1) && (board[i][1] == p1) && (board[i][2] == p1)) {
                return true;
            }
        }
        // Checks Player 1 verticle victory
        for (int j = 0; j < board.length; j++) {
            if ((board[0][j] == p1) && (board[1][j] == p1) && (board[2][j] == p1)) {
                return true;
            }
        }
        // Checks Player 1 diagonal victory(left to right)
        if ((board[0][0] == p1) && (board[1][1] == p1) && (board[2][2] == p1)) {
            return true;
        }
        // Checks Player 1 diagonal victory(right to left)
        if ((board[0][2] == p1) && (board[1][1] == p1) && (board[2][0] == p1)) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean checkP2Victory(char[][] board, char p2) {
        // Checks player 2 row victory
        for (int i = 0; i < board.length; i++) {
            if ((board[i][0] == p2) && (board[i][1] == p2) && (board[i][2] == p2)) {
                return true;
            }
        }
        // Checks Player 2 verticle victory
        for (int j = 0; j < board.length; j++) {
            if ((board[0][j] == p2) && (board[1][j] == p2) && (board[2][j] == p2)) {
                return true;
            }
        }
        // Checks Player 2 diagonal victory(left to right)
        if ((board[0][0] == p2) && (board[1][1] == p2) && (board[2][2] == p2)) {
            return true;
        }
        // Checks Player 2 diagonal victory(right to left)
        if ((board[0][2] == p2) && (board[1][1] == p2) && (board[2][0] == p2)) {
            return true;
        } else {
            return false;
        }
    }
    public static boolean checkDraw(char p1, char p2, char[][] board){
        int count = 0;
        for(int i = 0; i < board.length; i++){
            for(int j = 0; j < board[i].length; j++){
                if(board[i][j] == 'x' || board[i][j] == 'o' ){
                    count++;
                    if(count == 9){
                        return true;
                    }
                }
            }
        }
        return false;
    }

}

Answer: It looks like you are well aware of your IDEs formatting feature - the code is very well formatted.
DRY
checkP1Victory and checkP2Victory can be condensed into a single function, checkVictory. The logic is exactly the same, the only difference is the player token being checked.
Conditionals
Favor using the not (!) operator over checking explicitly for false.
Printing
Favor building strings and only using System.out.println on the result of a method call. For example, printBoard should return a String. Use a StringBuilder.
Separate concerns
Try to extract the idea of a TicTacToe game out into a class. Don't have any I/O in the class itself (no prints!) - you should be able to create a Driver (main class) that uses this TicTacToe game. The driver could use plain console I/O, like it is now, or possibly use a GUI approach. It could even simulate a game between two computers. Separate the logic from the input method, and you'll have more robust code.
Enum
An enumeration would be a better choice for marking cells, instead of using a character. You would have X, O, and then Empty. There is a good argument to be made to use something like PlayerOne, PlayerTwo and Empty, since it is the driver which would control how things are displayed. Perhaps your client wants to use Dogs and Cats, not Xs and Os.
Comment: Thank you for your input!  I dont think I have ever encountered Enums before so I will have to look into that. I will start to revise!
Comment: If you wish to receive more feedback, consider submitting another question with your new code. More pointed feedback can be given after you solve the bigger issues (sep. concerns, DRY) :)
Answer: Use conventional names.
Class names in Java use the CamelCaps notation, i.e. the class name should be TicTacToe, not ticTacToe.
Encapsulate / hide fields, and consider making them final.
Your field input is public, which means every other class could access it. It's not final, which means it could be changed from anywhere in the code. You might consider using private static final Scanner input = new Scanner(System.in); instead.
Encapsulate / hide methods
All of your methods are public, but the way they are written, they should (apart from unit tests) never be accessed from anywhere else. In such a case, making them public might not make sense.
Consider using OO
All your data is passed around between methods via arguments. Consider creating an instance of your TicTacToe class and turning parameters which are passed around frequently, like the board, into instance fields.
The input validation in player1() is bogus
I can enter a position which is out-of-bounds by first entering a position  at which there already is something, and then enter a position which is out-of-bounds.
I can also enter a position which is out-of-bounds and crashes the program by entering negative numbers.
Spelling
vertical is neither a beer or body part ;) (change verticale and verticle to vertical).
Redundant code
Did you notice that the contents of checkP1Victory() and checkP2Victory() are identical? You need only one of these two methods, and can make it generic for any player. This also seems more logical from the point of view of tic tac toe rules: The rules for winning are the same for player1 and player2.
Extract methods
In checkP1Victory() / checkP2Victory(), I'd extract 3 methods.
I'd extract the first loop into checkHorizontalVictory(), the second loop into checkVerticalVictory(), and the two if statements into checkDiagonalVictory().
This would simplify the code significantly, and you could get rid of comments.
Avoid check in method names.
check is a bad word to use in methods. There is a concept called CQS -  Command-Query-Separation that we want to follow with methods. Methods should be either commands or queries but not both. Commands are void methods that don't return anything, but they have side-effects. Queries return something but usually do not have side-effects. The name of a method should tell whether it is a command or a query, and with check that's problematic. It sounds like a command, but in your case it is a query.
How about hasPlayerWon instead of checkPlayerVictory() (resp. checkP1Victory() / checkP2Victory())?
Notice how nice that reads in if-statements:
if (hasPlayerWon(p2)) { ... }

Food for thought: If you go for a little more OO and delegation, you could even end up with code which reads as nicely as:
if (player2.hasWon(game)) { ... }

Truth doesn't need to be compared
Instead of while (gameOver == false) use while (!gameOver). Instead of if (xyz == true) use if (xyz).
Unused variables and values.
In method main(), the variables pos1 and pos2 are unused and can be removed.
In method main(), the initial values ' ' of variables p1 and p2 are unused and can be removed.
In method main(), the variable first is unused, and because it's initialized from input.next(), I believe it's a bug.
Method length
Consider splitting method main(), it is very long. Good method lenghts in Java are 1-3 lines, sometimes a little bit longer, but hardly ever more than 6-7 lines.
Consider changing or even removing checkDraw method.
This is a suggestion to the algorithm. Currently you determine whether the game is a draw by detecting that the all 9 fields of the board contain either 'x' or 'o'.
You could also find out the inverse faster, by finding out that one of the fields is not 'x' or 'o'.
Then you would not have to inspect the entire board, but could stop looking after you found the first ' '. It would also get rid of the count variable.
Alternatively, you could also count the number of moves in the main() method. If it reaches 9, it's a draw.
Consider using constants.
Mistyping 'x' as 'X' or 'o' as 'O' or '0' is all too easy and can lead to long long debugging sessions if you do not have unit tests (and it seems you do not have unit tests).
You could introduce constants
private static final char PLAYER1 = 'x';
private static final char PLAYER2 = 'o';

Then replace all other occurrences of 'x' and 'o' with PLAYER1 and PLAYER2. This can make the code easier to read, and it also makes the code easier to maintain in case your requirements change, i.e. because your customer / client / teacher / whoever wants to have something else instead of 'x' and 'o'.
Consider using an enum instead of char for your board.
Your board fields can only ever have three valid states:
 * ' '
 * 'o'
 * 'x'
However, the type char allows not 3 but 65536 different states, leaving each field potentially with 65533 invalid states. Parts of your code will inevitably be busy with preventing these 65533 invalid states from ever happening.
An enum is a class with a predefined set of instances. Here are two options:

You could have an enum with two values, and represent the empty field with null.
You could have an enum with three values, one of them being the empty field.

Here's the enum for the first option:
enum Player {
    PLAYER1('x'),
    PLAYER2('o');
    private final char displayChar;
    Player(char displayChar) {
        this.displayChar = displayChar;
    }
    public char getChar() {
        return displayChar;
    }
}

Both approaches have pros and cons, and enum might be new to you, so I'm not sure whether you really want to consider it already. But if you do, or even in the failed attempt of doing so, you might actually learn a lot, so it might be worth trying.
SRP violations
The SRP is the Single Responsibility Principle, and your methods violate it: They contain I/O and business logic at the same time. I/O and business logic are separate concerns and thus should be separated from each other. Imagine you want to create a graphical version, much of your code couldn't be reused without modification. And it turns out that reusable is a synonym to testable, and both are a subset of maintainable.
More Ideas for playing with the code further to learn more.

Allow human vs human and pc vs pc games.
Allow players to pick their symbols.
Split your program into multiple classes.

Consider unit testing, consider TDD
Title says it all.
Comment: Wow thank you so much for taking the time out to review and give such extensive feedback of my code.  Looks like I have a lot to learn so I will get crackin!

A basic game of Tic-Tac-Toe


What's the meaning of "不见面也有不见面的好"?

Question: I really couldn't understand the meaning of this sentences.
见面 means to meet, to see
不见面 means not meet, not see.
不见面也有不见面的好。
But I really couldn't get what it is saying.
Answer: We can break this up into three parts

不见面 - to not meet
也有 - also has
不见面的好 -  the good aspect (or benefits) of not meeting

There's also benefits of not meeting (or not seeing (each other)).
Answer: The construct <code>(action) 也有 (same action) 的好</code> is a generic way of expressing that the action (which is negative), in this case "not meeting", has some upside to it. So this sentence literally means: "there's a silver lining to not seeing you."
It seems you might have seen this in a list of romantic one-liners; in the original (不见面也有不见面的好,你永远是,我记忆中的样子), it goes on to explain the brighter side of not meeting is: "you will always remain as you are now in my memories."
Answer: something or somebody you meet will hurt again,
so have this sentence, not meet,sometimes good.
Answer: a pretext for being unable to see someone whom you are longing to see. there may or may not be any real "benefits" in not seeing each other as the alleged "benefits" merely serve to provide a certain degree of comfort to a sad reality.
"也有" is "yes ... but". If not seeing each other is a good thing, you would simply say "不见面有不见面的好" (without the "也"). "也" gives away the fact the not seeing each other is bad (sad) and is definitely not something you want, but you try to conceal your true feeling by pretending that it is not as bad as it really is.
Answer: If someone told you that, you can reply: 我知道,相见争如不见 or 相见不如怀念

What's the meaning of "不见面也有不见面的好"?


What is intuitively the Hodge dual of a $p$-form?

Question: Carroll in his textbook "Spacetime and geometry" defines the Hodge dual of a $p$-form $A$ on an $n$-dimensional manifold as $$(\star A)_{\mu_1...\mu_{n-p}}=\dfrac{1}{p!}\epsilon^{\nu_1...\nu_p} _{\ \ \ \ \ \ \ \ \ \ \ \mu_1...\mu_{n-p}}A_{\nu_1...\nu_p}.$$
Although this is pretty straightforward, I find that I lack any intuitive/geometrical understanding of this. What does the dual actually mean?
Comment: Related/possible duplicate: https://physics.stackexchange.com/q/313091/50583
Comment: Wiki definition: "It is defined on the exterior algebra of a finite-dimensional oriented vector space endowed with a nondegenerate symmetric bilinear form". The "nondegenerate symmetric bilinear form" in plain Physiclish is just the metric. OP's expression of Hodge dual $(\star A)_{\mu_1...\mu_{n-p}}=\dfrac{1}{p!}\epsilon^{\nu_1...\nu_p} _{\ \ \ \ \ \ \ \ \ \ \ \mu_1...\mu_{n-p}}A_{\nu_1...\nu_p}$ is restricted to the case of Euclidian flat spacetime.
Answer: There's a simple way to visualize differential forms that helps here.
One of the most important properties of differential $p$-forms is that they are tensors that can naturally be integrated over a $p$-dimensional submanifold. The simplest example is a one-form, which can be integrated over a one-dimensional curve $C$,
$$\int_C A = \int A_\mu dx^\mu.$$
Unlike the integration of a vector,
$$\int \mathbf{F} \cdot d\mathbf{x}$$
this integral requires no metric to define. Similarly, a two-form can be naturally integrated over a surface, for example
$$\int_S F = \int F_{\mu\nu} dx^\mu dx^\nu$$
could be interpreted as a magnetic flux if the surface is spatial.
This leads directly to the geometric interpretation of differential forms. The familiar visualization of a one-form is a set of hypersurfaces, i.e. submanifolds of codimension one. Similarly, two-forms may be interpreted as submanifolds of codimension two, and so on. In three dimensions, a one-form is a bunch of planes, a two-form is a bunch of lines, and a three-form is a bunch of points.
You can easily count the number of planes a curve goes through, the number of lines a surface intersects, and the number of points a volume contains. These are the geometric interpretations of integrals of one-forms, two-forms, and three-forms over curves, surfaces, and volumes. (The main thing missing from this picture is the sign; you should also think of the surfaces, etc. as coming with orientations, though that's harder to draw.)
The wedge product can be interpreted as taking the geometric intersection of the differential forms involved. For example, the wedge product of two one-forms in 3D is a set of intersections of surfaces, which is a set of curves, i.e. a two-form.
The interpretation of the Hodge dual, which is explicitly defined via the metric, is that it is the "orthogonal complement" of a differential form. The dual of a one-form in 3D is a set of curves perpendicular to the planes of the original one-form, so that the local densities of surfaces in both are proportional.

For completeness, here are a few more facts.
First, the exterior derivative $d$ corresponds to taking the boundaries of the surfaces associated with a differential $p$-form. That is why $d^2 = 0$ is just the usual "boundary of a boundary is zero" principle, and why a closed differential form is annihilated by $d$; its visualization is in terms of closed surfaces.
Second, one can also interpret the contraction of a $p$-form with a $(p, 0)$ antisymmetric tensor geometrically. A $(p, 0)$ antisymmetric tensor is called a $p$-blade and is constructed as the antisymmetric product of $p$ vectors. It can be interpreted as the $p$-dimensional volume element corresponding to the parallelepiped spanned by the vectors; for example the $dx^\mu dx^\nu$ above is a $2$-blade that is a small square in Cartesian coordinates.
Third, my interpretation is not the most common one. Most books treat $p$-forms in the exact same way as $p$-blades, i.e. as small volume elements. This is the point of view advanced in the three other answers to this question. It's a little simpler, but to use it you have to explicitly use the metric to convert forms to blades. My interpretation just generalizes the intuition we are usually given for $1$-forms as families of hypersurfaces, without needing to use the metric to modify the object.
Comment: @tparker I trawled through a lot of Math.SE questions a few years ago until I found an excellent one that basically says the same thing I say here. No idea how to find it again, though.
Comment: I'm not sure the expression "it's easy to see" is as appropriate to most people as to e.g. you, but upvoted. :-)
Comment: @TheQuantumMan I was about to edit to address this, but I see it's nicely explained in tparker's answer!
Comment: @StephenG Actually, in practice "it's easy to see" is just code for "I'm too lazy to check"! After coming back I realized that particular statement was just wrong, thanks for that.
Comment: @knzhou great answer, but I have a question: how can we see the "orthogonal complement" interpretation for the Hodge dual in a bit more generality so that the explanation of the example that you give for the dual of the 1-form comes out naturally?
Comment: This is a beautiful conceptualization that I hadn't come across before. Where did you learn it?
Answer: The $\epsilon$ symbol is (proportional to) the full-rank "volume form", which you can think of as a little full-dimensional box sitting at every point on your manifold. (Note that this is a different intuitive picture from the equally valid one used in knzhou's answer.) Each index corresponds to a different direction, or to one edge of the box coming out of one particular corner. Contracting the $\epsilon$ symbol with a $p$-form defined on a $p$-dimensional submanifold "collapses" the $p$ edges of the box that run parallel to the submanifold, which leaves a lower-dimensional box spanned by the $n-p$ remaining edges, which are clearly all perpendicular to the $p$ edges that got collapsed. (Note that by using the notion of "perpendicular", you're implicitly using the metric, which is hidden inside the mixed signature of the $\epsilon$ symbol in the equation you wrote above.) That motivates why the Hodge dual of a $p$-form is an $n-p$ form, and also why it's the local, point-by-point "orthogonal complement" of the original form, as knzhou explained.
Answer: I don't know if this is too basic for you, but think of freshman electromagnetism, where in order to define flux we associate an area vector with a small area on a surface. The area would more naturally be described by two vectors, $u$ and $v$, lying in its plane, such that the parallelogram they span has the area we're talking about. When we represent this area instead by a single vector $a$ perpendicular to the surface, we're taking the Hodge dual of the rank-2 tensor $u^av^b$. This works in three dimensions because 1+2=3, so the Hodge star converts a rank-2 tensor to a rank-1 tensor.
Answer: If you think of a blade as a subspace together with a real number, then the Hodge dual is the dual subspace together with the same real number.


How to programmatically enable/disable network interfaces? (Windows XP)

Question: I need to enable/disable completely network interfaces from a script in Windows XP. I'm looking for a python solution, but any general way (eg WMI, some command-line à la netsh, some windows call) is welcome and will be adjusted. Thanks.
Answer: Using the netsh interface
Usage set interface [name = ] IfName
            [ [admin = ] ENABLED|DISABLED
              [connect = ] CONNECTED|DISCONNECTED
              [newname = ] NewName ]
Try including everything inside the outer brackets:
netsh interface set interface name="thename" admin=disabled connect=DISCONNECTED newname="thename"
See also this MS KB page: http://support.microsoft.com/kb/262265/
You could follow either of their suggestions.
For disabling the adapter, you will need to determine a way to reference the hardware device.  If there will not be multiple adapters with the same name on the computer, you could possibly go off of the Description for the interface (or PCI ID works well).  After that, using devcon (disable|enable).  Devcon is an add-on console interface for the Device Manager.
Comment: Including all options produces the following message: "Dedicated interfaces can not be connected, disconnected, enabled, or disabled."
It should work, but it doesn't. Haven't tested on another computer, though; I will. Thanks.
Comment: have you found a workaround for the 'dedicated interfaces cannot...' error?
Comment: I get the same strange problem. Netsh appears to not work as intended, on this Windows XP system I am trying to do this on.
Answer: So far I've found the following Python solution:
>>> import wmi; c=wmi.WMI()
>>> o=c.query("select * from Win32_NetworkAdapter where NetConnectionID='wifi'")[0]
>>> o.EnableDevice(1)
(-2147217407,)

which is translated, AFAIU, to the generic WMI error 0x80041001. Could be permissions.
Comment: Obviously I am running this as a member of the local Administrators group, and the computer is not part of a domain.
Comment: Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\wmi.py", line 416, in __call__
    result = self.ole_object.ExecMethod_ (self.method.Name)
  File ">", line 3, in ExecMethod_
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'SWbemObjectEx',
'Invalid method Parameter(s) ', None, 0, -2147217361), None)
Comment: @HaifengLi: thanks, but I don't do Windows anymore, and neither the code above was tested on Python 3 (note the date of the answer).
Answer: I found this .VBS script on the internet. It has the cool advantage of actually working on machines where I cannot get NETSH to work for this purpose.
Const ssfCONTROLS = 3

sConnectionName = "Local Area Connection"

sEnableVerb = "En&able"
sDisableVerb = "Disa&ble"

set shellApp = createobject("shell.application")
set oControlPanel = shellApp.Namespace(ssfCONTROLS)

set oNetConnections = nothing
for each folderitem in oControlPanel.items
  if folderitem.name = "Network Connections" then
        set oNetConnections = folderitem.getfolder: exit for
end if
next

if oNetConnections is nothing then
msgbox "Couldn't find 'Network Connections' folder"
wscript.quit
end if

set oLanConnection = nothing
for each folderitem in oNetConnections.items
if lcase(folderitem.name) = lcase(sConnectionName) then
set oLanConnection = folderitem: exit for
end if
next

if oLanConnection is nothing then
msgbox "Couldn't find '" & sConnectionName & "' item"
wscript.quit
end if

bEnabled = true
set oEnableVerb = nothing
set oDisableVerb = nothing
s = "Verbs: " & vbcrlf
for each verb in oLanConnection.verbs
s = s & vbcrlf & verb.name
if verb.name = sEnableVerb then
set oEnableVerb = verb
bEnabled = false
end if
if verb.name = sDisableVerb then
set oDisableVerb = verb
end if
next

'debugging displays left just in case...
'
'msgbox s ': wscript.quit
'msgbox "Enabled: " & bEnabled ': wscript.quit

'not sure why, but invokeverb always seemed to work
'for enable but not disable.
'
'saving a reference to the appropriate verb object
'and calling the DoIt method always seems to work.
'
if bEnabled then
' oLanConnection.invokeverb sDisableVerb
oDisableVerb.DoIt
else
' oLanConnection.invokeverb sEnableVerb
oEnableVerb.DoIt
end if

'adjust the sleep duration below as needed...
'
'if you let the oLanConnection go out of scope
'and be destroyed too soon, the action of the verb
'may not take...
'
wscript.sleep 1000

Answer: I can't seem to find any basic API for controlling interfaces on MSDN, apart from the RAS API's, but I don't think they apply to non-dialup connections. As you suggest yourself, netsh might be an option, supposedly it also has a programmatic interface: http://msdn.microsoft.com/en-us/library/ms708353(VS.85).aspx
If you want to be pure Python, you can perhaps open a set of pipes to communicate with an netsh process.
Answer: The devcon tool can control the NIC, but not the interface directly. It's a command-line version of the Device Manager applet.
devcon disable (id or portion of name)
devcon enable (id or portion of name)

Comment: It doesn't seem to work with network interfaces. "devcon enable wifi", where wifi is the name of the wireless interface replies: "No devices enabled."
Answer: this is VB.Net
Dim objectQuery As New ObjectQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionId IS NOT NULL")
         Dim searcher As New ManagementObjectSearcher(scope, objectQuery)
         Dim os As ManagementObject
         Dim moColl As ManagementObjectCollection = searcher.Get()
         Dim _list As String = ""
         For Each os In moColl
             Console.WriteLine(os("NetConnectionId"))
         Next os

That will get all the interfaces on you computer. Then you can do netsh to disable it.

netsh interface set interface
   DISABLED
Comment: I've tried in the past all the combinations that netsh suggests:
`netsh interface set interface [name=]wifi [admin=]DISABLED` with either "The parameter is incorrect" or "One or more essential parameters is incorrect" messages.
Answer: You may need to use WMI. This may serve as a good starting point:
http://msdn.microsoft.com/en-us/library/aa394595.aspx
Comment: It's a good starting point indeed. I'm working on it. Thanks.


In a triangle, prove that $ \sin A + \sin B + \sin C \leq 3 \sin \left(\frac{A+B+C}{3}\right) $

Question:
Prove that for any $\Delta ABC$ we have the following inequality:
$$ \sin A + \sin B + \sin C \le 3 \sin \left(\frac{A+B+C}{3}\right) $$

Could you use AM-GM to prove that?
Comment: Note that $(A+B+C)/3= 60^\circ$, so the right hand side is equal to $3\sqrt 3/2$. It is well-known that $\sin A+\sin B+\sin C\leqslant 3\sqrt 3/2$, so it should be $\leqslant$ insted of $\geqslant$ in the question.
Comment: Use Jensen's inequality
Comment: Try some simple triangles.  Is it true?
Comment: @DragunityMAX why
Comment: which triangle inscribed in a fixed circle have the largest perimeter ?
Comment: https://math.stackexchange.com/questions/990418/maximum-value-of-sin-a-sin-b-sin-c
Answer: I'm sure there's a different way to approach this question, but here's one way using the graph of $\sin x $:

Consider $3$ points on the graph for $x\in(0,\pi)$. They are $(A,\sin A)$, $(B,\sin B)$, and $(C,\sin C)$ as shown. $A,B,C$ are such that $A+B+C=\pi$.
(Ignore the fact that $A,B$ and $C$ are angles of a triangle, they are just some values of $x$ that satisfy the condition $A+B+C=\pi$)
$A, B$ and $C$ are plotted on the graph of $y=\sin x$ and are joined to form a triangle, as shown.
Consider the centroid of the triangle, $G$, given by:
$$G=\left(\dfrac{A+B+C}{3}, \dfrac{\sin A+\sin B+\sin C}{3}\right)$$
Draw a line $PG$ as shown at $x=\dfrac{A+B+C}{3}$ (or $\dfrac{\pi}{3}$). This line intersects the curve at the point $P$ given by:
$$P=\left(\dfrac{A+B+C}{3}, \sin \left(\dfrac {A+B+C}{3}\right)\right)$$
From the figure, it is evident that the $y$-value of $P$ $>$ the $y$-value of $G$.
So we obtain the inequality $$\sin \left(\dfrac {A+B+C}{3}\right) >\dfrac{\sin A+\sin B+\sin C}{3}$$
Note that, for the case where $A=B=C$, we can deduce that $A=B=C= \dfrac{\pi}{3}$ and therefore $A,B$ and $C$ will coincide with point $P$ on the curve. For this particular case, we can deduce that $$\sin \left(\dfrac {A+B+C}{3}\right) =\dfrac{\sin A+\sin B+\sin C}{3}$$
Combining both the inequalities obtained, we get the desired result:
$$\sin \left(\dfrac {A+B+C}{3}\right) \geq \dfrac{\sin A+\sin B+\sin C}{3}$$
or
$$3 \sin \left(\dfrac {A+B+C}{3}\right) \geq \sin A+\sin B+\sin C$$
Credit for the answer: "Play with Graphs" by Amit Agarwal.
Comment: it's awesome mate ^ ^, thanks for your explaining !
Comment: no problem, glad to help!
Answer: We know in a triangle$ ABC, 0 \lt A,B,C \lt \pi$. So $sin A , sinB, sinC \gt 0$. Moreover in $[0,\pi],$ so $(sinx)''=-sinx \lt 0$, which is concave downwards. Using Jensen's inequality for concave downwards, we have:$
sin(\frac {A+B+C} 3)\ge \frac {sinA+sinB+sinC} 3$ or $sinA +sinB+sinC \le 3\sqrt 3 /2$


Can Microsoft XNA run on Windows 10?

Question: I have created a game using C# and Microsoft XNA 4.0. It works on fine on Windows 8 and 8.1, but my friend tried downloading it for a computer running Windows 10 and found that it wouldn't open. It wouldn't even appear in Task Manager when opening it was attempted. The computer in question has the Microsoft XNA Framework Redistributable 4.0 installed on it, so it should be working. Is Windows 10 simply not compatible with XNA?
Comment: Can't answer your question, but I recommend get away from XNA, it's a dead technology. http://www.gamasutra.com/view/news/185894/Its_official_XNA_is_dead.php
Comment: @Gusman But even though it's not being updated any further, it's still a useful development tool as it is, right?
Comment: The problem is you got stuck at DX9, and any bug you find will not be recoverable, there is MonoGame (http://www.monogame.net/) which is a reimplementation of XNA in Open source and it's portable to a ton of platforms, so it may be a good try. OR if you want to go to something a bit lower level but much more powerful use OpenTK or SharpDX
Comment: You could try running the application under Windows 7 compatibility.
Comment: @ManoDestra My friend tried running the application with both Windows 7 and Windows 8 compatibility and then tried running it as administrator. None of these solutions worked either.
Answer: XNA is no longer supported on newer versions of windows, it was discontinued and isn't supported on platforms newer than Windows 7. Luckily there is an open source implementation of XNA which is essentially the exact same thing and that is currently supported on all windows versions. It's called "MonoGame", here's the link to their website:
http://www.monogame.net/
Comment: actually this could not be any farther from the truth. the xna redist is still downloadable on their site and I develop with xna on Windows 10 just fine.yes support was dropped but it still works perfectly fine on newer windows.
Comment: I've heard of MonoGame which uses the same code as XNA. Just to check: If I were to copy all of the code in the original XNA game into a new MonoGame project, would it work exactly the same as it did in the original game or would there be some errors or changes that are unique to MonoGame? And would I need to have some kind of MonoGame redistributable installed on a computer in order run it, similar to the XNA redistributable?
Comment: In terms of code, you would need to do some refactoring. For example in XNA I believe the syntax for loading in an image was "content.load", whereas in MonoGame the syntax is "asset.load". So I would say about 80 to 90 percent of your code will not need to change, just the specific API calls which are different. As far as redistributables go, no, MonoGame should work as a standalone framework as is. They did have some issues in older versions with the content loader in terms of the .XMB files however this has been fixed.
Answer: Some updates:
On March 14, 2016, ID@Xbox announced that MonoGame is coming to Xbox One:
* https://mobile.twitter.com/ID_Xbox/status/709402975051980800
In the FB group Xbox One Indie Devs, Tom Spilman from the MonoGame team had some information to add, more info coming soon.
* https://www.facebook.com/groups/XboxOneIndieDevs/permalink/852775944827686/
Stay tuned to the Twitter account and FB group mentioned above, for new info when available.
Hope that helps!
Answer: I know this is a older post but just for those looking for an option like I was today (this post is still a top hit in google) its a bit of work to get setup, but XNA will in fact run on windows 10 just fine, and there is a way to actually use Visual Studio 2017 with XNA just fine as well:
http://flatredball.com/visual-studio-2017-xna-setup/
so if you have code for XNA or like the XNA framework (Like I do, I prefer the pure c# way not c# to some other bloated bridge like Unity) for 2D games then this will be your savior.
Enjoy :)
Answer: XNA does work on Windows 10 and even Windows 11. In 2021 I released a game using XNA Framework and it works but the user will have to install XNA Redistributable 4.0 for the game to run on their system so that's not ideal.
But then I ported my game to FNA Framework which is an open-source, identical, reimplementation of XNA. My codebase required almost no changes to work under FNA so I highy recommend it to you.
FNA requires no additional library installation. The DLLs need to be in the same directory with your executable and it will work.
You can see my game here if you are curious about the subject: https://cyon4d.itch.io/cozy-days
Answer: To add on what x2kpb said, your best bet at this point is to look at MonoGame for certain platforms, and FNA for others.
XNA, in its pure form, will not work as a new Windows 10 application. The platform to bring win32 (XNA) games to Win10 is called Project Centennial
Both Xbox One and Windows 10 will support MonoGame, per this video at last year's BUILD conference.

Can Microsoft XNA run on Windows 10?


A question on hiranyagarbha sukta

Question: What does rig veda hymn no.121 verse 5 mean by
 By him heavens are strong and earth is stedfast , by him lights realm and skys vault are supported.
Is this referring to the common myth that there  solid dome above earth as found in bible and quran or does it mean something else due to mistranslation in english.
Answer: No, it should be read as a metaphor, it simply refers to everything being dependent upon God's will. See Bhagavad Gita chapter 10, especially verses 32, 39, and 42. In verse 32 Krishna says (Swami Nikhilananda translator):

Of created things I am the beginning and the end and also the middle, O Arjuna...

And verse 39:

And that which is the seed of all beings--that I am, O Arjuna. There is no being, whether moving or unmoving, that can exist without Me.

and verse 42:

...With a single fragment of Myself I stand supporting the whole universe.
Comment: Thats what i thought intuitively ..thanks for your reference.

A question on hiranyagarbha sukta


Automatically Refresh a web user control

Question: How can we refresh a web user control automatically without a page postback in asp.net 2.0? i have tried meta tags in controls head tag but it also refreshes the whole page.
Comment: Could you provide more details as to what you are trying to accomplish?  As mentioned, UpdatePanel's may be what you need, or possibly just javascript.  A specific scenario will help identify the correct answer.
Answer: You could try implementing a little bit of the ASP.NET AJAX Framework into your app and wrapping that control in an UpdatePanel. It will work with .NET 2.0
Edit: Here is a quick link to a tutorial on using the ASP.NET AJAX UpdatePanel: http://ajax.net-tutorials.com/controls/updatepanel-control/
And here is the official introduction page from the ASP.NET website: http://www.asp.net/Ajax/Documentation/Live/tutorials/IntroductionUpdatePanel.aspx
Answer: User Controls are server based controls. Your only option might be some type of javascript but depending on what you are try to accomplish, unlikely.
Answer: There are several ways to do it and it depends on what your control is made of.
One of the easiest ways to do it is to wrap the control in an UpdatePanel and then use a Timer control to just update that UpdatePanel. But that might be expensive in terms of viewstate.
Another option is to use something like Jquery and a Javascript timer to count down and then refresh using static page Methods (http://encosia.com has examples).


Windows refused installing due unexistant ntfs partition

Question: Tried installing Windows 10 on a PC that has Ubuntu 16.04 installed. Ubuntu uses LVM and had /boot and /boot/efi partitions as separate disks. After i succesfully freed up some space (100Gb) for Windows, i tried to install it and failed after selecting free space for Windows installing. Backed up both /boot and /boot/efi folders, removed both partitions (except LVM ubuntu partition) and tried installing Windows again at the same place with Windows saying that my efi partition is in NTFS. So now i can't boot up, because i have no efi partition at all. How do i install windows in that state?
Comment: How did you freed the 100GB space? What exactly have you deleted?
Comment: I freed up some space by shrinking /root in sda3 LVM partition. I deleted sda1 (/boot/efi) and sda2 (/boot)
Comment: You do realize that you made Ubuntu unbootable, and that you need to use LVM tools to shrink LVM, don't you? Yes, first you need to shrink partitions inside the volumes but then shrink the volume itself otherwise it won't have unallocated space to install other OS. You recovered at most some hundreds megas by deleting the ESP and /boot (and those WERE necessary).
Answer: I've seen similar reports elsewhere. Apparently Windows, or at least the Windows installer, sometimes misdetects a Linux-created ESP as being NTFS. My suggestion is to back up the ESP, create a fresh FAT32 filesystem on it, restore its contents, and try again. (Be sure it's FAT32, not FAT16. Depending on the filesystem size, you may need to set this explicitly with the -F option to mkdosfs.) You'll need to edit /etc/fstab to adjust the "UUID" (really a serial number) associated with /boot/efi to get it to mount properly in Ubuntu when this is done.
If this fails, try this one more time, but this time, create the filesystem on the ESP using a Windows emergency disk. This may require jumping through some extra hoops, but I don't know the details of what you'd need to do, since I'm not familiar enough with the Windows tools.


How to use AND condition is gmail filter

Question: I'm sending a lot of email and would like to filter out bounced emails from my inbox.
I'm trying to create a Gmail filter that filters out all messages with a subject that contains certain text AND one of two possible strings in its content.
Currently, it says:
from:(firstname.lastname@example.com) ("Product Designer for the Future of Knowledge Management?" AND ("Your message wasn't delivered to" OR "Message blocked"))

Unfortunately the AND operator does not seem to work.
This article said:

AND: By default, Google combines all search terms with an invisible AND operator. For example, searching for Dunder Mifflin finds all emails containing the words Dunder and Mifflin.

This question is similar to the existing question "How to filter emails by subject containing a word?"
Answer: Try this:
from:(email@example.com) subject:(Product Designer for the future of Knowledge Management) {"Your message wasn't delivered to" "Message blocked"}


I have waited for 2days now my transaction not confirmed yet

Question: I have made 2 transaction but not confirmed yet
Blockchain: a68891b83177797c932873e3e5ff601bcea6e28b1cdbeb5a038dc0939c8371e0,
543c5f4612398c0b783fd3959a3390850a584c79a6c4fbe80bef88ebf455878f pls i need to be fix urgently
Answer: I can see that one of the transactions has been confirmed, so your problem is half solved. For the other transaction you just need to wait. If you're experienced enough you might as well want to rebroadcast the stuck transaction with a higher fee.
The problem
The transaction fee you have included in both transactions is way too low. At the current state of the bitcoin network, there is not enough room in blocks to fit all of the transactions, so the miners pick only the transactions with higher fees.
Prevent from happening again
If you require your transactions to be confirmed in a short period of time, then you need to include a much higher miner fee. You can use the following site as a guide as to what the fee should be:
https://bitcoinfees.21.co/


Publish collection of papers into a book?

Question: I have a very general question. Say I have written 10 papers, published them independently in different journals over the years - could I then just take these papers and make a book out of them and publish that, or is there then a copyright on the published papers which would prevent me from doing that?
Comment: The copyright question depends entirely on the kind of licensing you chose at the time you published each article. You would have to look at each of these and see if it is allowed to republish them in book form.
Answer: It is very likely that you would have assigned to the journal publishers the copyright to some or all of the papers you published, so you would not be allowed to publish the book without getting permission from those publishers. With that said, book anthologies of previously-published scientific papers are fairly common, and my understanding is that journal publishers are generally inclined to give their permission for a paper they hold the copyright to to be published in such an anthology.
A separate question is who would want to publish your book anthology. Unless you are a famous academic, I don't think such a book would be of interest to mainstream academic publishers, regardless of whether you need or can get the necessary permissions.
Answer: If you just want a compilation of your published papers in book form, I don't see how that's publishable, since it's all already published. You could probably find someone to create such a work, but not one that could be officially published.
If instead your intent is not to copy and paste the papers as a simple collection, but rather synthesize your corpus into a coherent, complete review, that's different. Nothing would prevent you from doing this - pretty much anyone can publish a book these days, though more established publishers would be preferable.
You'd need to get reprint/copyright authorization from the journals who own your papers, but only if you plan to reprint figures or in some cases, large sections of block quotes. Otherwise, a synthesis is a novel piece of work no different from anything else.


Can an accelerating body be at rest?

Question: A block of mass $1~\rm kg$ is lying on a table. It is stationary because the gravitational force is balanced by the force from the table. But the body should have an acceleration $g$ and consequently its change in momentum should be non-zero. But how come the body is at rest? Are there other examples where a body is at rest but is accelerating?
Comment: You may enjoy reading a general relativity approach to this question: https://physics.stackexchange.com/a/226564/123208 ... or you may find that it just adds to your confusion. ;)
Comment: Why do you think the body should have acceleration $g$? Newtonian gravity is NOT an acceleration. Masses interact with forces on each other, not accelerations.
Comment: This is essentially a duplicate of my questionhttps://physics.stackexchange.com/q/264128/113699....have a look here for a few answers
Comment: Just close your eyes and imagine that you are sitting in a chair of an accelerating rocket with acceleration $a = g$. This is famous Einstein equivalence principle. In this respect we **ALL** on Earth are accelerating.
Comment: @PM2Ring yes that helps. I wanted to know whether you can SAY that the stationary body is accelerating. As it turns out from both answers it is acceptable. thanx. Some people are highly confused on this page ;).
Answer: The body on the table is not accelerating because, as you said, the force of the table counteracts the force of gravity. The confusion here is perhaps from the term "acceleration due to gravity" but that doesn't mean that it has to cause an acceleration (at least once a steady state is reached).
An accelerating object can be momentarily at rest. For example, if you throw a ball into the air straight up, at the top of its trajectory it will be at rest.
Comment: It's a question of the net force: $a=F/m$. But you can't just consider gravity. You have to consider all of the forces on the object as $F$. The change in momentum is a consequence of $a$ not of $g$ (directly).
Comment: "...ball into the air straight up, at the top of its trajectory it will be at rest." but its change in momentum will give you the acceleration. but seemingly not the body on the table problem.
Answer: To elaborate on @rghome answer let's comparie the situation where a mass is "at rest" on a table versus another mass being  "at rest" at the same height at the top of a purely vertical trajectory,
In physics a body is "at rest" to an observer when it is stationary (motionless) in the reference frame of the observer, that is when it's velocity is zero. The mass on top of the table is at rest in the reference frame of an observer standing still on the floor next to the table. In the same frame let another object of the same  mass be launched vertically upward from the floor next to the table so that the top of its trajectory happens to be at the exact same height as the mass on the table. At that instant both masses are at rest (have zero velocity) to the observer.
But at that instant the net force acting on the mass on the table is $F_{net}=-mg+N=0$ where $N$ is the upward normal force of the table. From Newton's second law
$$a=\frac{F_{net}}{m}=0$$
The only force acting on the launched mass is the downward force of gravity
$$F_{net}=-mg$$
And it's acceleration is
$$a=\frac{-mg}{m}=-g$$
Both masses are momentarily at rest but only one is accelerating.
So a body may or may not be accelerating when it is at rest. It depends on whether or not it experiences a net force.
Hope this helps
Comment: no it does not help. you just restated my question in mathematical terms. I think the block on the table IS accelerating otherwise it wont't have a weight equal to $mg$. "Both masses are momentarily at rest but only one is accelerating.
So a body may or may not be accelerating when it is at rest. It depends on whether or not it experiences a net force." Both sentences contradict each other. Is the block on the table accelerating or not.
Answer: Consider the case of a mass attached to a simple Hooke's Law spring, resting in an equilibrium situation (horizontally, vertically, on an incline--it doesn't matter). Then, displace the mass from the equilibrium situation collinear with the spring, defining the $x$ direction, by the amount $A$ and release at t=0. The displacement from equilibrium will be described by
$$x=A\cos\Omega t$$
where $\Omega$ will be the angular frequency, a constant dependent on the spring constant and the mass.
If you take time derivatives to find the velocity and the acceleration, you will find that when the velocity is zero, the acceleration will be a maximum.
Answer: The body on the table is at rest and not accelerating in the reference frame of the table. A person doing a bungee jump next to it will at some point be able to say the body is at rest and accelerating with g. Many more reference frames are possible, inertial and noninertial, each giving a different answer.

Can an accelerating body be at rest?


MongoDB equivalent of SQL "OR"

Question: So, MongoDB defaults to "AND" when finding records. For example:
<code>db.users.find({age: {'$gte': 30}, {'$lte': 40}});
</code>
The above query finds users >= 30 AND <= 40 years old.
How would I find users <= 30 OR >= 40 years old?
Answer: There is no OR operator, but they say you can still do it:
http://www.mongodb.org/display/DOCS/OR+operations+in+query+expressions
Answer: matt -i too researched the $or business and hit a brick wall. i had saved this little link on googlegroups and was going to follow up on it at some point:
http://groups.google.com/group/mongodb-user/browse_thread/thread/4ac6f67622b3b951
sorry to not have answered the question but just wanted to make you aware that others were looking for the same functionailty at the time i was tentatively looking at this.
you could of course (depending on the language implementation) use the linq provider for mongo.
jim
[edit] for linq stuff see - http://schotime.net/blog/index.php/2010/04/29/nosql-norm-mongodb-and-regular-expressions/
Answer: There will be an or operator in the near future. The nightly Mongodb build has already an $or. You can also use $where and use JavaScript to express the or.
See http://groups.google.com/group/mongodb-user/browse_thread/thread/a9a4d8b863d84601

MongoDB equivalent of SQL "OR"


How much solar radiation hits a spacecraft in transit to Mars?

Question: How can I solve for the amount of radiation that hits a Mars transit vehicle, in transit? What formulas should I use? I am mostly focused on solar radiation.
Comment: What kind of solar radiation? Infrared, visible light, ultraviolett,solar wind? Photons or particles?
Comment: Does the crewed-spaceflight tag mean only radiation (of whatever kind) that reaches the crew?
Answer: It depends when the journey is made and many other things.
High energy solar protons are more of a problem during the solar maxima of the 11 year solar cycle and less so during the solar minima. The flux of high energy particles also varies over much shorter periods during solar storms which themselves produce variable levels of radiation. In fact solar storms produce a wide (and variable) spectrum of energetic protons. Solar storms also follow magnetic field lines and are directional. So this is not an easy question.
To add further complication if you are interested in radiation as a hazard for crews in deep space, Galactic Cosmic Radiation (GCR) also varies over the 11 year solar cycle being at a maximum during solar minima and at a minimum during solar maxima. It also comes in a spectrum of different particle types and energies.
High energy solar radiation tends to be easier to shield from than GCR, (although easier does not imply easy). I doubt that there is a simple formula that would provide what you want. There are too many variables in terms of timing, random effects and multiplicity and variability of radiation types.
Answer: The radiation situation in interplanetary space and on the surface of Mars is significantly different from the situation in near-Earth orbits. It is more dangerous and under certain conditions (with large solar flares) can pose a real threat to the life and health of astronauts. Radiation conditions in the Martian expedition will be mainly determined by galactic and solar cosmic rays, as well as secondary neutron radiation arising on the surface of Mars and during the interaction of cosmic radiation with the materials of the ship and the radiation shelter. The total doses that the cosmonauts will receive during the expedition may turn out to be about 4-10 times higher than in long-duration orbital flights (the dose that cosmonaut V.V. Polyakov received during the 14 months of the flight was 14 Centisievert (cSv)), but they should not exceed the maximum allowable exposure dose standards, except in cases of major solar events.
Comment: True. Things will probably become a little easier when Starship becomes operational. With the ability to send 100 tonnes to the surface of Mars, significant shielding is possible at least for solar energetic particle radiation especially if consumables like food and water stowage are arranged so as to help protect a storm shelter / sleeping area.


Plugin Settings Color Input Javascript Event Listeners

Question: Is it possible to attach JavaScript event listeners to the colour input field in a plugin's settings page, so that when a user selects a colour with the picker I can run an AJAX request?
Answer: If this is your plugin, you can register an AssetBundle with custom CSS and JS for your plugin. This will be loaded in your plugin settings page, and in your JS file you can then specify an event handler for your colour picker. You might need to add a specific class to the input in the settings template to ensure you can select it easily in your JS file.
If this is referring to a first/third-party plugin, you could use a plugin like CP JS to load a custom JS file into the CP and attach an event handler in that file to trigger your XHR.
Answer: In the end the problem ended up being that I did not add the event listener to the input elements after the document was ready. The following code fires the eventHandler function correctly when any settings input field is changed, including colour inputs.
$(document).ready(function () {
    $("form :input").change(eventHandler);
});


Why does deleting a Mac OS X app leaves its shortcut in the Launchpad?

Question: Whenever I delete an app from the Applications folder, its shortcut stays in the Launchpad. In order to delete it, I have to click on it (a question mark appears), and then drag to the trash can. Is it a bug, or does this mean I am doing something wrong?
Answer: It may be a bug, but I am thinking it may mean your Spotlight index is corrupt.
I just tried deleting Evernote from my Applications folder. After authenticating, it moved it to the trash. I then checked launchpad again, and it was no longer there. Then, when I dragged it back out of the trash and placed back into Applications folder. Relaunched launchpad, and it was there again on the last page. As in, worked as expected here.
Launchpad keeps its own plist of what files there are, etc, and thats why there are some modification tools to allow to you to edit it. But I am assuming they would use spotlight to 'watch' your Applications folder to add new items not through the Mac App Store. I assume Spotlight because its a great tool for the job, installing Lion does a huge spotlight re-index, and they do use spotlight often behind the scenes.
First, the GUI way I have seen online is to do this (I do the command line way below):

In system's preferences -> spotlight -> Privacy add the drive you want to re-index
Quit System's preferences
Logout of your sessions
Login again :-)
In system's preferences -> spotlight -> Privacy remove the drive you want to re-index
Wait.. a faily long time. You should see mdworker and/or mds running

Personally, I have always done it through the command line.

Launch 'Terminal' (located in /Applications/Utilities/)
At the command prompt, type this exactly: sudo mdutil -E /
You will be asked for your password, provide it, as this command requires
administrator privelages to run
You will receive a confirmation message saying that index will be rebuilt
Wait until index is finished rebuilding, this can take a while depending on the size of your hard drive, amount of files, etc.

While I can't find any documentation online that 100% confirms that Launchpad uses Spotlight for this, this would be the first place I would look for the problem you are having.
Comment: Thanks for a very informative reply. If Launchpad uses the Spotlight index, then rebuilding it could indeed help. I'll try that out as well, and report back. Oh, and +1 for the command line suggestion, I just learned something new!
Answer: I think that it is expecting you to remove the application directly from LaunchPad.  Launchpad obviously reads it's apps list and folder groupings/layouts from some configuration file, and so when you remove an App it hasn't necessarily had a chance to remove that icon and it's associated positioning etc from it's config.
It would be interesting to see how often it checks for removed files etc, maybe it's a one-time boot or login process (perhaps you can test this by removing (or moving) an app and seeing if the icon remains after effectively restarting the LaunchPad process.
The best workaround, is to remove directly in LaunchPad.  This should remove the App from /Applications, and remove it fully from the LaunchPad configuration.
Comment: Interesting. It that is indeed the case, it is not very user-friendly (for it is only possible to remove apps directly from Launchpad when these apps are downloaded from the Mac App Store).

I'll play around with my apps later on and see if these shortcuts disappear after logging out or restarting the Launchpad process. Thanks!


How to get "The Giant" zombies map

Question: Pretty self-explanatory, I would like to know how can I get the zombies map The Giant on Call of Duty Black ops 3 on Pc as well as if it's released yet.
Answer: It appears that if you buy the Season pass (available on steam), it comes with "The Giant" zombie map. From the link:

<code> About This Content
 The Call of Duty®: Black Ops III Season Pass delivers 4 epic DLC map packs
 in 2016 with all-new multiplayer content, including re-imagined
 fan-favorite maps from Call of Duty®: World at War and the Call of Duty®:
 Black Ops series, plus thrilling Treyarch Zombies content, all for one
 great price.*

 Fans that order the Season Pass will be among the first to experience
 the return of Zombies with "The Giant" Map in all of its undead glory
 on Day One. Set in a World War II-era research facility featuring the
 weapon-upgrading Pack-a-Punch Machine, re-live the chaos of Treyarch's
 classic "Der Riese" Zombies map, picking up the Zombies story with
 Dempsey, Nikolai, Richtofen, and Takeo where Origins left off.
</code>

Purchasing the Deluxe edition also gives it to you (since it comes with the season pass).
Comment: If I purchase Season Pass today, will I be able to play or I'll have to wait until the map is available to play?
Comment: @zETO I bought the Deluxe edition and it is available to play now (in fact, I just played it earlier today), I can only assume it will be the same for the season pass.

How to get "The Giant" zombies map


Where should I declare an enum class that concerns a class instantiated many times?

Question: I have a class that contains a color attribute, and I want to use an enumeration to handle it. Since at runtime my program may create thousands of instances of this class, where is the best place to declare the enumeration in order to optimize memory usage ?
At the moment, my class declaration looks like this :
class Node
{
public :
//constructors, methods, etc...
enum class Color : char{WHITE, GREY, RED, GREEN}

protected :
//Some private attributes
Color _color = Color::WHITE;
};

I know this is an acceptable way to do it, my question is : will it bring performances down when i got like 100k instances of this class ?
Comment: The `enum` declaration itself doesn't affect memory usage of your class at all, hence there is no difference.
Comment: _"will it bring performances down when i got like 100k instances of this class ?"_ Considering which alternative?
Comment: Writing my enum class declaration outside of the Node class ?
Comment: That's it, thank you !
Answer: I'm guessing you are concerned with class in the declaration of enum class vs enum.
The enum class and old style enum will generate exactly the same code and behave exactly the same in the "backend" of the compiler. The distinction happens in the semantic analysis (type checking) by the compiler (more strict checking compared to "traditional" enum types, so you can't do int x = WHITE; or enum { A, B }; Color c = A;).
Answer: As with any data type, the enum itself won't take up storage in your objects, it's instances of the enum that are stored. (Regarding this, there is no difference between enum and enum class.) So moving the enum out of the class does not make any difference in this respect.
So in your case, the color_ member takes up storage space. If there are subclasses where you don't need that, you might want to reconsider your class design. Otherwise, you are fine!


New campaign start

Question: On saints row the third, if I start a new campaign, will I have all of my costumes, weapons, and vehicles? I want to make sure before I start another campaign
Answer: Progress, equipment, vehicles, etc. are saved on a per character basis. Each new campaign means a new character starting from the very beginning.
The exception to this is any DLC you may have purchased. Those are unlocked for all current and future characters.
Answer: There is a way to do this if you're on the PC version of SRTT. Go to the Saints Row Modding Forums (or should that be fora?) and download the save editor. Once you've completed your game, save it and then open the save in the editor. There is a button on the right labeled 'New Game +', which resets the missions and activities, but allows you to keep your char, funds, guns, cars, respect levels & skills, and Saints Book activities & challenges. Save the file, and restart using Continue in the game.
The game effectively restarts from the beginning (the Bank Heist in Stilwater) and you can play through the missions again. It skips the bit where you do your char selection (you already have one selected) but in all other matters, it's effectively like playing the game through again with all your skills.
Obviously, use at your own risk and always make a backup before overwriting your save, but it works amazingly well for me and adds to my game experience.
Answer: No, you won't. Starting a new campaign means starting from scratch.

New campaign start


How do static objects work?

Question: I know how to work with objects.. but one thing in particular has me scratching my head.
Static methods.
I'll give an example.
Toolkit theKit = Toolkit.getDefaultToolkit();

I think that the theKit object now holds new Toolkit(); class.. but im not sure.
Furthermore I can do theKit.getScreenResolution(); now with theKit reference variable.
Is that because Thetoolkit class it self contains that method?
Forgive me, now that I wrote it all out it seems obvious but ill ask anyway. Thank you.
Comment: @Arun "equivalent" is not the right word. There's a lot more going on in that method than just `return new Toolkit()`.
Comment: @Arun not necessary (you can have `foo(); ... bar(); return new Toolkit();`) inside that black-box method.
Comment: @everything is possible but as naming convention of method its seem to be returning unique instance
Comment: @Arun talking about naming convention, it almost never (except one, very first call) do `new Toolkit();`
Comment: you answer to own question..Toolkit.getDefaultToolkit() is equivalent to new Toolkit(); It is like singleton
Comment: @om-nom-nom as i said everything is possible...yes you are right you can initialize any static content of the class...with such methods
Answer: static methods belong to the class. Not the instance.
Same is with all static member variables.
So you don't need to create an instance of an object to use the method. Since it belongs to the class you just access it via the class name.
A common usage for static methods is utility methods. You don't use an object (and it might not make sense for a concrete object to exist in your design of class hierarchy) and so you access the method via the class
Answer: This is a design patten. Now given the case, it is necessary that the Toolkit remains singleton.
So the library designer made sure that it remains singleton by itself providing a method to getDefaultToolkit.
getDefaultToolkit returns a Toolkit which can be used by the library users.
Now to provide access to such a method, given one cant initialize Toolkit by 'new Toolkit()`, the library provides a static method, which gives access to it
Comment: Not necessarily a singleton.
Comment: Yes. But `Toolkit` is a singleton. And hence the method is used to return it
Comment: Actually, this answer describes it the best.. because I really had trouble understanding why I'd use a static method for this particular case.
Answer: I can have a static method that indeed creates an instance of a class. Static methods doesn't belongs to an instance but to the class itself so you don't need to have an instance of a class to use its static methods. Simple example:
public class MyClassExample(){

public static MyClassExample getDefaultInstance(){
 return new MyClassExample();
}

}

Then you can instantiate MyClassExample this way:
MyClassExample example = MyClassExample.getDefaultInstance();

Answer: Toolkit theKit = Toolkit.getDefaultToolkit();

The above line is a factory technique to get the Class instance and getDefaultToolkit() is a factory method and it is obviously a static method(so you are calling directly using class name) which will return the instance of the class(in your case it is Toolkit class).We also use this technique in case of singleton.
And regarding your question, yes as the class contains the method getScreenResolution(), so you are able to call it and it is obvious.
Answer: Toolkit.getDefaultToolkit() is a static factory helper method to get instance of ToolKit class. The 'theKit' is a valid instance and you can use it the same way you use when you create object instance with new. Having such helper method is best practice as mentioned in effective java book 'Consider static factory methods instead of constructors'
Answer: The method getDefaultToolkit() is static which means that you don't need an instantiated object of the Toolkit class to access this method. When the class is known to the JVM, it is there and the static method can be accessed at all times. This is because they will never change! They will not alter their state, they will never do something else but return a ToolkitObject in this case.
And here I said it. Internally I am guessing that the method Toolkit.getDefaultToolkit() does something like this :
public Toolkit getDefaultToolkit(){
   return new Toolkit();
}

Well this would be too easy, but somewhere within that static method an Object will be created and returned.
So afterwards your variable theKid actually holds the reference to a real  Object. A non static instance, that can change and do things.. for example with the method theKit.getScreenResolution() it can give you the resolution of the current screen.. Not just a resolution.. but the exact resolution (which changes on every device with every screen)– meaning this method cannot be static, but needs an Object.

How do static objects work?


UV Editing problem when select all my character

Question: I'm new to blender and I am trying to do the owl tutorial on youtube. Unfortunately I have some problems with the UV Editing part. When I select every part individually it's look good in the UV editor. But when I select the entire character, it's look like these:  Does anyone know what's going on?
Answer: It looks like the UVs for some of the body parts are all funky! I bet there are some parts of the character that are getting missed when you select parts individually.
To start investigating, I recommend entering wireframe view, then selecting random parts of your character. Here I'm holding z, selecting "wireframe," and releasing z. This helps show parts of the model that may have been hidden before. Then I press c and start clicking and dragging on various parts of the model. I then hit right click to stop selecting. (You can hold Z and select "material view" to return to normal.)

While doing this, keep an eye on the UV panel on the left. Hopefully this is enough to help you find which parts of the models have the weird UVs. Then you can choose just those body parts and UV unwrap those all over again.
My guess is that the talons have problems, since there is so much detail on them, and they're small, so it may be easy to miss any issues with the textures.
There may be weird hidden shapes elsewhere on the body too.
I also think those long stretchy rectangles on the left are from the parts of the face that have the "tv static" appearance, like this:

My reason for saying that is: that when UVs get stretched so big that they go outside the texture, they wrap around all over again (like when Pac-Man goes off the screen and comes back out the other side :p), and the texture gets smaller and smaller on the final model. Demonstration:
https://i.gyazo.com/96a92179b4e04d14c672a10fc631302d.gif
(Above: Gyazo video where I'm stretching the UVs beyond the boundaries of the texture. The final result in 3D is that the texture tiles and looks very tiny.)
Best of luck!


Thermal density matrix QFT

Question: The density matrix of a system at finite temperature is give by
$$\langle\psi_1|\rho|\psi_2\rangle=\frac{1}{Z}\langle\psi_1|e^{-\beta H}|\psi_2\rangle, $$
where $Z$ is a normalization constant. We can then express this matrix element as the Euclidean path integral
$$ \frac{1}{Z}\langle\psi_1|e^{-\beta H}|\psi_2\rangle= \int_{\psi(t_E=0)=\psi_1}^{\psi(t_E=\beta)=\psi_2}\mathcal D\psi~e^{i \int_0^\beta dt_E~\int d^3 x ~\mathcal L_E[\phi]} ,$$
where $t_E$ is the Euclidean time and $\mathcal L_E$ is the Euclidean Lagrangian.
Question: If I want to describe a system at finite temperature with chemical potential $\mu$ corresponding to some $U(1)$ conserved charge $Q$ so that the density matrix is now given by
$$\langle\psi_1|\rho|\psi_2\rangle=\frac{1}{Z}\langle\psi_1|e^{-\beta (H-\mu Q)}|\psi_2\rangle, $$
is there a path-integral representation for this matrix element?
Answer: It is the same. Just add $- \mu Q$ to your Lagrangian $L_E$. Treat $H - \mu Q$ as your new Hamiltonian.

Thermal density matrix QFT


Why printf("%s\n", "123456789" + 3); //output: "456789"

Question: execution function:
printf("%s\n", "123456789" + 3); //output: "456789"

why output this result?
In the same way, what should I do if I want to output "123"?
Now I'm confused. Help me.
Comment: "what should I do if I want to output "123"?" --> `printf("%.3s\n", "123456789");`
Comment: You are getting bit by c's [pointer arithmetic](https://stackoverflow.com/questions/394767/pointer-arithmetic).
Comment: Try `printf("%d\n", 123456789 + 3);`
Comment: I want to use this feature to split strings.
Comment: Splitting strings in C is not a trivial procedure like it is in many other languages. This is partly because C uses null-terminators as opposed to a length to determine how long a string is. To split a string, you need to allocate memory, copy part of the string to the new string, then truncate your original string.
Comment: @user11376714 *I want to use this feature to split strings.* -- Choose a language, either C or C++.  This is becoming an [XY problem](http://xyproblem.info/)
Comment: Your sample code does not split strings. It just ignores a few characters but they are still there in same place.
Answer: printf() is passed a pointer to a string constant incremented by 3
printf("%s\n", "123456789" + 3);

printf() takes a format string argument followed by a variadic set of arguments.  In this case, the '%s' is the first (and only) variable in the format string.
There is only one argument in the variadic section after the format string:  a string constant:  "12345678" which resolves to a pointer to the '1' character; however, that pointer is incremented by 3 due to the "+ 3".  This moves the pointer 3 positions to the '4'.
Then, printf prints the string that starts at '4'.  As the string constant is terminated by a '\0' character right after the '9', printf prints "456789"
Printing the first 3 chars of a string
To print only the first 3 characters of a sting, use %.3s in the printf format string:
printf("%.3s\n", "123456789");

Comment: Thank you, @RingØ, once I read the first part of the question, I forgot to answer the second part.  I have edited the answer to provide the method to print 3 characters from a string without printing the entire string. `printf("%.3s\n", "123456789");`
Comment: Thank you for solving my problem.
Answer: Basically, strings are character arrays, meaning their name (variable name) points to the first element in the array.
For instance, in the array a[]={3, 4, 5}, a[0] is obviously 3.
However, the value of a itself is also 3 (like printf("%d", *a);)
If you increment a itself, you are incrementing the address of a, so the value of a + 1 would be 4.
Implicitly declaring a character array (what you did with the string) still requires the program to give it some form of address (That is, the location where the 1 in "123456789" is located)
That being said, incrementing the string itself basically acts the same as incrementing the array name, so "123456789" + 3 would give the address associated with "456789".
So what the printf basically sees is "print 456789".
I doubt I was able to explain this as simply as possible, or if you could even follow this, but I tried.
Best of luck!
Comment: Nope, the value of `a` itself is a pointer to the first element, not the value pointed to, so you have to dereference it (as you do with the `*` in front of `a`)  The value of `a` itself is not `3` as you post in your answer.  Please, edit your answer and add a comment mentioning me, and I'll take this comment off of the view.  Thanks.
Answer: One just can't add a string ("123456789") and a number (3).
What is it that you want? a) Integer addition or string concatenation?
a) 123456789 + 3
b) "123456789" + "3"

The compiler will not guess which option do you want!
So, one of the arguments needs to be converted to the type of the other, using some function such as (unsafe) atoi(), etc...
Answer: "123456789" is a string literal. It is an object of type char [10] in C. It is an object of array type.
When an object of array type is used with binary + operator, it gets implicitly converted (decays) to pointer type. The resultant pointer value points to the beginning of the array. So, the original char [10] array decays to char * pointing to character '1' in "123456789".
Binary operator +, when applied to a pointer, performs pointer arithmetic. Adding 3 to a char * pointer produces a pointer that points 3 bytes to the right of the original pointer. So, you get a pointer that points to character '4' in "123456789".
After that you use format %s to ask ask printf to print a string that begins from that '4'. And that is the output you get.

The same thing happens in C++, except that in C++ this string literal has const char [10] type and decays to const char * pointer,


Is 1 hour 10 minutes sufficient to transit in Dubai airport arriving from Johannesburg and departing to Standsted UK?

Question: Arrival time at Dubai on EK766 on 7/5/2019 is 08.20 and departure to London Standsted EK33 is at 09.30 on the same day. I am 73 years old and I would think that I would need assistance? Can this be arranged and if so how?
Comment: This is on one ticket, right? Call the airline and ask for assistance.
Answer: Yes. If it's all on one-ticket then Emirates will take care of it, it's their problem/issue. Also note emirates pad their connection times anyway, but if the connection becomes tight they will send a rep to the gate to meet passengers for tight connections. If it becomes really tight (due to late departure of first flight) ask a cabin member to ask ground services to send a golf cart so you aren't being made to run with the rep.  Many Emirates flight pairs have tight connection sometimes as little as 45 minutes and it all works out.


Remove a screw with a broken head

Question: Used an impact driver to screw into a (pre-drilled) stud. The head of the cheap screw broke off, just about flush with the drywall. How do I remove this screw?
Comment: Generally I wouldn't. Drilling it out isn't going to be fun. Can you not just move whatever it is you're hanging up or down an 1/8 of an inch?
Comment: If it's a situation where you absolutely have to remove it I've found it helps to pilot a hole right up against the screw to relieve some of the pressure. It can still be a real bear though.
Comment: @Mazura In this case the item to be hanged was deemed a failure (it was a bottle cap opener that didn't work) and so I needed to return the wall to original state. The screw shaft was penetrating slightly above the surface of the drywall, so I needed to remove it before patching.
Answer: Knock out the drywall around it until you can grab it with locking pliers. Either unscrew it or break it off (if it broke going in it may not want to come out any more cooperatively.) Spackle the hole and move whatever it is that caused you to drill it up or down a little bit so the new hole does not line up with the old one if the screw is broken off in place.
Comment: This worked nicely. The only variation was that I used heavy wire cutters to dig out the drywall and get a tight grip on the screw and give it a few twists. At that point it protruded enough for the locking pliers to get a grip on it.

Remove a screw with a broken head