SSH key auth, but still need password for sudo?

Question: SSH with public-private key authentication comes enabled by default with most Linux distributions. This is great because when I create accounts for remote users I don't have to email them sensitive info(passwords).
However, this process becomes useless when these users need to run sudo -- the server is still asking for their passwords. That means I still need to generate passwords for these users and figure out how to securely get it to them.
I know about sudoers file and NOPASSWORD parameter. However, I feel uneasy enabling it. I would still want some sort of authentication before users can run sudo commands.
While doing some research on this topic I found pam_ssh_agent_auth project, which from my understanding enables the same private/public key authentication as used for ssh connections but for sudo command.
It seems like with this module in place we can have completely passwordless accounts.
Why is this module or similar process is not part of standard Linux distro configs? Is there some security caveat I'm missing why this is not more widely adopted? Why passworded sudo is considered to be more secure than public/private key sudo?
Comment: Can't they just run `passwd` on their first login to set their password ?
Comment: @AndréDaniel `passwd` requires entering user's "current" password
Comment: There is public/private key alternative to sudo -- it's ssh :) -- see my answer for details.
Comment: Just adding feedback for this solution. It doesn't quite work for permission modifying commands like chmod and chown (there are legitimate workflows and use cases where this is needed), as those implicitly require root privileges - unless you grant r_service sudo rights!! In which case, why go through all that, when you can just enable sudo? Edit: This is reply to Galaxy's answer about not using sudo.
Answer: I am trying a different approach that doesn't require creating and managing passwords: I set up key-based authentication with the user's public key, disabled password-based authentication for ssh and set up the user accounts with an empty but expired password  (passwd -de). That way users get prompted on their first login and can choose their own passwords.
I am feeling a bit uneasy about the empty password but as far as I can tell, it's fine as long as password authentication for ssh is disabled and there are no other services running that require authentication (IMAP or something). Any opinions on this?
Comment: That's assuming SSH is the only way into the server right? (no local access, Apache/ftpd doesn't authenticate against local accounts, etc.) Also, what happens when someone does `sudo -u `...?
Comment: That's a creative solution.
Comment: I'd be afraid of the empty password.  Couldn't another user on the same machine get into and change the password from su or something similar?
Comment: Also, what happens when someone does `su `...?
Comment: With "sudo -u user_with_empty bash" you get a shell but obviously you'd need root/sudo privileges for that. What happens with "su user_with_empty" is usually defined by PAM. By default su'ing is denied on the distros I know (via /etc/pam.d/su that includes  /etc/pam.d/common-auth, see 'nullok_secure')
Answer: I suggest to avoid even installing sudo on your systems: it's an additional attack vector with usually no justification for having it.  I wrote an article on the sudo (mis)usage if you are interested to learn more on the topic: http://dmitry.khlebnikov.net/2015/07/should-we-use-sudo-for-day-to-day.html
Re: the original question - if you need some privileged command to be executed by non-privileged users you may use the following trick:

generate a passphrase-less SSH key
prepend the public part with the following: from="127.0.0.1",command="your_desired_command_here",no-pty,no-port-forwarding,no-agent-forwarding (you can also restrict the SSH session further, see "man sshd").  Note that the key should be separated from this header by a space character.
install that public key to privileged account's ~/.ssh/authorized_keys
provide the user with the private key (or create a script that simply SSH in over the loopback interface to the privileged account using the private key)

For example, if the privileged account is r_service (created with useradd -om -u0 -g0 -d /root/service -s /bin/bash r_service) the call to that privileged command from a non-privileged account would be something like:
$ ssh -i ~/.ssh/privileged_command r_service@0

This way you will grant your users to execute that privileged command without compromising the security model.
Comment: very interesting article
Comment: The article was a good read +1
Comment: @JohnMoser, first of all, I think it is a wrong place to discuss the article, but I will briefly address your comment.  1) the article does not promote `su` and actually specifically says that it is no different from any other escalation; 2) and 3) - I think you missed the point.  The proposal is to use an ephemeral key that has no value outside the host - even if it is stolen you can't leverage it unless you also has access to the account it was installed on.  And if you have such access, then you already possess enough access to execute the call no matter how it was configured.
Comment: Article misses 1) capturing `su` isn't different than capturing user password (just record the whole session); 2) access to a dev server as root isn't usually that useful (the critical data is shared resources); 3) in the dev server instance, I now have your private key without capturing your password you're using `ssh` from the same host to itself
Answer: In my opinion, sudo for server admins is a bit overkill. If people log in, and they have root access (through some mechanism), they usually do maintaining tasks, where they will use sudo for >90% of the time. The purpose of sudo is to give accounts that are logged in some separation between untrusted applications and admin-like tasks, and make users aware they are changing the system (and have to watch out). For desktops, both applies. For servers however, most tasks will already require sudo, so both points get weak. sudo has some advantages with its fine-grained control, but to rely on its logging capabilities, you would need to set up remote logging, as otherwise people with root access can falsify past logs.

Is there some security caveat I'm missing why this is not more widely
  adopted?

pam_ssh_agent_auth requires ssh-agent forwarding in order to work over ssh. Then however its a bit pointless to use it, as then every (non-cgrouped) process running under the user's account could use the agent to execute commands as root. This enables every such process to run sudo which is precisely what the NOPASSWORD parameter does.
My advice would be to have NOPASSWORD and be happy with it. It still gives people the feeling "now I change the system", but it doesn't have annoying passwords.
If you still wanted to have passwords, you could e-mail them in clear, but require them to be changed the first time they get used. An attacker would need both the email and the user's private key to be successful. If they already have access to the private key, they could do some nasty things to .bashrc and get access the next time the user gets sudo with a password that the attacker doesn't need to know.
Comment: `sudo` for servers is not an overkill when you must restart some service. And I can't hardcode specific command into `sudoers` due to issues beyond the scope of this question.

Can you please elaborate on your 2nd paragraph? ssh-agent is running on the client's system, not server, and only when connected.
Comment: From the [man page](http://linux.die.net/man/8/pam_ssh_agent_auth): *the ssh-agent listening to `SSH_AUTH_SOCK` can either be local, or forwarded.* With 'local' the man page means 'running on the server'.
Comment: I fail to see how using pam_ssh_agent_auth improves upon using sudo NOPASSWD either. If you you want to circumvent having to enter the sudo password repeatedly you could just extend the sudo timeout.
Answer: SSH authentication and security privileges are two different things, hence no point of having it as a default feature. However, it opens one more vector for attack(there is a CVE) and from my point of view makes it easier for users to overuse it, which is bad.
On the topic of passwords, one way is to send a short-lived password to the user and require him/her to change it after initial login. Or allow them to "register" their account and only work with the hash. There is pros and cons in every approach, but a good place for inspiration is the commercial and free Shell account services.
Answer: You can create a password for the user, then encrypt the password using the user's ssh public key (which you already have), then send the user the encrypted password.  Then, the user can decrypt the encrypted password using their ssh private key.
See https://superuser.com/questions/576506/how-to-use-ssh-rsa-public-key-to-encrypt-a-text for how to encrypt/decrypt messages using ssh public/private keys.


"Blocked by your IT admin" Samsung Galaxy 8

Question: I'm trying to install Android Auto from apk but I get the message "Blocked by your IT admin. Unknown apps can't be installed on this device." In the last 18 months I have downloaded that app already 2x without any problems.
I have already given permission to install unknown apps from Chrome and My files. Deactivated Play Secure and any device admin apps (the only one I saw was Find my location).
I do have work e-mail app but according to my employer "Our Mobile Device Management platform (MobileIron) doesn't block any installation on your private device, as a completely separate Workspace is created and managed by us, which doesn't interfere with your private configuration".
What else can I try doing before I ask them to remove MobileIron?
Answer: Had the same issue. For me it was only fixed by disabling Google Play Store in personal profile. It wasn't easy process as it depends on Google Play services which can be disabled only after stopping Work profile. So the flow was: 1) Stop Work profile from top menu, 2) Force Stop and disable Google Play Services in Personal Profile, 3) Disable and stop Google Play Store in personal profile. After this I started Work profile again.
Hope this will help.


Use Fact to decompose a given number

Question: Let Fact be the following decision problem. Given two natural numbers $k \le n$ the machine accepts if and only if $n$ has a non-trivial divisor that is less than or equal to $k$. Prove that if Fact $\in$ P then there is an algorithm that given $n$, it produces its decomposition into prime factors in polynomial time in the length of $n$.

I have tried to create this algorithm as follows:
Given $n\in\mathbb{N}$, if $\mathrm{Fact}(2,n)=1$ then $2\mid n$, in which case we take $n_1=\frac{n}{2}$, if $\mathrm{Fact}(2,n)=0$ then we see what happens with $\mathrm{Fact}(3,n)$ and we continue like this, my problem is that this algorithm is done in a time $O(2^n)$ which is not polynomial and all the algorithms that occur to me end in this problem is it possible to do this in polynomial time?
Answer: Use binary search to find the smallest factor, divide and repeat.

Use Fact to decompose a given number


Shorted receptacle, now another recep (GFCI) not working. Breaker perhaps?

Question: Receptacle on one breaker, light switch next to it on another breaker. Mistakenly touched receptacle black wire on light switch and caused sparks. Receptacle failed after that. Had another nearby GFCI receptacle STILL operating (dehumidifier operating entire time) that is on same breaker as fried receptacle. Turned off breaker (mistake in first place, thought receptacle and light switch were both on breaker). Breaker 20A, both plain receptacle and GFCI recep are 15A. Decided to go with 20A GFCI to replace fried receptacle. Installed and when turned on breaker NOTHING worked, including GFCI receptacle which does not reset and shows no light indicator. Do not know wire capacity (this was over fighting ants crawling through wall at receptacle). Switched Breaker back and forth and get NOTHING. Have decided to get obviously 15A receptacle to replace bad receptacle. Bought new breaker. Any thoughts? Have not seen charred wire and have not taken GFCI receptacle out for inspection.
Comment: Don't bother buying the other GFCI or the breaker. They aren't the problem.
Comment: Now is a good time to invest in a volt meter which you can pick up for about the price of a GFCI receptacle.
Answer: It sounds like one of the wire connections is faulty.  Problem is, it's not where you want it to be.
It's very common after an overload for a wire connection (where wire attaches to a device) to simply stop working.  What has happened is that it was making a poor connection up til now (either because backstab connections were used, or it was under-torqued) and the surge of current burned it out entirely.
For any given wire, this could occur on either end of the wire.  You don't know which.    When you replaced the receptacle, that obviously re-seated that end of the wires.  But the problem could be at the other end, which is presumably at another switch, recep, or wire nut that is also on that circuit.
It can also happen at "wire nuts" which aren't tight enough.  People who don't tighten wire nuts enough usually use tape to keep them from just falling apart, so tape is a warning sign.
So it becomes a "bug hunt" trying to find it.
Comment: Replaced plugin and it was fine. The GFCI was at the end of the wiring henceforth since the burned-out plugin was removed and the failed 20A GFCI was not right for the wiring gauge (I assume). Thanks for the advice.


Roots of Unity with Rational Real Parts

Question: All of the $4^{\text{th}}$ and $6^{\text{th}}$ roots of unity have real parts that are rational numbers. Are these the only roots of unity $z$ such that $\text{Re}(z)\in \mathbb{Q}$  ?
Comment: Re(z) is not rational for all of the $12^{th}$ roots of unity. $e^{\frac{i\pi}{6}}$ has real part $\frac{\sqrt{3}}{2}$.
Comment: Sorry about that, I should have said 6th roots of unity, question has been edited to reflect that.
Comment: The fourth roots of unity $\{\pm 1,\pm i\}$ also have this property.
Comment: thanks! question updated to reflect this.
Answer: Suppose $z^n=1$ and $\Re(z)\in \mathbb{Q}$. Then also $\left(\overline{z}\right)^n=1$, so $z$ and $\overline{z}$ are both algebraic integers. This means that $z+ \overline{z} = 2 \Re(z)$ is also an algebraic integer. The only algebraic integers that are rational are integers, so $2 \Re(z)$ must be an integer. Since $z$ lies on the unit circle we find that the only possible values for $2\Re(z)$ are $\{-2,1,0,1,2\}$. These values indeed correspond to the 6th roots of unity together with $\pm i$.
Answer: Let us take the $n$th root of unity. We want to find when $\cos{2\pi m/n}$ is rational for integers $m$. We know this is true for $n = 1,2,3,4,6$, just by substitution.
Now we prove that these are the only results. Take $m=1$. We will show that $\cos{2\pi/n}$ is irrational for all other values of $n$. My first instinct here was to use Galois theory, like the construction of numbers using a straightedge and compass, but a quick google search shows that this has already been done, for example, see  https://wilsonong.wordpress.com/2010/06/25/when-is-cos2pin-irrational/
I'll attempt to summarize the argument, and introduce some of the concepts of Galois theory.
Start with the rational numbers $\mathbb{Q}$, which are a field. We perform what is called a field extension by including $\zeta = e^{2\pi i/n}$, $\mathbb{Q}[\zeta]$ which is the smallest field containing both the rationals and $\zeta$. When studying Galois theory, we are interested in automorphisms of $\mathbb{Q}[\zeta]$ that leave the base field $\mathbb{Q}$ fixed. Under such an automorphism $\cos(2\pi/n)$ is mapped to $\cos(2\pi j/n)$. If $\cos(2\pi/n)$ is rational, it is fixed under the automorphism, forcing $j=1$ or $j=n-1$. This means the Galois group has at most two elements, only possible for $n=1,2,3,4,6$. A nice summary of relevant facts about cyclotomic extensions are given here http://www.math.uconn.edu/~kconrad/blurbs/galoistheory/cyclotomic.pdf

Roots of Unity with Rational Real Parts


s3 stuck at booting screen

Question: I bought a Samsung Galaxy S3 I9300 about a month back from eBay. It was working fine till the last Tuesday, but after that my phone started rebooting by itself. My Galaxy S3 is powered by Android 4.0.4 and unfortunately I haven't enabled the USB Debugging Mode, nor have I flashed it with any custom roms. So, I can't flash with any custom roms, the solution suggested by most of the threads I have browsed through. My phone is also not going into the recovery mode. Please help!
Answer: Enter Download Mode.
Download Odin
Download Offical Firmware from Here
place the Tar file in the PDA Location in Odin
and it will install the Offical Rom again.
Tutorial Here
if you have Kies Delete it just install the Drivers

s3 stuck at booting screen


Iranian National with U.S. Green Card need a transit visa? U.S > Vienna > Iran

Question: I am planning to travel to Iran (I am Iranian also) from the U.S. (and I have a permanent residency card i.e. Green card holder) ... do I need a transit visa at Vienna airport?
Answer: Short Answer: No, you don't need a transit visa for Austria.
Long Answer: If an airline passenger is refused entry at a transit point or destination, the airline is required to return the passenger to the point of departure at the airline's expense (although they may try to recover the cost from the passenger). Thus, airlines are very careful to determine what documents are required by a particular passenger's travel before allowing that passenger to board. Airlines use the IATA database Timatic to reveal what documents are required.
Putting your information into Timatic through this online portal (there other others), generates this:

National Iran (IR)
  /Residence USA (US)
Transit Austria (AT)
  /Destination Iran (IR)
ALSO CHECK DESTINATION INFORMATION BELOW
Austria (AT)
TWOV (Transit Without Visa):
  Visa required, except for Nationals of Iran, arriving from a
  non-Schengen Member State with a confirmed onward ticket for a
  flight to a third country which is not a Schengen Member
  State. They must:

have a residence permit issued by USA, and
stay in the international transit area of the airport, and
have documents required for the next destination.

...
Passport required.
  - Nationals of Iran are allowed to enter with an expired passport
VISA NOT REQUIRED.
...

Thus, because you will arrive from a non-Schengen state with an onward ticket for a third country which is not a Schengen state, you can transit in Vienna without a transit visa provided you stay in the airport's international transit area.
Comment: @baldeagle67 at the linked duplicate you will find links to the EU legislation that says that having a green card exempts you from a transit visa requirement if you would otherwise have one.  But do be aware that you will not be permitted to go through passport control without a regular Schengen (type C or D) visa.  In particular, if you have any checked luggage it must be checked through, because you will be unable to reach the baggage carousel.
Comment: Thank you David for the information ... I actually called the airline (Austrian airline) and the customer service refused to answer and told me to contact consulate of Austria! ... I am checking your link, why I do not get those information that you provided? it just gives me a general information
Comment: @baldeagle67 I presume you've not entered all the relevant information in the correct fields. I just entered your information again, and was rewarded with the same data. You could also try this different Timatic portal, which contains fewer fields and may be easier to use: https://cms.olympicair.com/timatic/webdocsI/spdbmainv.html


Powershell Copy-Item Fails When Azure File Share is Destination

Question: I am using Powershell and trying to copy a file to an Azure File Share. The Script I am creating creates a Sql Server backup and copies the backup file to the Azure File Share. I want to do this from a central VM because I want to run the script on multiple machines without having to log into each of them.
Connectivity looks something like this:
DeployServer-> SqlServer1 -> Azure File Share
On SqlServer1 I have created a mapped drive using the script provided by the AZ Portal. I have executed this script with Administrator privileges. I can connect and browse to the share from SqlServer1. I can display the contents of the File Share in Explorer and Powershell while RDP'd in to SqlServer1.
This is the script (connectivity details obfuscated) I ran to map this drive. This was provided by AZ Portal:
$connectTestResult = Test-NetConnection -ComputerName sumcomputername0.file.core.windows.net -Port 445
if ($connectTestResult.TcpTestSucceeded) {
  # Save the password so the drive will persist on reboot
  cmd.exe /C "cmdkey /add:`"sumcomputername0.file.core.windows.net`" /user:`"Azure\sumteststorage0`" /pass:`"OMITTED FOR SECURITY`""
  # Mount the drive
  New-PSDrive -Name Z -PSProvider FileSystem -Root "\\sumcomputername0.file.core.windows.net\ctestfileshare" -Persist
}
else {
  Write-Error -Message "Unable to reach the Azure storage account via port 445. Check to make
  sure your organization or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN,
  or Express Route to tunnel SMB traffic over a different port."
}

The Powershell script I have written executes as expected from 'Sql Server1'. The problem comes into play when I try to run the script from DeployServer via Invoke-Command.  The script called via Invoke-Command fails at the Item-Copy command  (I have also tried a simple cp command with the same result).
This is the command that fails:
Copy-Item $BackupPath -Destination $NetworkPath -Force –Verbose
This is the error
Cannot find drive. A drive with the name 'Z' does not exist.

    + CategoryInfo          : ObjectNotFound: (Z:String) [Copy-Item], DriveNotFoundException

    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.CopyItemCommand

    + PSComputerName        : sumip

How do I fix the AZ File Share (Z:) so it is available via remote Invoke-Command?
Answer: I could not solve this. Instad I used the Azure Powershell module to copy files to/from Azure. This let me skip the cp step.
https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-powershell


Why isn't supertab's  binding working?

Question: There is the supertab binding <c-tab> that is supposed to produce a normal tab, but that doesn't work on my system (Mac; tried in iTerm and terminal).  And I just remembered reading that Tab is equivalent to <c-i>. Wouldn't that imply that <c-tab> ≡ <c-c-i> (≡ nonsense)? (I don't really need this binding, <c-v><c-i> is fine; but it got me curious.)
Answer: You are right about tab being the same same as ctrl+i, as explained in :help key-codes:
                    *key-notation* *key-codes* *keycodes*
These names for keys are used in the documentation.  They can also be used
with the ":map" command (insert the key name by pressing CTRL-K and then the
key you want the name for).

notation    meaning         equivalent  decimal value(s)    ~
-----------------------------------------------------------------------
<Nul>       zero            CTRL-@    0 (stored as 10) *<Nul>*
<BS>        backspace       CTRL-H    8 *backspace*
<Tab>       tab         CTRL-I    9 *tab* *Tab*

Following the procedure on Vim FAQ "20.4. I am not able to create a mapping for the  key. What is wrong?" on my machine the output for ctrl+v tab differs from ctrl+v ctrl+tab, both on terminal and gVim,
So Vim is able to map ctrl+tab and tab independently.
You could use the following mappings to check if your problem caused by some problem in Vim recognizing ctrl+tab or in supertab plugin:
inoremap <c-tab> abc
inoremap <tab> def

Comment: From your answer I conclude that nothing can be done on my system. in iterm, c-tab produces nothing; in terminal, remapping tab also affects c-tab.

Why isn't supertab's  binding working?


WhatsApp can't be installed

Question: I seem to be encountering problems installing WhatsApp on my Huawei Y511-U10 model.
I factory resetted my phone yesterday, and downloaded apps a fresh. But whatsapp seems to be the only app that won't get installed successfully. When I try to install it it keeps on showing me "Whatsapp Messenger can't be installed. (Error code -24).
 I contacted Google Play Store and Whatsapp support for help but haven't yet gotten any solution for my problem. If there is some genious mind out there kindly assist me and I'll be greatful
Comment: What android  version your device is running?
Answer: Reading all the questions associated with this type error, you get the impression it will require root to enable you to delete the app from the /system partition if it remains.
Previous to doing that, I would suggest trying this, just to be sure it is not a file or folder remnant getting in the way:

Some apps leave remainders during uninstalls that aid in the
  restoration of state or level information upon re-installing a later
  version. Usually these remains are unimportant to a user who does not
  intend to re-install or to any other user where consistent state or
  level data is unimportant. These remains have a particular name in an
  app that can clean them up: "corpse files".
SDMaid
  is a disk cleaner that can locate, and delete, files related to
  corpses. Install the app, and select CorpseFinder from the menu to
  locate, and, optionally delete them.

DISCLAIMER: I am not the developer, just a satisfied user.
If this is not the solution, see the answers for more intensive actions through other questions here.

WhatsApp can't be installed


Character Tones in Modal Jazz

Question: I'm learning modal jazz harmony for the first time, and I am confused why the character tone of D Dorian is B and not F.  I can see the difference between Dorian and Aeolian is in the 6th degree.  But the difference between Dorian and Mixolydian is the ♭3.  If we look at the modes of one key, e.g. C, and arrange the modes in order of increasing number of flats (i.e. Ionian, Mixo, Dor, Aeol, Phryg, Loc) then the character tones move by fourths except for Dorian: F, B♭, A, A♭, D♭, G♭.  Surely it should be E♭??
I can see that Lydian doesn't fit into this pattern... but ♯4 obviously is the character tone of Lydian, so obviously the fourths thing is not that important.
Comment: What's the source for this?
Comment: Apparently the table came from this page https://www.thejazzpianosite.com/jazz-piano-lessons/modern-jazz-theory/modal-jazz/  Quote from the page: "_Character Tone = the unique note/degree that makes a particular scale sound like itself and helps distinguish it from the Major and minor scale, and from the other modes._" Did you read that and didn't understand it or what?
Comment: @piiperiReinstate Monica - I hadn't a clue where it was from, so it was impossible to read **or** understand! I'm not a complete idiot, but I do help them out when they're short...
Comment: Why was this downvoted? The question is perfectly clear and the OP has a better grasp of modes and scale degrees than thejazzpianosite
Comment: @Tim I was talking to the OP. After reading that description it's hard to understand what was left unclear ... but after this question on the internet it must be double-clear.
Comment: @MichaelCurtis - you are wasting your time asking about dvs. They're often the product of whimsical minds, accompanied by no backbone.
Comment: Actually the source was this video: https://youtu.be/mb0EFwzXIEo?t=681, but I didn't want to link to a video so found a table on a site I could link to.  I thought the video was a very good explainer, I just had that one question.
Answer: Character tones are those that most easily give away the character or harmonic nature of the mode.
If your tonic i.e. home note is D, and if that's the only note that's played, it does not taste like any mode. No third is played, so you don't even know if it's minor or major. You are free to imagine any kind of harmony around the D.
If in addition to the D (in the bass), you play an F, it starts to sound like a minor something. From the mode palette you can play D Dorian, D Phrygian, D Aeolian or D Locrian over D=tonic and F, and it would suit the D+F combination. Dorian, Phrygian, Aeolian or Locrian are minor modes, because their third is a minor third, "b3".
If in addition to the D and F, you play a B, from the mode palette the only alternative left is D Dorian, because that's the only minor mode that has minor third and a major sixth. The other minor modes have "b6" in the table.
If you think about this in terms of character chords (I don't know if that's a proper term), the character chords of D Dorian are: Dm and G. For D Lydian the character chords would be D major and E major.
Why the primary character tone in D Dorian is B and not F ... well, I would say that both F and B are what define the harmonic character, but maybe it is assumed that when you compare D Dorian to a normal D minor key and D natural minor scale, then it's the B you play if you want to tell other musicians I WANT DORIAN HERE.
Even D as tonic and B and F don't completely define the harmony. You could play, say, things from a D diminished scale and it would have D and F and B, but it still wouldn't be D Dorian. Or if you play random chromatic stuff, it can have D and F and B, but without creating a D Dorian sound.
The difference between D Dorian and D Mixolydian is not only the b3, it's the third and the sixth. Dorian is a minor mode, Mixolydian is a major mode. The character chords for D Mixolydian are D major and C major, D being the home note. Play the chords D and C/D (D in the bass), and repeat those two chords --> a pretty much instant D Mixolydian feeling is created.
Let's see some examples. Here is The Pattern Guitarist Group presenting their song Le Òssom Djãêz:

They thought the music could be better, so they hired a bassist who made a new arrangement of the tune by playing C. They called this Le Ionian Djãêz:

A new variation was created by putting D in the bass, called Le Dorian Djãêz:

F in the bass, Le Lydian Djãêz:

G in the bass, Le Mixolydian Djãêz:

A in the bass, Le Aeolian Djãêz:
Comment: Thanks for your really thorough answer.  I guess to summarise both this and @moonwave99's answer the important thing to distinguish first in the modes is whether they are major or minor first and it's the third that determines that, so it can't be a character tone in any of the modes.
Comment: @thenapking Or maybe your source material just isn't very good? It's someone's subjective view into the matter. I don't think that each mode has only one character tone. Apparently your table came from here: https://www.thejazzpianosite.com/jazz-piano-lessons/modern-jazz-theory/modal-jazz/
Answer: You don't have to force yourself in finding patterns you won't need.
I would keep it simple, and split the modes between minor and minor, based on their 3rd degree.
Let's keep locrian aside for a moment (even though I consider it more minor than major, practically speaking).
Major:
- Ionian
- Myxolydian
- Lydian
Minor:
- Aeolian
- Dorian
- Phrygian
You can keep ionian and aeolian as reference, as you know how they sound, and which harmony you can build with them.
For the remaining for, ask yourself what makes them differ from the reference, and you already know the answer.

Myxolydian: ♭7
Lydian: ♯4
Dorian: ♯6
Phrygian: ♭2

The question now is, on top of what am I playing? If there is a passage in D dorian, chances are that I will be playing over a Dm/G or Dm/Em sequence.
Both feature a B natural, that you want to outline in the melody. The B♭ of regular aeolian would have clashed with the B.

Besides this, make some music! Nobody is going to ask you to declamate the character tones of the modes in order.
Check for yourself what makes a certain mode different from the others, both in terms of harmony and melody. Listen to modal music. Write modal music. Iterate.
Comment: Thanks for this.  I wasn't try to find patterns for pattern's sake, but when I noticed that I thought it would make it easy to read the character notes off the circle of fifths... but it didn't work.  Both your answer and @piiperi-reinstate-monica make reference to modes being either minor or major.  That does explain why you aren't trying to differentiate Dorian from Mixolydian, but, in Modal jazz shouldn't all the modes be equal in some sense, rather than grouped up according to a concept from Diatonic harmony?
Comment: Technically, they are all still modes of the diatonic scale, so it's still diatonic harmony. Major and minor are still useful distinctions because modes can be used to solo over chords (from my understanding of modal jazz), so a major chord and minor chord could tell you whether to use a "major" mode or "minor" mode, whereas other notes of the scale be not as important.
Answer: Your misgivings about that chart of 'character tones' are well founded IMO.
The 'character tone' idea in the chart is a bit arbitrary.
The sixth degree of Dorian is the unique tone when compared with Aeolian. But not when compared to any other mode that used a minor tetrachord for the top part of the scale: Mixolydian and Phrygian.
When comparing to Mixolydian the third degree is the unique degree.
When comparing to Phrygian the second degree is the unique degree.
There are only two truly unique scale degrees within the diatonic modes: the raised fourth degree of Lydian and the lowered fifth degree of Locrian.
The lowered second degree comes next as fairly unique, because it is only found in Phrygian and Locrian. Traditionally Locrian is not used as a mode for composition so for all practical purposes the lowered second can be though of as unique to Phrygian.
If you eliminate Lydian, Locrian, and Phrygian for having truly unique degrees, that only leaves two pairs of modes: Ionian and Mixolydian for major where the seventh degree distinguishes them, and Aeolian and Dorian for minor where the sixth degree distinguishes them. However, it should be clear that merely the seventh and sixth degrees alone won't distinguish the mode. You at least need the third degree to know whether it's a major or minor family mode.
You really need to look at all tones to know what the mode is.
Another way to think about it is tonal and modal degrees. The first, fourth, and fifth degrees are the tonal degrees and the second, third, sixth and seventh are the modal degrees. The diatonic modes are determined by the modal degrees except for Lydian and Locrian which alter a tonal degree.
Yet another way to think about modes is combinations of tetrachords. There are four basic types: major, minor, phrygian, and harmonic. Ex, Dorian mode is two dorian tetrachords, one starting on the tonic, the second starting a perfect fifth above.
Keep in mind you can have modes that aren't diatonic like the double harmonic or Freygish scales.
Comment: Thanks for your reply Michael.  Your view does make sense, but I also understand why the maj/min distinction is still important, even in modal jazz.  My interest in character tones is that, as I understand it, chords that contain the character tone have more pull towards chords containing the root tone (as in functional harmony) and so when picking chords I need to be mindful of this.  Is this correct? Is there something else I should be mindful of when picking chords for certain points of the composition?
Answer: Simple answer: Most probably whoever said that B is the character tone of D dorian, meant "B is the note that distinguishes D dorian from D aeolian", i.e. the other most commonly used minor mode. D aeolian, aka D natural minor, has a Bb instead of a B, while all other notes are the same as D dorian.

Character Tones in Modal Jazz


How is the Simple Moving Average (SMA) calculated if some days have no trades?

Question: I want to calculate the 10-day SMA of a stock. However, there are some trading days when no trades took place for the stock (i.e. volume is zero). For the days that have zero volume, what is the stock price that should be used to calculate the SMA? Is it the closing price of the previous day that had a trade? Or is it $0?
Answer: A 10 "period' moving average involves the data for the last 10 periods of trading.  It could be for any period of time (minute, hour, day, etc.).
A market day when there is no trading is the same as a weekend or a holiday.  It is ignored, as is any shorter intraday time frame.
Comment: I guess this answer is appropriate in most situations where there are only a few periods with no trades. One situation where this answer is less appropriate: in illiquid securities where no trades happen for months at a time (e.g. some OTC stocks).
Comment: Mathematically, moving averages are useless with illiquid stocks or anything with a wide bid/ask spread.
Answer: It might depend on what you're using the SMA for, but I certainly wouldn't use zero.
I can see two viable options - the most intuitive to me is to use the prior closing price for the days on which there are no trades. That would cause the SMA to converge to the last price over 10 days.
Another option might be to use the prices for the past 10 days on which there were trades. That would cause the the SMA to be "flat" until the day after a trade).
Comment: "the prices for the past 10 days on which there were trades" — Does this mean the average of the prices of the past 10 days that had trades?
Comment: @Flux correct - although that would be my second choice by a longshot, depending on what the SMA was used for.
Comment: I thought about using linear interpolation for the missing prices. Not sure if that is a sound method though. It seems that most technical analysis tools use "forward-filling" (i.e. for days with no trades, the prior closing price is used).
Comment: I'm not sure linear interpolation would be helpful, if anything it would bias the HMA based on recent results. You could possibly use the beta of the stock and the return of some large index to imply a price. e.g. if the stock does not trade but has a beta of 2, and the S&P has a 1% increase one day, assume that the stock would have a 2% increase. At least that way you keep the HMA of the stock in line with market changes.
Comment: What is "HMA"? How is it related to the SMA?
Comment: Typo. I meant SMA.


Picard group of scheme over DVR

Question: Let $A$ be a DVR and let $X/A$ be a smooth, proper scheme with geometrically integral fibers. Is there an easy way to see that the Picard group of $X$ is isomorphic to the Picard group of the generic fiber $X_\eta$ of $X$?
Answer: This is too long to be a comment to Matt Emerton's answer. I think his conclusion is correct. Namely, if $X$ is smooth and proper over $A$, then $\mathrm{Pic}(X)\to \mathrm{Pic}(X_{\eta})$ is an isomorphism (whenever the generic fiber is geometrically connected or not). As explained by Matt, one can suppose $X$ is connected and we have only to show the injectivity. Clearly the kernel is generated by the irreducible components of the special fiber $X_s$. So it is enough to show that each of these irreducible components is a principal (Cartier) divisor.
Frist consider $A'=H^0(X, \mathcal O_X)$. It is finite and flat over $A$. As $X_s=X\otimes_{A'} (A'/\pi A')$ where $\pi$ is a uniformizing element of $A$, is smooth over $A/\pi A$, this force $A'/\pi A'$ to be separable over $A/\pi A$, hence $A'$ is étale over $A$.
The scheme $X$ is also a smooth proper $A'$-scheme with geometrically connected generic fiber. Let $s_1,\dots, s_n$ be the points of Spec$(A')$. Then $A'/\pi A'=\oplus_i k(s_i)$ and $X_s$ is just the disjoint union of the $X_{s_i}$. By Zariski, $X_{s_i}$ is connected, smooth, hence irreducible. Let $\pi_i\in A'$ be a uniformizing element at $s_i$ and a unit at $s_j$ for all $j\ne i$. Then the divisor div$(\pi_i)$ of $\pi_i$ on $X$ is $X_{s_i}$.
In Laurent's example, each copy of $\mathbb P^1_k$ is actually a principal divisor. So there is no more divisors on $\mathbb P^1_{A'}$ than on $\mathbb P^1_{\mathrm{Frac}(A')}$. Hope I don't miss something.
Comment: Shame on me. What was wrong in Matt's argument was the claim that the special fiber is irreducible, but as you show the conclusion nevertheless holds. What happens in my example is that if $L$ is an invertible sheaf on $X$, its restrictions to both components of $X_s$ must have the same degree.
Comment: Dear Qing, This looks good to me. I guess I'll have to go back and reedit my answer! Best wishes, Matt
Answer: Here is an argument, which hopefully is not too dodgy:
Firstly, if $D_{\eta}$ is an effective divisor on $X_{\eta}$, then the Zariski closure $D$
of $D_{\eta}$ will be an effective divisor on $X$.  Since $Pic(X_{\eta})$ is generated
by the classes of effective divisors, this shows that the restriction map from $Pic(X)$
to $Pic(X_{\eta})$ is surjective.
Now let $\mathcal L$ be a line bundle on $X$ which is trivial when restricted to $X_{\eta}$.
If we choose a non-zero section $f$ of $\mathcal L_{\eta}$, then multiplying by a sufficiently high power of $\pi$ (a uniformizer of $A$), we may assume that $f$
extends to a section
of $\mathcal L$.  The zero locus of $f$ is then some multiple of $X_s$ (the special fibre).
This is precisely the zero locus of $\pi$,
and so scaling again by an appropriate power of $\pi$, we may assume that $f$ is actually
nowhere zero, showing that $\mathcal L$ is trivial.
Note: I am assuming that the special fibre is irreducible.  [Edit: As Laurent Moret-Bailly points out below, what follows is incorrect, due to a confusion between connectedness and geometric connectedness. New Edit: As Qing Liu points out in his answer, while the argument given is not quite correct, the conclusion is actually okay!]
 But I think the general case
reduces to this. Namely, since $X$ is smooth over $A$, each connected component is irreducible, hence has connected generic fibre, hence has connected special fibre (Zariski's connectedness theorem), hence has irreducible special fibre (since the special fibre is also smooth by assumption).   Thus the above argument, if it is correct, should apply to each connected component separately.
Additional remark: Although I switched into the language of line bundles half-way through the above argument, this is not necessary (it is just the first thing that came to mind when I initially wrote the answer).  It is perhaps cleaner to think entirely in terms of restricting effective divisors $D$ on $X$ to $X_{\eta}$, and extending effective divisors on $X_{\eta}$ to all of $X$ by taking Zariski closure.  One easily sees that these operations provide an isomorphism between $Pic(X)$ and $Pic(X_{\eta})$, provided that every divisor supported on the special fibre is principal.  If the special fibre is irreducible, then there is only one reduced effective divisor supported on the special fibre, namely the special fibre itself, and this is principal, being cut out by the equation $\pi = 0$.
What Qing Liu's answer shows is that even if $X_s$ is reducible, it is still the case that
it breaks up as a disjoint union of components, each of which is principal.
Comment: @Matthew: the last paragraph is wrong. Let $A'$ be the normalization of $A$ in a quadratic extension $K'$ which is unramified and split. Take $X=\mathbb{P}^1_{A'}$ (viewed as an $A$-scheme). The generic fibre is $\mathbb{P}^1_{K'}$; the special fibre is $\mathbb{P}^1_{k}\coprod\mathbb{P}^1_{k}$ ($k$=residue field). In this example, $\mathrm{Pic}(X_\eta)\cong\mathbb{Z}$ while $\mathrm{Pic}(X)\cong\mathbb{Z}\times\mathbb{Z}$.
Comment: Dear Laurent, Thanks for this.  Regards, Matthew

Picard group of scheme over DVR


Are any of the quests in Horizon: Zero Dawn time sensitive?

Question: I started playing Horizon: Zero Dawn a few weeks ago and have been focusing mainly on sidequests and exploring the world. I advanced the game just enough so I got to Meridian, but as I collected more and more quests from NPCs, I started wondering if any of those tasks (or any quests in the game) were time sensitive or could become unavailable after advancing the main storyline. Are there any time sensitive quests at all in Horizon: Zero Dawn?
Answer: There are no time-sensitive quests in the game. There also isn't a real "point of no return" for the side quests, after you finish the game your game is reset to the point before the final mission and you can continue to explore and do sidequests.
There is a point where the game warns you to finish any unfinished tasks, but that only means that you are about to do a pretty long quest that you can't leave until you finished it.
There is an order to the three main quest series, if you do them out of order at some point one quest line will pause until you have done some of the other main quest lines.
Answer: There is no time gating to quests, but depending on where you are in the main quest characters may talk to you differently when giving quests. If you're later in the main storyline, side quest givers may talk about how honored they are to meet you or wonder why you aren't off doing something more important.
Similarly, when it comes time for the final battle, who shows up and what they say to you depends on which side quests you've completed and in some cases which conversation options you've chosen. Even characters from the Frozen Wilds DLC can show up.


How to use ContentObserver with RecyclerView?

Question: With ListView we have had a good native pattern to map some data from db to list:
DB -> ContentProvider -> CursorLoader -> CursorAdapter -> ListView
This approach was good in terms of data layer separation, performance and automatic data updates. But this pattern doesn't really fit new RecyclerView. There are some approaches to mimic old behavior:
Using the recyclerview with a database
But there is a problem with using old style notifyDataSetChanged with RecyclerView. It can't use ItemAnimator features, it loses scrolling position, and it's just ineffective.
So, how we can benefit from finegraned change notifications while using DB wrapped in ContentProvider? Cursor is static, and to get new data from it we need to get new Cursor. So, it seems that we will need an custom intermediate data layer, which will merge data from Cursors and expose the List of entities to RecyclerView.Adapter. Also, we will have to manually map ContentObserver onChange() events to RecyclerView notifications. This also means that we will have to get rid of CursorLoader. That is an incredible amount of work for such basic task.
Is there any better solution?
Answer: You can use the DiffUtils class to compute the differences between the old and new cursor.
When using it you just need to implement two methods :

areItemsTheSame() to know if two items represent the same logical item (even if the content is different). Usually you would base the answer on an identifying field of your item;
areContentsTheSame() to know if two items representing the same logical item have unmodified content.

Once the differences are computed, you can then just apply it to your adapter and it will automatically call the notifyItemChanged(), notifyItemInserted() or notifyItemRemoved() accodingly.


How to GET the current profile via pactl?

Question: There are examples out there of how to set the card profile via pacmd or pactl (with a simple set-card-profile). But is there any analog where i can check the currently set profile?
get-card-profile does not work and generates an error, i was hoping that even though it wasn't documented it would be there.
Answer: Ok, i have found the answer myself. It is somehow hidden within pacmd list-cards output. It has the section profiles:.
I do not know if it also outputs it somewhere all by itself.
Answer: You can run pactl list cards and see the currently selected profile under Active Profile.
Of course, you can filter the output to only show the profile information; for example, if you want to see only the currently selected profile for your bluetooth card, you can use something like
$ pactl list cards | awk -v RS='' '/bluez/' | awk -F': ' '/Active Profile/ { print $2 }'


Continuous on rationals, discontinuous on irrationals

Question:
Let $f: R \rightarrow R$. Show that the set of points of continuity of
  $f$ is a $G_{\delta}$ set. Explain why it follows from this that there
  is no function that is continuous on the rationals and discontinuous
  on the irrationals.

Solution:
I can prove the second part, although independently of the first.
In words:
No function can be continuous only on a countable dense set of $R$, such as $Q$. If the set, $X$, of continuity points were countable, then we could choose a nested sequence of intervals around points of $X$ where the variation in $f$ goes to 0, that eventually avoids all points of $X$. But the common point of the intervals would be a continuity point, contradiction.
How can I relate this to the first part?
Comment: Related: [here](http://math.stackexchange.com/q/67620/264), [here](http://math.stackexchange.com/q/138072/264), and [here](http://math.stackexchange.com/q/211511/264).
Answer: When you look at the intersection of a sequence of set of reals where oscillation (which you call variation) of f goes to 0, all you can say is that this is a G-delta set containing all rationals. How do you know this set has an irrational number? The idea is to exploit the fact that rationals are countable to build a nested sequence of compact intervals whose intersection avoids all rationals. This argument is called the Baire category theorem.
Answer: You have to use the following:
Let X be a complete metric space and let E be a subset of X. If E and X\E are dense, then at most one of E and X\E is F-sigma.
Since the rationals are F-sigma, we have that the irrationals cannot be F-sigma. If there is a function that is continuous only on the rationals, then the rational are G-delta, which implies that the complement (the irrationals) are F-delta, which is a contradiction.


Norm map over Galois extension

Question: Let $K$ be a Galois extension of $F$. Prove or disprove that any intermediate field $L$ of $K/F$ is of the form $L=F(\{N(a)\mid a \in K\})$, where $N$ the is norm map of $K/L$.
Comment: Welcome to mathSE: since you are a new user, I wanted to let you know a few things about the site. In order to get the best possible answers, it is helpful if you say in what context you encountered the problem, and what your thoughts on it are so far; this will prevent people from telling you things you already know, and help them write their answers at an appropriate level. Also, many find the use of imperative ("Prove or disprove") to be rude when asking for help; please consider rewriting your post.
Comment: "is of the form" is unappropriate here, since your $N$ depends on $L$. You should simply say something like "any intermediate $L$ satisfies $L=F(\lbrace  N_{K/L}(a) |a \in K\rbrace)$".
Comment: I can prove it if F is a finite field. But in general I guess it's not right and should have some counterexample. And I just can't find one...
Answer: This assertion is right. We only prove the case when L is an infinite field, the proof when L is just a finite field is much easier because the Galois group is generated by the Frobenius map and the norm is easy to compute.
Proof:Suppose that $K=F(\beta)$ with $f(x)=min(\beta,L)=\prod_{\sigma\in Gal(K/L)}{(x-\sigma(\beta))}$ $=x^n+a_{n-1}x^{n-1}+...+a_{1}x+a_{0}$. A simple observation here is that $F(\{a_{i}\})=L$, so we only need to show that $F(\{N_{K/L}(\alpha)\mid\alpha \in K\})=F(\{a_{i}\})$. Using the definition of Norm, we have $N_{K/L}(\alpha)=\prod_{\sigma\in Gal(K/L)}\sigma(\alpha)$, for any $\alpha$ in K. Let $\alpha=a-\beta$, where $a \in F$, we have $N_{K/L}(\alpha)=f(a)$. At last, using  a little linear algebra, we can show that $F(\{f(a)\mid a\in F\})=F(\{a_{i}\})$(hint: using Vandermonde Determinant). Now the proof is complete.

Norm map over Galois extension


How to run local (non-shell) scripts on a remote host via SSH?

Question: How can I make cat someFile | ssh someHost work when someFile is not a bash script? I want to remotely execute a perl script but I get a bunch of syntax errors from bash when I try the cat | ssh command.
Answer: If you want to push the Perl script through the SSH connection, you'll have
to run the Perl interpreter on the remote end. It'll read the script from stdin:
ssh remotehost perl < somescript.pl

In the case of Perl, it should even read the command line switches (except -T) from the hashbang line of the input.
If you want to give command line arguments to the Perl interpreter, you can
just add them to the command line after perl. If you want to give arguments to the script, you'll need to explicitly tell the interpreter to read the script from stdin (otherwise it will take the first argument as a file name to look for).
So, here -l goes to the interpreter, and foo and bar to the script:
echo 'print "> $_"  foreach @ARGV' | ssh remotehost perl -l - foo bar

Note that doing just ssh somehost < script.sh counts on the remote login shell being compatible with the script. (i.e. a Bash script won't work if the remote shell happens to be something else.)
Comment: I've found that cat perlScript | ssh remoteHost perl   works great. I'd like to pass a command line argument to perl. Do you know how I might do that?
Comment: @Sol, edited, since there's a slight difference between switches to perl and what goes to the script's `@ARGV`
Comment: A friend suggested this and it works great!

cat perlScript | ssh remoteHost perl /dev/stdin someArgument

The /dev/stdin part is most interesting.
Answer: ssh someHost will execute your default shell, which in turn will execute the commands it reads from standard input. Since you are sending the content of someFile to standard input, it logically tries to executes to content of someFile.
You don't tell us what someFile is supposed to contain. Assuming its content is supposed to be fed to your perl script, what you should do is:
cat someFile | ssh someHost your_perl_script

Or better:
ssh someHost your_perl_script < someFile

Comment: someFile is the perl script I want to execute remotely. Sorry I wasn't clear in the problem description.
Answer: in ordred to =>
Write local output into remote file: You just installed the apache on your $myhost. Now you want to test it.
You can echo the test string into file, only this time the file is in remote htdocs root:
echo "It works" | ssh firstname.lastname@example.com 'cat >> /usr/local/apache/htdocs/it_works.html'

Open remote file with less or cat:
With cat:
ssh email@example.com "cat /usr/local/apache/htdocs/it_works.html"
With less:
ssh firstname.lastname@example.com "less /usr/local/apache/htdocs/it_works.html"
Grep remote files:
With pipe:
ssh email@example.com "cat /usr/local/apache/htdocs/it_works.html" |  grep "works"
Just remote grep:
ssh email@example.com "grep works /usr/local/apache/htdocs/it_works.html"
Watching remote logs with tail:
This way you can watch the access to apache server in real-time:
 ssh email@example.com "tail -f /etc/httpd/logfiles/access_log"
The source for this answer is here.
Comment: Running `less` on the remote like that is a bit bare, since by default SSH (without `-t`)  doesn't allocate a terminal if a command line is given, so less only sees a socket, and most of its functionality is lost.
Comment: Does any of this answer the question here, anyway?
Comment: I'm trying to remotely execute a perl script. I think this may not be possible without copying the perl script to the remote machine.
Comment: check @ilkkachu answer.


SharePoint lookup filters

Question: Say you have the following:

Planet List
Country List
Region List
Town List
Street List

Street List has a content type called "Street", which in it has a lookup to the Town List.
So the flow for creating a new street is as follows:

Create a planet.
Create a country, specify planet in dropdown.
Create a region, specify country in dropdown.
Create town, specify region in dropdown.
Create street, specify town in dropdown.

Each list has it's own specific properties (Planet has "SE Co-ordinates", Country has "Main language", etc..). This means that these cannot be used as managed metadata tags.
Now, I'm going to create a new document in the document library which has a content type using the "Street lookup" field.
Obviously, in the document information panel in Word - I'm going to get a gazilion different streets to choose from (including ones from other planets :P).
You can always hack your way around it in the UI. But this seems like really basic functionality - am I the first one to add addresses to documents in SharePoint??
Answer: There are some third party solutions like SharePoint Cascaded Lookups from Codeplex, or using jQuery or Cross site and cascaded lookup from Virtosoftware.
Comment: Hi, could you please read the document information panel part of the question

SharePoint lookup filters


What are hyphal compartments?

Question: The hyphae are the branching filaments that make up the mycelium of a fungus. Hyphal compartments are part of the hyphae. What are they exactly?
Answer: I did a quick lookup on google for "hyphal compartments" and the number of online texts/books/citations using this term is quite meagre to say the least. One of the images that I found was this-

And I have reached to the conclusion that--
Hyphae cells (only in septate species) are known as hyphal compartments.
Quoting from wikipedia (read if you don't know about septate and coenocytic varieties of hyphae)

A hypha (plural hyphae, from Greek ὑφή, huphḗ, "web") is a long, branching filamentous structure of a fungus, oomycete, or actinobacterium.In most fungi, hyphae are the main mode of vegetative growth, and are collectively called a mycelium.
A hypha consists of one or more cells surrounded by a tubular cell
wall. In most fungi, hyphae are divided into cells by internal
cross-walls called "septa" (singular septum). Septa are usually
perforated by pores large enough for ribosomes, mitochondria and
sometimes nuclei to flow between cells. The major structural polymer
in fungal cell walls is typically chitin, in contrast to plants and
oomycetes that have cellulosic cell walls. Some fungi have aseptate
hyphae, meaning their hyphae are not partitioned by septa.
Hyphae have an average diameter of 4-6 µm.

What are hyphal compartments?


Convergence in the Wasserstein metric and the square root function

Question: Let $f$ be a smooth probability distribution on the unit square $S$ such that $f(x)>0$ on $S$.  Let $\{g_i\}$ be a sequence of smooth probability distributions such that $g_i(x)>0$ on $S$ as well and such that the Wasserstein distance $W_1(f,g_i)$ approaches zero.  Is it true that $$\iint_S \sqrt{f(x)} dx \geq \limsup_{i\to\infty} \iint_S \sqrt{g_i(x)}dx$$ assuming both quantities exist?  The other direction of the inequality is definitely not true because we could construct $\{g_i\}$ that is almost discrete, which would have very tiny values of $\iint_S \sqrt{g_i(x)}dx$.
Answer: Yes. Also, both quantities are guaranteed to exist: the left hand side because $f$ is smooth and bounded, and the right hand side because a lim sup always exists, and it's finite because the LHS is finite and the inequality is true.
Here is a sketch for the proof of (a slightly generalized version of) the inequality: suppose $f: \mathbb{R}^d \to \mathbb{R}$ is a uniformly continuous density and let $\delta$ be its modulus of continuity. For $\epsilon > 0$, let $$
\eta_\epsilon(x) = \frac{1}{|B_\epsilon|} \chi_{B_\epsilon}(x),
$$
where $B_\epsilon$ is the Euclidean ball of radius $\epsilon$ in $\mathbb{R}^d$.
Lemma
If $\|f - \eta_\epsilon * g\|_\infty \ge 4 \delta(\epsilon)$ then
$W_1(f, g) \ge C_d \delta(\epsilon)^2 \epsilon^{d+1}$, where $C_d$ is a constant depending only on $d$.
Proof (sketch): Choose a point $x$ such that $|f(x) - (\eta_\epsilon * g)(x)| \ge 3 \delta(\epsilon)$. Suppose that $f(x) \ge (\eta_\epsilon * g)(x) + 3 \delta$ (the other direction is similar). Consider a ball $B$ of radius $\epsilon$
around $x$: by the definition of $\delta$, $f(y) \ge f(x) - \delta \ge (\eta_\epsilon * g)(x) + 2 \delta$ for all $y \in B$. On the other hand, $(\eta_\epsilon * g)(x)$ is the average value of $g$ on $B$. Using this, you can find $\epsilon' < \epsilon$ so that $f$ has $\delta$ more mass on $B(x, \epsilon')$ than $g$ has on $B(x, \epsilon)$. To move $g$ onto $f$, you will have to move at least $\delta$ mass from outside of $B(x, \epsilon)$ into $B(x, \epsilon')$, which costs at least $\delta (\epsilon - \epsilon')$ in $W_1$ distance. Then you need to compute how small $\epsilon'$ can be: you'll get
$\epsilon - \epsilon' \asymp \delta \epsilon^{d+1}$.
Since $W_1(f, g_i) \to 0$, the lemma implies that
$$
\lim_{\epsilon \to 0} \lim_{i \to \infty} \|f - \eta_\epsilon * g_i\|_\infty \to 0.
$$
Since $f$ and $\eta_\epsilon * g_i$ are both bounded, for every continuous $\phi: \mathbb{R} \to \mathbb{R}$ we have
$$
\lim_{\epsilon \to 0} \lim_{i \to \infty} \int \phi(\eta_\epsilon * g) = \int \phi(f).
$$
Finally, if $\phi$ is a convex function (like the square root) then convolution with $\eta_\epsilon$ is an averaging operation and so Jensen's inequality implies $\phi(\eta_\epsilon * g) \ge \eta_\epsilon * \phi(g)$. So
$$
\int \phi(\eta_\epsilon * g_i) \ge \int \eta_\epsilon * \phi(g_i) = \int \phi(g_i)
$$
for every $\epsilon$ and every $i$.


How can I parent a rig to another rig?

Question: I have a rigged object that I'd like one of my characters, who is also rigged, to be holding even as his arms move. How can I attach this object to his hand?
Answer: When animating a character they may need to pick up objects and move them around. The ChildOf constraint is useful for this. The advantage of using the ChildOf constraint is that you can animate the influence to allow the character to pick up and put down the object.
As you can specify an armature and bone to parent to you can also parent different object bones to different character bones, allowing you to have the character hold a piece in each hand and stretch them, or hold the doll body in one hand and lift the doll arm in the other.
Answer: If I got what you want, you could use a copy location constraint on the "held" armature, to one of the other bones, like:
Answer:
First position the "held" rig to a bone in the "holding hand". This can be done by selecting a bone in the hand in edit-mode and pressing Shift S and choosing "Cursor to selected", then selecting the other rig in object-mode and pressing Shift S and choose "Object to cursor".

2.In pose-mode right-click on the rig that's to be held and then, holding Shift right-click the other rig. Still holding Shift, Right-click on same bone you postioned the cursor to before. Press Control-P and and choose "Bone" to parent the the second rig to the first.

How can I parent a rig to another rig?


Did Jesus promise Judas a powerful position in the future kingdom of God?

Question: Jesus told his disciples that, in the new Kingdom of God, they would sit upon twelve thrones judging the twelve tribes of Israel. Matthew 19:28, Luke 22:30. Didn't Jesus know that Judas was going to betray him.  So did Jesus offer a throne to Judas?  If so why?
Comment: Matthew 19:28 reads *you who have followed me*, and Luke 22:30 has *those who have stood by me in my trials*; not sure how Judas would qualify for any.
Comment: Welcome to Christianity SE and thank you for your contribution. When you get a chance, please take the [tour] to understand how the site works and [how it is different than others](https://christianity.meta.stackexchange.com/a/1809/50259).
Comment: @Lucian You should make an answer from that.
Answer: Judas was posthumously voted off the Apostle Island:

"For," said Peter, "it is written in the Book of Psalms: "'May his place be deserted; let there be no one to dwell in it,' and, "'May another take his place of leadership.'

So, no even though he was promised something he didn't get it. It's also worth remembering that Jesus is speaking to you and I in Scripture. Some would read that, in a sense, He offers us the same kingship if we are faithful.
Comment: That episode was a cliff hanger!
Comment: Did St.Peter made a wrong judgment or reading of this passage in Psalm? Jesus was clear on Acts1:8 before that passage, "The Holy Spirit will give you power"...The Holy Spirit has not yet come, but Peter and the Apostles already chosen & lay hands on Matthias? This is too soon, that's why, Peter & Apostles must act only upon invoking the assistance of the Holy Spirit. Why? St.Paul is the twelfth Apostle not Matthias..
Answer: Jesus did know that he was going to be betrayed and by whom.

While I was with them, I protected them and kept them safe by that name you gave me. None has been lost except the one doomed to destruction so that Scripture would be fulfilled. John 17:12

God is a gracious God and is called Saviour many times. This is obviously distinct from Jesus being called saviour also. We could rightly say they are 'co-saviours' as each could not save on their own. God needed Jesus to die, Jesus needed God to accomplish his mission.
It is this grace in which He called Saul - the chief persecutor of the church and made him a pre-eminent Apostle!

For you have heard of my previous way of life in Judaism, how intensely I persecuted the church of God and tried to destroy it. Gal 1:13

The grace of our Lord was poured out on me abundantly, along with the faith and love that are in Christ Jesus. 1Tim 1:14

Judas had a pre-determined role to fill and this he did - according to the plan of God put in place eons ago. Being 'doomed to destruction' does not have to be an eternal penalty, but for this age alone.
We cannot presume to judge Judas by our standards of corrupt men and somehow rule him out of salvation - Jesus did die for all - Judas included. If there is a place for him - it is not clearly stated there is, just an inference, then that is for God to decide.
Comment: Great answer, If that passage in John17:12 refers to Judas as doomed, then,Jesus callng him a "friend" is the key why Jesus paid aleady the betrayal of Judas, and Jesus can save him even in hell. Judas, was indeed saved, and included in the salvation plan.
Comment: The son of perdition is the only one, of all the Father gave him, that was lost.  Lost. in this context, is over against "all thine are mine and all mine are thine...that they may be one as we are one".  Judas was not in Christ when he died.
Comment: You can only say that because you misunderstand the plan of salvation God has provided. The absurd idea of eternal suffering and associated theories have totally hidden the truth on this matter. God knows the cause of evil and He is fully capable of dealing with it without making it man's fault.
Answer: Did Jesus promise Judas a powerful position in the future kingdom of God?
There was no passage on the bible that can support this question.
Judas was one of the chosen Apostles, but Judas did not made an "oath" during the Last Supper. The oath is like a Priest or Bishop receiving the full ordination from the hand of Jesus, consecrating them as a Bishop. Judas left the scene early, and did not made an oath to Jesus Christ.

In the Gospel of John, after the departure of Judas from the Last Supper, Jesus tells his remaining disciples [John 13:33] that he will be with them for only a short time, then gives them a New Commandment, stating:[28][29] "A new command I give you: Love one another. As I have loved you, so you must love one another. By this everyone will know that you are my disciples, if you love one another." in John 13:34–35. Two similar statements also appear later in John 15:12: "My command is this: Love each other as I have loved you", and John 15:17: "This is my command: Love each other."[29]

At the Last Supper in the Gospel of John, Jesus gives an extended sermon to his disciples.[John 14–16] This discourse resembles farewell speeches called testaments, in which a father or religious leader, often on the deathbed, leaves instructions for his children or followers.[30]

This sermon is referred to as the Farewell discourse of Jesus, and has historically been considered a source of Christian doctrine, particularly on the subject of Christology. John 17:1–26 is generally known as the Farewell Prayer or the High Priestly Prayer, given that it is an intercession for the coming Church.[31] The prayer begins with Jesus's petition for his glorification by the Father, given that completion of his work and continues to an intercession for the success of the works of his disciples and the community of his followers.[31]

https://en.wikipedia.org/wiki/Last_Supper
The departure of Judas is the key, why he cannot be consider a full pledged Apostle or a consecrated Bishop. And cannot be one of the Twelve described in the above passage. But Judas is definitely no longer in hell, after Jesus went in hell to preach the gospel. And the Catholic Church never teaches Judas was in hell, and if anyone or Catholic says, Judas is in hell, is a heretic according to one Archbishop.
https://catholicism.org/archbishop-paglia-says-its-heresy-to-say-judas-is-in-hell.html
In support of Ab.Paglia statement, this simple but realistic question is the key.Remember Judas is a friend of Jesus and Judas followed what Jesus commanded him to do on that night of betrayal.Jesus said to Judas, "go do it quickly.." and Judas obeyed..
"If you were Judas, and you saw Jesus in hell, offering salvation or the infinite mercy of God, to anyone who will believe He is the Messiah, will you accept Jesus offering salvation, after feeling the pain of being in prison?"
The answer If I were Judas is, Judas would definitely say to Jesus, "My Lord and my God, now I believe you are the Messiah, Son of the Living God, please forgive me.."
And one more thing, Judas is not the Son of Perdition either in the passage below;
St.Paul is not pointing to Judas as the "Son of Perdition", because it was not yet revealed..
Douay-Rheims Bible

Let no man deceive you by any means, for unless there come a revolt first, and the man of sin be revealed, the son of perdition."-2thessalonian2:3

Judas do not believe Jesus is the "Son of Man". Judas only betrayed Jesus looking unto him as "Rabbi" only.

The Son of Man will go just as it is written about him. But woe to that man who betrays the Son of Man! It would be better for him if he had not been born."

And in the gospel, Judas never profess that Jesus is the "Son of Man", Judas only look upon Jesus as a "Rabbi" and not the "Son of Man". Therefore, Judas may be "doomed" and cast down to hell or lost, but Judas was never the "Son of Perdition", because Jesus have a saving plan for all of his friends, including Judas.

Greater love has no one than this, that he lay down his life for his friends. 14You are My friends if you do what I command you..(John15:13-14)

And Judas is a friend of Jesus, and Judas followed what Jesus had commanded in him, on the night of betrayal.
Judas left the scene, and did not profess an oath, and was not consecrated as Bishop during the Last Supper.
Comment: Might there be two entitled the son of perdition, much like God calling Ezekiel "son of man" and Jesus calling himself "son of man".  It's pretty hard to not understand Judas in John 17:12.
Comment: @MikeBorden Not pretty hard, esp, after Ab. Paglia stated, " In the Catholic Church, if anyone said, Judas is in hell, he is a heretic." Therefore, Judas is not the son of perdition, because, the Church is certain now, Judas is not in hell, the real hell of the damned souls.
Comment: The son of perdition in John 17:12 was lost **while Jesus was with them in the world**.  The son of perdition in 2 Thess. 2:3 appears on the scene **in the latter days, long after Jesus ascended**.  They cannot be the same and, in John 17:12 *lost* is over against *kept* (not lost).


Can $A^2+B^2+C^2-2AB-2AC-2BC$ be a perfect square?

Question: I have come upon the trivariate polynomial $A^2+B^2+C^2-2AB-2AC-2BC$ and want to factor it.  Because of the symmetry, I am wondering if it can be a perfect square or if there is some other nice factorization.
Comment: "if it can be a perfect square" - maybe for some values of A, B, and C... ; "...if there is some other nice factorization." - I don't see any; the cross terms are troublesome.
Comment: Have you considered $ABC = 0$?
Comment: You can always factor it by considering it as a polynomial in one of the variables, but the resulting factorization isn't exactly nice; for instance, with respect to $A$,

$$\left(A-\left(B+C+2\sqrt{BC})\right)\right)\left(A-\left(B+C-2\sqrt{BC})\right)\right)\;.$$
Answer: As is noted in other comments and answer, the symmetry is a little illusory because of the signs. This is probably less than you were hoping for, but or any integral choice of $B$ and $C$, you can find an integer $A$ which makes the expression a perfect square. Just take $A = 2(B+C)$, and the expression equates to $(B-C)^2$.
Answer: $$
\begin{align}
& \left(\sqrt{a}+\sqrt{b}+\sqrt{c}\right)\left(-\sqrt{a}+\sqrt{b}+\sqrt{c}\right)\left(\sqrt{a}-\sqrt{b}+\sqrt{c}\right)\left(\sqrt{a}+\sqrt{b}-\sqrt{c}\right) \\
&  = 2ab+2ac+2bc -a^2 - b^2 - c^2.
\end{align}
$$
Comment: This is the right answer! Please upvote this answer.
Answer: A more symmetric factorization would be:
$$A^2 + B^2 + C^2 - 2AB -2AC - 2BC =$$
$$(A + B + C)^2 - 4AB - 4AC - 4BC =$$
$$(A + B + C - 2 \sqrt{AB + AC + BC}) (A + B + C + 2 \sqrt{AB + AC + BC})$$
if
$$AB + AC + BC \ge 0$$
Answer: You can use Wolfram Alpha to get some alternative forms
The first two listed are
$$(A-B-C)^2-4BC$$
$$A^2-2A(B+C)+(B-C)^2$$
As J.M. says, it will all depend on the value of $A,B$ and $C$


Is it more efficient to drive with the windows down or the AC on?

Question: When driving, is it more efficient (in terms of gas consumed) to use the air conditioner, or to drive with all of the windows down? While the air conditioner reduces efficiency through drag on the engine, driving with the windows down increases air drag on the car. I know this problem could be easily solved with a better knowledge of how both of these systems worked, but I can't seem to find hard numbers to support it.
Answer: This depends on driving conditions, mainly speed and temperature.

AC fuel consumption increases with temperature
fuel consumption due to open windows increases with speed

The SAE found that AC is more efficient at highway speeds.
Modern cars incorporate tricks to reduce AC fuel consumption: the AC compressor is preferentially engaged when you're slowing down and disengaged when accelerating, for instance. Using an electric motor to power the compressor can reduce losses too.
Answer: TL DR: Windows down w/o AC nets better fuel mileage.
There was an episode of Mythbusters which covered this subject. They found windows down without A/C will run significantly further than will a comparable vehicle with the A/C on and windows up. Here's a writeup from the Discovery site which talks about it:

With five gallons of gasoline in each tank, the MythBusters saddled up their SUVs and circled Northern California's Altamont Raceway at 45 miles (72 kilometers) per hour to see which one ran out of fuel first. Before starting their engines, Jamie cranked up the AC, Adam rolled down his windows, and the pair set off on their race to nowhere.
In the end, Jamie's air-conditioned SUV stopped first, while Adam's window-cooled car ran for 15 miles (24 kilometers) more. Since rolling down the windows sustained Adam's SUV for a significantly longer distance, the MythBusters busted the expert advice.

Here's the video segment of the episode.
Mind you, there are naysayers out there who didn't like how this was tested and the result.
All-in-all I didn't have any huge issues with the testing results from Mythbusters, mainly because I believe there was equal amounts of gas used in both vehicles and they were fairly evenly matched. Then, after the testing was complete, there's a huge difference in what each vehicle traveled. The difference is non-trivial: it is significant.
Comment: Mythbusters' testing was limited to low speeds (45/55 mph). In my car, driving with all 4 windows down, turbulence (and as a consequence, drag) rapidly rises from ok to very uncomfortable when accelerating through that speed range. So we might both be right: open windows use less fuels at low speeds, AC is more efficient at high speeds.
Comment: @Hobbes -  Could be. The OP was asking for objective data, so I provided.
Comment: interesting both SAE (above post) and mythbusters used big suv's / v8 sedans.  Do the experiment with something highly fuel efficient and aerodynamic and I expect you will see far more sensitivity and so convincing results.
Comment: @agentp - You should roll out there and do that ... I'd definitely be interested in the results!


Does completeness of $X/Y$ imply completeness of $X$?

Question: Does completeness of $X/Y$ imply completeness of $X$ ? Where $X$ is normed space and $Y$ closed inifinty dimensional subspace of $X$. I tried take $c_{00}$ (space of the finite sequence with supremum norm) and for the subspace every sequence that have $0$ on the first coordinate but I can't prove that this quotient space is complete.
Answer: Indeed, you can construct a counterexample with $c_{00}$.
Equip $c_{00}$ with any $\|\cdot\|_p$ norm and let $Y = \{(x_n)_n \in c_{00} : x_1 = 0\}$. Then $Y$ is the kernel of the bounded linear functional $f : c_{00} \to \mathbb{C}$, given by $f(x_n)_n = x_1$. Hence $Y$ is closed in $c_{00}$ and the induced map $\tilde{f} : c_{00}/Y \to \mathbb{C}$ given by $\tilde{f}((x_n)_n + Y) = x_1$ is an isometric isomorphism.
So $c_{00}/Y \cong \mathbb{C}$, which is finite-dimensional and hence Banach.

The statement is true if $Y$ itself assumed to be complete.
Let $(x_n)_n$ be a Cauchy sequence in $X$. Then
$$\|(x_m+Y) - (x_n+Y)\| = \|(x_m - x_n) + Y\| \le \|x_m-x_n\|$$
so $(x_n + M)_n$ is a Cauchy sequence in $X/Y$ so it converges to an element $x + M$.
We have $\|(x_n -x) + M\| = \|(x_n+M) - (x + M)\| \to 0$ so for every $n \in \mathbb{N}$ there exists $p(n) \in \mathbb{N}$ and $y_n \in Y$ such that
$$\|x_{p(n)} + y_n - x\| < \frac1n$$
Notice that $(y_n)_n$ is Cauchy in $Y$
$$\|y_m-y_n\| \le \|y_m - x_{p(m)} - x\| + \|x-x_{p(n)} - y_n\| + \|x_{p(m)} - x_{p(n)}\| \xrightarrow{m,n\to\infty} 0$$
so it converges to an element $y \in Y$.
$$\|x_{p(m)} + y - x\| \le \|x_{p(m)} + y_n - x\| + \|y - y_n\| \xrightarrow{n\to\infty} 0$$
so $(x_{p(n)})_n$ converges to $x-y$. Since $(x_n)_n$ is Cauchy, it also converges to $x-y$.


Mail Question Advice sought

Question: Okay this is somewhat complicated to explain. Long story short I'm divorced. My ex-wife had kids from previous marriage. Both her and the kids' dad reside at the same address. They've both encouraged me to stay involved and write to the kids which I have.  Now my ex-wife doesn't want me to do so anymore but the kids' dad is fine with me doing so.......So I sent a letter specifically addressed to the kids' father and the kids and she told me she took it and threw it away......What do I do in this situation.
Comment: Your ex-wife may have violated federal law by doing that, as outlined in user6726's answer.  Your specific course of action, however, probably depends on the terms of your divorce, in particular child custody arrangements.  If she has violated those, you should probably start by pointing it out to her, and, if necessary, take it up with your divorce lawyer or the courts.
Answer: The only legal answer pertains to federal law about interfering with the mail. Most federal law pertains to taking of mail from mailmen, postal drop-boxes and the like. When it is delivered, it can go into a "letterbox", or a door slot. There is apparently no statutory definition of "letterbox", but it is interpreted or explained by the USPS here.

Except as excluded by 1.2, every letterbox or other receptacle
  intended or used for the receipt or delivery of mail on any city
  delivery route, rural delivery route, highway contract route, or other
  mail route is designated an authorized depository for mail within the
  meaning of 18 USC 1702, 1705, 1708, and 1725.

The crime Obstruction of Correspondence 18 USC 1702 says

Whoever takes any letter, postal card, or package out of any post
  office or any authorized depository for mail matter, or from any
  letter or mail carrier, or which has been in any post office or
  authorized depository, or in the custody of any letter or mail
  carrier, before it has been delivered to the person to whom it was
  directed, with design to obstruct the correspondence, or to pry into
  the business or secrets of another, or opens, secretes, embezzles, or
  destroys the same, shall be fined under this title or imprisoned not
  more than five years, or both.

If a letter is addressed to some other person and not you, then you are not the person to whom it was directed. This does not mean you have to sort the mail and take only your from the box, but you cannot take it with design to obstruct the correspondence. Assuming that the mail-disposer does not confess, you would have to establish (in court, not just persuade yourself) that the letter was received, and not by the addressee. Certified mail provides you with the signature of the person who receives is (forging the signature would be a crime as well).
This is not necessarily applicable to letters sent only to the children (assuming they are minors, and she has custody exclusive) – the clear crime would be obstructing correspondence with the father. Custodial parents have broad discretion with respect to their minor children, so she could well be entitled to filter her children's mail. The divorce agreement would be highly relevant in this case.
Comment: The mail disposer confessed to the sender that "she took it and threw it away."  But what about the terms of the divorce?  There might be a civil remedy.

Mail Question Advice sought


WPF DataGrid multiselect binding

Question: I have a datagrid that is multi-select enabled. I need to change the selection in the viewmodel. However, the SelectedItems property is read only and can't be directly bound to a property in the viewmodel. So how do I signal to the view that the selection has changed?
Comment: See also http://stackoverflow.com/questions/1579700/wpf-toolkit-datagrid-multi-select-how-to-get-selecteditems-out
Answer: Andy is correct. DataGridRow.IsSelected is a Dependency Property that can be databound to control selection from the ViewModel. The following sample code demonstrates this:
<Window x:Class="DataGridMultiSelectSample.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:tk="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
    Title="Window1" Height="300" Width="300">
    <StackPanel>
        <tk:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding}" EnableRowVirtualization="False">
            <tk:DataGrid.Columns>
                <tk:DataGridTextColumn Header="Value" Binding="{Binding Value}" />
            </tk:DataGrid.Columns>
            <tk:DataGrid.RowStyle>

            </tk:DataGrid.RowStyle>
        </tk:DataGrid>
        <Button Content="Select Even" Click="Even_Click" />
        <Button Content="Select Odd" Click="Odd_Click" />
    </StackPanel>
</Window>

using System.ComponentModel;
using System.Windows;

namespace DataGridMultiSelectSample
{
    public partial class Window1
    {
        public Window1()
        {
            InitializeComponent();
            DataContext = new[]
                              {
                                  new MyViewModel {Value = "Able"},
                                  new MyViewModel {Value = "Baker"},
                                  new MyViewModel {Value = "Charlie"},
                                  new MyViewModel {Value = "Dog"},
                                  new MyViewModel {Value = "Fox"},
                              };
        }

        private void Even_Click(object sender, RoutedEventArgs e)
        {
            var array = (MyViewModel[]) DataContext;
            for (int i = 0; i < array.Length; ++i)
                array[i].IsSelected = i%2 == 0;
        }

        private void Odd_Click(object sender, RoutedEventArgs e)
        {
            var array = (MyViewModel[])DataContext;
            for (int i = 0; i < array.Length; ++i)
                array[i].IsSelected = i % 2 == 1;
        }
    }

    public class MyViewModel : INotifyPropertyChanged
    {
        public string Value { get; set; }

        private bool mIsSelected;
        public bool IsSelected
        {
            get { return mIsSelected; }
            set
            {
                if (mIsSelected == value) return;
                mIsSelected = value;
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("IsSelected"));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}

Be sure to set EnableRowVirtualisation="False" on the DataGrid element, else there's a risk that the IsSelected bindings fall out of kilter.
Comment: Perfect. And thanks for the sample code - illustrates it nicely.
Comment: Thanks. Hope you don't mind me adding `EnableRowVirtualisation="False"` to your example, because without it, there's a bug where the binding isn't on new rows.
Answer: I haven't worked with the DataGrid much, but one technique that works for the ListView is to bind to the IsSelected property of the individual ListViewItem. Just set this to true for each object in your list, and then it will get selected.
Maybe the object that represents a row in the DataGrid also has an IsSelected property, and can be used in this way as well?
Answer: Guys, thanks for the help. My problem was solved. I think the problem is pretty common for new WPF developers, so I will restate my problem and as well as the solution in more details here just in case someone else runs into the same kind of problems.
The problem: I have a multi-select enabled datagrid of audio files. The grid has multiple column headers. The user can multi-select several row. When he clicks the Play button, the audio files will be played in the order of one the columns headers (say column A). When playback starts, the multi-select is cleared and only the currently playing file is highlighted. When playback is finished for all files, the multi-selection will be re-displayed. The playback is done in the viewmodel. As you can see, there are two problems here: 1) how to select the currently playing file from the viewmodel, and 2) how to signal to the view from the viewmodel that playback is finished and re-display the multi-selection.
The solution: To solve the first problem, I created a property in the viewmodel that is bound to the view's SelectedIndex property to select the currently playing file. To solve the second problem, I created a boolean property in the view model to indicate playback is finished. In the view's code behind, I subscribed the the boolean property's PropertyChanged event. In the event handler, the view's SelectedItems property is re-created from the saved multi-selection (the contents of SelectedItems was saved into a list and SelectedItems was cleared when playback started). At first, I had trouble re-creating SelectedItems. It turned out the problem was due to the fact that re-creation was initiated through a second thread. WPF does not allow that. The solution to this is to use the Dispatcher.Invoke() to let the main thread do the work.  This may be a very simple problem for experienced developers, but for newbies, it's a small challenge. Anyway, a lot of help from different people.
Answer: Just use SelectedItems on any MultiSelector derived class , and use methods Add, Remove, Clear on IList it returns .

WPF DataGrid multiselect binding


Who was Rabbi Matzliach of the Upper Galilee?

Question: In this question, it is brought that three halachic responsa by the Rif, originally written in Arabic, were translated for the Ramah of Fano into Hebrew. The Ramah stated that the translation was done by two rabbis in Venice: Rabbi Matzliach of the Upper Galilee and Rabbi Shlomo Ma'aravi. I suspect that Rabbi Shlomo Ma'aravi is the Rasah, Rabbi Suleiman Ochana, who was also sometimes known as Rabbi Suleiman Ma'aravi, and was one of the students ("cubs") of the Ari. But I don't know who Rabbi Matzliach was. Does anyone have any idea?
Comment: Have you looked in Seder hadroros not by the books now
Comment: @Dr.Shmuel Didn't think about that. I'll check. Thanks!
Comment: So the Seder Hadoros HaKotzair (p.138) has a Rabbi Mazliach bar Eliyahu (aka אבן אל בצאק) who lived at the end of the 10 - early 11th century. From the chachmei Sicily and one of the main talmidim of Rav Hai Gaon and one of the main Rabbonim of the Aruch - does that sound right?
Comment: @Dov Sadly no. The two rabbis appear to have been contemporaries of the Ramah Mipano, and that is indeed the case for the Rasah. But thanks for the interesting info nonetheless.
Comment: Ah okay (15 char)
Answer: The bibliographer/historian Abraham Yaari in his work  שלוחי ארץ ישראל (p. 273),  identifies מצליח מהגליל העליון alternatively as רב מצליח מצפת. He includes him in the chapter on emissaries from Ottoman occupied Israel in the 17th c. and states that he came to Venice. It does not appear to be the case that further biographical information is known about him beyond the fact that R. Menahem Azariah da Fano commissioned him to translate the aforementioned responsa.
Comment: Thank you! (15)
Comment: @Harel13 My pleasure


Site not saving my number of times visited/logged in

Question: I have noticed over the past several weeks that my logins seem to not be registering.  I have visited every day for almost a month trying to work on my consecutive day badge.  And yes, my name is at the top of the screen when I am logged in.  Am I doing something wrong?
Comment: How odd, because it worked fine for you in September and I don't know of any changes to the login that might effect this. I'll have to ask help from the team on this
Answer: Have a look at this Meta.Stackoverflow question

login pages, along with a number of other homepage style pages, don't count as "access"

So simply go look at a question and you should be fine!
Answer: Usually, what gets people is that they're using the site every day in local time. But consecutive days count UTC days. For example, if you pause between Saturday morning and Sunday late evening and live in America, you've missed Sunday.
Furthermore, there is some limited protection against automatic downloads counting as a visited day. Being active in any way (posting, commenting, voting, …) definitely counts. In between, the SE team has not revealed exactly what counts as a visited day; I believe refreshing the home page (including its images and other content) is sufficient, and browsing one question is definitely sufficient.
Consecutive days are explained in the badge FAQ under "Enthusiast" and "Fanatic".
Answer: From what I read about this on Meta, for the consecutive day count it's not enough to only login, you also need some minimum level of activity.
I guess accessing a question should usually be enough: that should count as access to an internal page.
Comment: You don't have to ask a question or anything like that.  I log into travel every day and don't ask a question and it has been fine for the past 80 days.  I log in and browse the questions but it is not counting my days in a row.


Pepper tree has dying parts

Question: I can't seem to attach a picture because it's too large but I have a multi-trunk pepper tree that has been beautiful for years. All of a sudden I'm noticing the tops of the branches on the right side are dying. The rest of the tree looks beautiful. It's only dying at the top. It's beautiful on the trunk and the bottom because I have a lot of shoots coming from the bottom of the trunk.
It looks like it's dying from the top down on these branches which are all off of one of the trunks. What could be causing this? I live in Gilbert Arizona and it's been really warm here in the 80s to 90s so it's not because of cold.
Comment: Take a screenshot of the photo and then try uploading.
Comment: I once had problems uploading pictures on the site for the same reason. Then someone told me that Whatsapp automatically compresses the picture to a manageable size. If you don't have a file converter, try to send the photo via whatsapp to one of your contacts and have him/her send it back to you. The new image will be small enough for uploading.
Answer: If you mean a Schinus variety (usually commonly called pepper tree), how old is it? 30 years is considered  a long life span for these trees - they are not particularly long lived, so it might just be its simply old.
Otherwise, die back in parts might be indicative of a problem of some sort at the root, if the dying part has no other evidence of a problem, such as insect infestation or obvious infection with fungal disease. Inspect the tree thoroughly, examining backs of leaves and woody parts for any signs of infection or infestation or fungal growth such as shelf or bracket fungus. You will need to remove the dead parts if they're completely dead, if possible.

Pepper tree has dying parts


Stopping div/container size changing with scroll bar?

Question: Hi everyone! First time posting on stackoverflow.
I was wondering if there was a way/how to stop the size of a container shifting when a scrollbar is added to it
like, if I take a div and slap overflow-y:scroll; into its style, it adds a nice and nifty scrollbar, but aligns all the dynamically positioning content inside of it to the left a little bit because the scrollbar changes the actual size of the content area?
I'm not great with web dev vocabulary, but I hope you understand what I mean.
I found that on iOS, adding overflow-y:scroll; also doesn't physically add a scroll bar and doesn't change the size of the container; all of the stuff inside of it stays centered
But if I add a scroll bar to a div with items inside of it positioned to a relative percentage, the size of the container will change and therefore all the content will move
tl;dr how do I keep my stuff in the dead center even after I add a scroll bar
I was thinking making it statically positioned but I want the horizontal height to stay relative
can I specify a static position for the x but not the y?
thanks.
Comment: Can't you make the div wider when you add the scroll bar?
Answer: you can use overflow-y:hidden;
Comment: That hides the scroll bar.  Not what the OP asked for.


Splitting a stringstream that contains comma separated entries

Question: I have two strings that look as follows:
string text1 = "you,are,good";
string text2 = "1,2,3,4,5";
stringstream t1(text1);
stringstream t2(text2);

I'm using the following code to to parse it as comma separated data
template <typename T>
std::istream &operator>>(std::istream &is, Array<T> &t)
{
    T i;
    while (is >> i)
    {
        t.push_back(i);

        if (is.peek() == ',')
            is.ignore();
    }
    return is;
}

where "is" is t1 or t2. This separates text2 but fails with text1. Could you guys please help me with that and tell me why it doesn't work with strings?
I need a general code that would parse strings and numbers.
Thanks for any efforts :)
Answer: If you need to split the string exactly at commas, the easiest approach I'm aware off is to redefine the meaning of space for a stream. This is done easily replacing the std::ctype<char> facet. Here is a version of this which I posted before...
#include <iostream>
#include <iterator>
#include <string>
#include <set>
#include <algorithm>

using namespace std;

typedef string T; // to simplify, always consider T as string

template<typename input_iterator>
void do_something(const input_iterator& first, const input_iterator& last) {
    const ostream_iterator<T> os(cout, "\n");
    const set<T> words(first, last);
    copy(words.begin(), words.end(), os);
}

#include <locale>
template <char S0, char S1>
struct commactype_base {
    commactype_base(): table_() {
        std::transform(std::ctype<char>::classic_table(),
                       std::ctype<char>::classic_table() + std::ctype<char>::table_size,
                       this->table_,
                       [](std::ctype_base::mask m) -> std::ctype_base::mask {
                           return m & ~(std::ctype_base::space);
                       });
        this->table_[static_cast<unsigned char>(S0)] |= std::ctype_base::space;
        this->table_[static_cast<unsigned char>(S1)] |= std::ctype_base::space;
    }
    std::ctype<char>::mask table_[std::ctype<char>::table_size];
    static std::ctype_base::mask clear_space(std::ctype_base::mask m) {
        return m & ~(std::ctype_base::space);
    }
};
template <char S0, char S1 = S0>
struct ctype:
    commactype_base<S0, S1>,
    std::ctype<char>
{
    ctype(): std::ctype<char>(this->table_, false) {}
};

int main() {
    std::cin.imbue(std::locale(std::locale(), new ::ctype<',', '\n'>));
    const istream_iterator<T> is(cin), eof;
    do_something(is, eof);
    return 0;
}

Comment: Sure. you could either set up the stream using the locale as above or you could deal with strings specifically. The things is that reading a string stops when the stream finds a space. Since your input doesn't contain any spaces, it is necessary to turn commas to be considered spaces (or somehow deal with strings differently).
Answer: The istream >> operator when applied to a string discards the eventual initial spaces and reads up to the first "space".
It works the same for whatever type (including int). It works in your code because at the ',' the "int reader" fails, and assumes the following is something else.
The simplest way to read comma separated strings is using the std::getline function, giving a ',' as a separator.
In your case, your template function
template <typename T>
std::istream &operator>>(std::istream &is, Array<T> &t)
{ ...... }

remains valid, but requires a specialization
std::istream &operator>>(std::istream &is, Array<std::string> &t)
{
    std::string r;
    while(std::getline(is,r,','))
        t.push_back(r);
    return is;
}