Simplest python network messaging

Question: I have a machine control system in Python that currently looks roughly like this
goal = GoalState()
while True:
    current = get_current_state()
    move_toward_goal(current,goal)

Now, I'm trying to add in the ability to control the machine over the network.  The code I want to write would be something like this:
goal = GoalState()
while True:
    if message_over_network():
        goal = new_goal_from_message()
    current = get_current_state()
    move_toward_goal(current,goal)

What would be the simplest and most Pythonic way of adding this sort of networking capability into my application?  Sockets could work, thought they don't particularly feel Pythonic.  I've looked at XMLRPC and Twisted, but both seemed like they would require major revisions to the code.  I also looked at ØMQ, but it felt like I was adding an external dependency that didn't offer anything that I didn't already have with sockets.
I'm not opposed to using any of the systems that I've addressed above, as what I believe to be failings are probably misunderstandings on my part.  I'm simply curious as to the idiomatic way of handling this simple, common issue.
Answer: The are at least two issues you need to decide on:

How to exchange messages?
In what format?

Regarding 1. TCP sockets are the lowest level and you would need to deal with low level things like recognizing messages boundaries. Also, TCP connection gives you reliable delivery but only as long as the connection is not reset (due to for example a temporary network failure). If you want your application to gracefully recover when a TCP connection resets, you need to implement some form of messages acknowledgements to keep track what needs to be resend over the new connection. OMQ gives you higher level of abstraction than plain TCP connection. You don't need to deal with a stream of bytes but with whole messages. It still does not give you reliable delivery, messages can get lost, but it gives several communication patterns that can be used to ensure reliable delivery. 0MQ is also highly performant, IMO it is a good choice.
Regarding 2, if interoperability with other languages is not needed, Pickle is a very convenient and Pythonic choice. If interoperability is needed, you can consider JSON, or, if performance is an issue, binary format, such as Google protocol buffers. This last choice would require the most work (you'll need to define messages formats in .idl files) this would definitely not feel Pythonic.
Take a look how exchange of messages (any serializable Python object) over a plain socket can look like:
def send(sockfd, message):
    string_message = cPickle.dumps(message)
    write_int(sockfd, len(string_message))
    write(sockfd, string_message)

def write_int(sockfd, integer):
    integer_buf = struct.pack('>i', integer)
    write(sockfd, integer_buf)

def write(sockfd, data):
    data_len = len(data)
    offset = 0
    while offset != data_len:
        offset += sockfd.send(data[offset:])

Not bad, but as you can see having to deal with serialization of a message length is quite low level.
And to receive such message:
def receive(self):
    message_size = read_int(self.sockfd)
    if message_size == None:
        return None
    data = read(self.sockfd, message_size)
    if data == None:
        return None
    message = cPickle.loads(data)
    return message

def read_int(sockfd):
    int_size = struct.calcsize('>i')
    intbuf = read(sockfd, int_size)
    if intbuf == None:
        return None
    return struct.unpack('>i', intbuf)[0]

def read(sockfd, size):
    data = ""
    while len(data) != size:
        newdata = sockfd.recv(size - len(data))
        if len(newdata) == 0:
           return None
        data = data + newdata
    return data

But this does not gracefully deal with errors (no attempt to determine which messages were delivered successfully).
Comment: Actually, 0mq does give you reliable delivery if you use a broker (like rabbitMQ) which supports that.
Comment: There's a binary JSONish format (BSON obviously :-P ) which is cross-language (used e.g. by MongoDB) and would be a very good compromise between flexibility (which protobufs don't give you) and decoding speed (which JSON is reasonably bad at).
Answer: If you're familiar with sockets, I would consider SocketServer.UDPServer (see http://docs.python.org/library/socketserver.html#socketserver-udpserver-example). UDP is definitely the simplest messaging system, but, obviously, you'll have to deal with fact that some messages can be lost, duplicated or delivered out of order. If your protocol is very simple, it's relatively easy to handle. The advantage is you don't need any additional threads and no external dependencies are needed. It also might be very good choice if you application doesn't have concept of session.
Might be good for a start, but there are much more details to be considered that are not included in your question. I also wouldn't be worried of the fact, that sockets are not very Pythonic. At the very end you're going to use sockets anyway, someone will just wrap them for you and you'll be forced to learn the framework, which in best case may be overwhelming for your requirements.
(Please note my opinion is highly biased, as I love dealing with raw sockets.)

Simplest python network messaging


Sum of digits divisible by $27$

Question: I know that every third number is divisible by $3$ and hence, sum of its digits is divisible by $3$. Same holds for $9$ also. But how do we generalise it? We know that the divisibility condition for higher powers of $3$ is not about the sum of digits. How can we find $n$ such that in a group of $n$ consecutive positive integers, there is a number such that the sum of its digits is divisible by $27$ (or $81,$ say)? Does it exist? Please prove or disprove.
Comment: Do you understand what makes things work for 3 and 9. Do you have any thoughts about connecting that idea with 27 or 81? Also, since this problem is a bit open ended, it reads like a contest or challenge problem - could you provide the source so we know it's not an active contest/application problem?
Comment: https://math.stackexchange.com/questions/328562/divisibility-criteria-for-7-11-13-17-19
Comment: No, I was just thinking about it, related to no contest. I know the idea for $3$ and $9$, we write number as $n_0+10n_1+100n_2+...$ and then take out the sum of the digits, remaining sum turns out to be divisible by $9$, making things easy.
Comment: This is another question by me https://math.stackexchange.com/questions/3305361/observation-about-multiples-of-999
Comment: polynomial remainder theorem.
Answer: New answer instead of editing the - already accepted - answer because the argument is significantly different (and much simpler).

Let $Q(x)$ denote the digit sum of $x$.

Let $r\ge 1$. Then $n=10^r-1=\underbrace{99\ldots 9}_r$  is the smallest $n$ such that among any $n$ consecutive positive integers, at least one has digit sum a multiple of $9r$.

That no smaller $n$ works, is immediately clear because in $1,2,3,\ldots, 10^r-2$, all digit sums are $>0$ and $<9r$.
Remains to show that in any sequence of $n$ consecutive integers, a digit sum divisible by $9r$ occurs.
This is well-known for $r=1$. For $r>1$, consider $n$ consecutive positive integers
$$a,a+1,\ldots, a+n. $$
Among the first $9\cdot 10^{r-1}=n-(10^{r-1}-1)$ terms, one is a multiple of $9\cdot  10^{r-1}$. Say, $9\cdot 10^{r-1}\mid a+k=:b$ with $0\le k<9\cdot 10^{r-1}$. Then $Q(b)$ is a multiple of $9$, and as the lower $r-1$ digits of $b$ are zero, we have $Q(b+i)=Q(b)+Q(i)$ for $0\le i<10^{r-1}$ and hence
$$Q( b+10^j-1)=Q(b)+9j,\qquad 0\le j\le r-1.$$ (Note that $k+10^{r-1}-1<10^r-1$, so these terms are really all in our given sequence). It follows that $9r$ divides one of these $Q(b+10^j-1)$.
Answer: Note that the natural numbers $\{1,2,\cdots, 999\}$ contain integers for which the sum of the digits is any specified value $\pmod {27}$
Considering the multiples of $1000$ we see that each block of $1000$ integers contains one which ends in three $0's$.
Starting from any integer $k$, we go to the next multiple of $1000$ (a gap of at most $999$).  We then add whatever three (or fewer) digit integer we need to "correct" the sum of the digits $\pmod {27}$, which takes, at most, another $999$.
Thus, every block of $2\times 999$ consecutive integers contains at least one for which the sum of the digits is a multiple of $27$.  A similar argument works for any desired divisor.
I expect the bound could be tightened considerably, but at least this shows that a bound exists.
Comment: Simple insight, great help, thank you:)
Answer: Let $Q(x)$ denote the digit sum of $x$.

$999$  is the smallest $n$ such that among any $n$ consecutive positive integers, at least one has digit sum a multiple of $27$.

First note that none of the $998$ consecutive integers $1,2,\ldots ,998$ has digit sum a multiple of $27$.
Any sequence of $999$ consecutive integers is either of the form
$$\tag11000N+1,\ldots, 1000N+999$$
or
$$\tag21000N+k+2,\ldots, 1000N+999,1000(N+1),\ldots, 1000(N+1)+k$$
with $0\le k\le 997$.
In $(1)$, the digit sums are $Q(N)+Q(i)$ with $i$ running from $1$ to $999$ and hence $Q(i)$ covering all values from $1$ to $27$. We conclude that $(1)$ contains a term with digit sum a multiple of $27$.
So let's look at $(2)$: We know $Q(N+1)\equiv Q(N)+1\pmod 9$, hence $Q(N+1)\equiv Q(N)+(1\text{ or }10\text{ or }19)\pmod{27}$.

If $Q(N+1)\equiv 0\pmod{27}$, then already $1000(N+1)$ has the desired property.
If $Q(N+1)\equiv 1\pmod {27}$, then among $1000(N+1),\ldots, 1000(N+1)+899$, all remainders $\bmod27$ occur, which solves the problem for all $k\ge 899$. For $k\le 898$, the sequence contains $1000N+900$, $1000N+909$, and $1000N+999$ with digit sums $Q(N)+9$, $Q(N)+18$, $Q(N)+27$.
As $Q(N)\bmod 27$ is one of $0$, $9$, $18$, we are done.
More generally, if $Q(N+1)\equiv r\pmod {27}$ with $1\le r\le 9$, then
$Q(1000(N+1)+999-100r)=Q(N+1)+27-r\equiv 0\pmod{27}$, which solves the problem for all $k\ge 999-100r$. For $k\le 998-100r$, the sequence contains $1000N+(1000-100r)$, $1000N+(1009-100r)$, and $1000N+(1099-100r)$ with digit sums $Q(N)+10-r$, $Q(N)+19-r$, $Q(N)+28-r$.
As $Q(N)\bmod 27$ is one of $r-1$, $r+8$, $r+17$, we are done.
If $Q(N+1)\equiv 10+r\pmod{27}$ with $0\le r\le 8$, then $Q(1000(N+1)+89-10r)=Q(N+1)+17-r\equiv 0\pmod{27}$, which solves the problem for all $k\ge 89-10r$. For $k\le 89-10r$, the sequence contains $1000N+999-r$, $1000N+909-r$, and $1000N+900-100r$ with digit sums $Q(N)+27-r$, $Q(N)+18-r$, $Q(N)+9-r$.
As $Q(N)\bmod 27$ is one of $r$, $r+9$, $r+18$,  we are done.
If $Q(N+1)\equiv 19+r\pmod{27}$ with $0\le r\le 7$, then $Q(1000(N+1)+8-r)=Q(N+1)+8-r\equiv 0\pmod{27}$, which solves the problem for all $k\ge 8-r$. For $k\le 8-r$, the sequence contains $1000N+999-r$, $1000N+909-r$, and $1000N+900-100r$ with digit sums $Q(N)+27-r$, $Q(N)+18-r$, $Q(N)+9-r$.
As $Q(N)\bmod 27$ is one of $r$, $r+9$, $r+18$,  we are done.
Comment: Great answer, thanks a lot.
Comment: or use polynomial remainder theorem for a rule.
Answer: Obviously there are number whose digits add to $27$.  ($999$ or $524385$ etc.) and obviously the sum of the digits $27$ is a multiple of $9$ so they are a multiple of $9$ but are they a multiples of $27$; and must multiples of $27$ have digits adding to a multiple of $27$.
Well, $27$ itself is an obvious counter example of the latter.
And $999= 27*37$ but $524385= 27*19421\frac 23$ so the first is not true either.
So the question I guess is why not?
Well the rule works for $9$ because $9 = 10-1$.  And it works for $3$ because $3|9$.
Details:  If $k|b-1$ and $n= \sum_{i=0}^m a_ib^i= \sum_{i=0}^m (a_i)(b^i-1) + \sum_{i=0}^m a_i$.  Now $b^i-1 =(b-1)(b^{i-1} + b^{i-2}+ ..... + 1)$ so $(b-1)$ divides all of the $b^i-1$ so $b-1$ divides $n$ if and only if $(b-1)$ divides $\sum_{i=0}^m a_i$.  If we let $b= 10$ and $b-1=9$ and $a_i$ be the digits of $n$ that's our result.
And it follows that if $k|b-1$ then $k|(b^i-1)$ so $k|n$ if and only if $k$ divides $\sum_{i=0}^m a_i$ as well.
And this will be true for any decimal system base $b$ (not just $b=10$ and and $k|b-1$ (not just $3|9$).
The fact that $3^2 = 9$ is mostly a coincidence and powers of $3$ is a bit of a red herring.  It's not powers of $3$ going up that matter, but factors $10-1$ going down that matter.
We can note that in base $7$ a number is a multiple of $6$ if and only if the sum of the digits is a multiple of $6$ and a multiple of $2$ or of $3$ if and only if the sum of the digits is a multiple of $2$ or of $3$ respectively but nothing can be said of $4$ or $3$.  ($11_7 = 8$ is a multiple of $4$ but $1+1=2$ is not.  And $12_7 =9$ is a multiple of $9$ but $1+2=3$ which is not.)
Why doesn't it work?  Well.  $27 = 3*(10-1)= (3-1)*10 + (10-3)$.  The sum of the digits of $27$ are $(3-1) + (10-3) = 10-1$.  Our rule of $9$s apply and we can't jump magically to $27$.  And if we increas by $27$ if we ignore carrying and borrowing we get $ab + 27 = (a+2)(b+7)$ and the sums of the digits are $a+b + 9$.  That's an increase of $9$; not of $27$.  Ind if we carry (i.e. $b \ge 3$ or $a \ge 8$ or $b\ge 3$ and $a\ge 7$) we get the sums are $(a+2+1)(b+7-10)$ or $1(a+2-10)(b+7)$ or $1(a+2+1-10)(b+7 - 10)$ and the sum of the digits stay the same or decreases by $9$; not $27$.
But if $b-1 = k^m$ then in base $b$ we will have that multiples of $k^i; i\le m$ will have the sum of the digits add to a multiple of $k^i$.
Example in base $28$ then sum of the digits of a multiple of $27$ will add to a multiple of $27$.
FWIW $999_{10} = 28^2 + 7*28 + 19 = 17T_{28}$ where $T$ is the digit for $19$.
And $27*92 = 2484_{10} = 3*28^2+4*28 + 20= 34U_{28}$ where $U$ is the digit for $20$ is another example.
Less trivial example.  The number $8ATR_{28}$ were $A=10$ and  $T=19$ and $R=17$ will have digits that add to $8+10+19+17=54$, so my claim is that it ought to be a multiple of $27$. And
$8ATR_{28} = 8*28^3 + 10*28^2+ 19*28 + 17 =$
$8(27+ 1)^3 + 10(27+1)^2 + 19(27+1) + 17 =$
$8(27^3 + 3*27^2+3*27 + 1) + 10(27^2 + 2*27 + 1) + 19(27+1)+17=$
$[8*27^3 + 3*27^2 + 3*27 + 20*27^2 + 2*27 + 19*27] + 8 + 10 + 19+17=$
$27(8*27^2 + 3*27 + 3 + 20*27 + 2 + 19) + 54 = $
$27(8*27^2 + 3*27 + 3 + 20*27 + 2 + 19 + 2)$ is a multiple of $27$.
And indeed $8*28^3 + 10*28^2+ 19*28 + 17=184005 = 27*6815$

Sum of digits divisible by $27$


How to delete a Workflow History list?

Question: I have a workflow history list that I keep accidentally using to create new workflows, but it is corrupt so I spend a lot of time recreating workflows because I can't figure out how to delete it, and it is the default.  Thanks!!
Answer: The workflow history list is a hidden list so it won't show up under View all site content,
you need to navigate directly to it by appending the following to your site's url  /Lists/workflow%20history.
You can use SharePoint Designer to delete the history list by going under All Files -> Lists.
The history list should be displayed there and you can go ahead and delete. But think really hard and long before you do so because of unintended consequences.
If you find that your site is worse off, you can recover the deleted list from the site recycle bin.
Comment: Just what I needed, thanks! I created a list with the wrong name by mistake, so I don't expect any unintended consequences from deleting it. :)
Answer: Check out this tool over here. Never actually tested but looks to be what you need!  Cleanup Workflow History
Comment: This link no longer works

How to delete a Workflow History list?


Boltzmann Transport Equation nonlinear terms

Question: Let's take into consideration the classical Boltzmann Equation for gas kinetics (i'm writing down the one obtained in Huang K. - Statistical mechanics, equation (3.36)):
$$\left(\frac{\partial}{\partial t} +\frac{\mathbf p_1}{m}\nabla_r+\mathbf F\nabla_{p_1} \right)f_1=\int d^3p_2 d^3p'_1 d^3p'_2 \delta^4(P_f-P_i)|T_{fi}|^2(f'_2f'_1-f_1f_2)$$
which is an integro-differential nonlinear (due to the $f'_2f'_1$ and $f_1f_2$ terms) equation in the distribution function $f_1$.
In a textbook I'm reading it is said that another feature of such equation is that

the nonlinear terms $f'_2f'_1$ and $f_1f_2$ are calculated for
  different values of the momentum.

What could be the meaning of this statement? Could "the momentum" be the $\mathbf p_1$ in $f_1(\mathbf x_1, \mathbf p_1, t$)?
Comment: I think it means that $f_1$ is a shortcut notation for $f(\vec{x}, \vec{p}_1,t) $; then $f'_1 = f(\vec{x},\vec{p}'_1,t) $ etc...
Answer: The meaning is that in the scattering term on the RHS of the Boltzmann transport equation you have the products of the distribution functions $f_1$ and $f_2$ for different momenta $p_1$ and $p_2$.
Comment: Thank you. But in the case of $f'_2f'_1$ we take into consideration every value of $p'_1$ and $p'_2$, due to integration...


How to efficiently scout early drops en route?

Question: Can anyone think of a good tactic for knowing if an air drop is coming early on? I emphasize early because at that time frame every resource is even more precious and I need to build my army. I can't just put a strand of marines surrounding the enemy base, the drop could fly out from anywhere and sneak over. I'd like to know before they make it to my base but what's an efficient and cost friendly way of monitoring this?
Comment: There is some good information here: http://gaming.stackexchange.com/questions/6715/dealing-with-the-dreaded-terran-base-race/6718#6718
Comment: Gaining air superiority will discourage your opponent from going drops, but this isn't a real 'solution'. If there was a catch-all anti drop strategy save building 99^99 photon cannons in your base then no one would be using drops.
Answer: You have a few options:

When you build your 2nd food supply, get that scout in the base and keep it there as long as possible.  You may be able to determine if he is going air.
Watch Towers.  Get a unit on a watch tower quickly.  I usually use my first couple of Zerglings.
Informative 'scouting'.  Scans, sacrificial Overlords, fast Observers can be excellent in determining what he has and might be moving out with.

I recently had a match where because of my overlord placement and watch towers, I saw his Banshees move out.  Gave me plenty of time to get Overseers, Hydras and an extra Queen to defend.
Take a look at Map Control for more info on just that: Map Control which relates to determing what your opponent is doing.
Comment: so there isn't really a good way, either method is spotty and inefficient
Comment: @Shogan: Why is that?  Everything Robb said are standard suggestions
Comment: @BlueRaja it may be that there isn't a way to do what Shogun wants.  I realize this can be frustrating, but Robb's answer is pretty much what I do.  You have to learn to anticipate some things...
Answer: I think both of the answers here are good answers, but since you seem unsatisfied let me try to contribute.
When playing as Protoss or Terran I often find its useful to use my Pylon/Supply Depot to help give me vision around my base.  This isn't, by any means, a replacement for scouting, but it does give me a little advanced notice on drops.  Since most maps have your main on a cliff, spreading out these (otherwise useless) structures helps monitor not only the edges but extends the range of your viewing.
Now this technique won't stop a drop, and it won't even really give you too much advance warning, but when every second counts, these are invaluable.  You also have the benefit of power for Warpgates.  If your opponent drops near the edge, these aren't advanced enough warning, but they do provide a nice distraction while you move your army.  If he bypasses them and moves to your mineral line, they're a more advanced warning.
By comparison, Overlords almost trivialize this problem as you can spread them about the map, around your base and even around your opponent's base.
I know its not a solution, but it should help.
The truth is, there is no cheap, effective, sure fire way to guarantee you catch drops.  Certainly map control helps, as does scouting, but if there was an easy fix for this terran's would probably never drop.
Comment: Good points, tzenes.  I think a hard counter does not exist for the Drop, other than knowing when it is coming.
Comment: yes good points, ideally though I want to see when they are preparing to leave their base rather than about to enter my base, so if my army is halfway to their base I could route them back in time or intercept
Comment: @Shogun I think the strength of a drop is that you can't do just that.  Its design is to exploit the immobility of your large force.  You're sort of looking at this backwards instead of saying "how can I see this so I can move my slow clunky army back in time?" you should be saying "My composition has a weakness, how can I adapt it so be less slow and clunky?"
Comment: @Robb there are a verity of strong counters against drops: Air dominance, fast units (Speedling, Hellion), rapid transport (dropships, Nydus Worm), static defenses.  However, none of these are going to solve the problem of getting a large, slow, army back in time (though they'll all help).
Answer: As it sounds like you are playing Terran.
Sensory Towers - I can't recommend them enough, And follow those up with perimeter Turrets starting in the back of your base to nail those incoming drops.
It also doesn't hurt to place a solitary marine at each watchtower.
Comment: If you don't have the resources for a sensory tower at that point in the game, you might want to re-evaluate your econ structure.
Comment: I can't spend money on those early it will kill my military, also I want to see at their base not once it arrives.
Comment: Right, unless you didn't know they were there? But I was sure that anyone could see the circle regardless of if they have ever actually gained vision of the tower.
Comment: I'm talking about 6-9 minutes in though, I suppose I could build sensor towers around their base, but can't the enemy see the sensor tower feedback on their map?
Comment: They can only see the ring of influence if they see the tower itself. Until that point they have no idea.
Comment: @Shogun: If you were building sensor towers around my base, my first point of call would be to destroy them...to the point of destroying it/them as soon as it/they went up...unless you plan of defending them fiercely.........
Comment: You can see the circle without seeing the tower. This can be abused, for example by poking in with some units while the army gathers at another position just outside of the range. This can cause panic for the terran so he sends all units to the wrong place and is not in position when the main army enters the sensor range. This doesn't mean that sensor towers are bad, just that you shouldn't fully trust in what they seem to show.


Where can I find an Oval Stone?

Question: I've been told that you can get an oval stone from a captured Chansey, but I cannot find where to catch one. Where can I find an oval stone?
Answer: you can obtain a Oval stone in the left part of the Unknown Dungeon.
After becoming the Pokemon League Champion, the Unknown Dungeon at the northern part of Pokemon Village will become accessible. Since you can't Fly to Pokemon Village, you'll have to make your way through the Winding Woods again. The quick path is south, west, northwest, southwest, south, and south through Route 20.
Answer: You can't get the oval stone from wild Pokémon, but there is one hidden in a rock in the Unknown Dungeon of Pokémon Village. This video shows you where to get it.
You can catch Chansey in the friend safari. However, a wild Chansey might hold a lucky punch or a lucky egg, but not an oval stone. While Happiny is coded to be able to hold an oval stone in the wild, you can only get a Happiny in X and Y by breeding Chansey.

Where can I find an Oval Stone?


Must include every mentioned source in the bibliography?

Question: I am writing a book about an engineering subject but nothing very technical, just introductory to middle level. I made a bibliography section at the end of the book. There are also several sources, such as organization or government websites, from where I took only a statistical figure for example and I mentioned that source right there in the text. I didn't use them anywhere else. Do I need to include them also in the bibliography?
Answer: I think it would be better. Websites change, and so it is good practice to include the date you accessed it. It is also good practice to say who wrote or compiled it and the year it was published. And if you are including that information, it will be rather a lot to put in the middle of the text.
So it is best to include them in the bibliography, yes. Alternatively maybe you could put the information in footnotes.
If it is a normal published book, the publisher will have a policy about this, so it is up to them.


How to increase root partition size by shrinking home partition using gparted live usb?

Question: I have Windows and Arch Linux installed in my system. I plan to increase the size of my root partition by shrinking the home partition using GParted live USB. But there is a swap partition between my root and home partition. I thought of shrinking the home partition and adding space to the swap and then shrink the swap then add it to the root since the unallocated space must be adjacent to the one being resized. I am not sure whether this going to work.
Answer: You can keep the size of the swap partition, you just need to move it:

Shrink the home partition, the freed space is now between swap and home.
Move the swap partition, so that the freed space is between swap and root partition.
Increase root partition.
Comment: After doing this, will I need to make some changes in the fstab file or something?
Comment: No need to change anything afterwards. You only change the start and end positions of the partitions.
Comment: Thank you, I will try it out.
Answer: When I did it, I deleted swap and re-created: swap does not rely on persistence, it is only using the cheapness / size of secondary storage.
I did have to change the uuid of swap in /etc/fstab
Reason to do it this way:
To avoid moving the big-ish swap partition (faster, not wear-out secondary storage device).


Would leaving a due date field blank mean "No due date" to a user?

Question: I am being questioned whether a user will intuitively know that leaving a Due date field blank (and is not required), will mean there is no due date. Any thoughts for an explanation or other suggestions?
Answer: It sounds like the lack of a due date is a valid use case that needs to be made more obvious.
It can be hard to tell the difference between "hasn't entered a due date yet" vs. "there will never be a due date."
If the ability to enter things like "59 days" is not a critical feature, you can solve this problem by using a select dropdown instead of a text input. Use date ranges that make sense in your context. It will also help users enter the data faster if they only need to think about selecting one of the available options instead of typing in a custom value from scratch.
Comment: The user needs to be able to enter explicit number of days.
Answer: As a user, I wouldn't be certain if the box should be left blank, I should enter a "0", or if entries without due days weren't allowed.  I think adding a checkbox for the due date and having the due date box greyed out if it is unchecked would be the most clear.  Preventing the user from making an entry if there is no due date removes any ambiguity.
Comment: By answering "as a user" that really means you're just giving one subjective opinion. That may or may not be the case with the majority of users though.
Answer: I think this should be more specific than leaving a blank field. A blank field can get ambiguos as there can be many interpretations from the point of view of the user.
I would go, as suggested by poison-ivy, with an explicit option for "no due date". Or telling the user via a tooltip, that leaving a blank would mean "no due date".
Answer: Since it is not a required field, it is possible that a user just forgets to enter the due date. As a user (assuming I know this), it would make me questions whether there is no actual due date or if it was just missed.
If users are expected to enter a due date most of the time, I would make this a required field and have an option "no due date".


Embed an iFrame through Rich Text Content

Question: I have a custom object with a custom field as Rich Text format.  I have an iframe I need to have inserted that will display on the front end.  Is it possible to do this?
Answer: The iframe tag is not one of the supported HTML tags and attributes available in a rich text field. You could use a image or use a iframe via a visual force page.
Answer: No you can't have an iframe inserted into a rich text field.
Even if you had the possibility to edit HTML (which is not possible) I don't believe it would very secure to do so.


What are the drawbacks of transmitting RF frequencies through an antenna that is designed for different frequency?

Question: I've heard of a magic "resonant frequency" that antennas are designed for, what happens if you transmit a frequency through an antenna that does not have the same resonant frequency?
Comment: What is your "initial question" ? And if the signal is sufficiently out of band, it could be that your antenna will reflect all energy back to the poweramplifier, destroying it.
Comment: Fixed the initial question thing. It's more to the point now.
Answer:
Part of your output power will be ultimately wasted as heat in the antenna,
feedline, matching elements, transmitter etc. (less range)
Energy will "bounce back" from the antenna to your transceiver. May potentially damage it.
Energy "bounced" from the antenna may cause intermodulation distortion in your transmitter. The transmitter will become a poor mixer (the device may not be compliant/legal, may transmit undesired frequencies).
When receiving (if the same antenna is used for RX/TX) you will "hear" other frequencies better than the one you are using for communication (worse sensitivity, higher noise level).
Answer: What happens if you send a broadband signal through a high pass filter? It gets attenuated. Same thing for an antenna more or less.
Here is a plot of what the impedance of a resonant antenna looks like. If you transmit signals in the capacative or inductive region, the current going into the antenna will 'see' more impedance and the signal will either reflect back to the receiver or get attenuated.
So that may be a good thing if you want that signal on that particular frequency to not get transmitted. Or a bad thing if you have a signal that needs to be transmitted with an antenna with the wrong impedance.

Source: radio electronics
Answer: Ideally, your antenna system (consisting of the feed line, the antenna, other components in line) will all present the same impedance at a given frequency;  resonance is one way to potentially achieve this, but NOT a requirement.
The typical impedance values are 52 or 75 ohms in an unbalanced system (using coaxial feed line to the antenna) but with a balanced system may be 300-400 ohms...I've seen others. In a perfect world, you'd want the TX output design impedance to match the characteristic impedance of the feed-line which would also match the feedpoint impedance at the antenna.
System losses stay low under these conditions.
In general, a properly designed antenna will present this feedpoint impedance (say 52 or 75 ohms) at or near resonance and depending on the type will vary as you move to either side of resonance.  As you move from resonance, inductive and capacitive reactance will exist and change the feedpoint impedance. (for example, a 1/2 wave dipole antenna presents about 73 ohms, Real, at resonance.  This is handy.  If you shorten it, it looks capacitive, if you lengthen it, it appears inductive.)
So if you use antenna designed for a given frequency on another frequency, and don't change anything in the feedline or other components, you'll likely end up with an impedance mismatch between the feedpoint of the antenna and the feedline, which will also result in a mismatch between the transmitter and the feedline (transformed according to the length of the feedline).
Depending on the degree of the mismatch and the type of feed-line, this condition will result in increased system loss -- meaning increased heat dissipated by the antenna system components (like the feedline), thus taking away from electromagnetic energy actually radiated.
Does this mean that an antenna resonant on one frequency can't be used on another?  Nope.  It just means that in order to maintain, good efficiency the complex impedance that differs from the nominal feedline Z needs to be transformed via an antenna tuner or a matching network to the feedline Z to ultimately present the transmitter with a load it is designed to work with.   This is commonly done in order to use a non-resonant antenna efficiently and effectively.
Resonance is handy, but not necessary if you employ proper matching at the right place in the system.
Answer: Having fitted CB radios back in the day : if you did not tune or match the antenna to the radio then it would destroy the transmitter part...
Many were taken for repair due to that error...
Still have the RF meter somewhere...


Meaning of negative density

Question: Charge density depends on the area/volume and the amount of charge. Before electromagnetism I used to think of density as being positive only.
What is the intuitive meaning of negative density? Does it just tells us that the charge is negative or is there more information related to the negative sign?
Comment: think of a gas of electrons. How would you define the charge density? Now take neutral matter, which is made of charged particles like electrons and protons? How come that charge density is zero for neutral matter when it actually contains charge distributions?
Comment: I didn't know it was neutral :P I thought of density as mass density until now, so the amount of stuff per amount of space. Could you answer your own questions please? Now I'm curious
Comment: The idea is that you define charge density whenever you have some charges (like mass density whenever you have some mass spread across a certain region). If you separate positive and negative charges and you just *count* them you end up with two positive densities whose sum is a positive quantity. So for neutral matter, where there are in general both positive and negative charges cancelling each other, you would have a positive charge density, unless you subtract one density from the other, which means that you can assume one of the two to be negative in the first place.
Answer: If the electric charge density of a region of space is negative, that would mean that there are more negative charges than positive charges in that region.
When people use the word "density" casually, they usually mean mass density (or sometimes number density).  Mass (as far as we know) can only be positive, and the number of particles can only be positive, thus those types of densities are only positive.
Electric charge, however, is free to take positive or negative values, because of the nature of electric charge - some particles have positive charges (e.g. protons), and some have negative charge (e.g. electrons).
Answer: It tells us that the charge is negative.
Surface charge density is negative when the surface is covered by -ve charge. Same goes for volume charge density.

Like any density, charge density can depend on position, but charge and thus charge density can be negative.

Wikipedia
Comment: Woah, that was close. I was just ahead by 6s :)
Answer: The term negative charge density is incorrect. By definition: charge density is the amount of charge per unit length (linear charge density), unit area (surface charge density) or unit volume (volume charge density). Corresponding units are: $C/m$, $C/m^2$ and $C/m^3$ respectively. There can not be less than zero charge, therefore charge density can not be negative. Consequently, there can be a density of negative charge but can not be negative charge density.
The concept of charge density should not be mixed with existence of negative and positive charges and related net charge concept. Example: hydrogen atom has one negative charge (-1e) and one positive charge (+1e), so in total the net charge of the system is 0. Charge density plotted along the line drawn through the atom center will have two spikes, in the center and one radius apart. Everywhere else the charge density would be zero, since there is no charge. For both spikes the density would be the same, since there only one charge per unit length, and positive, regardless of the fact that in the center the charge is positive and one radius apart it is negative.

Meaning of negative density


Rebound doesn't work

Question: I have recently had a really hard landing and bottomed out my fork, this time it was different though, when I went back to do the jump again I noticed that when I changed the rebound setting it wouldn't switch between fast and slow, also the fork is acting weird.
Comment: Age, Brand and model of fork might help someone answer this.
Comment: You might have blown up the damper. Is there oil coming out of the fork?
Answer: I think Maple hit it on the head.  The damper works by restricting (partially or fully) the flow of oil from one chamber to the other.  If you have ever seen a french coffee press, where you can open and close the "doors" to the sieve.  If you were to press really hard with it closed, you could easily blow those doors off their hinges.
It is quite possible that the damper is blown even if there is no oil leaking.
Comment: "blow the blow those doors"   Can you rephrase that ?

Rebound doesn't work


Will Meta Stack Exchange be merged with Meta Stack Overflow?

Question: Will Meta Stack Exchange be merged with Meta Stack Overflow?  Would such a merge be a good idea?  A bad one?
Answer: I'd prefer changing jurisdiction as commented there, i.e. make things more consistent and less history burdened:

meta.SO: meta questions concerning SO like retag requests etc., just like the beta-metas now
meta.SE: everything concerning the SE framework itself.

The only consistent alternative (IMHO) would be merging all meta sites into one, also solving the "bug reports belong on meta.SO" issues at the beta-metas at the moment. And tagging might prevent cluttering...
Answer: Doubtful at this point.
meta.se is a support site for SE 1.0.
Maybe once all the SE 1.0 sites (except for the tiny handful of "protected" ones) are decommissioned, we can do something different.
edit: we decided to make this change, as the # of living, legacy SE 1.0 sites has dwindled to a fairly small number.
Comment: So why doesn't MSE replace MSO and let MSO become the per-site meta of SO?
Comment: did you have a look at http://meta.stackexchange.com recently? Almost all questions are about SE-2.0 in fact. And even worse, spam occurs and is not flagged into oblivion after a mere two days. Didn't you mention broken windows should be avoided?
Comment: And, while you're at it, @Jeff, do look at the meta.SE FAQ.  It doesn't mention SE 1.0 at any point, so how are people supposed to *know*?
Comment: @ivo why doesn't England use the Euro? Sometimes there are political and time reasons..


Can I replace a toilet tank, only? what do I need to know regarding tank size to match to existing bowl?

Question: I have to replace a toilet tank that has cracked down the entire side.  What dimensions, and capacities to I need to know when finding a tank to fit the existing bowl?
Answer: It is possible to buy just the tank which matches your toilet.  I have done just that when I smashed my tank trying to move the toilet to fix the seal.  The model number was printed inside the tank and a little internet searching found the tank, with all the hardware in it, could be shipped to the hardware store right beside my house for about $80, which was about 1/3 of the price of the new toilet.  Since the hardware was included, the repair was incredibly simple.
Try searching for any identifying information inside or outside the tank or bowl.  If you can find something, don't be afraid to spend 20 minutes looking, you could save a bit of money.
Comment: Yup. Done this for a cracked tank.  You'll need a very wide wrench for the tank nut. They sell them in home depot.  Honestly, it was a giant PITA.
Comment: Same story here-- was able to find that my toilet (Mansfield) was sold through Menards, and I was able to special order just the tank online for $40 and pick it up at the store for no extra cost.  When replacing the tank, be sure not to overtighten the bolts that fasten the tank to the bowl or you'll crack the tank again!
Comment: @BrianRogers Wish I read this earlier - I just cracked the tank!
Answer: This is usually impractical. An entire new toilet with matching parts is often going to cost less (and much more reliably fit and work together correctly) than sourcing a part for a specific older toilet.
While all of the other hardware that goes into a toilet is normally available as aftermarket parts, I have never seen tanks and bowls sold separately, so I'm guessing if you can get them that way at all it's going to be special order, and I would not be the least surprised to find it more than the cost of a whole new toilet. I'm not saying it never happens, but I've never seen it.
Comment: There are tons of sites that sell tanks.  Finding out which one you can install can be hard but you can use measurements and markings to help with that.  I would say I buy an average of 2-3 tanks a year online.  I quit "just replace the toilet" because I tried to do that with a wide mounted bowl... well I pickup new toilet and it didn't cover the tile - at all.  So 4 toilets later, nothing was covering the tile.  So I had to demo tile in small bathroom because bowl was already at the dump...  Plus it is just wasteful to throw something away that works.
Answer: Throwing in my $0.02.. The decision of whether or not to replace the tank should be based on the toilet. If the toilet is old, then it would be better to replace it. Beginning in 1994, a new US government mandate stipulated that any toilet sold in the US has to be a low-flow toilet which uses no more than 1.6 gallons per flush (gpf). This was done to reduce the amount of water consumption in US households.
The new low-flow standard used half of the water of the old standard which was 3.2 gpf. Since the new toilets used less water, they didn't work quite as well. They would clog frequently and would also require several flushes to go down properly. Toilet manufacturers were flooded with complaints (pun intended), and they improved the designs so they would operate properly on 1.6 gpf.
As a general rule of thumb, if it was manufactured after the year 2000, then you are fine.  The manufacture date as well as model number, etc. should be inside of the tank somewhere. If it was manufactured not too long ago, and it is a name brand, then chances are that you would be able to find a replacement tank. If it is older, and/or it isn't a name brand, then it may be better to replace the whole thing.
Comment: Honestly in my area - no water issues here - we keep the 80s and below toilets or the new ones (within 5-6 years).  There is actually a black market in the midwest for the old 3.2s.  They go for 50-100 used in good condition.  (You do have to install these after inspection though)  The original low flows sucked.  They didn't have the power and you can tell if you got one.  The only reason I ever see people replacing the 3.2s is wanting a higher seat.  Which the 3.2s that are high are gold.  I agree with everything except the 2000... maybe 2005-2008 I would start keeping.
Comment: @DMoore My parents had one of the original low-flows in their house and it was terrible. The year 2000 recommendation was conservative. I agree that they improved them quite a bit since that time.
Answer: Check if any local salvage yards have tanks and lids to buy. If you can't figure out the make and model, then go by the number and location of carriage bolts in the tank and find one that matches the holes. I have paid $5 for replacement lids and used tanks are not much more expensive.


Getting Masechtos for Daf Yomi

Question: Is there a subscription service (ala Chayenu) for Daf yomi where I can receive an easily transportable Gemara for the upcoming week(s)
Comment: In addition to the answer below, artscroll has an iPad version which is perfect for learning on the go, and Koren's PDFs can serve the same purpose.
Comment: I think Oz-Vehadar offers this for their paperback mesivta volumes
Answer: There are a few options that I can think of:

Koren Publishers write here:

Subscribers to the hardcover edition will receive each volume in advance of the Daf and an email containing a link to download the PDF.  Each PDF contains the side-by-side English-Aramaic translation and commentary by Rabbi Adin Steinsaltz and  color images. Vilna page not included.

Although if you're looking for a more transportable option as far as a hard Gemara this might not be so ideal.

Artscroll run a similar offer here where you can setup a standing order and receive every volume as you go through Shas. It writes as follows there:

Receive every volume of the Digtal Schottenstein Edition of the Talmud just in time for the Daf Yomi Cycle! Sign up now and never miss having your volume in time again. There is no charge for this convenient service, and you can cancel at any time.
You will automatically receive:
A 20% discount off the prevailing list price (currently $9.99)
Each volume will be added to your digital volumes 2 weeks before the start of that volume in the Daf Yomi Cycle - and for added convenience, automatically billed to your credit card.
We will only add those volumes that you have not already purchased through ArtScroll.com - Once you click on the "Place in Cart" button, you will be given the option to exclude any volumes you already own.
Why sign up for the ArtScroll Standing order rather then the Apple and Google play Monthly Subscription:
The price when purchased per volume is cheaper than the the monthly subscription. Save up $100 over the course of the subscription
YOU have more control of which volumes you will receive. You can indicate which volume you already have that you want to skip receiving
If you want to get ahead of the daf or you want your volume early - you can purchase it whenever you want and exclude getting it later.

Alternatively, if taking a gemara around with you is your main priority the daf is accessible in many places online which you can print in advance, without actually purchasing a gemara. For example Hebrewbooks and all-daf to name a couple.

Getting Masechtos for Daf Yomi


Bracket and dot notation in compiled CoffeeScript

Question: I have this piece of code in a Node/Express app:
app.use "/static", express.directory("#{__dirname}/public")
app.use "/static", express.static("#{__dirname}/public")

It compiles to this:
app.use("/static", express.directory("" + __dirname + "/public"));
app.use("/static", express["static"]("" + __dirname + "/public"));

By curiosity, I am wondering: why is the dot notation used for the first call and the bracket notation for the second call?
Answer: Because static is reserved in ES3. (not anymore in ES5).
Answer: Because static is a reserved word in Javascript prior to EcmaScript 5 .
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Reserved_Words
Some browsers might throw an error if it is used as an object property with the object.word syntax .
object['word'] ensure no error will be thrown.
Answer: static is a reserved word (reserved for future use as a keyword) in javascript.
You can see a list of reserved words here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Reserved_Words
For example, x.in compiles to x["in"], because in is also a reserved word.


Replace Gfci plug with standard

Question: I need to use a timer for my pool filter but the filter plug is a  Gfci so it won't turn on automatically. Can I replace the plug with a standard plug?
Comment: My reading, which the OP should confirm, is that the GFCI plug automatically trips when power is cut, preventing its effective use with a timer.
Comment: The manufacturer has obviously decided that use of a GFCI is prudent. It's your device though, so sure, you can replace the plug with a more basic one. If you do this, I would recommend you also replace the outlet with a GFCI outlet, so you still have protection against ground faults.
Comment: I agree with @CactusCake.  Code usually dictates GFCIs within 6 feet of a water source, but for a hot tub I would go the extra mile and use GFCI because of the presence of water at the pump.  Meanwhile, using a GFCI generally will not impede electricity unless it trips due to an actual ground fault.  Please clarify in your question whether this is the problem you're having.
Answer: Does the cord/plug-mounted GFCI really trip every time power fails?  Or are you assuming it will because other GFCIs do?  That is a design choice by the GFCI manufacture, and that would be a rather stupid design choice for a cord-mounted GFCI. For this very reason.
Change the order of things
Right now the sequence is:

Breaker panel
Place you would like to put the timer
GFCI

Change the order so the GFCI is before the timer.
Since this appears to be an appliance with a GFCI integrated into its power cord, this gives you three ways to do this, in order of increasing badness:

replace the appliance power cord with a better GFCI cord which does not trip when the power is cut.
Hack the appliance to include a timer.
use a GFCI upstream of the receptacle, and then replace the appliance's power cord with one that is not GFCI.

Your insurance company will not like the last two.
Answer: We have a hair dryer which has what looks like a GFCI plug. This plug does not trip when power to it  is interrupted. The GFCI receptacle in my garage does not trip when I cycle the breaker to that circuit. The two GFCI breakers  in my panel do not trip when there is an interruption to the incoming power. What is all this talk about GFCIs tripping when the power goes off and comes back on?
Try the GFCI plug to the pool filter and see how it performs when the power is cycled off and then back on.

Replace Gfci plug with standard


Can you change the wavelength of light keeping frequency constant and can you do the opposite as well?

Question: Can you change the wavelength of light keeping frequency constant and can you do the opposite as well?
I understood the basics but please don't hesitate to go deeper into the concept. Also, If you happened to have an elegant explanation please drop it here if you can.
Comment: Possible duplicate of [why does the frequency of a wave remain constant?](https://physics.stackexchange.com/q/263288/)
Comment: Possible duplicates: https://physics.stackexchange.com/q/22385/2451 , https://physics.stackexchange.com/q/21336/ and links therein.
Answer: Frequency: acoustic optics can change the frequency.
Wavelength: the speed of light $=3\cdot 10^8 m\cdot s^{-1}$ in vacuum, change a material with different reflective index change the wavelength.
Answer: Wavelength times frequency gives the speed of a wave: $\lambda \nu=v$. The speed of light in a vacuum is a constant, but light can move more slowly in media (for example in water). For a photon of fixed energy, the frequency is fixed, so the wavelength of light should change when it goes into a medium in which the speed of light is slower than in vacuum. In fact, the amount that the wavelength changes is related to the index of refraction $n$ of the medium. If the wavelength in vacuum is $\lambda_0$, then the wavelength in the medium will be $\lambda = \lambda_0/n$.
Answer: As mentioned, wavelength changes in different media depending on the index of refraction. Changing the frequency can be done with non-linear optical effects, notably frequency doubling and similar effects. This change in frequency has a corresponding change in wavelength however, as opposed to the change in wavelength in different(linear) media which holds frequency constant.
Answer: Why does frequency remain constant?
The reason that light does not change its frequency is because of conservation of energy. Light is made up of quanta (small discrete particles). The energy of light is proportional (or equal if you use appropriate units) to its frequency.
$$E=nh\nu$$
Where $n$ is number of quanta. When this light ray goes to a different medium the energy must be conserved. Hence the frequency remains same. The relation between the new and the old wavelength can also be calculated using this relation.
Is the opposite possible?
To my knowledge the opposite is not possible for light rays. Since the speed of light is constant for every observer in a medium the frequency and wavelength must change. It is not possible to keep wavelength constant while changing the other two.
Hope this helps.


php + apache + tomcat

Question: I installed PHP, Apache, Tomcat in Cent OS 5
Tomcat and Apache work fine together.
But PHP! that's problem.
The Source inside php is this
<?php phpinfo(); ?> //This works well only if the Filename is index.html but doesn't work if it's index.php..

I have short knowledge neither in linux and php.
Hope my question is in right form. thank you
Answer: In your httpd.conf add a line like this:
AddType application/x-httpd-php .php .php3 .php4 .php5

Then restart Apache and you're on your way :)
Answer: If you want to make index.php as your default page add
DirectoryIndex index.php index.html

inside your Apache Virtualhost entry.

php + apache + tomcat


When will this site be closed?

Question: With about a question a day, half of them off topic, doesn't seem like the site is viable. When the decision is going to be made?
Comment: It's only been 40 days.  Give it time.
Answer: Without giving specifics, yes there's a decline. However the exact same thing happened with the travel site, in fact it had a worse start (I went hunting through meta comments I posted about it back then a few weeks ago to confirm this).  Then organic results started kicking in and it slowly grew, getting occasional bursts of traffic from articles on lifehacker, reddit, hackernews and more.
It's very early days. We already have more users than travel did at the same time.  It's now a successful graduated SE site.  Expats can be too.
Answer: See the blog on 'when a site goes quiet'. We generally don't shut a site down unless one or more things happen:

Nobody is really using it for anything any longer. It's just tripping people up by showing up in search results.
The community completely ceases taking responsibility for its content. Nobody is closing, nobody is editing, nobody is reviewing - it's all falling on the moderators.
We can't find anyone willing to moderate the site (exacerbated if the bullet above is also true)
The site loses all relevance. That hasn't happened yet, but if a site grew up around some kind of product, and that product vanished - then everyone stopped using it ... there wouldn't be much point in having a site full of questions about it
Extremely bizarre circumstances where the site begins doing more harm than good with the content it delivers. Also has yet to happen.

As long as people are coming here, asking questions, getting answers in a reasonable amount of time, editing, closing, raising meta discussions, curating tags, etc - we're willing to give a beta as long as it takes.
Parenting SE has been in beta a little over three years, and still receives barely two questions every day. We would not dream of closing that site, in fact we're enjoying the challenge of figuring out how we can help boost new questions there.
Many sites are never going to be huge, but will serve small communities better than anything else on the Internet. That's the goal - be an awesome site for Expats to save hours of their lives searching through horribly broken resources found elsewhere. Keep doing that, and you have nothing to worry about.
I fully expect this site to graduate within 1 - 1.5 years, it's just a matter of getting it exposed in the right places.
Comment: I remember OnStartup was closed, and I don't think any of the bullets you listed was relevant then.
Comment: @littleadv That's bullet #2 - there were about 15 people actively interested in maintaining the site, and hordes of people that drove by with very poor questions, never sticking around afterward. A situation that is _very_ unlikely to happen again.

When will this site be closed?


Ways to connect Arduino / Microcontroller to the Web?

Question: What are the best ways to connect an Arduino or a microcontroller (PIC...) to Internet/Web. I would like to be able to send and recieve information from the Arduino/PIC to the Web and vice-verse even if there is no WiFi around. Maybe connecting to my phone using Bluetooth and using it's internet data (3G) is a good idea? What I am trying to achieve is Google Search and response from the results using Arduino, everywhere. (Carrying my phone with the 3G around is not a problem since I don't think it's a good idea to connect to the radio cells around and probably illegally get information from the internet? Any suggestions will be helpful.
Comment: Have you tried to google something like "arduino wifi module"?
Answer: There are GSM shields for the Arduino, yes. But as far as using it as a hotspot for your phone, most likely not. I doubt you can connect your phone to the internet via the GSM shield because you'd essentially be stealing data from a network provider.
However, some of these shields have a SIM card slot so you can place your SIM card inside the device to connect to a network and you can essentially allow it to have the same functionality as your phone and you could make a hotspot that way. For instance, you can send text messages with the shield or you can connect to the internet with the shield.


A question concerning archimedean places on number fields

Question: Let $L$ be a number field and $G=Aut(L\mid \mathbb{Q})$. Let $|\cdot|$ be the usual archimedean value on $\mathbb{C}$ and, by abuse of notation, its restriction to $\mathbb{Q}$. Then the archimedean values on $L$ are of the form $|w|_{\sigma,s}:=|\sigma(w)|^s$ for all $w\in L$, a positive $s$ and $\sigma$ an embedding of $L$ into $\mathbb{C}$. By taking non-equivalent such $\sigma$ (equivalent here meaning equal modulo composition with complex conjugation) we may identify the archimedean places on $L$ with all the $|\cdot|_{\sigma,1}$. and $w\in L$ defines an archimedean absolute value on $L$.
Take two such non equivalent embeddings and the corresponding places $v_1$, $v_2$ and their completions $L_{v_1}$ and $L_{v_2}$. By Ostrowski's theorem both completions must be isomorphic to $\mathbb{R}$ or $\mathbb{C}$. Let us assume they are both isomorphic to $\mathbb{R}$, that is, $|w|_{v_1}=|\tau(w)|^s$ and $|w'|_{v_2}=|\tau'(w')|^t$ for some positive reals $s,t$ and all $w\in L_g$, $w'\in L_{g'}$ ($\tau$ and $\tau'$ are the aforementioned isomorphisms). We must have $s=t=1$ because $v_1$ and $v_2$ coincide with $|\cdot|$ on $\mathbb{Q}$. We must also have $\text{id}=\tau'\circ\tau^{-1}$ (because there are no nontrivial field automorphisms of $\mathbb{R}$) so for $w=w'\in L$ the above becomes \begin{equation}|w|_{v_1}=|w|_{v_2}
\end{equation}
which is a contradiction
Question: where is the error?
Comment: Why would both completions of $L$ be isomorphic to $R$ or to $C$?
Comment: Any field that is complete with respect to an archimedean valuation must be. It's Theorem 4.2 on Neukirch's book. Of course, one could be isomorphic to R and the other to C, but I just wanted to take two embeddings such that the completions were both real (that might not be done for every $L$, but, say for $L$ the splitting field of an irreducible polynomial with 3 real roots and 2 complex conjugate roots).
Answer: The error is in writing $\tau'\circ \tau^{-1}= id$.  This composition doesn't even make sense if you're considering both sides as maps $\mathbb{R}\to\mathbb{R}$, since $\tau$ does not have an inverse as a map $L\to\mathbb{R}$ (it only has an inverse when its codomain is restricted to $\tau(L)$).  We can write that $\tau'\circ \tau^{-1}$ is a field isomorphism from $\tau(L)$ to $\tau'(L)$, but this isomorphism need not extend to an isomorphism $\mathbb{R}\to\mathbb{R}$ between their completions because it does not preserve the absolute value.  So you don't get an automorphism of $\mathbb{R}$, and you can't conclude $\tau$ and $\tau'$ are the same.


Why is storing passwords in version control a bad idea?

Question: My friend just asked me: "why is it actually that bad to put various passwords directly in program's source code, when we only store it in our private Git server?"
I gave him an answer that highlighted a couple of points, but felt it wasn't organized enough and decided this might make sense to create a canonical question for.
Also, how does not storing passwords in the source code relate to principle of least privilege and other foundations of information security?
Comment: @EpicKip good luck deploying any kind of web server without plain text passwords stored in any files.
Comment: Because you don't want a [$14,000 AWS bill](https://dev.to/juanmanuelramallo/i-was-billed-for-14k-usd-on-amazon-web-services-17fn).
Comment: The answer is pretty short, because you should never store a password plaintext. Not even on a file called TotallyNotMyPasswords.txt. Nowhere.
Comment: What are these passwords for?
Comment: @DaveCarruthers There are setups in which this is possible (for instance with windows and AD authentication) other then that, passwords can be saved in [protected configuration](https://stackoverflow.com/questions/4155187/securing-a-password-in-source-code)
Comment: It's more of an industry concept, developer turn over, separation of dev ops role, overall control, and having multiple environments for one application are all reasons not have passwords in the code (source if you will).
Comment: Related on SO: https://stackoverflow.com/a/1197512/5419599
Comment: One good reason is that it means you'd need two different processes for open source and closed source products. You def can't store passwords in source control for open source products. Simpler if use common process
Comment: @DaveCarruthers You can either store an example configuration file in your repository and manually add that configuration file on the first deploy, or you can store the plaintext passwords in CI variables like Gitlab has and generate those configuration files + deploy in a CI script, which hides that information from everyday use, unless you have administrator rights/compromised the private git server.
Comment: Why would devs even *know* the passwords for any environments besides dev/test?
Comment: I'd like a little clarification: The answers to this question should be focussed on the security side of storing passwords in version control? (I think yes, because it's posted on "information security".)  I gave this question some thought and I think there are reasons for not storing password together withn source code that go beyond security.
Comment: What's wrong with using [version control for passwords?](https://www.passwordstore.org/) /deliberate misinterpretation
Comment: Uber [recently figured out the hard way](https://arstechnica.com/information-technology/2015/03/in-major-goof-uber-stored-sensitive-database-key-on-public-github-page/) that this is a bad idea.
Comment: @DaveCarruthers Many setups use environment variables instead. They're populated either by hand (ex. for dev work) or from an encrypted value (ex. [Travis CI](https://docs.travis-ci.com/user/encryption-keys/)) or via an encrypted database (ex. [HashiCorp Vault](https://www.hashicorp.com/products/vault)) or via a secure service (ex. Heroku). The idea is to reduce your attack surface down to a single key stored either in a daemon (like Vault) or a service (like Heroku or Travis).
Comment: By this point I thought it was widely appreciated that only _hashed_ passwords (perhaps with "salt", etc) need to be stored anywhere at all... ?
Answer: The way I see it, not storing passwords in Git (or other version control) is a convention. I suppose one could decide not to enforce it with various results, but here's why this is generally frowned upon:

Git makes it painful to remove passwords from source code history, which might give people a false idea that the password was already removed in the current version.
By putting the password in source control, you basically decide to share the password with anyone who has access to the repository, including future users. This complicates establishing roles within a developer team, which might have different privileges.
Source control software tends to get pretty complicated, especially "all-in-one" systems. This means that there's a risk this system might eventually get compromised, leading to password leakage.
Other developers might be unaware that the password is stored and might mishandle the repository - having keys in the source means that extra care would have to be taken when sharing the code (even within the company; this might create a need for encrypted channels).

I cannot say that every pattern related to infosec is good, but before breaking them it's always a good idea to consider your threat model and attack vectors. If this particular password got leaked, how difficult would it be for an attacker to use it to harm the company?
Comment: Also, and to a lesser degree, password *history* is exposed.  If the password has been changed over time, knowing previous passwords may be useful in guessing future passwords should access be revoked.
Comment: "Convention", to me, implies "everyone generally agrees to do it this way, despite it not having any particularly significant advantage, apart from everyone agreeing that it's to be done this way", but you're giving some pretty significant dis/advantages, which leans more towards "this is a bad idea". Removing the parts about convention would improve the answer quite a bit IMO.
Comment: @NotThatGuy No, convention just means "everyone generally agrees to do it this way".  It's important to note, because following conventions is generally really important and valuable in its own right.
Comment: I'm not sure it's fair to call a known anti-pattern of "short passwords" an "infosec convention".
Comment: @Adonalsium What I meant to say is that it's a pattern related to infosec that is not within best practices and one shouldn't mindlessly follow other people's patterns.
Comment: Note that when removing passwords from source control, you don't need to purge them from the history: you just need to change the passwords.
Comment: @OrangeDog unless that history of passwords is a good indicator for future passwords (which doe snot hold true if your passwords are secure and random, but this isn't always the case).
Comment: That's a fair take.
Comment: I'm with @Adonalsium : convention fails to carry your meaning and much better terms are available: poor idea.  needlessly risky. etc
Comment: I mean for "stuff other people do" convention works, but it also can mean "stuff other (knowledgeable) people think is a good idea and is common place for a reason".
Comment: In addition to item 4, git is a distributed repo system. Anyone who can clone the repo to, say, a development laptop could lose that laptop, and now passwords are part of that data breach.
Comment: Also, there may be employees that occasionally work from home. Some of these (and I've known some) use their home PC to develop, instead of their company laptop. This means relying on their home PC's security instead of the company one's.
Comment: I would add that in many environments, devs are not allowed access to production systems at all and ops/admins will have to maintain all passwords. Since passwords will expire in 45/60/90/180 days on many systems, devs **cannot** maintain the passwords and you don't want ops to have to go into the code, so you put all credentials in a separate config file and when ops deploys the build they put the current production password(s) into the config file and update that file when passwords expire. It's possible that devs not knowing production passwords is legally required on federal systems.
Comment: I'd agree that calling this a convention is inaccurate and misleading.  Conventions are just customs, or "social norms" where you could do it completely differently and it'd be OK as long as everyone else did it that way.  The classic example is which side of the street we drive on.  We all agree which side, and follow it.  But left/right is arbitrary and would (and does) work equally well no matter which the society picked.  That isn't the case here.  If everyone put passwords in version control, it'd still be bad.
Answer: First, the non-security reason:
Password Change Workflow
Passwords change independently of a software application code.  If a DBA changes a database password, does it make sense for developers to have to update the code, get a new build and release to production, and try to time it all?  Passwords are a runtime configuration artifact, not development artifact.  They should be injected via configuration files, environment variables, or whatever configuration paradigm you are using.
Authorization scope
Generally, version control systems provide authorization control so only authorized users can access it.  But within a repository, permissions are generally either read/write, or read-only, or possibly some bells and whistles like GitHub provides.  You're unlikely to find security constraints that let developers get source code, but not passwords.  If you can clone a repo, you can clone a repo.  Period.  In many environments, developers don't have full access to production.  Sometimes they have read-only access to production databases, sometimes no access.  What if developers do generally have access, but you don't want all of the interns, new hires, etc. to have access?
Environments
What if you have multiple environments, like a development environment, QA environment, staging, and production?  Would you store all of their passwords in version control?  How would the app know which one to use?  The app would need to have a way to know the environment, which would end up being a configuration setting.  If you can make the environment name a configuration setting, you can make the database password a configuration setting (along with the connection string, username, etc.)
History
As others have mentioned, version control is designed to preserve history.  So older passwords will still be retrievable, which may not be the best thing.
Compromise
How many times have we seen headlines in the news about source code for some product being leaked to the world?  Source code is whatever is in version control.  This is probably the top reason to not put passwords in version control!
However...
That said, passwords need to be stored somewhere.  What the above concerns are alluding to is not necessarily that they shouldn't be stored in version control at all, rather, that they should not be stored in the product's source code repository in version control.  Having a separate repo for config management, operations, etc. is very reasonable.  The key is to split operations from development when it comes to security credentials, not necessarily to avoid version control altogether.
Also, for non-production environments, I've stored passwords and API keys for external systems in configuration files within the product source code as defaults.  Why?  To make it painless when a developer checks out the code, they can just build and run it and not have to go fetch extra config files.  These are credentials that rarely change and do not lead to any trade secrets.  But I would never do this with production secrets.
So the bottom-line is... it depends.
Comment: Your first point is bigger than it sounds - having passwords tied to the source-code versioning can make it impossible to reliably `git-bisect` to find when bugs originated, for example.
Comment: +1 for suggesting a separate repo with more granular access.
Comment: @TobySpeight We must have very different definitions of "impossible". In a dev environment it'd be rather strange to change passwords anyhow - they are after all by definition not a secret - so there's rarely a reason to change them. And if there is, it should be trivial to replace the old config files with the new ones as part of your bisect script. I mean that's by far the easiest part of the script that has to build your whole project and then host it.
Answer: It's always important to keep in mind that suggestions do have to be tailored to fit your use-case.  Security safeguards taken by, say, the NSA to protect all the zero-days they keep around for a rainy day should be much more stringent than security safeguards taken to protect up-votes on a cat-picture-posting site.  On one extreme, I can think of an example when keeping passwords/tokens/etc in a private git repository might be reasonable:
If that repository is only accessed by one person and the application doesn't store any information of any value.
In that case, go to town!  Just keep in mind what @d33tah said in his answer - scrubbing things out of a git repository can be surprisingly difficult (the whole point, after all, is to keep a history of everything forever) so if down the road you decide you want to collaborate with more people but don't want them gaining full access to all your systems, then you're going to have a bit of a head-ache on your hands.
That is what it really comes down to.  Your code repository is in some way "public", even if only shared with collaborators.  Just because you want to collaborate with someone doesn't mean you want to give them full access to your infrastructure (which is effectively what happens when you put passwords/tokens in your code repository).  It is easy to think "yes, but I trust the people that I'm collaborating with!", but that is simply the wrong way to look at the scenario, for a number of reasons:

In actual practice a large fraction of data leaks start with internal actors (collaborators, employees).  By one study about 43% of data breaches started with an internal actor.  Half of those were intentional, and half accidental.
That last point is important and why this isn't just about trust.  Roughly 20% of data breaches are accidental and caused by internal people.  I'm smart enough to know that I'm not smart enough to get everything right all the time.  What if I turn my repository public to make room for some fun integration tool and forget that I have credentials in it?  What if I have a backup hard drive that I forgot to encrypt and it walks out of my office?  What if one of my passwords gets leaked and someone uses it to guess the password for the account to my git repository (cough gentoo github repository cough)?  There are any number of accidental mistakes that I can make that might result in my git repository being exposed, and if that happens and I have credentials in there and the person who finds them knows what they are looking at, I might very well be hosed.  That sounds like a lot of and's but the reality is that this is how breaches happen.
Even if I trust someone, that doesn't mean that I have to give them full access to everything [Insert cheesy quote about how power corrupts].  Again, putting credentials in a git repository means that I am potentially giving full access to all of my infrastructure to all of my collaborators.  There is always the chance that you don't know that person as well as you think, and they might decide to do something they shouldn't.  Even if you personally know and trust everyone one of your collaborators with your life, that doesn't mean that they won't make some of the above mistakes (or any of the endless options that I didn't mention) to accidentally release your code.

In short, good security is about having layered defenses.  Most hacks happen because hackers find weaknesses in one area that allows them to exploit weaknesses in another area, which leads somewhere else, which finally takes them to the big payoff.  Having as many security safeguards in place as makes sense for your situation is what keeps the whole thing secure.  This way when a backup-harddrive walks out of your office, and you realize that it wasn't encrypted, you don't have to ask "Was this a targeted attack and do I now have to change every single credential I have everywhere because they were all in the git repository on that backup drive?".  Again, depending on your situation this may not apply to you, but hopefully this helps explain in what scenarios this might matter.
Comment: +1 for "...this is how breaches happen." Life is chaotically random, and it is utterly amazing how many times a long string of seemingly random acts can collude together to form the perfect accident (breaches, fires, vehicle collisions). Keeping the password out of the repo removes the possibility that a breach will expose the password.
Answer: Keeping secrets (passwords, certificates, keys) separate from source code makes it possible to manage source and secrets according to different policies. Like, all engineers can read the source code, only the people who are directly responsible for production servers can access the secrets.
This makes life easier for developers because they're not bound by the strict security policies that are needed to protect the secrets. Source control policies can be made much more convenient for them.
Comment: As a person directly responsible for production servers, I can tell you that under no circumstances do I want developers to have QA or production-environment credentials.  If they have them, then they'll "fix" a problem be tweaking things until they start working, won't document their changes, and the whole thing will fall apart because the ratio of Wolfsbane to Eye of Newt is off.  Do whatever you want in your Dev environment, but give me a clean code package to deploy, with documentation of what I have to do to make it work, and the only access I might grant you is read-only to logs.
Comment: @WayneWerner It's not just "don't break, and don't leak", it's "make damn sure I can replicate this reliably".  The separation of roles between dev and ops forces them to explicitly communicate dependencies so that we can do that reliable replication.  Fix it now in dev, document for me what you did to fix it so I can fix it in QA, and if that didn't work, you didn't document it well enough.  Try again.
Comment: @MontyHarder That's definitely due to the tension between the ops goal of "don't break, and don't leak" and dev goal "fix stuff now".
Answer: This convention, like many other security "best practices" is a handy way of making sure that things don't go wrong because of bad habits or routine.
If you always remember that your sensitive passwords are in your version control system and
if you never give anyone who shouldn't have the password access to the repository and
if your repository is stored as safely as these secrets require and
if your deployment process is likewise safe, secure and protected from unauthorized people and
if you can be sure that all the backups and copies of your repository are and... you can probably add a couple more "if"s specific to your context.
...then you can well store your passwords in your version control system.
Under most circumstances, at least one of those "if"s is either not sufficiently compliant to your conditions, or is outside of your control.
For example, in many settings your developers should not have access to the production database. Or the backup system is outsourced to another department. Or your build process is outsourced to the cloud.
That is why in general, not storing your passwords in your version control system is a best practice that makes sure you don't fall into one of those traps because you didn't think about them. "no passwords in git" is easier to remember than a long list of conditions that you need to satisfy to safely store passwords under version control.
Answer: Other answers are great, but consider also the problem of backups. You have much more flexibility on where, how, and for how long you store your code repository backups if they don't contain sensitive information about how to access your server or admin accounts.
From another more security-focused angle, just your code backup might be an interesting target for unethical competitors in your business. Depending on your business, most competitors in a "rule of law" country wouldn't touch it anyway. A code backup with passwords will be a target for any criminal organization interested in your users' data, or interested in blackmailing your company.
The damage from a code repository breach would be greater with the passwords for similar reasons. Would you rather have your source code stolen and published, or have all your users exposed to identity theft, with a potential lawsuit or even criminal case against you for failing to secure their private data (think GDPR)?
Answer: "why is it actually that bad to put your keys directly in your main door, when we live far away from civilization?"
Because people who want to do bad things, will do easilly and the cost of doing hard for them is not too high. Keep your keys with you not next to the door. Common sense.
Private repo? How many people have access to download it? And how many people are connected to its computers? And then... Are all they free from danger?
Comment: To extend the metaphor: Do we make a copy of the office door keys for every employee, or just give them out on a need-basis?
Answer: It also depends on the source code control system.
Git has the attitude that the source code control system should give you a reliable history of the project. Which is not a bad attitude to have. But there's the effect that if you checked a password into git, it's very hard to remove it from your repository.
Perforce has a command "obliterate" for that purpose. If you checked in a password, or someone checks in an 8 gigabyte uncompressed video file, or someone checked in some third party code that is infringing someone's copyright and should never have been checked in, or someone who got fired checked in lots of porn on their last day at work, you can "obliterate" it. It's completely gone from the repository and from the history.
Comment: [It's easypossible to remove passwords from Git history](http://www.davidverhasselt.com/git-how-to-remove-your-password-from-a-repository/) and [rewrite the history to your liking](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History).


Database atomic operations implementation

Question: The question is about queries that are not wrapped in 'begin-commit' block, but about plain inserts and updates that are atomic in PostgreSQL, MySQL (innodb engine at least). So how is this implemented internally?
Answer: A transaction is started for each statement that occurs outside of an explicit transaction block. Whether a commit is automatically issued following the statement is dependent on the RDBMS configuration. MySQL has the autocommit option, SQL Server has IMPLICIT_TRANSACTIONS, PostgreSQL is always auto commit.
PostgreSQL:

In the standard, it is not necessary to issue START TRANSACTION to
  start a transaction block: any SQL command implicitly begins a block.
  PostgreSQL's behavior can be seen as implicitly issuing a COMMIT after
  each command that does not follow START TRANSACTION (or BEGIN), and it
  is therefore often called "autocommit". Other relational database
  systems might offer an autocommit feature as a convenience.

InnoDB:

In InnoDB, all user activity occurs inside a transaction. If
  autocommit mode is enabled, each SQL statement forms a single
  transaction on its own. By default, MySQL starts the session for each
  new connection with autocommit enabled, so MySQL does a commit after
  each SQL statement if that statement did not return an error.

SQL Server:

SQL Server operates in the following transaction modes.
Autocommit transactions - Each individual statement is a transaction.
Explicit transactions - Each transaction is explicitly started with
  the BEGIN TRANSACTION statement and explicitly ended with a COMMIT or
  ROLLBACK statement.
Implicit transactions - A new transaction is implicitly started when
  the prior transaction completes, but each transaction is explicitly
  completed with a COMMIT or ROLLBACK statement.
Comment: I'm not sure what you mean. [START TRANSACTION](http://dev.mysql.com/doc/refman/5.0/en/commit.html) disables autocommit in MySQL.
Comment: thx Mark, things made clear. But one question about MySQL: what is autocommit is on and I wrap several queries in transaction? Wrapped transaction are not possible in MySQL as far as I'm concerned


Geometric condensation patterns on windshields

Question: I noticed these patterns in the condensation on the inner surface of my car's windshield when I turned on the defroster. Usually when I see lines like these on condensation I assume it's because of snails/slugs altering the surface chemistry of the glass, but in this case 1) the lines seem too straight to be from a snail, 2) the angles are too sharp/consistent, and 3) there aren't any snails in my car. They also don't seem to be ordered enough to be artefacts from the manufacturing process (it's a new car). Anyone have any ideas?
Comment: My first thoughts were: scratches, cracks, or spider webs.  The topology of the lines makes spider webs seem unlikely.  Cracks in a new car's windshield would be unlikely, and the topology seems wrong.  I would drag a razor blade or fingernail across one of the lines to see if I could feel a scratch.   One more possibility: the windshield may have been wrapped in something that left those lines, in the form of contamination on the surface.  You could try scrubbing a place on one of the lines, using acetone; then see if the mark shows up next time there's condensation inside your windshield.
Comment: I have never seen these patterns until recently while parking in an area that is somewhat urban. Wondered ... Could these be caused by wifi long wavelengths? This seems to be a fairly new phenomenon as I've never seen them before but read reports of it happening over the last ten years. They seem too straight and sharply angled to not be created by something that can generate somewhat of a pattern albeit random. Similar to some photos of patterns for wifi long wavelengths.
Answer: Condensation patterns like this are commonly caused by tiny amounts of dirt or chemical residues on the glass surface that locally alter the condensation kinetics. I do not know what caused this particular pattern but try cleaning the window off with Windex/ammonia cleaner and a clean paper towel and see if the pattern persists.
By the way, people who work in cleanrooms with silicon wafers used to exhale on a wafer to see if it was properly cleaned. If it wasn't, swirly patterns of condensation would show up indicating contamination from the previous processing step.


Jboss/Tomcat monitor

Question: I'm looking for a tool (in linux) that can montior a tomcat/jboss process and if the process fails, I can respawn either or both without having to manually ssh into the box, do any house keeping and then start them up again. I'm not too sure if there is a good tool out there that can monitor the health of jboss/tomcat and report on it's performance. I know jvisualvm gives you various tools, but I'm looking for a disaster recovery solution that is a bit higher level than jvisualvm.
Answer: Java Service Wrapper is an application that wraps your Java process and installs it in the system using service (Windows) or daemon (Linux). It pings the VM periodically and restarts it when it does not respond. Worked for us in production with several application, including Tomcat, JBoss, Mule, etc. Actually Mule ESB is even bundled with this application in the distribution.
Also you don't have to run the application manually when the system starts.
Comment: community edition : linux 64 bit : not available. who does use 32 bit, nowadays ? sigh !!!
Answer: I'm currently working on a daemon to do this and more, since JOPR nor naggios didn't do what we needed, but those are good tools you could use. I'm not sure but JOPR (or whatever is called today) can restart your servers in case something goes wrong.
A custom made solution as we're working on shouldn't take you more than a week. The main problem, is that to start either JBoss or Tomcat you have to call the startup scripts. But the startup script will restart the service if the exit code is 10, something like this:
<code>while $? -ne 10; do
  start_jboss
done
</code>
So, this daemon which is made in Java uses JMX to connect to the JBoss server and tells JBoss to go down and exit with status code 10 using a method in a MBean. I'm at home, so I'm not sure the exact name of the MBean you have to call for this but I'll provide more info tomorrow.
Answer: I am using monit to control the launch of Tomcat/JBoss.

Jboss/Tomcat monitor


Can a Supreme Court justice be nominated and confirmed under two different presidents?

Question: For example, if President Trump nominated a justice on his last day in office, could that person then be confirmed by the Senate during a Biden administration?
Comment: The answer is different based on the timing. The nomination automatically expires at the end of the term, which is before the end of Trump's term. If it really was his *last* day, it would be "active." If it was before the last day of Congress' term, the nomination would have to be redone by Biden.
Answer: Yes and no. It's theoretically possible for the Senate to confirm a candidate nominated by a previous President. It's important to remember that even though it's commonly called "confirmation," the word used in the Constitution is "consent." So the Senate merely consents to the appointment of a candidate, and the President can still decide after the confirmation process not to follow through with making that appointment.
(Notably the Constitution doesn't say anything about "nomination," so the Senate can "confirm" anyone they wanted. The nomination process only exists as a practical measure because the Senate does not want to waste their time going through a lengthy and intensive confirmation process for candidates that the President isn't going to appoint.)
But this couldn't be done as a way for the Senate to force through a candidate that the sitting President doesn't like.  Theoretically, Joe Biden could still decide to appoint a Trump nominee, but he would not be required to, and given the current political climate in the US, it seems unlikely that he would.
(It's also worth noting that for the same reasons of practicality mentioned above, the President can withdraw a nomination at any point in this process. Wikipedia has a list of Unsuccessful nominations to the Supreme Court of the United States, which lists 11 cases of withdrawn nominations.)
Of course this is all speculative, since it hasn't happened, and a President who wished to appoint a candidate nominated by a previous administration would most likely officially re-nominate the candidate and let the Senate re-confirm. (In your example of the last day in office, or even going back a couple weeks, the Senate that confirmed the original nomination would still be the sitting Senate, since the new Congress is seated on January 3, while the President isn't replaced until January 20. Barring any major developments, there would be no reason to expect the Senate not to re-confirm.)
Comment: While it hasn't happened for a justice, there's probably precedent for the case where the new administration fails to appoint a candidate that the previous administration nominated and senate confirmed from all the way back in _[Marbury v. Madison](https://en.wikipedia.org/wiki/Marbury_v._Madison)_.


How to sample color from a palette at a fixed color distance

Question: How can I sample from a gradient color scheme palette in segments of a fixed color distance? I.e, the next element appended to the generated list is a fixed distance from the most recently added color in the list.
I have an initial color and would like to make regular samples from a color palette starting from this initial color.
Comment: Somewhat related to `ResourceFunction["SampleColors"]`
Answer: We can make a little helper function:
ClearAll[SampleGradientFixedColorDistance]
SampleGradientFixedColorDistance[cf_, n_, m_ : 250] :=
 Module[{dists, vals, colors, if, max, newvals},
  vals = N@Subdivide[m];
  colors = cf /@ vals;
  dists = BlockMap[Apply[ColorDistance], colors, 2, 1];
  dists = Prepend[Accumulate[dists], 0];
  max = Max[dists];
  if = Interpolation[Transpose[{dists, vals}]];
  newvals = if /@ Subdivide[0, max, n - 1];
  cf /@ newvals
  ]

Which we can then call:
colors = SampleGradientFixedColorDistance[ColorData["Rainbow"], 20]

Compare it with linear sampling of the color scheme:
linearcolors = ColorData["Rainbow"] /@ Subdivide[20 - 1]

Now we can compare the distances between successive colors:
ListPlot[{BlockMap[Apply[ColorDistance], colors, 2, 1],
  BlockMap[Apply[ColorDistance], linearcolors, 2, 1]},
 PlotRange -> All, PlotLegends -> {"Adjusted", "Linear"},
 Frame -> True]

It is not perfect, because color distances are not so nicely 'additive'. But it gives a reasonable improvement on the built-in.
Comment: Any way of modifying this to start at an arbitrary intial color? I realize some colors may not exist inside the palette but then I could just use FindMatchingColor.
Comment: I'm not sure if that makes 'sense': to which point in the scheme would you go? the first? If your first choice is 'too far' one can not guarantee that 'n' colors is possible…
Comment: So I have the color `#c4d167` but would like to take samples of colors that are evenly spaced beginning at `#c4d167`. I don't want any sort of "wrapping around" the gradient if that is what you are asking. But I think it shoulud be possible to take fixed sample segments to the right and to the left beginning at `#c4d167`.
Comment: So starting at #c4d167 then move to the first color of the gradient, then continue taking steps of the same size in the gradient?
Comment: Result would look like `colorset = {..., c - Δd, c, c +  Δd,...}` where `c = #c4d167` and `d` is the fixed color distance.


Ajax and Django forms

Question: I'd like to add Ajax to my admin form for editing a model. The model has a list field. I would like the Ajax to create a list of inputs with add and remove buttons, automatically calling back to the server when the user clicks "add" or "remove".
What I'm stuck on is: how does the widget know what the backing model is? If it doesn't know, how can it update the values? (I would want to provide Urls like api/remove-list-item?pk=foo&item=bar to the front end.)
This makes me think that it doesn't fit with the general Django framework philosophy to be doing this. Instead, perhaps I should be keeping the values locally and sending them through the same validation process as the rest of the data. But I'm a bit unsure of how to do this.
Answer: I am doing something similar to this (although not in an admin form).  I'm not sure if it is a recommended way of doing things...but it does seem to work for me.
I have an action set on a html form in the template that calls a view which basically has the sole task of updating the data in the database and returning a "success" (or whatever I happen to want it to return).
On the template side of things I also use the jquery form plugin, which I use to update the div to show the new value.
Again, I'm not sure if this is the way others would recommend, but I do feel it seems to make sense....and it does seem to work just fine.
Answer: In urls.py, make a rule like:
(r'^api/remove-list-item/(?P<id>\d+)$', 'yourApp.views.remove'),

then in the yourApp.views have something like:
from django.shortcuts import get_object_or_404, redirect

def remove(request, id):
  dbObj = get_object_or_404(YourModel, id=id)
  dbObj.active = False # Or whatever you want to do with the object
  dbObj.save()

  return redirect('some-view')

You can then make queries like /api/remove-list-item/123

Ajax and Django forms


If God transmit messages to Muhamad in various ways, how does Muhamad know which messages goes where?

Question: Does the Quran contain all of Allah's revelations? (Sunni view)
This one says that not all of God's message is in Quran.
Some go to Quran. Other goes somewhere else.
How does Muhamad knows, oh, this message is in Quran. This one can go to Hadits?
Answer: First of all the given answers of the linked question don't seem satisfactory to me even if they provide enough information to already answer your question which seems to me based on a superficial reading.
The qur'an (and only the qur'an) is the revelation of Allah the almighty. Usually if Muhammad () got a new revelation he would call his scribes and dictate it to them. He would even tell them were to arrange it in the middle of the existing texts. See for example Prophet Muhammad SAW was illiterate, who wrote the Quran then? and also Is the Quran really preserved or are there missing parts of the Quran?.
Else the sunnah be it what we call hadith or hadith qudsi is related to the prophet () and his interpretation of the qur'an in the daily life and his knowledge about Allah the almighty. He neither would call any scribe nor ask people to write it down. So the sunnah consists of reports of what he said or did or confirmed (or didn't deny) beyond the qur'an.
Nevertheless it is interpreted as a kind of revelation based on a litteral interpretation of the verses:

Your companion [Muhammad] has not strayed, nor has he erred, (2)
  Nor does he speak from [his own] inclination. (3)
  It is not but a revelation revealed, (4) (53: 2-4)
Answer: I'm going to answer your question with a question that should be an answer to your inquiry.
Some memories that you yourself have, you know you've lived them in real life and were not a dream.
How do you know that these memories are memories of real events and not memories of dreams? You just know.
You may say that I can confirm with people, or with evidence in the environment. But there will still be some memories that you know have happened that you would not have anyone to confirm with or anything left in the environment as evidence. Yet you somehow know that they were real.
This does not mean that that's how Prophet Mohamed PBUH knew how distiguish. But it is to give an analogy that something of the like is very possible, in fact it is happening in your own self and you don't doubt it.
I hope this helps.
Cheers.
Comment: I understand. However, perhaps as a muslim you can add details. Things like if Gibrael come and says, "Muhamad, this one goes to Quran", "This one? Oh this one is just what's going to happen tomorrow". Your analogy is valid. Of course, people often have a false memory.