How can I encode a string for HTML?

Question: I'm looking for a simple way to HTML encode a string/object in Perl. The fewer additional packages used the better.
Comment: What exactly do you mean by "HTML encode"?  Can you give an example input and the desired output?
Comment: What character sets/locales do you have to handle?
Answer: HTML::Entities is your friend here.
use HTML::Entities;
my $encoded = encode_entities( "foo & bar & <baz>" );

Answer: When this question was first answered, HTML::Entities was the module most people probably used. It's pure Perl and by default will escape the HTML reserved characters ><'"& and wide characters.
Recently, HTML::Escape showed up. It has both XS and pure Perl. If you're using the XS version, it's about ten times faster than HTML::Entities. However, it only escapes ><'"& and has no way to change the defaults. Here's the difference with the XS version:
Benchmark: timing 10000 iterations of html_entities, html_escape...
html_entities: 14 wallclock secs (14.09 usr +  0.01 sys = 14.10 CPU) @ 709.22/s (n=10000)
html_escape:  1 wallclock secs ( 0.68 usr +  0.00 sys =  0.68 CPU) @ 14705.88/s (n=10000)

And here's the fair fight with pure Perl versions on each side:
Benchmark: timing 10000 iterations of html_entities, html_escape...
html_entities: 14 wallclock secs (13.79 usr +  0.01 sys = 13.80 CPU) @ 724.64/s (n=10000)
html_escape:  7 wallclock secs ( 7.57 usr +  0.01 sys =  7.58 CPU) @ 1319.26/s (n=10000)

You can get these benchmarks in Surveyor::Benchmark::HTMLEntities. I explain how I distribute benchmarks using Surveyor::App.
Comment: Given the fact that `HTML::Entities` looks for wide characters too, the pure Perl fight might not be that fair. It could be interesting to alter the code in the pure Perl version of `HTML::Escape` to include the same cases under its own algorithm and see that fight again.
Answer: Which do you need to encode, a string or an object? If it's just a string, then you should just have to worry about encoding issues such as UTF-8, and CGI::escape will probably do the trick for you.  If it's an object, you'll need to serialize it first, which opens up a whole new set of issues, but you might want to consider JSON-encoding it.
PS. Although since I can't find any recent documentation on this method (it's actually imported from CGI::Util and is marked as "internal"), you should probably use escapeHTML() as daxim points out in his comment: http://search.cpan.org/perldoc?CGI#AUTOESCAPING_HTML
Comment: The function is called `escapeHTML`. Proper deeplink: http://search.cpan.org/perldoc?CGI#AUTOESCAPING_HTML
Comment: @daxim: `CGI::escape` very much exists; it's actually defined in CGI::Util and imported into CGI proper. If you look at the source there are some subtle differences in implementation, which are sadly not well described in the documentation.
Comment: Alright. I'm not able to undo the vote because it is too old.
Comment: @daxim: I've edited the post so you get another crack at that vote :)

How can I encode a string for HTML?


Creating a DEM from irregularly spaced contour lines in QGIS

Question: I'm using QGIS to work with a contour line shapefile with contour lines that are not spaced evenly (e.g. not just 100 meter elevation increase between each line). The increase ranges from a 100 meter increase to a 5000 meter increase. Is there anyway to create a DEM from this data, or do I need to find a way to regularly space the elevation data?
Comment: Interesting. If you need DEM for a specific location, you can find it on internet and if you from europe, you can get it from this **[link](https://land.copernicus.eu/imagery-in-situ/eu-dem/eu-dem-v1.1)**
Answer: I'd suggest r.surf.contour tool, which is found in the Processing Toolbox > GRASS > Raster(r.*).
Note 1) This GRASS tool can be run only when you use "QGIS Desktop 3.xx.x with GRASS 7.8.x".
Note 2) This tool requires a raster as input.

A small example of uneven contours (100, 200, 300, ..., 1000, 1500) was rasterized by Rasterize (Vector to Raster) in the Processing Toolbox > GDAL > Vector Conversion . This tool produces a Rasterized layer.

Start r.surf.contour tool.

Select Rasterized layer as the input raster layer, and make sure to calculate the region extent of this layer (even though it says optional).

Final output layer is called DTM from contours. The quality of the image depends on how you set the pixel size. Please note I have rasterized the contour to 300 x 400 pixels (the above image).
Comment: @ScottCasey My contour (vector - lines) was one layer without sub-zones. What you are seeing is the gradient color scheme, and it (the class) can be any number.
Comment: Thank you! I'll try this when I get some time!
Comment: Hmm, when I try this, I get a layer output that only has two sub layers instead of the 5 that you show. One is negative and one is positive, and both are the same magnitude. Not real sure where the values come from as neither of them are elevations that are represented in the contours.
I also note that your contour layer has 5 sub layers, where did those come from? My contour does not have those.


Which is the correct way to say it "who are you spending it with?" Or "whom are you spending it with?"

Question: As per the grammar rules, if "I" is the subject of the sentence then the other person must the object. And generally whom is used in the objective form but in this case the prior format is more common than the latter. So which one is correct?
Answer: "With whom are you spending it?" is the "most correct". But in real life, when speaking, one would say "Who are you spending it with?". The word "whom" is very unusual in spoken text nowadays; most people use "who" for all cases, not just the nominative.
From the OED:

Although there are some speakers who still use who and whom according to the rules of formal grammar as stated here, there are many more who rarely use whom at all; its use has retreated steadily and is now largely restricted to formal contexts. The normal practice in modern English is to use who instead of whom (and, where applicable, to put the preposition at the end of the sentence): who do you wish to speak to?; who do you think we should support?
Answer: Much depends on location and audience.  Some English speakers expect the proper use of "whom", and wince when ending a sentence with a preposition.  Others could not care less.
While I know how to use "whom", perhaps because I'm American, I rarely use it.   In most situations it sounds too formal, or even (to some extent) pretentious.
Then again, "Who are you spending it with?" already sounds somewhat stilted and formal, so in any situation where I might say something like that, I would probably feel obligated to use "whom" and reorganize the sentence appropriately.  Without more context, I couldn't say what the informal version would be, but possibly something like:

Who are you going with?
Who is going with you?
Who else will be there?

and so on.
Again, it's a personal choice.  Other English speakers might feel your example is perfectly ordinary conversation.


Is PyOTA Sandbox up?

Question: As I'm reading on this guide (http://pyota.readthedocs.io/en/latest/getting_started.html#getting-started)
one should be able to connect to the Sandbox network to test an application.But as I try to ping the related url ('https://sandbox.iotatoken.com/api/v1/') it doesn't seem to existIf it isn't up anymore, how can I test my applications? I've read about making transactions with value '0', but it seems pretty slow
Comment: Keep an eye on https://github.com/iotaledger/iota.lib.py/issues/170 for updates on this issue.
Answer: The Sandbox is indeed down, and as a replacement the PoWbox has recently been launched.
While the Sandbox used to be its own IOTA testnet isolated from the normal public testnet, the PoWbox is an addition to the public testnet that can be used to reduce the PoW load for your prototypes you are testing (which are running on the public testnet). So you essentially are using the normal testnet (which does not need any kind of API token) but can also get the PoW advantages that you had on the sandbox.

Is PyOTA Sandbox up?


Tv remote connection to an Arduino

Question: I have a tv remote that I want to connect to an Arduino so that I can send a series of commands to the TV using the remote.  I would like to open the remote and solder transistors or a Transistor Array in place of the buttons.  I have never done this before, so what do I need to be aware of?  I think that I will need to power the remote using the Arduino's power supply, but I am a bit foggy on the details.
Answer: If you're just running lines to the buttons, you won't need to power the remote from the arduino.  You could just let it keep the internal batteries.  But it would be possible to wire it up for power as well.
As a learning project, you could just take it apart and see if you can access the button contacts.  See if the contacts are split.  If so, shorting one side to the other should count as a button press.  But the details have nothing to do with an arduino.  They would depend on your specific remote and how it's constructed.
If your purpose is really to control the TV (rather than learning about the remote and fiddling with it), it will be much easier (and probably cheaper) to blast the IR without involving the remote at all.  A single IR transmitter and a library would work in most cases.  As an example: http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
P.S.  By coincidence, Adafruit just posted an updated guide to IR library use on Arduino.  https://learn.adafruit.com/using-an-infrared-library/overview
Comment: That library is probably the best option.  Still, if I were to use the 'short' rout, I still need to automate the pressing of buttons in a specific order / timing.  I opened the remote and it does use two sided contacts.  How can I short them in a controlled, automatic way using an Arduino?
Comment: If you get an IR photodiode, you can read the output from the remote, store it either as flash or in program data. I've seen it done, Practical Electronics years ago on a PIC, so I know it works. You could add a 'learn' mode to your program.. you know, 'Press "1" now' sort of thing.
Comment: @Hoytman, An electrically easy way is to use a solid-state relay.  Treat it like an LED from the arduino and when it's on it completes the circut.  Use it to bridge the button.  More complex would be to tie the two devices together to ground and feed power to the correct side of the button.  That's more difficult in terms of investigation (which side is low and which is high) and making sure the voltage is good.  But it would probably be cheaper (no SSRs to deal with).
Comment: +1 for IR blasting. There's no need to complicate it by involving the remote except to program the Arduino with the command sequences.
Answer: Using an IR library as mentioned in a previous answer is likely to be about the best approach.  However, if you decide to use electronic switches to jumper across the remote's switch contacts, consider using CMOS analog switch chips for the purpose.  If each button on the remote connects one contact to a common net, inexpensive chips like 74HC4051 and CD74HCT4067 would serve for 8 or 16 buttons each, respectively.
I don't have a reference for an affordable many-SPST-contacts CMOS switch.  Inexpensive chips with a few such contacts are available.  The 74HC4053, for example, contains three SPDT CMOS switches.  Handling a dozen buttons would use four 4053 chips.  A CD4007 probably could provide three SPST switches also.

Edit: The figure above shows pinouts of CD4051/52/53 devices.  To use a CD4053 as three separate switches, connect V- and GND to Arduino ground, V+ to +5V or +3.3V, and each of COMA,B,C to one circuit contact to be switched.  With NCA, NCB, NCC connected to the other contacts of circuits A, B, C, raise ADDA, B, or C and drop INH to close circuit A, B, or C.
If your remote has dozens of buttons, it's likely that they are arranged in rows and columns for multiplexed scanning.  In this case, follow the printed circuit tracks to identify which buttons attach to which rows and which columns.  Suppose there are eight or fewer of one or the other; eg, suppose there are 5 columns and 8 rows.  In this case, you would hook up 5 CD4051 chips: connect V- and GND to Arduino ground, V+ to +5V or +3.3V, and the COM of each 4051 to a different column line.  Connect NO0–7 to row lines 0 to 7.
To close circuit j in column k, put j in binary on ADDA,B,C of all 4051s and drop INH on 4051 #k.  (Either use one DIO line per INH, or use a DM74LS138 or MM74HC138 (etc.) and put k in binary on the A,B,C select lines of the '138.)
Comment: Hoytman, see edit. Please remember to upvote useful answers.
Comment: That sounds good, could you give me draw me a quick schematic of how to connect the chip?
Comment: Great answer, but I really should do as the other answer recommends.

Tv remote connection to an Arduino


Will I lose third party apps if I delete user 501?

Question: One users account is broken. No apple apps work. Can I delete and create a new user and not lose Registered Apps like Adobe. The problems with the account seem to never end. Fix one another pops up. Made another user to see if it was just the one. All apps work on second user.
Answer: Probably not. If you look at your Macintosh HD You should see...
Applications/
Library/
System/
Users/

Typically Applications are installed globally in this top level Applications directory here.
If you look in
Users/
    |_ MyUserName
        |_ Applications
        |_ Desktop
        |_ Documents
        |_ Downloads
        |_ Etc Etc.

Hardly ever are applications installed in this Applications directory.
So unless you see any there. It should be ok to remove the problematic user.


Pre-Requisites for Mutual Authentication

Question: For Mutual Authentication, the client must contain the CA certificate of the Server and his own Certificates, and the server must contain the CA certificate of the Client and his own Certificates.In this way , the Server may contain multiple CA-Certificates for different clients ?
Is this correct ? In this way Server may be loaded with various Client Certificates ?
Can anyone please mention few of the applications which use Mutual Authentication.
Answer: The server will indeed have and announce to the client (during SSL handshake) a list of trusted client CA, and the client will have to provide a client certificate signed by a CA on that list.
you said: In this way Server may be loaded with various Client Certificates?
I guess you meant "Client CA". The server wouldn't be pre-loaded with the actual client cert, unless it's a self-signed (root) cert.
At work, I see SSLMA used between technical components that need to be talking to each other for security-sensitive functionality. E.g. webapp1 -> webservice2, if webservice2 is doing something that you don't want to expose to everyone in the network. Webapp1 may have authenticated and authorized the end-user; but if webservice2 isn't set up to authenticate/authorize the end-users, it may suffice to have webservice2 accept a limited number of SSLMA clients; including webapp1.
On the internet, I haven't seen that much use of SSLMA (from browser to website), but there are cases, e.g. to log on to some government or banking websites. Typically, the client cert is then installed on a smartcard. I can think of only a few examples in Belgian context, not sure if that would help you.


Set owner of NFT

Question: I'm new to smart contract I don't know is this a right question.
Is it possible that someone else mint the NFT but the owner of that NFT is the person who deployed the contract ?
Answer: TL;DR. Yes.
Non-Fungible Token is a concept. There are many implementations of that concept, and there's no limit on what you can implement.
Most of the NFTs in the Ethereum ecosystem follow the ERC20, ERC721, or ERC1155 specification, but those are interfaces and not specific implementations.
Answer: There is many what ifs that could be written here.  Here's one I think of instantly.
If I understand your question, in theory it can happen. Lets say you are minting on a marketplace that automatically holds your NFT until it sells.  There are a couple phone apps that do this, like beyond mars.  This would mean that the minter or contract owner would be listed as owner until the NFT is transferred to the person who actually interacted with the smart contract.  Another many people misunderstand is lazy minting, which isnt minting at all and no one has an NFT until the sell.
Personal Opinion:
I am a founder of an NFT marketplace online. Shhhhh. I don't like the idea of me or someone that works for me, holding an artists artwork/NFT indefinitely.  For this reason we only hold it after the artist mints it and takes possession, then initiates a sell action with the smart contract themseves.  At which point they pay a small gas fee to transfer it to the contract and its held until it sells, expires or the artists cancels the sell.

Set owner of NFT


What's the mechanism in the formation of this quinone?

Question: I need to solve this problem for homework. In an article, I saw a quinone formation, but I don't understand the mechanism. In these reactions, the authors used KI (potassium iodide) and AcOH (acetic acid) to generate an alcohol, but I do not understand why an alcohol is generated. Also, they used toluene and p-TsOH·H2O for the opening of the epoxide ring and the formation of a double bond, but I am not sure about this. Here I leave the name of the article (Maruo et al., 2013, "Biomimetic Synthesis of Zeylanone and Zeylanone Epoxide by Dimerization of 2‑Methyl-1,4-naphthoquinone"). I appreciate your help.
Answer: Although I'm not 100% positive, I assume the first step is for both conversion of the epoxide and removal of the MOM protecting groups. Acidic conditions are generally sufficient for removing MOM protecting groups, so I would expect the acidic conditions in the first step to remove the MOM groups; however, the iodide also plays a critical role  in converting the epoxide to the alkene.
In this case, conversion of an epoxide to an alkene is a net reduction. Therefore, iodide will act as a reducing agent. I assume the first step (A) to be nucleophilic attack by the iodine on the electrophilic epoxide, facilitated by the acidic conditions. We can then perform a net protodehalogentation by attacking the iodo subsitutent with another nucleophilic iodide (B). This is the key redox step. Iodide is oxidized to iodine and the substrate is reduced. Here, the only step left is to eliminate a molecule of water (C) to produce the alkene product. I assume this is the purpose of the second step of reflux in toluene with TsOH. Elimination of water generally goes better in nonpolar solvents like toluene as it can be removed directly with something like a Dean-Stark trap, shifting equilibrium towards the alkene.


How is a $4\times 4$ Matrix built (concerning position, translation, scale and rotation)?

Question: I am given to understand that a $4\times 4$ matrix can contain position, translation, scale and rotation, but I don't know where all of these are in the matrix.
What I have seen so far is that position are on 11, 22 and 33 and that translation is on 41, 42 and 43, but where do the scale and rotation belong?
Comment: They are all over the place, think about what transformation would rotate $e_i$ (a standard basis vector) $\phi$ degrees towards $e_j$ for instance
Answer: For the simplest case take for instance $e_1=\{1,0,0,0\}$ and $e_3=\{0,0,1,0\}$. Rotating $e_1$ towards $e_3$ by $\theta$ radians in the plane spanned by $e_1,e_3$ it would move along the circle $\cos(t)e_1 + \sin(t)e_3 = \{\cos(t), 0, \sin(t),0\}$
The matrix that does a rotation in that plane looks like:
$$
\left(
\begin{array}{cccc}
 \cos (\theta ) & 0 & -\sin (\theta ) & 0 \\
 0 & 1 & 0 & 0 \\
 \sin (\theta ) & 0 & \cos (\theta ) & 0 \\
 0 & 0 & 0 & 1 \\
\end{array}
\right)$$
Note that it has ones at position $(2,2)$ and $(4,4)$ since anything in the span of $e_2$ and $e_4$ is unaffacted, and the rest behaves just like it does in the $2 \times 2$ case.
Don't think of the diagonals as containing position, for instance take the matrix that has $\{a, b, c, d\}$ on the diagonal and zero elsewhere. When you multiply this matrix with a vector $\{v1, v2, v3, v4\}$ you get a new vector $\{a\ v1, b\ v2, c\ v3, d\ v4\}$  If this is not obvious grab pen and paper and do it
So this matrix scales vectors a certain amount in each of the standard basis directions, you can think of it as stretching the entire space by a corresponding amount in each direction.
The same way
$$\left(
\begin{array}{cc}
 2 & 0 \\
 0 & \frac{1}{2} \\
\end{array}
\right)$$
Does the following when applied to the points in a circle:

So instead think of a matrix as an operator that does something to a vector, if we want to combine the action of two matrices (operators) we can just take the result of the first one and then apply the second operation to that. This way we have just defined a new operator, which we can get in matrix form by simply doing matrix multiplication of the two matrices.
You can combine the rotation in the $e_1,e_3$ plane and the stretching operation. But first you have to know in which order you want to do the things.
If we stretch first the resulting matrix is:
$$
\left(
\begin{array}{cccc}
 a \cos (\theta ) & 0 & -c \sin (\theta ) & 0 \\
 0 & b & 0 & 0 \\
 a \sin (\theta ) & 0 & c \cos (\theta ) & 0 \\
 0 & 0 & 0 & d \\
\end{array}
\right)$$
But if you rotate first and then stretch:
$$
\left(
\begin{array}{cccc}
 a \cos (\theta ) & 0 & -a \sin (\theta ) & 0 \\
 0 & b & 0 & 0 \\
 c \sin (\theta ) & 0 & c \cos (\theta ) & 0 \\
 0 & 0 & 0 & d \\
\end{array}
\right)$$
Hopefully this examples gives you some intuition to why $AB$ often is different from $BA$
Comment: But how would it look if I want to combine it all into 1 matrix? Is that possible?
Comment: @Friso1990 Yes, I updated the question. I suggest you play around with constructing $2 \times 2$ matrices that does some particular actions, once you know how it works for $2 \times 2$ matrices you know how it works for $n \times n$ matrices :)
Answer: It depends on how you "apply" the matrix to given points/vectors by multiplication. You can
(A) regard a vector as a "row" and you place it to the left of the matrix when multiplying, or
(B) regard a vector as a column, and place it to the right
These two calculations will give you different results, obviously.
In either case, rotation and scaling are represented by the top left $3\times3$ matrix.
In case (A), the first three elements in the bottom (fourth) row of the matrix represent translations. In case (B), you have to put your translation quantities in the fourth column, instead.
I've only told you about 12 elements of the matrix. You may be wondering what the other 4 are for. They are for "perspective" transformations.
A pretty good reference is shene-notes. He uses convention (B).
Answer: I'm not sure if this will help but these are the three elementary rotation matrices :
Around $x$ axis : $R_x = \begin{pmatrix} 1 &0& 0\\ 0&\cos \theta & -\sin \theta \\ 0&\sin \theta & \cos\theta \end{pmatrix}$
Around $y$ axis : $R_y = \begin{pmatrix} \cos\theta &0& \sin\theta\\ 0&1 & 0 \\ -\sin \theta & 0 & \cos\theta \end{pmatrix}$
and around $z$ axis : $R_z = \begin{pmatrix} \cos \theta & -\sin \theta&0 \\ \sin \theta & \cos\theta &0 \\ 0&0&1\end{pmatrix}$
Now, a matrix that contains rotational information and translational information is composed by :

one of the above matrices or a composition of two or more of these matrices
a $3\times 1$ vector that contains position/ translational information

Generally it can be written like this :
$\left[\begin{array}{c|c} R & L \\ \hline 0 & 1\end{array}\right]$
where $R$ denotes one $3\times 3$ rotational matrix (see above) and $L$ denotes a translational $3\times 1$ vector with (three coordinates).
One example of usage of these type of matrices is to create homogeneous transform matrices.
You can find some explanations about these matrices here.


In a given range how can i find how many times a two digit number appears ?

Question: I want find how many times a two digit number appears in a given large range , Range is 10^500 . Example : I want to find 21 in given range and the range is 15 to 240 , there are total of 12 numbers that contains 21 in it,  21,121,211,212,213,214,215,216,217,218,219,221 . If the range is  2120 to then  21 appears 7 times . 2120, 2121( 2 Times ) , 2122 , 2123, 2124, 2125 . So,  How can i find the number of occurrence of a two digit number ?
Comment: Are the appearances allowed to overlap? E.g., in $1111$, does $11$ appear two times or three times?
Answer: Zero one digit numbers contain a "21".
One percent of two digit number contains a "21", so there are $$ (1 \times 0.01) \times 10^2 = 1 $$ "21"s up to $10^2$.
One percent of three digit numbers contain a "21" in the first two digits and one percent contain a "21" in the last two digits (none do both), so there are $$ (2 \times 0.01) \times 10^3 = 20$$ "21"s up to $10^3$.
One percent of four digit numbers contain a "21" in the first two digits, one percent in the middle two digits, and one percent in the last two digits, so there are $$ (3 \times 0.01) \times 10^4 = 300$$ "21"s up to $10^4$.
So the pattern is:  up to $10^n$, 1% have "21" in digit positions $n$ and $n-1$, 1% have "21" in digit positions $n-1$ and $n-2$, ..., and 1% have "21" in digit positions $2$ and $1$.  This is $n-1$ copies of 1%, so there are $$ ((n-1) \times 0.01) \times 10^n = (n-1) \times 10^{n-2}$$ "21"s up to $10^n$.
Answer: We solve a restricted version of the problem, where we count the number of occurrences of $21$, or any other two-digit number, and first digit not equal to $0$, in the interval from $0$ to $10^k-1$. We assume $k\ge 2$.
First let us pad any number that has fewer than $k$ digits with initial $0$'s, so that all numbers have exactly $k$ digits. Now pick a "random number" in o ur interval (all numbers equally likely).
For $i=1$ to $k-1$, let random variable $X_i$ be equal to $1$ if the $i$-th digit is $2$ and the $(i+1)$-th digit is $1$. Let $X_i=0$ otherwise.
Then $W=X_1+\cdots +X_{k-1}$ is the number of occurrences of $21$ in our randomly chosen number.
We have $\Pr(X_i=1)=(1/10)^2$. Thus by the linearity of expectation $E(W)=(k-1)(1/10)^2$. It follows that the number of strings of $21$ is equal to $(10^k)(k-1)(1/10)^2$.


Lattice and carrier temperature

Question: If I hold a semiconductor sample at a certain temperature $T$, its lattice temperature $T_l$ will equalize: $T_l=T$. But how is this lattice temperature related to the carrier (electron or hole) temperature $T_{e/h}$ if we assume a Fermi-Dirac distribution of carriers in thermal equilibrium $f^{e/h}_k=\frac{1}{\exp( [E^{e/h}_k-\mu_{e/h}]/[k_BT_{e/h}]) + 1}$? The carrier temperatures are not the same as the lattice temperature, are they? Is there a relation between $T_l$ and $T_e$ or $T_h$? Or does this depend on further knowledge of the system?
Answer: Most of the time (e.g. at room temperature), the temperature of the lattice $T_\ell$ is equal to the electronic temperature $T_e$. The simpliest argument to give in favor of this is that electrons are strongly coupled to phonons via the so-called electron/phonon coupling.
In that way, the thermal equilibrium of the lattice is directly linked the thermal equilibrium of the electrons, so that $T_\ell=T_e$.
But electron/phonon coupling cease to be efficient for temperatures under approximatively $10\,\mathrm{K}$ (depending on your sample). So if you are able to cool your semi-conductor (or metal) under this temperature, you will actually only be able to cool the lattice but not the electrons : $T_\ell<T_e$.
That's why people who are working in low temperature physics and cryogenics are having such an hard time to actually cool a sample below a few $\mathrm{K}$.
Comment: Is there a good estimate how the hole temperature differs from the electron temperature?
Comment: I actually don't know any case where the hole temperature is different from electron temperature. I would say they are always equal since holes are just mathematicals tricks to describe electrons.
Comment: But, consider the Fermi distribution I described in my question. If you do not lose carriers, than the number of electrons and holes must be the same. You get the number of carriers by integrating the distribution and then you obviously need a different temperature for electrons and holes since they have a different mass and chemical potential.
Comment: I do agree that there exists some cases where effective mass of electrons and holes is different, especially when you do the separation between light and heavy holes in the valence band. But most of the time, $m_h=-m_e$ still valid. And clearly, there is no such a thing as different chemical potential for electrons and holes. And it's very doubtful that one can define temperature for holes as a real thermodynimical measurable quantity since electrons and holes in semi-conductor can not be separated in two well independant systems.

Lattice and carrier temperature


How many generations passed between Bhagiratha and Rama?

Question: Is anything written about the lifespan of the kings who were Rama's ancestors (the Sūryavaṃśa / Ikṣvāku Dynasty) up until Bhagīratha?
Answer: 14 generations -

The son of Dilipa was Bhagiratha. The son of Bhagiratha was Kakustha whose son was Raghu from whom the royal line has since been named. The
sons of Shri Raghu were known by the names of Pravriddha, Purushadaka,
Kalmashapada and Soudasa. The son of Kalmashapada was Shankhana who
rising to great power, by a curse, was destroyed wth his whole army.
The mighty hero Sudarshana was the son of Shankhana and his son was
Agnivarna and Agnivarna's son was Shighraga. His son was named Meru,
and Meru's son was Prashusvara, and his son was the great Sage
Ambarisha. The son of Ambarisha was the truthful Prince Nahusha, whose
son was the virtuous Nabhaga. Nabhaga had two sons, Aja and Suvrata,
and the son of Aja was the illustrious sovereign Dasaratha.

https://www.wisdomlib.org/hinduism/book/the-ramayana-of-valmiki/d/doc424087.html


disability insurance starting medical residency

Question: My daughter will start a medical residency in July 2022.  Evidently, she can purchase a disability policy at that time without medical underwriting.  I am wondering,in general, do these policies end when she finishes her residency in 3 years and then she needs to again undergo medical underwriting, or can she keep the original policy long term?
Comment: Please add a country tag.
Comment: How is the policy being purchased?  If through an employer, generally speaking, no underwriting is necessary.   If through an agent, unlikely as she could just continue to pay the premiums.  However, I would check with the agent.
Answer: Such policies tend to be for a limited amount of monthly income  for a students, residents and recent grads.  How long they last would depend on the terms of the policy and contacting the insurance company would provide a definitive answer.
Though they lack earnings, this group has significant future earnings potential so most insurance companies have a "Special Limits & Streamlined Underwriting for New Professionals" which simplifies the underwriting process - no proof of income or lab testing.
I think it's reasonable to conclude that insurance companies want to get their foot in the door, hoping that when the student/resident graduates, they continue with their company.  It's a reasonable bet on their part since they are young and healthy and the policy limits are modest.
Answer: White Coat Investor is an opinionated site with an overview of the issues here. The site also shows advertisements from insurance brokers.
Among the interesting claims in the overview page:

An "own occupation" policy may be cheaper to buy as a medical resident and to keep for the entirety of one's career
The institutional affiliation as a medical resident may provide access to exclusive, valuable insurance products for individuals
Conversely, the group products offered by the institution are unlikely to be the best choice


Can I use MIUI's auto SMS + MMS backup + restore thing on another custom ICS rom?

Question: MIUI's built in SMS + MMS backup works quite well. However, I want to try out new custom ROMs. Is it possible to add integration of that MIUI service onto another ICS rom?
Comment: No, that service is dependent on the MIUI framework. Maybe you can move the service to other ROMs but most likely it will never work. Unless the dev integrated some MIUI goodies :P
Answer: Answer: No you can't.
Reason: You can't install the MIUI Backup App on another rom, because it's a signed system APK.
Solution: Use a backup solution which is available for all roms. If you just want to backup and restore SMS, then use the free https://play.google.com/store/apps/details?id=com.riteshsahu.SMSBackupRestore
Source: I'm a MIUI Beta tester and former moderator on the original forum en.miui.com
Answer: I don't think you can use the MIUI specific functionality, but using Titanium backup you can backup your SMS and MMS:

Open Titanium Backup
Press the search icon at the top and then the filter icon which appears to the right of the search input box
At the bottom of the 'Filters' Screen, press the "Create label" button
Enter the label name - "SMS"
Press the "Add/Remove elements _" button
Find and check the "[SMS/MMS/APN] Dialer Storage 2.2" checkbox - It may be called 'Messages (SMS & MMS)' depending on what OS you're using.
Press the "OK" button and then the "Save" button
Press the back radio button
Select the "Schedules" tab
Press the "Add new schedule" button located at the bottom
On the schedule that just appeared, titled 'Redo backups for newer app versions', press the "Edit" button
On the top combo box select the arrow to pull down the menu.
Select the "Backup all system data" option
On the next combo box that says "No filtering", click the arrow to pull down a menu.
You should see your label you created.
Select your label.
Select the time you want your backup to take place
Select the days you want your backup to take place
Press the "Save" button
Check the "Enabled" check box to enable your schedule

Now Titanium Backup will automatically backup your messages at the specified time and day or days.
Note: You will need the Titanium backup pro key to access the batch operations.
You can also backup your call call history by adding '[CONTACTS/CALLS] Contacts Storage 2.2' or 'Call Log' to a label
Taken in part from this guide on XDA
Comment: Backing up system(ie non-user) apps with Titanium Backup sometimes causes FC or crashes when restored to a different ROM (esp AOSP <-> OEM ROMs), I wouldn't recommend it.
Answer: You can backup SMS, MMS and call logs to your GMail account with this free app. Being online, you wouldn't lose your backups even if wipe your sd card or lose your phone.
This is better than using Titanium Backup, as it can sometimes cause issues.


How can I set that only root + a given user can shut down my pc?

Question: If I'm using Ubuntu 11.04, how can I configure it such that that only two users can shut down/suspend/hibernate my PC: the root user and one regular user?
Answer: The shutdown binary will only work for the root user.  The typical approach to this is to set up sudo rules to allow the user to execute shutdown as root.  Assuming the user doesn't already have full sudo permissions
(the first user on an Ubuntu desktop system does, for example) you might add the following line to /etc/sudoers (using the visudo utility, for safety):
joe    hostname=(root) /sbin/shutdown -h now

If you want them to be able to shut down without being prompted for their password, then add the NOPASSWD option, like this:
joe    hostname=(root) NOPASSWD: /sbin/shutdown -h now

You can modify the way they can run shutdown by using wildcards or explicit declarations.  For example shutdown -h now allows an immediate halt of the system, it will not reboot.  You could allow -r instead to reboot the system.
After you configure sudoers, joe can run the following command to reboot the system:
sudo /sbin/shutdown -h now

As joe, you can run the following command to see what commands you have access to run using sudo:
sudo -l

Answer: To disable shutdown from the login menu, edit the /etc/gdm/gdm.conf-custom file and in the [greeter] section add SystemMenu=false. This won't affect the panel menu, though, I am not sure how to disable that without disabling it for all users, but if you disable it for all users you should be able to work around it by using the shutdown command from a terminal instead. To disable for all users, see this link; I have not verified that these instructions work on Ubuntu.
Note that there is no way to stop them from just unplugging it or pressing the power button on the front of the PC, so the trend in linux distributions for home use has been to allow these functions to all users sitting physically at the computer with no obvious way to disable it.
Answer: For the power button, you might want to look into /etc/acpi/events/power_button . While you are at it, you might also want to look in /etc/inittab for ctrlaltdel .


Finite-dimensional faithful unitary representations of SL(2,Z)

Question: Does $SL(2,\mathbb{Z})$ have a finite-dimensional faithful unitary representation?  No such representation exists for $SL(2,\mathbb{R})$, but I don't see a reason why one shouldn't exist for $SL(2,\mathbb{Z})$.
Comment: $SL(2,Z)$ is the amalgam $$. So I'd take $v$ the diagonal matrix $(i,-i)$ (so $z=-1$) and I'd take for $v$ a random conjugate (in $SU(2)$) of the diagonal matrix $(t,t^{-1})$, where $t=\exp(2i\pi/6)$. This is not a complete proof but an expectation, that for a generic conjugate they indeed generate the amalgam.
Comment: @YCor's suggestion works - one can prove a faithful action of $SL(2,Z)$ on the Bruhat-Tits tree associated to $SU(2)$ for the representation variety, and then restrict to a generic value to get a faithful representation. But I'll point out that low-dimensional representations are classified in this paper: https://mathscinet.ams.org/mathscinet-getitem?mr=1815266
Comment: The answer is certainly yes; there should even be a faithful representation into $SU(2)$. On the other hand there's no faithful finite-dimensional unitary representation of $SL(3,\mathbf{Z})$.
Comment: Thanks.  Do you mind saying something about how such representations are constructed or providing a reference?
Answer: Here a non-explicit proof of the existence of a faithful representation of $\mathrm{SL}_2(\mathbf{Z})$ in $\mathrm{SU}(2)$, using basic algebraic geometry and topology, and relying on the amalgam decomposition of $\mathrm{SL}_2(\mathbf{Z})$.
[The basic idea is that if all representations in $\mathrm{SU}(2)$ were non-faithful, by Zariski-density this would also be the case for representations into $\mathrm{SL}_2$. We need to use the particular form of the presentation of $\mathrm{SL}_2(\mathbf{Z})$, since the argument will not carry over representations of $\mathrm{SL}_3(\mathbf{Z})$ in $\mathrm{SU}(3)$.]
Let $P_t$ be the set of $2\times 2$ matrices with determinant 1 and trace $t$. Both $P_0$ and $P_1$ are irreducible as algebraic varieties (being $\mathrm{SL}_2$ conjugacy classes). Then for $K$ a field of characteristic zero, $P_0(K)$ is the set of elements of order 4 in $\mathrm{SL}_2(K)$, and $P_1(K)$ is the set of elements of order 6 in $\mathrm{SL}_2(K)$.
For every $(g,h)\in P_0\times P_1$, $g^2=h^3$ equals $-I_2$. Hence the set of representations of $$\mathrm{SL}_2(\mathbf{Z})=\langle u,v\mid u^4=v^6=[u^2,v]=[u,v^3]=1\rangle$$ (restricting to those for which the image of $u$ has order 4 and the order of $v$ has order 6)
into $\mathrm{SL}_2(K)$ can be naturally identified to $(P_0\times P_1)(K)$. Note that $P_0\times P_1$ is irreducible.
Write $P_t^\sharp=P_t(\mathbf{C})\cap\mathrm{SU}(2)$. Then using that $\mathrm{SU}(2)$ is Zariski-dense in $\mathrm{SL}_2(\mathbf{C})$ and describing $P_t(\mathbf{C})$ as a conjugacy class, one deduces that $P_t^\sharp$ is Zariski-dense in $P_t(\mathbf{C})$. So $P_0^\sharp\times P_1^\sharp$ (which is a 4-dimensional real manifold) is Zariski-dense in $(P_0\times P_1)(\mathbf{C})$.
For every given nontrivial element $w$ in $\mathrm{SL}_2(\mathbf{Z})$ the set of representations vanishing on $w$ is a proper subvariety of $P_0\times P_1$, hence has dimension $\le 3$. By Zariski density of $P_0^\sharp\times P_1^\sharp$, we deduce that its intersection with $P_0^\sharp\times P_1^\sharp$ is a proper Zariski closed subset (because $\mathrm{SL}_2(\mathbf{Z})$ admits one faithful representation into $\mathrm{SL}_2(\mathbf{C})$, the standard one); in particular it has empty interior (in the ordinary topology). By the Baire theorem, the union over all $w$ is still a proper subset. Hence we deduce the existence of an element of $P_0^\sharp\times P_1^\sharp$ defining a faithful representation.
Comment: Just to state the obvious: this answer describes the extra mileage you need to go for having a faithfu two dimensional unirep. Just to get a faithful f.d unirep it is a lot easier to induce one from a finite index free group...
Comment: @UriBader thanks for noticing. I guess the smallest index of a free subgroup is 12, so this yields a 24-dimensional representation that has finite kernel, hence kernel of order $\le 2$ (I guess 2). Using a 1-dimensional representation (through $C_{12}$ that's faithful on $-I_2$, we eventually get a faithful 25-dimensional unitary representation.


c# inheriting generic collection and serialization…

Question: with reference to c# inheriting generic collection and serialization… question
If you are providing a paged collection it is useful to pass back the total available so the client can set up they paging control. Does anyone know a nice way to achieve?
Also why is this "By Design" seems pointless.
Cheers.
Answer: See PagedList for example.
Comment: Thanks mate, looks interesting.


Commit a large number of files in RStudio using GIT panel

Question: In RStudio, if you are dealing with a directory that contains a large number of files, and you want to commit and push the recent changes (that you made on all of them) to your repository, the GUI Git component gets super slow and practically doesn't work. Any idea?
Answer: Of course you can ignore the GUI and stick to the command-line Git forever, but if you don't want, a quick jump to the command-line git would solve this problem for now.
The temporary solution that I found is as follows:

Click on the blue-gear icon on the GIT panel, inside RStudio.
Select Shell (a terminal window will pup up!)
Write the add and commit command in the terminal:

{ATTENTION: The following command will commit changes on ALL files! You may want to use what is appropriate for your situation!}
<code>    git add -A && git commit -m 'staging all files'
</code>

Now you can go back to the GUI Git, and click on push button. All files that you staged in the terminal window, will be pushed up to your repository.
Comment: This worked for me only when using double quotes around the commit message.


How to show current year in view?

Question: Is there a function I can use to show the current year in a view? I have tried
<%= Time.now  %>

to try and show the time but this does not work for me.
Answer: <%= Time.current.year %>

http://pleac.sourceforge.net/pleac_ruby/datesandtimes.html
Answer: I'd rather use Date class to get year than Time class (if you only need the Date, you don't need to consider hours, minutes and seconds).
<%= Date.today.year %>

c.f. http://ruby-doc.org/stdlib-2.1.0/libdoc/date/rdoc/Date.html#method-c-today
Answer: I think the best way to get the current year considering application timezone is:
Date.current.year

Comment: Agreed. Also, `Date.current` is the same as `Time.zone.today` if `config.time_zone` is set.
Comment: This is the best answer.  Date.current is the most appropriate.
Answer: I like to use:
Time.zone.now.year

This takes into account the current timezone (incase you have overridden it for a particular user).
Answer: Despite that it has already been answered, I thought it might come handy for those who want to look at benchmark results for all the suggested solutions.
require 'benchmark'

n = 500000
Benchmark.bm do |x|
  x.report { n.times do ; Date.today.year; end }
  x.report { n.times do ; Date.current.year; end }
  x.report { n.times do ; Time.current.year; end }
  x.report { n.times do ; Time.zone.now.year; end }
end

    user     system      total        real
0.680000   0.030000   0.710000 (  0.709078)
2.730000   0.010000   2.740000 (  2.735085)
3.340000   0.010000   3.350000 (  3.363586)
3.070000   0.000000   3.070000 (  3.082388)

Now, it may perhaps seem over the top for something as simple as that, however, from a simple optimisation perspective for a high throughput application, I will consider using Date.today.year
Said so, if your application is Time Zone sensitive, perhaps Date.current or Time.zone based methods are your best bet.
Check out this wonderful Railscast by Ryan on Time Zones

How to show current year in view?


How can I emulate a 'fake' printer (driver) in Windows?

Question: For testing, my application needs to send a document to the printer. I don't really want to print this out, so I am looking for a 'fake' printer driver which could essentially print to nothing. I know that nul exists, but I also need the fake printer to support pausing. Any idea if the nul port can do this or any other fake printer driver?
Comment: why not use the XPS printer driver or an application like CutePDF which emulates a PDF printer ?
Comment: @sathya: Exactly. +1
Comment: Because for me it prompts for a dialog for the filename to save as. For testing this won't work for me, but it is a great answer.
Comment: @sathya, why not post that as an answer? Seems a lot of people like that idea ;)
Comment: @nhinkle wasn't sure if that was the right option :)) posted as an answer now.
Comment: PDFCreator can be configured to auto-save documents.
Answer: Create a new printer and set its port to NUL:
You will need to add a new local port and just type NUL: where it asks for port name.
Comment: How do you pause such a printer or make it offline?
Comment: @TheCrazyProgrammer: In the same manner you'd do so for a real printer.
Answer: I recommend the free and open-source PDFCreator
You can pause printing from PDFCreator's control dialog
Comment: That looks suspiciously like the built-in Windows print dialog...
Comment: @Hello71 It should, it is the Windows print dialog.  A PDF printer like netvope mentioned installs itself as a windows printer and does the work after the document is printed to it.
Answer: As I had mentioned in the comments, Windows ( Vista & above) come with a XPS printer driver which you can use. Else install CutePDF which emulates a printer driver.
Answer: For completeness, Microsoft actually has two different virtual printers included with office, depending on which version of office you use:  Microsoft Document Image Writer for Office 2003, and Microsoft XPS Document Writer for Office 2007 and newer.
Of course, like the PDF option these will both still create files on disk.  But in the Windows world it's very likely you may already have one of these available.
Answer: You can use doPDF

doPDF is a free PDF creator that does what the name suggests, creates PDF files. Once installed it will allow you to convert any type of printable documents to PDF files. doPDF7.3 installs itself as a virtual PDF printer driver so after a successful installation will appear in your Printers and Faxes list and also in the list of All Programs. Using doPDF you can convert to PDF in two ways:

Print to PDF via the virtual printer driver doPDF. You would do this exactly as you print to a regular printer, just the result will be a PDF file, not a printed piece of paper.
Using the doPDF Startup window. doPDF has an executable file (accessible from the start program group) that you can run in order to start a conversion wizard.


Is the flash on a Nikon D5600 supposed to pop up and fire automatically, if so what camera settings to achieve this

Question: Pretty much as title.  I have just acquired a Nikon D5600 and had gained the impression from somewhere that the onboard flash is supposed to pop up and fire automatically if light levels are too low.  But I have tried various different camera settings in very poor light, even total darkness, and haven't been able to make this happen.  If this is supposed to happen, what camera settings will achieve this?
Comment: There is a small button just below the flash that makes it pop up, which will fire the flash when you hit the trigger. Otherwise I think it fires usually only with Auto mode
Comment: Yes, thanks, I'd got that far.  My problem seems to have been, although I thought I'd tried them all, that I was using the wrong modes.  Incidentally, it is in covered in the User Guide, but it's in the specifications section, which is why I didn't find it initially by eye - I only found it when I had an electronic copy I could search.
Comment: @ssn - That is in fact the correct answer. If you write it as such, then it could be accepted by the OP.
Answer: Only in auto mode will the flash automatically pop up. If you are in the manual type modes, you have to hit the flash button on the top left side of the camera to pop the flash up.
Answer: Nothing much about it in the User Guide supplied with the camera, but it's there in the D5600 Reference Manual, printed page 101, pdf page counter 127.  This lists the modes for which the flash pops up automatically, and, using the Auto mode (defined by the Auto/Camera icon), I've checked that it works as expected, which hitherto I had not been able to do.


Is 'aerial view/map/painting' the right term for a map/painting drawn/painted from a bird's-eye view?

Question: It was an aerial view of the city.
It was an aerial map of the city.
It was an aerial painting of the city.
Any other ways to say this?
Answer: Here are some synonyms you might find useful:

It is an aerial perspective of the city
It is a satellite view of the city (photograph, not map)
It is a bird's eye view of the city
It is an aerial view of the city
It is an ordinance survey of the city (British english, map - not photograph)
It is an overview of the city (somewhat archaic)
Answer: If it is a painting, one might likely say 'a painting of an aerial view' of the city, 'a painted map' of the city, or perhaps 'a hand-painted map' of the city.
'Maps' are typically created in this perspective, so it would likely go unmentioned as in: 'a map' of the city.  Exceptions might call attention to their deviation from the norm: 'a 3D-perspective map' of the city.
An aerial painting of the city could be ambiguous as one might believe that the painting was painted while the artist was airborne.
'Satellite view' or 'satellite photograph' would be correct only for very-high altitude photography (as might be taken from a satellite.)  'Aerial photograph' would be a better term to use if the photo were taken from a plane, a hot-air balloon or some other airborne yet non-satellite platform.
I hope this helps!


Correct way?: most abundant 10 african and 10 european ingredients

Question: Lets say I want to talk about the 10 ingredients most frequently found in each continent, while being as concise as possible. I have the choice to say 10 most abundant ingredients in african and european continents, but then it becomes unclear whether the 10 are the sum of both, or 10 in each, and how they are split. How would you say this?
Comment: There are many different ways of saying this e.g. *The 10 most abundant ingredients in each of Europe and Africa*, *The most abundant 10 ingredients in both the European and African continents*, *The 10 most abundant ingredients in Europe and in Africa* etc.
Answer: You only need to repeat in to disambiguate:

10 most abundant ingredients in the African and in the European continents.
Answer: Adding both adds some clarity:

10 most abundant ingredients in both African and European continents.

This is perhaps still not 100% (although I would use "across both" instead of "in" or "in both" if I meant 10 in total). However, I would expect the rest of the article to remove any doubt about which is meant.
Also, depending on what you are writing about, I might say "cuisine" instead of "continents" – depends on whether you are talking more about what is grown there or what is eaten there (there may be differences).
Finally, note that both African and European should have initial capital letters (see Should broader types be capitalized?).
Comment: "Adding *both* adds some clarity:" How?
Comment: @Kris Because I see "_in both X and Y_" as short-hand for "_in X and in Y_".
Answer: I think I'm commenting here just to clarify or get things much clearer that you need to add both to easily indicate ohh there's two continents he meant. SO, it would be 10 Most Abundant Ingredients in both African and European Continents, and once again, that structure is quite common in use which is actually what you are expecting. Thank you
Comment: Yes, indeed, you are. Please use comments, if you have the privilege.


Is reverse tonotopical organisation possible?

Question: In human cochlea tonotopical organisation is that higher frequency sounds are detected near the entrance whereas lower frequency sounds are deep inside the cochlea. Is this tonotopical organisation (high frequencies at the entrance, low - deep inside) justified by some physical or biological constraints or it doesn't matter and we could in principle have cochlea where low frequency sounds are detected at the entrance?
Answer: There are indeed constraints: in principle, low-frequency sound waves travel better in viscous media (look here for a simple explanation). The idea behind that is that being sound a vibration in the medium, it causes its molecules to move. The faster the movement (that is, the higher the frequency) induced by the wave, the more the particles will disperse their energy by crashing into each other. This leads to more loss of energy for high-frequency waves compared to low-frequency ones when travelling in a medium.
Now, all of this leads to the detection of high frequencies being better at the beginning of the canal. However, here is the law that quantifies the loss of amplitude of the wave with distance. As you can see, the damping is higher for high frequencies, as well as high viscosities. However, plugging in some sensible numbers (20 kHz for very high-frequencies heard by humans, 1500 m/s for the speed of sound in endolymph, 1 centipoise for its dynamic viscosity, 1 kg/liter for density) gives a negligible loss of intensity (something like 0.0001. I'm sorry for the poor formatting, but I'm on my phone right now and I hope you will try to run the calculation yourself).
Now, a possible need for the accurate detection of even higher frequency sound waves in water for the fish in which the cochlea appeared is possible. However, I neither know if that is the case, nor if the difference would be a significant one.


Why is my refrigerator tripping breaker?

Question: I have been troubleshooting this problem and I have narrowed it down to the ground in the unit. When I disconnect the ground from the frame, it runs fine, and has no problems. When I reconnect the ground, it trips the breaker. We recently cleaned and defrosted the unit. and thats when the problem started. It ran fine before that. I ohm'ed out the ground to the temp control, and that is fine also. I ohm'ed out that same wire to the frame and that was all over the place. I can only assume that wire is causing the problem. Is it possible I got something wet and that is causing it?
Comment: I do not have any idea what your issue is, but I would not operate the refrigerator without the ground wire. If the refrigerator has developed an electrical fault (e.g. by a hot wire coming loose or otherwise electrifying the chassis), then the ground wire and breaker are doing exactly what they are supposed to do i.e. the ground wire is sucking up the fault current and subsequently causing the breaker to trip.  If you operate without a ground wire, then the fault current will have to find another path....  possibly through you!
Comment: Are you tripping a breaker or a GFCI (RCD)?
Comment: Bob is correct. The ground wire is there to complete the circuit and facilitate the operation of the breaker in case of a ground fault. A ground fault means the equipment is shorted to the metal frame. Without the ground wire the metal frame is energized and looking for a way to get to ground. Like you touching the fridge and the kitchen sink at the same time or the frame of the range. Get it fixed!
Answer: The path of least resistance.
When the ground is removed, the current is forced to go through the compressor, and fridge works.
When you replace the ground, there is a path from hot to ground, that avoids the compressor.

So your problem is somewhere between the 'hot' wire on the plug and the compressor.

Possibly a problem in the receptacle where the hot wire will short when the ground pin is inserted, but unlikely. If you want to test for this, plug in something else with a ground pin, wiggle the cord, and if it works, the fridge is the problem.

My vote would be for someplace where a wire was pinched while working on it.

The wire should be loose - long and had too much room to move around and got pinched, or it should be really tight, because it did not have enough room to move.
There does not have to be much damage to the insulation for this to happen, but running your fingers along the wires should be enough to find it.
Best of luck to you
Answer: Your problem indicates a ground fault because the GFCI keeps flipping before the breaker and that's what a Ground Fault Circuit Interruptor does,  it protects home owners against ground faults, potentially moist or wet locations that can disrupt the voltage between 5 - 7 mA
Your specific problem is caused by the oxidization of the defrost heating element, the elements are Nichrome to withstand the heat, when the elements power up for the first time they form this chromium like strucure around the element protecting it from water and moisture
what's flipping the breaker is the moisture sitting on the oxodized Nichrome, when it kicks on every couple of hours it detects that water and flips the GFCI by raising the voltage up 5 to 7 mA.
With that being said, you might think that your defrost heating element is bad, it isn't, it's just getting old. You may notice discoloration.
If your fridge isn't on the circuit that's on the sink wall or in the garage then you don't need a GFCI, but some people like the GFCI on the fridge just incase the fridge develops a leak and gets into the drywall and insulation
If your fridge is flipping the Breaker in the Breaker box or sub panel then there's a more serious issue, obviously there's a short or reverse polarity.
A bare wire could be touching another or could be exposed to water
when working on any electrical around moist or wet conditions, always use waterproof connectors and a piece of wire shrink wrap.
Sorry im late
Comment: Actually, a GFCI is only needed in a kitchen if the receptacle outlet is within six feet of a sink or if it serves countertop space. Contractors usually try to locate the refrigerator receptacle more than six feet away from the edge of a sink to avoid having to put a refrigerator on a GFCI and potentially spoil a lot of food if it ever nuisance trips while the occupants are away.
Comment: I think it's over kill to have a gfci at the beginning of every circuit, but I still think it should be raised none the less, water damage can happen anywhere, spilt drink, kids water toys, and especially wintery conditions where you may overlook something so simple, the counter is implemented due to the sink, so NEC says everything else is alright for the fact that there's not a faucet nearby.


Prove $0! = 1$ from first principles

Question: How can I prove  from first principles that $0!$ is equal to $1$?
Comment: Please don't state questions as orders; write them as questions.
Comment: You haven't stated what your definition of factorial is. An inductive definition would have as the base case 0! = 1, so there's nothing to prove from that definition, for example.
Comment: Wow, I've been coding too much lately and read this question as asking to show `0 != 1`, (or for the non coders $0\neq 1$).
Comment: For any cardinal c let c! be the order of the group of permutations of a set of cardinality c.
Comment: Or to put it differently, $0!=1$ *is* one of the "first principles" in the most typical formulation.
Comment: What do you consider as "first principles"?
Comment: Because there is ONLY ONE way to do nothing. http://math.stackexchange.com/questions/20969/prove-0-1-from-first-principles/485421#485421
Comment: Simple. Instead of defining $0!$, define $1!$ instead, then prove that $0! = 1$.
Comment: See https://www.quora.com/How-do-I-prove-0-1-1/answer/Dan-Christensen-8 (includes link to my formal proof without using empty products)
Comment: `0! = 1` in a weird way reminds me of my consciousness. That way of doing nothing in just one and only one way, that is me.
Answer: We need $0!$ to be defined as $1$ so that many mathematical formulae work. For example we would like
$$n! = n \times (n-1)!$$
to work when $n=1,$ ie $1! = 1 \times 0!.$
Also we require that the formula for the number of ways of choosing $k$ objects from $n$ is valid for $k=n.$ ie
$${n \choose k} = \frac{n!}{k!(n-k)!}$$
is valid when $k=n.$
Things need to work when we extend our definition of the factorial via the gamma function.
$$\Gamma(z) = \int\limits_0^\infty t^{z-1} e^{-t} \,\mathrm{d}t,\qquad \Re(z)>0.$$
The above gives $\Gamma(n)=(n-1)!$ and so we require $0!=1,$ since $\Gamma(1)=1.$
Comment: The argument about the factorial formula isn't needed: that formula would hold anyway when $k=n$: maybe you mean $k=0$?
Answer: I'm not sure that there is anything to prove. I think it follows directly from the definition of factorial:
$$ n! := \prod_{k = 1}^n k$$
So if $n=0$ the right hand side is the empty product which is $1$ by convention.
Comment: It also follows the "n! = number of ways of arranging n objects" convention: there is only one way of arranging no objects. (That's what Wolfram says, anyway.)
Comment: You can also prove it by moving the space: "0! = 1" $\Leftrightarrow$ "0 != 1", which is computer notation for "0 $\neq$ 1" :-). Then it depends on what you count as "first principles". If we're dealing with the natural numbers, this follows from the Peano axiom that the successor of a natural number is not 0 (1 being defined as the successor of 0). If we're dealing with general rings or fields, 0 $\neq$ 1 is part of the axioms for those structures (which is to exclude the trivial cases of one-element rings and fields).
Comment: @joriki Thats just fudging notation. In the same sense I can say that 1! = 1.
Comment: @TheGreatDuck: How's that? That's not true when you move the space.
Comment: Exactly you said 0! = 1 therefore 0 != 1. I can also say 1! = 1 therefore 1 != 1. Your reasoning is flawed.
Comment: By convention is that for the multiplicative monoid of the semiring $\mathbb{N}$, we define the empty product $x^0$ to be the identity element which is $1$.
Comment: @Rawling You said that " "n! = number of ways of arranging n objects" convention: there is only one way of arranging no objects." I just wanted to ask that doesn't there exist infinite number of ways of arranging n objects ??
Answer: One of the simplest ways of doing this is to observe that if you have
$$
6!= 720
$$
then divide both sides by $6$ to get
$$
5!=120
$$
then divide both sides by $5$ to get
$$
4!=24
$$
then divide both sides by $4$ to get
$$
3!=6
$$
then divide both sides by $3$ to get
$$
2!=2
$$
then divide both sides by $2$ to get
$$
1!=1
$$
then divide both sides by $1$ to get
$$
\text{[fill in the blank here]}
$$
Comment: Then divide both sides by zero to get $(-1)!=\infty$, which is consistent with $\Gamma(0)$
Comment: But how is this a proof by "first principles"?  (How is it a proof at all??)  To be sure, I find the question itself somewhat fishy: first tell us what the definition of $0!$ is, then we can talk about how to prove $0! = 1$...
Comment: It's not a proof, but it could be the reason why the definition was written in the first place.
Comment: The question does not want this kind of proof (which is nevertheless excellent). I think it wants a philosophical discussion of why mathematicians allow this sort of reasoning?
Comment: @MorganRodgers : ha ha...... Probably I can do that, but it's not worth doing in this context.
Answer: $0! = 1$ is consistent with, and for reasons related to, how we define the empty product. See, for example, this entry on empty product.  This is simply the name of the phenomenon Michael Hardy alludes to:

Empty product:
The empty product of numbers is the borderline case of product, where the number of factors is zero, that is, the set of the factors, is empty. In such a "borderline" case, the empty product of numbers is equal to the multiplicative identity, which is $1$.

Some of the most common examples are the following:

The zero$^{\text{th}}$ power of a number $a$: $a^0 = 1$,
The factorial of $0$: $0! = 1$,
The prime factor presentation of unity, which has no prime factors.

Just as ${n^0 = 1}$ for any $n$, and the "prime factorization" of $1$ = $1$, we define, as a matter of convention, $0! = 1$.
Comment: `empty product of numbers is equal to the multiplicative identity` -  means defined to be multiplicative identity ?
Answer: Because there is only one way to do nothing.
Comment: As a professional procrastinator, I disagree. $^{\textrm{is joke}}$
Comment: @columbus8myhw, haha.
Answer: The empty product is taken to be equal to 1. Take logs and you get an empty sum equal to zero, which is somehow more intuitive, but this trick of taking logs to convert a product into a sum never seems to get a mention in the literature. [Assumes products have positive terms]
Comment: @robjohn:L Indeed - I still have my slide rule, and ten years ago I used it as a "mystery object" for a youth group - they didn't know what it was. I remember using it in A-level chemistry practicals to set up the instants, and do the calculations quicker than schoolmates with their Sinclair calculators! But the point I was making was more that taking logs can take the mystery out of infinite products (and the notion of convergence applicable) by turning them into (less elementary) infinite sums.
Comment: One of the primary uses of logs before calculators was to multiply numbers using addition and log tables.  Slide rules also used logs to turn multiplication into addition.
Answer: Let's try a different approach from my other answer to this:
To multiply a number $N$ by $6!$ is to multiply it by six factors and get
$$
N\cdot1\cdot2\cdot3\cdot4\cdot5\cdot6.
$$
Similarly to multiply $N$ by $0!$ is to multiply it by $0$ numbers:
$$
N.
$$
But that is the same as multiplying it by $1$
$$
N\cdot1.
$$
Multiplying $N$ by no numbers at all is multiplying $N$ by $1$.
(This answer doesn't apply only to factorials; it may be taken as a general explanation of why, when one multiplies no numbers, one gets $1$.)
Answer: One can prove this by convention (that is based on what 'works', based on base cases for product of a list).
But for a proof from 'nothing' as it were...define what factorial is supposed to mean. I think of it as the number of one-to-one, onto (=bijective) functions from a set of size $n$ to itself. if$n$ is 0 then the set is the empty set. How many bijective functions are there from $\emptyset$ to $\emptyset$? (a function is a set of ordered pairs (with some restrictions)? There are no legal pairs for these restrictions, and so there are no legal subsets of these pairs...other than the empty set. So $\emptyset$ -is- a function (it -is- a set of pairs (empty of course), all of whose pairs satisfy the function criteria). No other functions will work so $\emptyset$ is the only function that works. So there is only 1 bijective function on a set of size 0. So $0! = 1$.
Yes, this is weird, but it works. Negative numbers, complex numbers, they're all weird even when you just manipulate their properties. But you'll get over it.
Comment: I remember in my college days getting drunk and using this argument in an attempt to settle this $0! = 1$ matter. See also https://math.stackexchange.com/a/789411/432081
Answer: Similar to @Mitch's answer, but with a slight twist at the end.
For any $n$, we define $n!$ to be the the number of invertible functions from a set of size $n$ to itself.  The question is thus restated as "Prove that there is exactly one invertible function from the empty set to itself."
Now, it should be clear that there can't be more than one function from $\emptyset$ to itself, because in order for two functions to be different, they have to give different values for at least one input (clearly impossible if the domain is empty). The question therefore reduces to "Prove that there is at least one invertible function from the empty set to itself."
Well, assuming we can all agree that the empty set is a set, meaning an object in the category of sets, the empty set must have an identity function (morphism) defined on it; every object in every category is required to have an identity morphism. Further, identity morphisms are always invertible because $Id\circ Id = Id$, so we are done. $\Box$
http://en.wikipedia.org/wiki/Category_of_sets
This answers the question if and only if the "first principles" include axioms of category theory (and a few facts about sets).
Comment: Note: this argument also shows that $0^0 = 1$, if we define $a^b$ as the number of functions from a set of $b$ elements to a set of $a$ elements (for nonnegative integers $a$ and $b$).
Comment: Why isn't this the accepted answer? It is by far the best.
Answer: Explanation 1:  We define $n!$ as the product of all integers $k$ with $1\le k \le n.$ When $n = 0$ this product is empty so it should be 1.
Explanation 2:  If $n$ is a nonnegative integer, we define $n!$ to be the number of orderings on a set with $n$ distinct objects.  If $n = 0$, this set is empty.  Vacuously, it has 1 order.
Answer: You can define $\exp(x)$ as
$$
1 + \frac {x} {1!} + \frac {x^2} {2!} + \frac {x^3} {3!} + ...
$$
but the following seems more uniform:
$$
\frac {x^0} {0!} + \frac {x^1} {1!} + \frac {x^2} {2!} + \frac {x^3} {3!} + ...
$$
These are only equal if $0! = 1$
Not a proof, but makes sense to me!
Comment: In think that, in the context of power series, $0^0$ is always taken to be $1$. This is even used in other power series like $\left(1+x\right)^{-1}=\sum \left(-1\right)^n x^n = 1-x+x^2-x^3+\cdots$, so that it has nothing to do with the factorial at all
Comment: so we finally found a good possibility for support of spam?
Comment: Well, almost equal. There is an exception at $x=0$ where the first term on the latter sum has a $0^0$ which is indeterminate.
Comment: @RomanChokler Yes, but in that case, we take it to mean $\lim_{x\to0}\left(x^0\right)$ rather than $x^0\big|_{x=0}$.
Answer: $0! = 1$ usually is one of the "first principles".
Comment: That would make sense. I thought it was always proven by definition.
Answer: First we state that $n!=\frac {(n+1)!}{(n+1)}$. Now let $n=0$ then $0!=\frac{(0+1)!}{(0+1)}=\frac{1!}{1}=1$ Hence $0!=1$
Comment: Nice answer. However you would have to know (n+1)!  before knowing n! Which n is your "base case"?
Answer: $${n \choose R} = \frac{n!}{R!(n-R)!}$$
You know: ${n \choose 0}=1$, so:
$$\frac{n!}{0!n!}=1\implies\frac{1}{0!}=1\implies 1=0!$$
We know every set has $2^n$ subsets
we know empty subset is unique
so
Answer: The way, I think about it is via permutations. Suppose you have $n$ objects then to permute them you have $n!$ factorial ways. So, for example, if you had $3$ objects then to permute them you would do $3!$ which is $6$. Suppose, you had $0$ objects then how many times could you permute $0$ things? Once. Therefore, $0!$ should be $1$. This is just an intuitive explanation and a proof by no means.
Comment: and why is that?
Answer: $n!$ is defined as the number of way n distinct object can be arranged.
For example,
$1!$ is described to arrange $1$ object,i.e $1$ way.
$A$
$2!$ is described to arrange $2$ object,i.e $2$ way.
$AB,BA$
$3!$ is described to arrange $3$ object,i.e $6$ way.
$ABC,ACB,BAC,BCA,CAB,CBA$
Similary, $0!$ describe the way to arrange $0$ object.$0$ object means nothing.There comes a hypothetical thinking,there is $1$ way to arrange $0$ object or nothing,that is nothing.
So, $0!=1$
Answer: You cannot prove that $0!=1$ from first principles, because it is a convention. First, we define "$!$" as follows:
$n!=1\cdot2\cdot3\cdot...\cdot(n-1)\cdot n$
This has no meaning for $n=0$
. But it would be useful if it had one. So, we make the convention that $0!=1$
. This is the best choice, because:

For $n>1$
, $n!=n\cdot(n-1)!$
If we want to extent this for $n=1$
, we must have: $1!=1\cdot0!\Rightarrow1!=0!\Rightarrow0!=1$.

There are $n!$
ways to arrange $n$ objects into a sequence, for $n\geq1$. For zero objects, there is only one arrangement. So, if we want to extent the formula $n!$
to be applicable to zero objects, we must have $0!=1$.

A taylor series is an infinite series of the form:
$$f(a)+\dfrac{f'(a)}{1!}\left(x-a\right)+\dfrac{f''(a)}{2!}\left(x-a\right)^{2}+\dfrac{f'''(a)}{3!}\left(x-a\right)^{3}+...$$

If we aggre that $0!=1$
, we can write the same thing using the sigma notation: $$\begin{array}{c}
\infty\\ \sum\\ k=0 \end{array}\dfrac{f^{(k)}(\alpha)}{k!}
 \left(x-a\right)^{k}$$
From these and other cases (see previous answers), we conclude that the best choice is to give $0!$
the value 1.
A comment on "$0!=1$ because, by definition, $\begin{array}{c}0\\ \prod\\ k=1 \end{array}k=1$": It is, correct, of course, if we define  $n!=\begin{array}{c}n\\ \prod\\ k=1 \end{array}k$, but, what came first, the "!" notation or the capital pi notation?
Actually, the question mark notation is older. The first use of $n!$ is due to Christian Kramp of Strasbourg, in "Élémens d'arithmétique universelle" (1808), p.219. But there are even older notations for the factorial, like $n^{*}$, by J. B. Basedow, in "Bewiesene grundsätze der reinen mathematik", Vol I (1774).
Also, Leonhard Euler uses $M$ for $1\cdot2\cdot3\cdot...\cdot m$, in "Calcul de la probabilité dans le jeu de rencontre", (1753), p.259 and p.265. The use of the capital pi, is found in Gauss: "Commentationes Societatis Regiae Scientiarum Gotti", (1813), vol.II, Classis Mathematicae. In sec.18, p.24, we find the formula
$$ \varPi(k,z)=\dfrac{1\cdot2\cdot3\cdot...\cdot k}{(z+1)(z+2)(z+3)...(z+k)}k^{z} $$
In sec.19, p.25, we find the formula
$$\varPi(k,z)=\dfrac{1\cdot2\cdot3\cdot...\cdot z}{(1+\dfrac{1}{k})(1+\dfrac{2}{k})(1+\dfrac{3}{k})...(1+\dfrac{z}{k})}$$
etc.
Although Gauss use capital pi for formulas which include repetitive multiplication, it is not yet the modern notation. Also, in sec.21, p.26, Gauss writes: $\varPi z=1\cdot2\cdot3\cdot...\cdot z$.
The above references are taken from Florian Cajori, "A History of Mathematical Notations", vol.2, section 448-449. (Cajori's reference for Basedow's book, directs at page 259, but I could not find the notation there. Perhaps the page number he mentions is wrong).
Answer: Also remember that $n! $ is the number of ways to arrange $n$ objects.  We have only one way to arrange $0$ objects, i.e; $0!=1$.
Answer: To shed some more light on the combinatorial intuition, and to define things formally, we can proceed the following way. we begin with a (finite) set $T$. We now define a set of sequences $Seq(T)$, which is defined inductively as:

The empty sequence exists for any set $T$: $\forall T \in Set, \texttt{EmptySeq} \in Seq(T)$
For If we have a sequence $seq \in Seq(T)$, and an element $t \in T$, we have an element which is the element that appends $t$ to $seq$: $\texttt{append}(seq, t) \in Seq(T)$.

For example, the sequence $[1, 2, 3]$ can be encoded as:
$$
\texttt{append}(\texttt{append}(\texttt{append}(\texttt{EmptySeq}, 1), 2), 3)
$$
A permutation of $T$ is defined as an element of $Seq(T)$  of length $|T|$, where each element $t \in T$ occurs exactly once. We can formalize (1) length, (2)occurs exactly once as follows:
$$
\begin{align*}
&\texttt{count}: Seq(T) \times T \rightarrow \mathbb{N} \\
&\texttt{count}(EmptySeq, \_) \equiv 0 \\
&\texttt{count}(\texttt{append}(t, seq), t_0) \equiv
  \begin{cases}
     1 + \texttt{count}(seq, t_0)  & t = t_0 \\
      \texttt{count}(seq, t_0) & t \neq t_0
  \end{cases}\\
\\
&\texttt{length}: Set(T) \rightarrow \mathbb N\\
&\texttt{length}(\texttt{EmptySeq}) = 0 \\
&\texttt{length}(\texttt{append}(t, seq)) = 1 + \texttt{length}(seq) \\
\\
&occurs: Seq(T) \times T \rightarrow \{ true, false \} \\
&occurs\_once(seq, t) \equiv [count(seq, t) = 1] \\
\\
&is\_permutation: Seq(T)\rightarrow \{ true, false \} \\
&is\_permutation(seq) \equiv \forall t \in T, occurs\_once(seq, t) \land length(seq) = |T|
\end{align*}
$$
Now, we have the machinery to ask ourselves

how many permutations of the empty set exist?

This is equivalent (by definition) to:

how many sequences of length $0$ exist in which every element of the empty set occurs exactly once?

There is only on sequence of length 0, $\texttt{EmptySeq}$
This (vacuously) contains all elements of the empty set exactly once. Since the empty set has no elements, this sequence contains all of them.

Combining this, we can see that $\texttt{EmptySeq}$ is a permutation of the empty set. It must be the only permutation, since any other sequence will have length greater than 0.
Hence, there is one permutation (the empty permutation) of the empty set.

References

To make this notion of "inductively defined set" $Set(T)$, we will need to use either some lattice theory to define least fixed points.
We can also use a theorem prover such as Coq, where we can define objects such as $Seq(T)$ and reason mathematically about them.
Answer: Perhaps it helps to consider this question in a broader context, where we consider "empty products" more generally. Let me introduce "Capital pi" notation, which is analogous to sigma notation for sums. If $a_1,a_2,\dots,a_{n-1},a_n$ are a list of numbers, then we define
$$
\prod_{i=1}^{n}a_i=a_1\cdot a_2\cdot\dots\cdot a_{n-1}\cdot a_n \tag{*}\label{*}\, .
$$
The product on the right-hand side of $\eqref{*}$ is obtained by letting $i=1,2,\dots,n-1,n$. A few remarks about this notation will come in handy:

The letter $i$ is called a "dummy variable", meaning that it is an arbitrary symbol that can be replaced with another letter without changing the value of the product, i.e. $\prod_{i=1}^{n}a_i=\prod_{r=1}^{n}a_r=\prod_{k=1}^{n}a_k$.
The right-hand side of $\eqref{*}$ should not be understood literally
as a product of at least four factors. For instance,
$\prod_{i=1}^{3}a_i$ should be taken to mean $a_1\cdot a_2\cdot a_3$.

To make this product notation precise, we require a recursive definition: first we let $\prod_{i=1}^{1}a_i=a_1$, and second we let $\prod_{i=1}^{n}a_i=\left(\prod_{i=1}^{n-1}a_i\right)\cdot a_n$ when $n$ is an integer greater than $1$. Notice that in order to make this definition work, we need to agree that the "product" of a single term $a_1$ to be $a_1$. Therefore, while the "product" of a single term seems like an unnatural idea at first, it is convenient to agree that the product of a single number is itself.
It is for a similar reason that we agree that the product of no numbers at all—the empty product—is equal to $1$. It's not because empty products have to be defined in this way, but rather that this is a convenient notational convention. Why is it convenient? Well, notice that if $n>1$, then $\prod_{i=1}^{n}a_i=\left(\prod_{i=1}^{n-1}a_i\right)\cdot a_n$. If we want this equation to be true when $n=1$, then it ought to be the case that $\prod_{i=1}^{1}a_i=\prod_{i=1}^{0}a_i\cdot a_1$, and so assuming that $a_1$ is non-zero, we must define $\prod_{i=1}^{0}a_i$ as $1$. Of course, we don't want one rule for when $a_1=0$, and one rule for when $a_1\neq 0$, and so the simplest convention to adopt is that $\prod_{i=1}^{0}a_i=1$ regardless of whether $a_1=0$.
How does this relate to factorials? Well, by definition $n!=\prod_{i=1}^{n}i$, and so $0!=\prod_{i=1}^{0}i=1$. In this case, we are motivated by the desire for the equation $n! = n(n-1)!$ to still hold when $n=1$. It's not that $0!$ has to be defined in this way, but rather that this is the most natural definition. This is why it doesn't make much sense to "prove" that $0!=1$; it's not a a matter of proof—it's a matter of definitions.
It turns out that there are a diversity of other reasons why it is convenient to define $0!$ as $1$, which you can read about here. It is fortunate that in every context where $0!$ crops up, it seems obvious what it "should" be. In other cases, we are not so lucky. For instance, sometimes it is convenient to define the degree of the zero polynomial as $-1$, but other times it convenient to define it as $-\infty$, and other times still it feels more natural to leave it undefined. This example shows that mathematical definitions are quite flexible, and that they suit our needs depending on the context, rather than being eternal truths etched into stone.
Answer: I will interpret "from first principles" as "from base cases," which otherwise are set more or less "by convention/definition," except we then want to distinguish empty from trivial base cases (see the nLab entry about the phrase "too simple to be simple" for what I'm getting at).

Start with $n! := n \times (n - 1) \times ... \times 1$
Replace $1$ with $n - (n - 1)$
Evaluate $2! = 2 \times (2 - (2 - 1)) = 2 \times (2 - 1) = 2 \times 1 = 2$
Check to see that $1! = 1 \times (1 - (1 - 1)) = 1 \times (1 - 0) = 1 \times 1 = 1$

If we interpreted $0!$ as conforming to the scheme from (1), though, the result would be $0! = 0$, which goes against the tradition. Instead, take $0!$ to be the empty case of the factorial function, or then the case in which nothing is being multiplied down towards $1$ (by contrast, $1! = 1$ is the trivial case of the function). Interpreted in this way:

Now we have only the term $n - (n - 1)$ to evaluate, without multiplying it by anything externally, or then $0 - (0 - 1) = 0 - (-1) = 0 + 1 = 1$. "QED"

So then we define $n!$ for the empty and trivial cases:
$$
n!=
\begin{cases}
n - (n - 1), n = 0\\
n \times (n - (n - 1)), n = 1\\
\end{cases}
$$
... and then loop back to (1) above to get the normal sense of the function.

An exotic "proof" (not the best word for it) involves the combination-theoretic interpretation of Pascal's triangle. When we have 3 items, there are one way to combine them all, three ways to combine any two, three ways to have any individual item, and then one way to have none, so we go to $2^3 = 8$. So go to the case of 1 item: you have only the all- and the none-cases, so you go to $2^1 = 2$ for all the combinations as such. When you go to 0 items, you lose the all-case, and are left with only the none-case, so you go to $2^0 = 1$. Now, you can compare the intended meaning of $0!$ to $2^0$, here, so it is "sensible" to set $0! = 2^0 = 1$ as such. Note that this means that zero is the only finite number that shares the property of the alephs such that $2^{\aleph_{\alpha}} = \aleph_{\alpha}!$, so one might justify setting $0! = 2^0$ by some sort of "reflection principle," which might count as "from first principles," I suppose.
Answer:
For any finite set $S$, $\Pi (S)=\Pi(S\cup\{1\})$

By definition of the factorial
$0!=\Pi\{\}=1\cdot\Pi\{\}=\Pi\{1\}\cdot\Pi\{\}=\Pi\{1\}=1$

Prove $0! = 1$ from first principles


OpenZeppelin ERC721: difference between safeMint and mint

Question: Can you highlight the core difference between two functions: mint and safeMint? Why its called "safe"? and when both of them should use? cause, for me, functions' syntax is pretty similar.
Answer: There was the answer here:
_mint vs _safeMint, which is best for ERC721?

To summarize, safeMint is there to prevent someone minting ERC721 to a contract which does not support ERC721 transfer. So the ERC721 token is stuck there forever. If you are sure this won't happen, you can directly use _mint to save the gas cost.
See more: ERC721.sol#L262


Is $n^{1.03} = \Omega(n \log \log n)$?

Question: We had this problem on our Algorithms final. It threw me off because if $\log$ is $\log_2$ then graphing the function shows this is not true, but if $\log$ is $\log_{10}$ then it looks like it is. How can this idea be formalised?
Comment: Btw, also $n^{1.03} = \Omega(n\log(n))$ holds.
Answer: To compare complexity orders, plots are your false friends. Because you may need to look at astronomical values to detect curve crossings. Nothing replaces analytical study.
For example, on a plot $n^{30}$ (in blue) seems to completely outperform $3^n$, but in reality, the latter grows much faster !

You are probably aware that $e^x=\Omega(x)$ [by Taylor, $e^x>1+x+\frac{x^2}2$]. This implies $e^{ax}=\Omega(ax)=\Omega(x)$, for any $a>0$. Now we can replace $x$ by $\log(n)$ and get
$$n^a=\Omega(\log(n))$$ and $$n^{a+1}=\Omega(n\log(n)).$$
Needless to say, this implies
$$n^{a+1}=\Omega(n\log(\log(n))).$$
Comment: Thanks, I will accept this solution over the others as it answers my question in a more general way.
Answer: Remove a factor n, then the question is whether $n^{0.03} = O(\log \log n)$. The problem is that $n^{0.03}$ grows very fast, but not for small n, not for large n, but for absolutely huge n.
Assume "log" is the base 2 logarithm. Then for $n = 2^{100}$ we have $n^{0.03} = 2^{100 \cdot 0.03} = 2^3 = 8.$ $\log \log n$ on the other hand is $\log \log 2^{100} = \log 100 \approx 6.9$. Almost the same. If you draw a graph up to the huge $n = 2^{100}$ it looks quite plausible that the answer to your question is yes. Take $n = 2^{1000}$ and now you are comparing $2^{30}$ to $\log 1000 \approx 10$. Take $n = 2^{10000}$ and now you are comparing $2^{300}$ to $\log 10000 \approx 13.1$. $n^{0.03}$ grows faster than the logarithm and the logarithm of the logarithm.
Comment: This clarifies so much!
Answer: Recall what big-omega means.
$f(n)$ is $\Omega(g(n))$ if there exists an $n_0$ and a constant $c$ such that for all $n > n_0$, $f(n) \ge c\cdot g(n)$.
To satisfy this definition, $n_0$ can be as large as it needs to be, and $c$ can be as small as it needs to be. Part of the challenge is finding a suitable $n_0$ and $c$.
As a hint, to get you started:
$$\log_2 x = \frac{1}{\log_{10} 2}\log_{10} x$$
That is, $\log_2 x$ is $\log_{10} x$ up to a constant factor. This is part of why, in asymptotic analysis, we can often just say $\log n$ without specifying the base.
Comment: I don't think that this answers the question. $\log_{10}(\log_{10}(n))$ and $\log_{2}(\log_{2}(n))$ differ by a linear relation. This is probably what the OP wants to understand.
Comment: Yes, but thank you @Pseudonym for the additional insight.

Is $n^{1.03} = \Omega(n \log \log n)$?


Why is it necessary to pump the brakes while bleeding them?

Question: I was just wondering, whenever I visit any site it says pump the brake pedal three times then keep pressing it, what is the actual benefit of pumping it? And why not just press down the brake pedal and then open the bleeder screw without pumping?
Comment: I never "pump" it.
but then now I use a vacuum bleeder too.
Comment: @Zero if we aren't using a vacuum bleeder, why do they pump it?
Comment: maybe just to kinda exercise it and move things around to get it going easier? not sure
Answer: You need to have positive pressure in the brake lines to get rid of any air; the pumping ensures you've built up enough pressure.  And if the other sites you've read didn't mention it, you repeat the process (pump, hold, loosen bleeder valve while maintaining pressure on the pedal, close bleeder valve) until a solid stream of brake fluid comes out; that is the sign all the air is gone.  And you can definitely tell the difference by the sound of the fluid coming out.
Comment: Nope.  I've seen fellow auto-shop classmates try it, and no substitute for pumping.  Sure there is some reason, but I know it works best.
Comment: if you just press the brake pedal till its end, won't that make enough pressure?
Answer: In past experiences I've found that intially pumping the pedal at the start was all I've ever needed and from there on only 1 push of the pedal is needed. The reason  why is because when you repeatedly pump the brakes your taking that single air bubble and causing it to break up into many bubbles that must travel to the bleeder. Ultimately when it's all said and done I still prefer gravity bleeding starting at the left rear then right, then right front then the left. Takes a little longer but the advantages are you won't need someone to pump/hold the pedal and no chance of air accidentally being sucked back by late closing of bleeder when pedal is released.


How to brief a party on WoD setting

Question: I am not sure what a good method for briefing a party in WoD is. When the players are just before the character creation stage, is it standard to tell the party what city they will be starting in, if they know anything about the supernatural etc? Or is it more normal to give the players a lot of flexibility here. I know there could be several answers to this type of question, so if there is any actual official nWoD rules or info on this. That would also be very helpful.
Answer: It depends mostly on one thing: Shall the game be a complete surprise or not.
I made one surprise game and it worked only because the players said beforehand they are ok with being surprised.
Else the players should be told the following things before character creation:

What city the game is run in
What is currently up in the city, thus is there something special happening and how does it differ from the real city
What supernatural species the players could play inside the city and what could be problematic (if there is a hunt by all species on the mages players should be warned at this stage that mages could have troubles)

Aside from that no further info to the players is needed at that stage. Then when they create the backstory of their characters further infos could be given as then it can be seen WHAT the chars could know. From experience it is sadly so that most players can't separate competely between player and character knowledge thus if you want them to not be influenced by that give them only infos that their characters know.
As examples here:
A character that lives in a suburb where a gang is active may know that the people of that gang are quite tight knitted and have big dogs at their side during raids. A supernatural char may even know more that the big dogs are unusual as they can't be dominated or even that they are werewolves depending ont he abilities of that char,... .
Another thing is: Many other supernats would know that vampires gather time and again at this special club. But for example a vampire who lived in the city would know that its elysium and the prince is calling for a meeting of all vampires once per half year, ....
Thus to sum it out a good method I found from experience is that you should give out infos all know before cahracter creation and also infos that affect what is playable or what could pose problems for the player or the campaign.  And then during the character creation you talk with the players and together find out what they know about the REAL situation in the city and what they know about their own and other supernatural splats.
That helps a lot in avoiding that the players unconsciously use player knowledge instead of only character knowledge and also leaves some mysteries for them to be solved.
Comment: Thanks that was very helpful. Since WoD is so shrouded in mystery I wondered how much info to divulge.
Comment: No problem. Its not just wod though as you can apply the same principle to as good as any game system (at least if you want to include some small horror / mystery part there)

How to brief a party on WoD setting