"User Friendly" .net compatible Regex/Text matching tools?

Question: Currently in our software we provide a hook where we call a DLL built by our clients to parse information out of documents we are processing (the DLL takes in some text (or a file) and returns a list of name/value pairs).
e.g. We're given a Word doc or Text file to Archive. We do various things to the file, and call a DLL that will return "pertinent" information about the file. Among other things we store that "pertinent" data for posterity.
What is considered "pertinent" depends on the client and the type of the document, we don't care, we get it and store it.
I've been asked to develop a user friendly "something" that will allow a non-programmer user to "configure" how to get this data from a plain text document (<humor>The user story ends with the helpful suggestion/query "We could use regex for this?"</humor>)
It's safe to assume that a list of regex's isn't going to cut this, I've written some of these parsers for customers, the regex's to do these would be hedious and some of them can't be done by regex's. Also one of the requirements above is "user friendly" which negates anything that has users seeing or editing regex expressions.
As you can guess, I don't have a fortune of time to do this, and am wondering is there anything out there that I can plug in to our app that has a nice front end and does exactly what I need? :)
No? Whadiyamean no! . . . sigh
Ok then failing that, anything out there that "visually" builds regex's and/or other pattern matching expressions, and then allows one to run those expressions against some text?
The MS BRE will do what I want, but I need something prettier that looks less like code.
Thanks guys,
Answer: Have you looked into Expresso? It can "visually" build a regular expression and explain it, but the users will still need to understand some basic regular expressions. It is also .NET-centric and can export code (and I think even DLLs) for your regexes.
I find it extremely "user friendly", but then again, I'm a programmer. ;) I also think that regular expressions just are not "user friendly" almost by their nature.
Comment: I hear ya, 'regular expressions' aren't a requirement in this, they are - possibly - a means to an end :)


Wordpress Custom Post Thumbnail Not Showing On Homepage

Question: This is NOT a question about the featured image meta field. I've tried to find an answer but every search I've tried shows people trying to add the 'featured image' meta to their custom post type. I have that enabled for my theme and my custom-post type. It seems to work just fine. I've set a 'featured image' and I see it when I edit the post. My theme is a custom child of twentyeleven.
On my homepage I'm displaying recent entries (both 'post' type and 'custom-post' type) with the title, an excerpt, and a thumbnail to the left. The thumbnail is displaying properly for all my 'post' types, but not for my 'custom-post' type. I'm not sure where I need to look or what I need to add to get custom-post to show the thumbnail.
Adding Code:
This is in the 'content.php' from my custom theme. It's mostly appropriated from twentyeleven but I think I've made some minor changes. As far as I can tell the 'if' isn't proving true for the custom post type.

      $thumbnails = get_posts('numberposts=5');
      foreach ($thumbnails as $thumbnail) {
        if ( has_post_thumbnail($thumbnail->ID) && $thumbnail->ID == $id) {
          echo 'ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';                 echo get_the_post_thumbnail( $id, 'thumbnail', array('class' => 'alignleft') );
          echo '';
        }
      }

Update:
The problem looks like it's related to

    $thumbnails = get_posts('numberposts=5');

It's only pulling from the 'post' type so it can't check against my 'custom-post' type. I get the correct thumbnail when I change the code as follows, but then none of the 'post' thumbnails work.

    $args = array(
        'numberposts'     => 5,
        'post_type'       => 'pnw_picture-post');

      $thumbnails = get_posts($args);

So I guess the solution is to pull both of those types in a single query.
Answer: Can you post the code that you are using that you think should be returning the post thumbnail?
You may just be looking for the_post_thumbnail from the WP Codex
Answer: I took a closer look at the twentyeleven content.php - It looks like whatever I put in my child content.php is completely different. I hadn't realized I had changed so much of the code.
This is the modified working code to pull in both post types:

    $args = array(
        'numberposts'     => 5,
        'post_type' => array ( 'post', 'custom-post'));

      $thumbnails = get_posts($args);

      foreach ($thumbnails as $thumbnail) {
        if ( has_post_thumbnail($thumbnail->ID) && $thumbnail->ID == $id) {
          echo 'ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';                 echo get_the_post_thumbnail( $id, 'thumbnail', array('class' => 'alignleft') );
          echo '';
        }
      }


Virial theorem and the energy in a gas

Question: I clearly am interpreting the Virial Theorem incorrectly, but I don't know how. In dipole gases, the molecules can exhibit five kinetic modes, while they can only experience 2 potential modes. Doesn't the Virial Theorem say the two must have an equal distribution of energy?
Comment: No, there is less energy per each mode so that the relation between total kinetic and potential energy is still given by the virial theorem. For energy per mode see equipartition theorem.
Comment: Are you certain? I was taught that there are the $3*(1/2)KT$ Joules of of KE, then a set of $2*(1/2)KT$ kinetic Joules from rotations and another set for potential within the bond. Upon rereading the Virial Theorem, it says that N particles held by a potential, so might it be that the potential only "sees" the rotational kinetic? I'm confused.
Comment: I don't understand your concern. Could you please elaborate?
Comment: Don't dipole gases have an unequal distribution of energy? 5/7 kinetic?
Comment: Since when? Can you provide a reference? Are you confusing modes and expectation values?
Comment: Probably, I thought since there were more modes there would be more kinetic energy.
Comment: Yes, you're right. I don't think we understand each other. It would help if you were to write down the Hamiltonian.
Answer: The Virial Theorem does not require an equal distribution of energy amongst the kinetic and potential modes.  It doesn't even require an equal distribution of energy amongst the kinetic or potential modes!  Kinetic energy tends to surround wherever potential energy used to be, kind of.
Answer: The short answer is that the motion of a diatomic gas is not periodic, so the virial theorem does not apply. Let's see exactly what is going on.
In fact, let's consider the even simpler case of a monatomic ideal gas. Here there is also an apparent contradiction, because there is kinetic energy but no potential energy, while you would say the virial theorem implies energy should be evenly distributed amoung kinetic and potential.
$\newcommand{\v}{\mathbf{v}}\newcommand{\s}{\boldsymbol{\sigma}}\newcommand{\r}{\mathbf{r}}\newcommand{\f}{\mathbf{f}}$
To discover the source of the contradiction, let's look at what the virial theorem says. The virial theorem comes from the observation that for a periodic system, things look the same after a very long time. This means that there can't be a net flow of momentum in the long run. The flow of momentum, which I will call momentum current is the sum of two pieces. The first piece is just caused by moving objects carrying momentum along with them. This piece is given by $\rho \v \otimes \v$, where $\rho$ is the mass density and $\v$ is the velocity field. The other way momentum can flow is to be transferred by forces. The second piece of the momentum current is (minus) the stress, $\s$. The net flow of momentum can be measured by the spatial integral of the momentum current, $\int_\textrm{space} \ \  \rho \v \otimes \v - \s d \r$. Now since we know that there can be no net flow of momentum in the long term, the statement of the virial theorem becomes $\langle \int_\textrm{space} \ \  \rho \v \otimes \v - \s d \r \rangle = 0$, where $\langle \cdots \rangle$ denotes a time average.
We can rewrite the virial theorem as $\langle \int_\textrm{space} \ \  \rho \v \otimes \v  d \r \rangle = \langle \int_\textrm{space} \ \   \s d \r \rangle$. Next notice that $\int_\textrm{space} \ \ \sigma_{ij} \ d \r = \int_\textrm{space} \ \ \sigma_{ik} \partial_k r_j \ d \r =  \int_\textrm{space} \ \ \partial_k \sigma_{ik}  r_j \ d \r - \int_\textrm{space} \ \r_j \partial_k \sigma_{ik}   \ d \r$. On the right hand side, the first term is a surface term, so it can be ignored. The second term can be transformed using $\partial_k \sigma_{ik} = f_i$, where $f_i$ is the body force per unit volume. Thus we find $\langle \int_\textrm{space} \ \  \rho \v \otimes \v  d \r \rangle = -\langle \int_\textrm{space} \ \   \r \otimes \f d \r \rangle$.
If we have a system of point particles, the virial theorem becomes $\langle \sum_\alpha   m_\alpha \v_\alpha \otimes \v_\alpha  \rangle = -\langle \sum_\alpha   \r_\alpha \otimes \f_\alpha \rangle$, where $\alpha$ indexes over all particles. Taking the trace, we get $\langle \sum_\alpha   m_\alpha \v_\alpha \cdot \v_\alpha  \rangle = -\langle \sum_\alpha   \r_\alpha \cdot \f_\alpha \rangle$, and finally identifying $\sum_\alpha   m_\alpha \v_\alpha \cdot \v_\alpha$ with twice the kinetic energy, $2T$, we get $2T = -\langle \sum_\alpha   \r_\alpha \cdot \f_\alpha \rangle$. Now the right hand side of this equation can be related to the potential energy for power law forces, and for a harmonic force, you get that potential and kinetic energies are equal.
So in summary, we saw that for periodic systems there is no net momentum current, so the "kinetic" piece $\rho \v \otimes \v$ must cancel the stress piece $-\s$. Doing in integration by parts, we were able to relate the $-\s$ piece to $\r \f$, which we then related to potential energy, and thus we basically got that kinetic energy was equal to potential energy up to some factor.
Now the reason that our monatomic gases don't satisfy the virial theorem is that the atoms just go in straight lines. Therefore the system is not periodic and there is no stress piece to balance the kinetic piece. Therefore we shouldn't expect there to be a potential energy.
Now what about the more complicated case of a diatomic gas? Consider first a single molecule. It's center of mass will just move in a straight line and so its motion is not periodic. But if we look in the center of mass frame, then the motion is periodic, and in the case of a harmonic potential, we find the kinetic energy must be equal to the potential. Now boosting back to the lab frame we get our three unbalanced translational modes back. So we have three translational plus two rotational kinetic modes, giving us $\frac{5}{2} kT$ of kinetic energy. On the other hand, the potential modes only balance out the rotational kinetic modes, so we still just have $\frac{2}{2} kT$ of potential energy. Since energies just sum, this same analysis works a whole gas of molecules.

Virial theorem and the energy in a gas


Generating Functions To Deal With

Question: I've been working on producing a closed-form generating function for the
coefficients $a_n = \binom{n}{2}.$ I was wondering what might be a good
procedure to start on this. I get that
$$\sum_{n=0}^{\infty} x^n = x^0 + x^1 + x^2 + ... = \frac{1}{1-x}$$
by the convergence of geometric series. However, I'm wondering what might be
the proper steps to get LHS to look like $\sum_{n=0}^{\infty} \binom{n}{2}x^n.$
Unfortunately, I have a general lack of familiarity with discrete math, so any
help would be greatly appreciated.
Answer: Differentiate term-by-term twice:
$$
\begin{aligned}
\frac{d}{dx} \sum_{n=0}^\infty x^n
&= \sum_{n=1}^\infty n x^{n-1} \\
\frac{d^2}{dx^2} \sum_{n=0}^\infty x^n
&= \sum_{n=2}^\infty n(n-1) x^{n-2}.
\end{aligned}
$$
Next, since $a_n = \binom{n}{2} = \frac{n(n-1)}{2}$ and $a_0 = a_1 = 0$, we have
$$
\begin{aligned}
\sum_{n=0}^\infty a_n x^n
&= a_0 + a_1 x + \sum_{n=2}^\infty \frac{n (n - 1)}{2} x^n \\
&= \frac{x^2}{2} \sum_{n=2}^\infty n (n-1) x^{n-2} \\
&= \frac{x^2}{2} \frac{d^2}{dx^2} \sum_{n=0}^\infty x^n \\
&= \frac{x^2}{2} \frac{d^2}{dx^2} \frac{1}{1-x} \\
&= -\frac{x^2}{\left(1 - x\right)^3}.
\end{aligned}
$$
Answer: You know that $\dbinom{n}{2} = \dfrac{n(n-1)}{2}$.
Start with the geometric series formula: $$\displaystyle\sum_{n = 0}^{\infty}x^n = \dfrac{1}{1-x}.$$
Next, differentiate both sides with respect to $x$: $$\displaystyle\sum_{n = 1}^{\infty}nx^{n-1} = \dfrac{1}{(1-x)^2}.$$
Note that the $n = 0$ term disapears since $x^0 = 1$ is a constant. Now, you got the $n$ factor, but you still need the $n-1$ factor. So differentiate again to get: $$\displaystyle\sum_{n = 2}^{\infty}n(n-1)x^{n-2} = \dfrac{1}{(1-x)^3}.$$
This is almost what you need. Can you figure out how to manipulate both sides to get $$\displaystyle\sum_{n = 0}^{\infty}\dfrac{n(n-1)}{2}x^n = ?$$

Generating Functions To Deal With


Music Sheet - Same note twice on same place

Question: I have seen below highlighted note on one sheetmusic. I am wondering what does it mean. How to play this note in Piano. Why do they mention two tails for same note. if it is same note , there is only one note is required. Please explain the meaning of this note.
Comment: I don't know too much about piano sheets specifically but you can see this pattern often when there are two separate voices on the same staff. It means that both the lower and the higher voice play the same note. The two tails indicate that and make it easier to read each voice separately.
Comment: There have been several questions asking exactly this, and several with very similar thoughts. It is a dupe.
Comment: They are very common in classical guitar, where a fretted note is doubled with an open string.
Answer: I've never seen notes like that before so I searched it and find out what it supossed to mean.
Officially there are names for each part of a note:
https://en.wikipedia.org/wiki/Stem_(music)
This specific, (in this case) doubled part is the stem.
I find some sites describing this note type, but first here is an answer directly from here:
Why does this note have a stem pointing up and another pointing down?
Not stack:
https://www.virtualsheetmusic.com/experts/robert/stemmed-notes/

Sometimes you'll even have double stems with two different rhythms.
  You'll have a half note and a quarter note on the same note. The note
  holds for one line and the next line is going on with faster notes
  while that note is continuing to hold. There's great complexity and
  counter point delineating distinct musical lines. To be able to play
  more than one on one instrument, like you do on the piano, on stringed
  instruments like violin and cello, and guitar, classical guitar, we
  all see these on a regular basis.

I'm glad I find you question because this was really interesting for me as well. I hope I helped :)
Comment: They are very common in classical guitar, where a fretted note is doubled with an open string.


Library to differentiate people by their voice timbre

Question: Say there are 3 people in the room. Each of them have a unique voice timbre. I want to recognize people by their timbre and know who's speaking.
Answer: The task of taking a long contiguous audio recording and splitting it up in chunks in which only one speaker is speaking - without any prior knowledge about the voice characteristics of each speaker - is called "Speaker diarization". You can find links to research code on the wikipedia page.
If you have prior recordings of each voice, and would rather do classification, this is a slightly different problem (Speaker recognition or Speaker identification). Software tools for that are available here (note that general purposes speech recognition packages like Sphinx or HTK are flexible enough to be coaxed into doing that).
Comment: Wow! Thanks for such an extensive answer. I'm interested in doing this live, basically detecting when and who is speaking and maybe writing that to a separate file, or just writing to log when and who spoke.
Comment: Did you find any library which works in real time. I came across IBM Watson Speech Recognition API, but it is not open source.


How to report abuse to website hosting company (GoDaddy)

Question: I'm not sure if this is the right place to ask such a question...
Let's say that a website posted a picture of me, without my consent, and I want to be removed (it's something private, could compromise my career if it's seen by someone that shouldn't). I sent them an email asking nicely that they should remove it, but they didn't respond and the picture is still there.
Using 'Whois' I found that the website is hosted by GoDaddy.
Is there a way (an email address, for ex.) to report to GoDaddy that one of the sites they're hosting does something illegal and to force them to remove the photo? I searched the site and found nothing about such a thing.
Thnaks in advance!
Answer: This is a difficult question. Yes, you can email the hosting provider and request that they take action. But it depends on their terms and conditions. If the website doesn't break the hosting companies terms, then the hosting company doesn't have to do anything. This would then mean you would have to take legal action privately  and take them to court. But then you are faced with the issue that the image in question is in the public domain so therefore can't be removed. There has been a lot of these types of stories in the press, and most of the time the image remains online.
But you must also remember that if you are going to the hosting company saying that the image is illegal, at some point or other they will want to know why it is illegal. If the content of the image is illegal, then you will be in trouble yourself as it is you in the image. If not, then you will have to go to a solicitor.
Also, powers a web host or even you have over websites depends on the country where the server is located. GoDaddy may be an American company but the server with this website on could be in Russia or the UK. So exactly what powers you have on getting the image taken down also changes depending on the country. GoDaddy would be able to tell you this though.
Answer: If they are in the US you can send a DMCA take down request to Godaddy asking them to remove the picture. They will notify the user of the request who can either take it down, respond saying it is not a copyright violation and leave it, or ignore the request at which point Godaddy will take the page down themselves. Keep in mind that that picture probably does not violate any copyrights so this could be seen as an abuse of the DMCA and it also doesn't mean that the picture will come down. But if you really want to get that picture taken down it might be worth trying.
Answer: This is not abuse in the sense that no law has been broken and the activity in question could hardly be described as malicious.
Unless you want to break the law to get the picture taken down, I would recommend that you talk to a lawyer and be prepared for a lengthy and fruitless process.
Once an image is on the web you have no control over it - the real lesson here would be to avoid doing things on camera if you don't want other people to see them and, failing that, don't try to abuse existing processes (or abuse departments) - you're wasting your time if you do.
Comment: "no law has been broken" how do you know? I think we're all assuming the same type of image here, and there are laws in many countries that cover that sort of thing, not to mention if the OP took it themselves, they can leverage copyright law to get it taken offline. Here's one of many court cases involving an unfavourable outcome for someone distributing photos of someone else: http://www.nzherald.co.nz/technology/news/article.cfm?c_id=5&objectid=10688845
Comment: I read "a picture of me" to mean "someone else took it", "without my consent" to mean "whomever took it posted it", and "could compromise my career" to mean "I'm doing something I shouldn't be in this photo" - the asker would (should?) know to talk to the police if any actual laws (i.e. asker is under 18 with someone posting nude photos) have been broken here.
Answer: On Godaddy.com scroll to the bottom and click "legal".  From there locate copyright infringement claims.  They'll explain what you need to include in your claim which you must follow to the letter.  Then email your claim to them using the included email address.  Make sure you include all the information necessary or your claim will be delayed.  Do note that Godaddy.com is very slow at times with responding to claims.  Some of our past claims have taken from 1 day to 2 weeks to get resolved; so start now.  Hope this helps.  Good Luck!
Comment: Agreed.  Making a copyright infringement claim under the DMCA is probably the fastest way to get it taken down.  ISP's are required to respond to such claims in an expeditious manner to maintain their "Safe-Harbor" status.
Answer: You can Report to Godaddy By visiting through this link- https://supportcenter.godaddy.com/abusereport
You should also Request to Google To remove Your Image from Google Search or Images by visiting this link- https://support.google.com/legal/answer/3110420?visit_id=1-636556553238719718-955607050&rd=1
Both Companies will remove your Content FRom Those sites and Godaddy can also take action against that website if they found it against their policies (I'm Enough sure That they Will Help you).
Just provide Information How much you can to make your side strong and legal.
If you want You can take Help of Godaddy Customer Support Also and their Forum...
Answer: This is some of the most inaccurate information I have ever read... I have dealt with DMCA for 7 years now, if somebody posts ANYTHING on a server that violates my copyrights or personal rights such as software, images of me etc. it MUST as stated right in the DMCA code be taken down. The hosting company has no say at all, it's law.
If you do not know what you are talking about stop blogging. Jesus you will have people thinking they can't do anything. Worst information ever. Go learn the law first then write. How irresponsible are you?
Now for accurate information, yes you can file a DMCA and by law they have to remove it. Now the other party can try and say it's not violating a copyright but there is more to it than that, you can have images removed if they are of you. I have had images removed many, many times.


gnu screen - changing the default escape command key to ALT-X?

Question: In GNU screen, I want to change the default command binding to Alt-s (by tweaking .screenrc) instead of the default C-a, the reason is I use emacs hence GNU screen binds the C-a key, sending "C-a" to the emacs becomes tedious (as @Nils said, to send "C-a" I should type "C-a a"), as well as "C-a" in bash shell, and I could change the escape to C- but some of them are already mapped in emacs and other combinations are not as easy as ALT-s . If anyone has already done a ALT key mapping, please do let me know.
Answer: It is possible to work around :escape command limitations using registers and :bindkey command. Just put this in .screenrc:
# reset escape key to the default
escape ^Aa

# auxiliary register
register S ^A

# Alt + x produces ^A and acts as an escape key
bindkey "^[x" process S

## Alt + space produces ^A and acts as an escape key
# bindkey "^[ " process S

See http://adb.cba.pl/gnu-screen-tips-page-my.html#howto-alt-key-as-escape
Answer: From my reading of man screen it seems like the only meta character that screen can use for the command binding is CTRL:
   escape xy

   Set  the  command character to x and the character generating a literal
   command character (by triggering the "meta" command) to y (similar to
   the -e option).  Each argument is either a single character, a two-character
   sequence of the form "^x" (meaning "C-x"), a backslash followed by an octal
   number (specifying the ASCII code of the character),  or a backslash followed
   by a second character, such as "\^" or "\\".  The default is "^Aa".

If there is some mapping that you don't use in emacs, even if it's inconvenient, like C-|, then you could use your terminal input manager to remap ALT-X to that, letting you use the ALT binding instead.  That would be a little hackish though.
Comment: You don't have to preface the escape key with Control. I use "escape `~", which sets the it to backtick (without Control). I don't think you can use Alt-anything, though.
Comment: thanks. That's sort of tricky, perhaps there could be a direct way to do this
Comment: @silentbicyle thanks. yeah i know I dont have to preface with Control, "escape `~" doesn't work for me. And I ll become tedious when I have to actually ~ in any of the programs running on the shell, that is the reason why I prefer CTL/ALT mapping.
Comment: See my answer below. The "escape" command uses so-called caret notation. So you use ^G for G as the control character. The tricky part is that "escape" expects two concatenated arguments: the "controlling character" (a by default) and a meta character ([ by default)
Answer: I'm an Emacs and screen user as well.  Although I rarely use Emacs in a terminal -- and as such in a screen session -- I didn't want to give up C-a for the shell either (which uses Emacs key bindings).  My solution was to use C-j as the prefix key for screen, which I was willing to sacrifice.  In Emacs programming modes it is bound to (newline-and-indent) which I bound to RET as well, so I really don't miss it.
By the way: I know this is an advise rather than an answer, but I felt this would be valuable enough to post nevertheless.
Answer: To make Alt+X the default prefix for commands and free C-a, add the following lines to .screenrc:
escape ^||
bindkey "^[x" command

As a side effect C-| will be command prefix too. If you need this keys to be free too, then fix "escape ^||"  accordingly.
Comment: How does `^[x` be transfered to `Alt-x`, where `^` means `Ctrl`(I'm not sure)? Does `[` mean `Alt`? Thanks.
Comment: If you are blessed with an `Alt Gr` key (in, for example, a Latin American keyboard), you can take advantage of it as third level modifier to input a rarely used symbol which you can bind as command key.  For example, with my LA keyboard in Ubuntu, I have `bindkey "ð" command` in .screenrc.  So, I use `Alt Gr + d` (which sends the ð character) as my command key.
Answer: Screen doesn't have any shorthand syntax for alt bindings, but you can give it the octal code directly. For instance on my machine, Alt-x has the hex code F8, or 370 octal, so putting
escape \370x
in my screenrc changed the escape code to alt-X
Tested and works with screen 4.00.03 on Linux.
You may have to change the escape, since I think this may depend on things like your language and codeset, etc: how I found out what my escape code was was to type
$ echo -n ^QM-x | perl -ne 'printf "%lo\n", ord($_)'

^Q is the quoted-insert command for readline (it inserts what you type directly without trying to interpret it) and M-x was a literal Alt-X.
Comment: I have tried this trick and it doesn't work for me. Is there a way to debug this?
Comment: Hi Siva - I think the most likely difference is due to the terminal encoding of the meta keys. I'm using xterm with the xterm termcap/terminfo setting; it's possible other terminals like kterm or gnome-terminal, or different TERM settings, use a different encoding. What does my echo trick produce on your machine?
Answer: Something I have had for years in my .screenrc:
escape ^Zz

which is now hardwired in muscle memory for me.
Somehow I ended up having to share a screen with someone else's config, and now I keep stopping processes all the time (bash ^Z)... Not funny...
Answer: Fellow emacs user here.
The best solution I've found is a ~/.screenrc file with the following:
# C-a :source .screenrc

escape ^gg

Live updated here: https://gist.github.com/1058111
See also: http://ubuntuforums.org/showthread.php?t=498675
Comment: I'm not a fan of this. C-g is one of the last keys I would want to give up in Emacs.
Comment: btw, this works really well for me because ^G is the "cancel" sequence in emacs. So if your muscle memory 'spasms', you don't mess anything up in emacs.
Comment: Change it to "escape ^\`[" to use backquote. C-\` is not bound to anything in Emacs by default.


How the Shuddhadvaita Philosophy is pure non Dualism while admits reality of the world and reality of the souls?

Question: How Shuddhadvaita Philosophy is pure non Dualism while admits reality of the world and reality of souls?

Reference one
Reference two
Comment: I would like to minimise the two links, but I don't know how?
Answer: Vallabhacharya was a critique of Sankara's Advaita philosophy. In his opinion, Sankara's Advaita was not strictly non-dual because of the presence of both Brahman and Maya. Vallabhacharya's main criticism was regarding the existence of the Maya. If you accept Maya or Avidya, which is the root cause of the existence, then it is basically dualism. Maya is something equivalent to the Prakriti of Sankhya. Maya is something that cannot reside in Brahman.
According to Vallabhacharya Brahman alone exists. That's why it is known as Shuddhadvaita or pure non-dualism. Brahman has three properties: sat (existence), chit (consciousness) and ananda (bliss). This world is a real manifestation (Avirbhava) of Brahman. However, despite going through this manifestation, Brahman remains changeless. This is known as "Avikrita Parinamvada".
Manifestation happens through the process known as "Tirobhava", which means Brahman hides some of its properties while it manifests. It is a process of full or partial concealment. Brahman with sat, chit and ananda is the Purushottama. This is the highest Brahman. He is Krishna. From Purushottoma, Akshara Brahman manifests. Akshara Brahman has sat and chit properties. Bliss is missing. From Akshara, Jivas emerge as numerous sparks emerge from a fire. That's why Jivas are real (sat) and conscious (chit), but they lack bliss (ananda). Matters have only one property - sat. They do not have consciousness or bliss. But nonetheless, they exist.
Source: Bhakti Schools of Vedanta by Swami Tapasyananda (Chapter: Sri Vallabhacharya: Philosophy)


What's the proper background process behaviour for a non-GUI Java app?

Question: What's the proper way for a Java command line application to do background work without hogging resources? Should it use sleep() in the loop or is there a more elegant/efficient way?
Answer: Some heuristics:

Don't attempt to make scheduling decisions in your application. The operating system's scheduler is way better than yours will be. Let it do its job.
Don't poll if you don't have to. For instance, instead of sleeping n seconds, then waking up to check a non-blocked socket, block on the socket. This second strategy plays better with the operating system's scheduler.
Don't use an enormous heap if you don't have to, and try not to allocate enormous chunks of memory at one time. A thrashing application tends to have a negative effect on system performance.
Use buffered I/O. Always. If you think you need non-buffered I/O, be absolutely sure you're right. (You're probably wrong.)
Don't spawn a lot of threads. Threads are surprisingly expensive; beyond a certain point, more threads will reduce your application's performance profile. If you have lots of work to do concurrently, learn and use java.util.concurrent.

Of course, this is just a starter list...
Answer: I'd only use sleep() if there's no work to be done.  For example, if you're doing something like polling a task queue periodically and there's nothing there, sleep for a while then check again, etc.
If you're just trying to make sure you don't hog the CPU but you're still doing real work, you could call Thread.yield() periodically.  That will relinquish control of the CPU and let other threads run, but it won't put you to sleep.  If other processes don't need the CPU you'll get control back and continue to do your work.
You can also set your thread to a low priority:
myThread.setPriority(Thread.MIN_PRIORITY);
As Ishmael said, don't do this in your main thread.  Create a "worker thread" instead.  That way your UI (GUI or CLI) will still be responsive.
Comment: It's a nitpick, but I believe that setting the thread priority only sets the priority of the thread within the JVM - it does not set the priority of the OS-level thread.  If you're worried about hogging resources outside the JVM, you still need to set the process priority in the OS.
Comment: @Jared: I think you're right about that, and I wouldn't consider it a nitpick.  Threading requires OS support and has OS-specific behavior.  On an early version of Java for Solaris there was something called Green Threads, which was basically a workaround for a lack of OS threading capability.
Comment: That's not entirely true. See http://www.javamex.com/tutorials/threads/priority_what.shtml
Comment: If you have a task queue, you should use an instance of BlockingQueue which handles wait/notify correctly without resorting to a sleep. When you sleep, you could very well hurt throughput because new tasks are arriving just as you go to sleep.
Comment: @Dave: I agree that blocking is better than sleep() when available.  That way you're immediately woken up when the work arrives.  The situation I had in mind is the case when "tasks" are received as files in a particular folder.  In that case I think you're stuck with sleep().
Answer: There are several ways. I would use ExecutorService... for example:
ExecutorService service = Executors.newCachedThreadPool();

Callable<Result> task = new Callable<Result>() {
    public Result call() throws Exception {
        // code which will be run on background thread
    }
};

Future<Result> future = service.submit(task);

// Next line wait until background task is complete
// without killing CPU. Of course, you can do something
// different here and check your 'future' later.
//
// Note also that future.get() may throw various exceptions too,
// you'll need to handle them properly

Result resultFromBackgroundThread = future.get();

This is Java 5 code, ExecutorService, Callable, Future and similar are in java.util.concurrent package.
Answer: One place to start is to make sure that only those resources are being used and no other objects (so that they become garbage collected).
Placing sleep() in a single threading application is only going to halt the current thread. If you're trying to accomplish data being processed in the background while information still needs to be presented to the user then it is best to put the background process in a seperate thread.


Can we use ftp in place of tftp in pxe boot

Question: Tftp is used to get OS image from pxe server to client as it uses UDP for file transfer. But can we use ftp for the same. If yes then how and if no then why?
Comment: You can't, because the TFTP protocol is different from the FTP protocol, and PXE clients only support TFTP (because it's less complex than FTP, note the "trivial" in TFTP). Of course you can write your own BIOS with your own PXE client which does support FTP ... but then it'll still only work on computers with your custom BIOS.
Answer: In theory, yes you can... you'll just need to design a PXE standard extension for FTP, then write a new netboot firmware to implement that extension, then flash it to your NICs.
In practice, it's probably not worth of the effort unless you have a very hard requirement for FTP specifically.
But before you start that development project, note that iPXE can use HTTP. You can either use TFTP-based PXE to load iPXE as your first-stage network bootloader, and then have it switch to HTTP for speed, or - if your NIC is supported by the iPXE project - get iPXE in a flashable format and flash it into your NIC, and then use HTTP for all netboot-related file transfers.


How to bulk convert all the file in a file system branch between Unix and Windows line break format?

Question: Everybody knows :-) that in Windows plain text files lines are terminated with CR+LF, and in Unix&Linux - with LF only. How can I quickly convert all my source code files from one format to another and back?
Answer: That depends: if the files are under version control, this could be a rather unpopular history-polluting decision. Git has the option to automagically convert line endings on check-out.
If you do not care and want to quickly convert, there are programs like fromdos/todos and dos2unix/unix2dos that do this for you. You can use find: find . -type f -name '*.php' -exec dos2unix '{}' +.
Comment: This will run `dos2unix` on *all* files, the ones that already have Unix line-breaks (LF),
as well as the ones in need to convert the Windows line-breaks (CRLF) to LF.
This should be fine, I think. But it's worth a comment. :-)
Comment: Also, I prefer to start with `find . -type f -name '*.php' -exec echo dos2unix '{}' \;`
in order to see what files will be affected before going through with the actual conversion.
Of course, you might not want to follow my suggestion if
the number of files affected is *huge*.
Answer: There are several dedicated programs, including

dos2unix and unix2dos from the dos2unix tools
todos and fromdos from the tofrodos tools

Simply pick the tool for the appropriate direction and pass the names of the files to convert on the command line.

If you don't have either, but have Linux or Cygwin:
sed -i -e 's/\r\+$//' filename             # dos|unix -> unix
sed -i -e 's/\r*$/\r/' filename            # dos|unix -> dos

If you have perl:
perl -i -pe 's/\r+$//' filename            # dos|unix -> unix
perl -i -pe 's/\r*$/\r/' filename          # dos|unix -> dos

With only POSIX tools (including BusyBox), to go from unix to dos, you'll need to pass the CR character literally in the sed command.
cr=$(echo | tr '\n' '\r')
sed -e "s/$cr*\$/$cr/" <filename >filename.dos
mv filename.dos filename

In the other direction, you can simply delete all CRs:
tr -d '\r' <filename >filename.dos
mv filename.dos filename

You can use wildcards to convert many files in the same directory at once, e.g.
sed -i -e 's/\r\+$//' *.txt

To convert all files in the current directory and its subdirectories, if your shell is zsh, you can use **/, e.g.
sed -i -e 's/\r\+$//' **/*.txt

You can use **/ in bash ≥4, but you need to run shopt -s globstar first (you can put this line in your ~/.bashrc). You can use **/ in ksh93, but you need to run set -o globstar first (you can put this line in your ~/.kshrc.
If you can only use the tools that require a redirection, use a for loop.
for x in *.txt; do
  tr -d '\r' <"$x" >"$x.dos"
  mv -- "$x.dos" "$x"
done

If you don't have **/ or need more complex matching to select which files to convert, use the find command. Here's a Linux/Cygwin example which converts all files under the current directory and its subdirectories recursively, except for files called .o and under subdirectories called bin.
find -name 'bin' -type d -prune -o \
     \! -name '*.o' \
     -exec sed -i -e 's/\r\+$//' {} +

Here's a POSIX example. We tell find to start a shell that can perform the necessary redirection.
find -name 'bin' -type d -prune -o \
     \! -name '*.o' \
     -exec sh -c '
       tr -d '\r' <"$0" >"$0.dos"
       mv -- "$0.dos" "$0"
' {} \;

You can make the find method slightly faster, at the expense of more complex code, by using a loop in the shell command.
find -name 'bin' -type d -prune -o \
     \! -name '*.o' \
     -exec sh -c '
       for x; do
         tr -d '\r' <"$x" >"$x.dos"
         mv -- "$x.dos" "$x"
       done
' _ {} +

Answer: winscp will also auto-convert, if told so.
If your files reside all in the same directory:
DIRECTORY=/your/directory
unix2dos $DIRECTORY/*

Comment: WinSCP doesn't seem to autoconvert files in the current directory - it's more about automatically converting files as part of a transfer process. Even vanilla `ftp` did that.
Answer: Changing from ASCII text, with CRLF line terminators to ASCII text
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 10 2018 21:31:58)

All files in current directory
for i in *; do vi -c "set fileformat=unix | wq" "${i}"; done

Specific mask (all filenames in current directory starting with word "file")
for i in file*; do vi -c "set fileformat=unix | wq" "${i}"; done

Another mask (all filenames in current directory that contain the word "file")
for i in *file*; do vi -c "set fileformat=unix | wq" "${i}"; done

To convert files back to CRLF just change fileformat=unix to fileformat=dos:
for i in *file*; do vi -c "set fileformat=dos | wq" "${i}"; done

This is the quickest way if using vim to convert fileformat.

Alternatively sed can also be used to remove all ^M by pressing CTRL+V and then CTRL+M
for i in *; do sed -i s/^M// "$i"; done

or
for i in *; do sed -i s/^M// "${i}"; done

This will also change all CRLF files in current directory to ASCII text.
Comment: Your `vi` suggestions will only work when `vi` is aliased to `vim` (the `set fileformat` option is not part of standard `vi`)


Can not follow the example for max-flow-min-cut on Wikipedia

Question: This Wikipedia example is very confusing. Its saying the max flow = min cut. But I see the max flow = 9 and the min cut = 7. If not, how does the capacity =min cut here? Which is the max flow min cut theorem.
Answer: Max flow isn't 9 it is 7. 4 from s to 1 and 3 from s to 2.It cannot have more than that.You can see that it is also equal to min-cut.
Answer: The flow depicted in the diagram has value 7. This is the total amount of flow out of the source node $s$, as well as the total amount of flow into the sink node $t$. Since the total capacity out of the source node $s$ is 7, this flow is maximum, i.e., no flow has larger value. This is also the value of the cut which separates $s$ from the rest of the graph. The existence of a flow of value 7 shows that this cut is minimum (if there was a cut of smaller value then there couldn't be a flow of value 7 since it could not cross the cut).
While the total capacity of edges incoming at $t$ is 9, no flow saturates these edges. Consider the thought experiment in which we changed the capacity of these edges to be infinite. Would you then say that the max flow is $\infty$?
That the max flow is at most the min cut is not hard to see: basically, each cut constrains each flow, and in particular the max flow is at most the min cut. The non-trivial part of the max flow min cut theorem is that the it is possible to achieve a flow whose value is the min cut, or conversely that there exists a cut whose value is the max flow.
Answer: Okay, really sorry. I got confused with maximal and max flow in the graph. Obviously, the maximal is what is at most the capacity, and max flow is how much at most can flow though this network. The answer to the former is of course 9, where at the latter is 7.
In this case the max flow from s to t through 1 is 4 and from s to t through 2 (as first node) is 3 which equals the min cut, which is the dashed arrow.
I hope this helps anyone who had the same confusion.
Comment: I'm not sure what you mean. A "maximal" object is one that can't be added to; a "maximum" object is one that is bigger than all others. For example, vertex 1 is a maximal independent set in the graph in your question (you can't add another vertex and stil have an ind. set), whereas {s,t} is a maximum ind. set, since there is no ind. set with strictly more than two vertices. So I don't understand how you can claim that the maximal flow (9) is bigger than the maximum flow (7): that's impossible.
Comment: encase you miss understood at most you can push through 9 in this graph through t which is the capacity at t, the capacity at s is 7, which is the max that can be passed through the whole graph.


I designed a PCB around the IP5328P powerbank SoC and it is not working. Why?

Question: I am building a powerbank PCB based around IP5328P, a bi-directional PD3.0 and fast charge power bank SOC. I designed a PCB with components inspired by NeoThai's work on that and ordered the PCB. After soldering all the parts, the things happening are as follows;

When I plug in charging power through micro-USB and type-C ports, the LED animation of LED1, LED2, LED3 and LED4 shows that it is charging. The battery is getting the charging current, but the fast charging of the battery is not working compared to the original commercial circuit. The battery's voltage before charging was 3.7V.
When I plugged in the USB cable for charging my phone the USB type-A ports were not providing any power. Hence the output features are not working as well.
Push button works well. Single press, it shows the charge using LED bar display. Double press turns the bar display OFF

Here are the things I tried while troubleshooting:

I checked the circuit diagram with the typical application schematic (page 2 of the datasheet) and also another creator of a similar powerbank PCB on PCBWay and the main components, but there seemed to be no faults by 3 more people in my acquaintances.
I resoldered a new PCB with the same components to make sure that all the solder connections were proper and checked each and every join thrice to make sure all the connections are solid.
Checked if the MOSFETs responsible for turning ON and OFF the USB type-A ports are working or not by providing an external HIGH signal to the MOSFET's GATE.  They turned ON but the voltage is not being boosted to 5V. Instead, I am getting RAW battery voltage on the OUTPUT.
The IC doesn't seem to be boosting the power. The original circuit already boosts the battery voltage to 5V at the drain of the MOSFET before turning the MOSFET ON. I can't measure that voltage on my circuit.

I'll be attaching the circuit diagram and the image of the PCB with this post.
Can anyone help me figure out the problem that I am facing?
Comment: Please provide data sheet links for relevant chips.
Comment: Did you find a solution to your problem?
Comment: May be the  IP5328P does the first charge ever only with slow small current to learn the capacity of the battery. Second or third charge of the 75 % discharged battery will be done with fast high current. The battery is a new one in good condition?
Comment: It's a brand new battery. A 10000mAh Li-Po
Comment: I already provided the link for datasheet in the description. Please click the hyperlinks
Answer: Maybe the problem is the VSYS net. In the circuit diagramm I see no connection from pad 8,9 to pad 22, 23, but this connection is required.


Applications of High School Geometry

Question: Sometimes I struggle to give my students a sufficient number of reasons why they should study Geometry in high school, other than that it helps them think and increases their understanding of the world.  Aside from sports and teaching itself, what are examples of jobs/careers that apply this material?
Comment: I wouldn't focus on careers. I'd talk about how it helps you learn to visualize. And I'd focus on making the course interesting.
Comment: Frame challenge: "Helping the students think" and "increasing their understanding of the world" are already two extremely good reasons  to teach something in high school. Why should high school students read Shakespeare or Poe or Dante or Goethe other than that it helps them think and increases their understanding of the world?
Comment: Don't go down the slippery slope of made up reasons and motivations. It's all about learning to think abstractly. Prefrontal cortex development happens at about this age, and that's when abstract reasoning blossoms or dies. The slippery slope can end up as "why do I have to learn how to read if my computer can read text out loud to me." Of course I am being whimsical, but...
Comment: May be ponder questions such as: Why do cars need differentials?  What makes a lathe work? Ok, that was circles. May be include scissor lifts and such to get parallelograms and triangles into play? My god child enjoyed it immensely when I constructed extendable "scissors/pliers" for him from his legos. Not really career related, but...
Comment: @JochenGlueck I am still not convinced about Shakespeare. I still think that was a waste of time.
Comment: @JochenGlueck That's fine for the teacher, but the students generally don't appreciate it now. If you're trying to motivate the students, you need to give them a reason they'll care about, and "helping you think" won't cut it for many.
Comment: [...] If a student says "I don't like your math class because I don't see what it's good for in practice", then they typically don't mean "tell me two applications and I'll be fine again." Instead they're telling you "I've got no idea what you're actually talking about." This indicates a problem with the teaching (maybe, but not necessarily due to the teacher) and it I don't see how this could be solved by explaining to the students why the contents are "important".
Comment: @DKNguyen: If you say so, then maybe it was indeed a waste of time for you. Since I don't know you and since I wasn't there I have no way of knowing whether you personally might feel different about the experience if the teaching had been different. I'm quite confident to say, though, that it probably wouldn't have improved your opinion about reading Shakespeare in highschool if the teacher had told you that this were important because it were "useful" for your everyday life or had "applications" to your future career.
Comment: The general problem is that people in general, and children/teens even more so, are bad at thinking about the future and preparing for it. They don't know what they're going to be when they grow up and what it will require. But I've lost count of the number of times in a [so] question I've pointed out that the solution is a basic application of high school algebra, probably something about which they said "I'll never need this in real life."
Comment: Highly relevant [talk by Grant Sanderson](https://www.youtube.com/watch?v=s_L-fp8gDzY). To paraphrase him, why do you not question the real world applications of reading fiction? If you ever read Harry Potter, when was the last time you needed to cast Wingardium Leviosa? You learn geometry because it's _bloody fun_.
Comment: Perhaps the most frequently-used *direct* application might be dinner. Once you can compute the area of a circle, you quickly see how much money you waste buying [pizza sizes other than largest](https://www.npr.org/sections/money/2014/02/26/282132576/74-476-reasons-you-should-always-get-the-bigger-pizza).
Comment: I would not go down that road. It's a trap. You'll just end up listing a lot of careers that they might not see themselves in and they will become even more adamant that your course is useless.
Comment: "Chance prefers the prepared mind."--Louis Pasteur
Comment: @Barmar: Yes, the reasoning in my comment is mainly relevant for the teacher. Regarding the students though, the vast majority of them won't appreciate it either if you tell them that geometry will be really useful for those who study mechanical engineering later on in college or that geometry is good for do-it-yourself carpentry or cutting down trees, as well-meant as those examples might be. The problem with this entire line of thought is that it takes the students complaints way too literally. [...]
Comment: @JyrkiLahtonen "What's a lathe and why should I care? 'Making things' is done in China... I'm going to be a financial analyst."
Comment: Pretty much any trade for starters.  You can show them the 3,4,5 triangle trick for checking if an angle is square as an example.
Comment: Why not surveying? Wasn't that introduced about 6- or 5,000 years ago first to asses taxes and then to help settle disputes about land ownership?

(How is it acceptable that any of that is not part a basic part of the curriculum in every school?)
Answer: Every time I'm doing carpentry/DIY remodeling on my house, I use so much high school geometry that it makes me chuckle.
I've had instances where I need to cut angles to make pieces parallel and used Alternate Interior reasoning to pull it off. I've had times where the angle I can measure is complimentary to the angle I need to cut, so I have to figure out how to reflect the piece or the cut line to get it right. I've needed pieces of plywood cut that were general quadrilaterals (because nothing is square in old homes) and was able to pull it off by measuring diagonals and marking equidistant points using a string compass. And of course there's all the tricks for actually getting a square corner.
Of all the subjects taught in school from algebra to calculus to abstract algebra, I've used high school geometry far above and beyond the others in these types of "real" world situations. Set up an equation and solve for $x$? Not sure I've ever really had the need to do that outside of my professional life (okay, maybe a few times when I was baking). Need to literally construct a congruent triangle? I can't even begin to count how many times.
Comment: There was a question a while ago - not sure if it was in math or garden&landscaping - from a landscaper: "My client wants a circular lawn, but the center is within the house. How can I achieve this?".
Comment: A few years ago, I had my conservatory roof replaced. The fitter measured the heights at the front and back, and the dimensions of the floor. Then he went to measure the length of the roof, and I told him what it would be (with a quick bit of Pythagoras). The look on his face, you'd think I'd just pulled a white rabbit out of my mouth. It's kind of shocking how few tradies really know basic geometry which would be so valuable to their work.
Comment: I agree completely. I have an antique set of compasses that belonged to my grandfather, who was a carpenter. It is similar, if not identical to [this](https://americanhistory.si.edu/collections/nmah_1214582). I have used it for some little household projects where precision was important.
Answer: Here's my rant that I gave to my students:
You are learning this right now because some of you will need this later in life. You may need this information for your daily job. You may need this information to check off a requirements to GET your job.
We don't know who will actually need to use this yet.
We do know that it will be MUCH harder to start learning this when you are all older.
We teach it to all of you now, while you are young and have an easier time learning.
Math education is a tower. You have to build one floor before you can start on the next. The floor of Geometry opens the door to higher math.
There are many jobs where you WILL need to reach for the top of this tower of mathematics. Many of them are good jobs.
We all benefit from the things those people create with their knowledge and experience.
Your phone could not exist without very intelligent, hard working people who most likely learned this math when they were young.
The internet, streaming video, video games... all require a ton of math to work.
Some of you may never need to worry about internal angles or parallel lines again after this class, but the world is better when everyone learns this now.
Even if you don't think you'll ever go into a career that requires it, you do not know what your future holds for you either.
If you do end up needing this, it really, REALLY sucks having to go back and start learning it in college.
Comment: The problem is that the students come with very different learning styles and attitudes. Some learn what ever the "authority" tells them to learn, some find maths genuinely interesting, some don't and cannot motivate themselves to learn something without apparent need. The typical "bad at school, good at their job" people usually fall into the last category.
Answer: The problem here is usually less a matter of 'I know of no instances where I will use this' and more 'I cannot relate things I actually do to the abstract concepts here'. A very large number of things people do regularly actually use a huge amount of math, but they never think about that because they have trouble translating from the abstract aspects to concrete applications.
The best example of this that I can think of for geometry is actually shooter games. You can't do accurate target-lead calculations without using trigonometry, and thus you need at least a basic understanding (be it formally taught or simply learned intuition) of trig to be able to reliably hit moving targets. Most people who play shooters regularly have such an understanding, but in many cases it's an intuitive skill and they can't explain it easily in formal mathematical terms, if at all. But, on the other hand, having a knowledge of trig can greatly accelerate learning that as an intuitive skill.
Comment: Then you get to Minecraft speedrunning, where top players used to have to do geometry/trig calculations in seconds. Now they have programs to do some of it for you, but the person writing the programs is working with geometry, trigonometry, and statistics in order to get accurate results.
Answer: [This may seem indirect, but I want to give you something different, therefore additive.]
Nate:  For geometry, specifically, I think you have to tell the kids something along the lines of

"This course is going to feel different from algebra class...and it will feel different from the classes after, where you get back to algebra.  In
this class, we are going to do a lot of proofs.  It's important that
you see what it means to prove something logically.
Even if you don't remember every picky part of geometry class, you will know what it means to prove something and know what that feels like.
Geometry was a wonderful invention by the Greek philosophers and
something that many important thinkers like Abraham Lincoln loved.
Because they loved to think logically.
Some of you are going to love how this class is different
from last year's algebra.  And some of you are going to hate it...and
want to get back to equations with letters and numbers.  But...I'm
just warning you so it won't be such a shock, this year is going to be very different from algebra."

Note:  I'm actually way less proof-y than the average "want to teach real analysis in calculus class" MSE/MESE type.  So this is a sinner counseling morality.  But geometry is an exposure to proof.  It just is.  And even if it's wrong...that's what it is.  And I don't really even think it's wrong or if it is, very wrong, to have an exposure to proofs.

Realistically, I think straining to find direct applications in daily work (or personal) life is not the right rationale for the course.  It's a part of the overall math program, which is mostly (i.e. well over 50%) a tool for science and engineering, which there are a lot of jobs in.
For students that are college-bound in STEM, they need to learn a lot of math...and later math has some dependencies on geometry.  Especially trigonometry, which is all over the place in ODEs, calculus, kinematics, electrical engineering, etc.
For kids that are college-bound in non-STEM, they will need less math overall, but still may need some (e.g. medical fields).  And geometry will be a small part of that.
And all of them, college-bound or not, will need some basic grounding in math/science to be citizens and read the newspaper, with some amount of perspective.  Yes, they won't all have perfect or deep mastery...and will forget a lot of it.  Same could be said of history and geography...how many people have read Mahan and have some insights from him on modern geopolitics?  All that said, if you don't know France is west of Germany is west of Poland...or that the Germans invaded Russia in WW2, you can't thoughtfully read NYT articles about NATO security.
P.s. I wouldn't transfer this explanation as is.  But you need to be informed by it.  Often I find these questions are more coming from instructors who are concerned themselves about the relevance of the courses, rather than because they really are too often challenged by students (95% of whom will take direction and intuitively know that the course content is fixed) and can't reply well.  I would probably avoid getting too much into these relevancy debates.  Especially don't open them if you don't know how to handle them!  The kids have to do it because it is a part of school.  Someone made a decision what is needed and that's that.  You don't need to say it so brutally, but at least in your mind, know it is true.  And don't let the one doubting Thomas derail your class.

Edit:  (Hope I don't lose my, surprising, +1s for this)  I'm not sure that you want to say this...or if you do, be careful how you package it.  This is a little Machiavellian...but geometry is a pretty core part of the SAT-Math exam.
If we want to get meta, we can argue what's the point of the SAT (and there are good arguments pro/con).  But if we just live in the rat race we live in...doing better is helpful to kids.
Now it's not really a pure subject matter test...has aspects of aptitude (in the title even).  But it's not a pure aptitude test either.  It certainly is a lot easier to take that test if you've had basic geometry (and basic algebra) than if you have to nuke everything out from pure smarts.  I mean look at vertical angle theorem.  ETS loves that...wants to make babies with that theorem.
Comment: +1 Large parts of this never ending "practical usage of xyz"-debate are rather misguided because they miss many of the points in your answer.
Comment: +1 Also you mention college bound vs not. Early in high school, say grade 9 or 10 when geometry is taken, nobody knows which students are college bound! We do not sort students early on to "you will be a chess grandmaster, you will be a gymnast, you will be a mathematician,..." So we have to treat >all< students in geometry as college bound. Most students will not want to hear this, but it is good for the instructor to think about. Again..+1 on your answer!
Comment: +1 I am glad to hear that people still teach about proofs in their geometry classes.
Comment: If anything, it's too much. But it is what it is (not complaining).  80%+ is proofs.  Death by congruent triangles.  Maybe less than 10% (each) are construction (which seems a sop to tradition)  and mensuration (area, volume...useful!)  I also felt that the course sort spent too much time in plane geometry and ended up skimping on solid geometry.  Also, sad that there was not even a "look at the animals in the zoo" type of exposure to some more interesting geometric objects (truncated pyramids and the like).  I ended up getting that in mechanical drawing instead!
Answer: Before you cut a tree down,
it is quite useful to know where it will land,
which requires calculating its height.
There are several methods depending on similar triangles, e.g.,
Wikipedia article.
A variation was depicted in this classic Tom & Jerry cartoon:

Comment: Take a stick the length of your arm or a bit longer. Hold it so that the length above your arm stands above your. Walk to where the top of the tree lines up with the top of the stick when your hand is at eye-level. You're standing about where the top of the tree will fall, if the tree falls in your direction. Assuming the ground is more or less level. OTOH, actual arborists take down trees in less risky ways than felling the whole thing. Especially when you have to worry about where it falls.
Comment: Although I have to admit I don't understand the woodpecker's calculation.
Answer: In general, it makes it more difficult for someone to deceive you. It also lets you better recognize when you're getting a good deal.
It helps when you're buying something based on dimensions to determine whether the price is reasonable or not. The size might not be super critical so you might be willing to spend a bit more to go up a size to have some extra material if the cost per volume gets better for the larger size, or save money by going down a size because the cost per volume sky rockets for the larger size:
"Why are these 1/2" rods so expensive? They're nearly double the price of the 3/8"! What a rip off! Oh wait, 1/2" is only 33% more diameter than 1/2" but that means the cross sectional area is 76% more. I guess that's why it costs so much."
I've also seen people complain about that a 5" vise is a rip off because it costs double the 4" version of the vise. You can look at the photos of the two vises and notice that the 4" and 5" vises look identical. The 5" vise doesn't have any ungainly proportions because there is no difference in proportions. It might be obvious if I point that out, but how is a person uneducated in geometry going to notice this? That means the 5" vise isn't just like the 4" vise except only the jaws are 25% wider. It's that the 25% larger in all 3 dimensions which means it's 1.95x more material. THAT's why it costs double. Incidentally, that also means it's weighs double and you might not want to deal with that for only a 25% increase in jaw width.

It comes up when buying a house. It seems a lot of people only know of square footage by feel, or comparative numbers, or looking at other houses of known square footage. Especially for specific rooms, can just go to a kitchen, look down, notice that the tile size is 12" x 12" which makes it one square foot and just counting up a set number of those in particular sized rectangle just looking at that.
It also helps you calculate the best pizza size to buy to get the most pizza for your money.
It helps you figure out the shortest wood plank you can get away with while still being at an angle where the mouse can easily climb up it to get into your bucket mouse trap.

Oh, and perhaps the most important thing it does for you as far as your students are concerned:
For the girls, it helps prevent them from being easily impressed by rudimentary knowledge when, for their elective, guys from the second and third year of the engineering program start taking introductory STEM courses meant for first year art students as a way to meet girls. They would get closer to them by helping them with their homework and impressing them with basic knowledge. Your students may laugh, but this actually worked for multiple guys when it happened to the point there were complaints about other students about showboating. It's one thing to be impressed when someone solves the heat equation. It's another to be impressed when someone finds the area of a circle.
For the guys, it helps them meet and impress girls in the arts program who did not pick up this knowledge.
Answer: The answer to most "when am I gonna use this" questions is the same.  The best analogy that I've heard is a gym.  People go to the gym and do bicep curls with weights.  Why?  Are they ever going to need to lift something while they're somehow restricted to moving only the lower half of one arm?  Of course not.  They do it because that exercise isolates and strengthens a specific muscle group.  By doing many such exercises, they develop a body that can use all of those strong muscles together to do all sorts of things that weren't part of their exercise routine.  You don't go the gym and practice moving a couch up the stairs, you build up all the individual muscles so that when you need to move a couch up the stairs you can do it.
School is the same way.  The classes you take and the activities you do isolate and strengthen specific parts of the mind.  A strong mind can tackle tasks that are far beyond anything you could ever learn in school.  To get there, though, you have to have a well-balanced exercise routine that increases in intensity as you grow.

Speaking specifically about high-school geometry, I've always ranked that class as the most important class out of my entire primary education.  At one point, my teacher explained that the course really didn't have anything to do with shapes or angles or any of that stuff.  The purpose of the course was to learn proofs and by extension, developing deductive reasoning skills.  All the stuff about shapes and the other things we typically associate with geometry are all just a delivery mechanism for learning this core concept.  They're easy to draw and visualize, which makes it easier to learn than if you were doing the same with a more abstract subject matter like algebra or philosophy.  My teacher said that she didn't care if we left the class and instantly forgot how to calculate the volume of a cylinder.  She was more concerned with whether we could approach a scenario by taking observations, applying logic and facts that we know to be true, and then arriving at a solution for a problem that we've never encountered before.
Looking at geometry from that lens, when does any of this apply to real life?  Every time you read or hear something and want to figure out whether it's true.  Every time something in your house breaks and you need to get it working again.  Every time you need to navigate any sort of situation that's new or unusual.  In other words, all day, every day.  Many professions (medicine, law, engineering, software development, auto mechanics, etc.) are directly based on this type of deductive reasoning loop.  Even outside specific job scenarios, it's a process that (hopefully) runs inside your head every time that you have to think your way through a problem.  If you don't learn how to reason effectively, you'll be prone to making poor decisions and find it harder to continue to learn as you go through life.  Or even worse, you might not have the courage to try and tackle new problems at all.
Answer: My wife is a quilter.  We are constantly scaling shapes, figuring out how much fabric is needed to make something, finding the best way to cut fabric to make a given shape, computing how many squares to make a quilt of a desired size or the border to stretch a center to a desired size, and many more.
Answer: I think a big part of why I was successful with math in junior high and high school is because I had a strong interest in video game programming. It turns out that 3D rendering is a lot of just algebra, linear algebra, geometry, and trigonometry. There are many different career fields where this is relevant (video games, movies, architecture, etc), and the nice thing is that it can be a fun topic for kids to learn.
I do a lot of spatial computing now, and interestingly, many of the math concepts underpinning 3D rendering are applicable to GIS (Geographic Information Systems), which made learning spatial computing very easy for me. Specifically, one of the major types of data used in GIS is "vector" data, which consists of points, lines, and polygons. GIS is used in many professional fields (environmental sciences, infrastructure planning, economics, etc.). GIS expertise can lead to very well-paying jobs.
Answer: you can use history of mthematics for that.
Geometry has played a pivotal role throughout history in various fields, and understanding its applications can inspire students to appreciate its value beyond the classroom. Here are refined examples to illustrate this:
Ancient Land Measurement: In ancient Egypt, geometry was vital in calculating the area of land for taxation and re-establishing boundaries after the Nile's annual floods. This demonstrates geometry's role in governance and civil administration.
Astronomical Discoveries: The Greeks used geometric principles to estimate large distances, such as the gap between the Earth and the Sun. These methods laid the groundwork for modern astronomy and space exploration.
Cartography and Navigation: During the Age of Discovery, geometry was crucial for mapmaking and navigation. It helped explorers chart courses and map the Earth's surface, leading to the world as we know it today.
By presenting geometry as a historical tool that solved real-world problems and paved the way for current technologies, we can inspire students with tangible examples of how geometry shapes our understanding of the world. These historical applications not only show geometry's practicality but also its enduring legacy in advancing human knowledge and society."
Answer: As is fashionable, I talked to my pupils about careers in artificial intelligence. I think they were interested. I will be told that logic that comes into play in AI is not geometry. I'll get to that. Today's mathematics doesn't pay much attention to classical geometry because we have so much to teach that we often don't have the time to do it. But getting students to study classical geometry is never a waste of time.
Everyone knows or should know that if classical geometry does not play a major role in modern mathematics, on the other hand the spirit of geometry reigns everywhere (the sentence is not mine, I don't remember who said it). It is perfectly illusory to learn anything in mathematics without some basic geometry. For example, if we consider one of the simplest structures, that of vector space, do not connect the elementary results from linear algebra to elementary geometry, it is to build on sand and condemn oneself to psitassism.
And how can we learn logic, in order to return to it, without having some geometrical results to illustrate its principles? (see here for example).
In short, there is no math without geometry. And since I've heard that $75\%$ of the jobs offered today more or less use math, I don't hesitate to repeat it to the students.

Applications of High School Geometry


Fastest way to check if InnoDB table has changed

Question: My application is very database intensive. Currently, I'm running MySQL 5.5.19 and using MyISAM, but I'm in the process of migrating to InnoDB. The only problem left is checksum performance.
My application does about 500-1000 CHECKSUM TABLE statements per second in peak times, because the clients GUI is polling the database constantly for changes (it is a monitoring system, so must be very responsive and fast).
With MyISAM, there are live checksums that are precalculated on table modification and are VERY fast. However, there is no such thing in InnoDB. So, CHECKSUM TABLE is VERY slow.
I've hoped to be able to check the last update time of the table, Unfortunately, this is not available in InnoDB either. I'm stuck now, because tests have shown that the performance of the application drops drastically.
There are simply too many lines of code that update the tables, so implementing logic in the application to log table changes is out of the question.
Is there any fast method to detect changes in InnoDB tables?
Answer: For the table mydb.mytable, run this query:
SELECT update_time
FROM information_schema.tables
WHERE table_schema='mydb'
AND table_name='mytable';

If you want to know what tables have changed in the last 5 minutes, run this:
SELECT table_schema,table_name,update_time
FROM information_schema.tables
WHERE update_time > (NOW() - INTERVAL 5 MINUTE);

Give it a Try !!!
UPDATE 2011-12-21 20:04 EDT
My employer (DB/Wweb hosting comany) has a client with 112,000 InnoDB tables. It is very difficult to read INFORMATION_SCHEMA.TABLES during peak hours. I have an alternate suggestion:
If you have innodb_file_per_table enabled and all the InnoDB tables are stored in .ibd files, there is a way to ascertain the time of the last update (up to the minute).
For the table mydb.mytable, do the following in the operating system:
$ cd /var/lib/mysql/mydb
$ ls -l mytable.ibd | awk '{print $4,$5}'

This timestamp is from the OS. You can't go wrong on this one.
UPDATE 2011-12-21 22:04 EDT
    [mysqld]
    innodb_max_dirty_pages_pct=0;
Add this to my.cnf, restart mysql, and all InnoDB tables will experience fast flushes from the buffer pool.
To avoid restarting, just run
mysql> SET GLOBAL innodb_max_dirty_pages_pct=0;

UPDATE 2013-06-27 07:15 EDT
When it comes to retrieving the date and time for a file, ls has the --time-style option:
$ cd /var/lib/mysql/mydb
$ ls -l --time-style="+%s" mytable.ibd | awk '{print $6}'

You can compare the timestamp of the file against UNIX_TIMESTAMP(NOW()).
Comment: Thanks for the answer, but as i said, update_time in information_schema.tables is NULL for InnoDB tables. Also i'm not sure that innodb_max_dirty_pages_pct=0 is a good idea, because it will sacrifice performance... I was thinking about a solution with triggers, to insert a random value at a reference table for each of the watched tables, but then i'll need 3 triggers per table only for this...
Comment: +1 for the file system check, so long as the buffer flushing is regular enough (roughly once per second is the default), then this time stamp will be pretty accurate, and probably good enough for most cases...
Comment: Maybe it's OK for a local database, but i have multiple remote slaves, so this is not working...
Comment: Are you sure you can't go wrong w/ the idb moddate?  A change could be just living in the buffer pool in memory and not gotten flushed to disk yet.
Comment: Also selecting from information_schema.tables is kind of slow too... i takes about 300ms to check one table. For comparison doing a "CHECKSUM TABLE" on a MyISAM table with millions of rows with Live Checksum enabled is taking less than a milisecond.
Comment: Wonderful solution – this was suitable for my purposes.
Comment: Would this be possible for views also?
Comment: Please note that I have just tried this with MariaDB and it is still a valid approach!
Comment: @YannisP. Thank you for validating my approach
Comment: Perfect solution! It also works for MariaDB too.
Comment: With ssh over remote server and running command to run list which shows updated of table timestamp take more. and is quite complex to parse value, compared to simple sql select. As well huge overhead for configuring trusted tunnels or vpns...
Answer: I think I've found the solution. For some time I was looking at Percona Server to replace my MySQL servers, and now i think there is a good reason for this.
Percona server introduces many new INFORMATION_SCHEMA tables like INNODB_TABLE_STATS, which isn't available in standard MySQL server.
When you do:
SELECT rows, modified FROM information_schema.innodb_table_stats WHERE table_schema='db' AND table_name='table'

You get actual row count and a counter. The Official documentation says the following about this field:

If the value of modified column exceeds "rows / 16" or 2000000000, the
  statistics recalculation is done when innodb_stats_auto_update == 1.
  We can estimate the oldness of the statistics by this value.

So this counter wraps every once in a while, but you can make a checksum of the number of rows and the counter, and then with every modification of the table you get a unique checksum. E.g.:
SELECT MD5(CONCAT(rows,'_',modified)) AS checksum FROM information_schema.innodb_table_stats WHERE table_schema='db' AND table_name='table';

I was going do upgrade my servers to Percona server anyway so this bounding is not an issue for me. Managing hundreds of triggers and adding fields to tables is a major pain for this application, because it's very late in development.
This is the PHP function I've come up with to make sure that tables can be checksummed whatever engine and server is used:
function checksum_table($input_tables){
    if(!$input_tables) return false; // Sanity check
    $tables = (is_array($input_tables)) ? $input_tables : array($input_tables); // Make $tables always an array
    $where = "";
    $checksum = "";
    $found_tables = array();
    $tables_indexed = array();
    foreach($tables as $table_name){
        $tables_indexed[$table_name] = true; // Indexed array for faster searching
        if(strstr($table_name,".")){ // If we are passing db.table_name
            $table_name_split = explode(".",$table_name);
            $where .= "(table_schema='".$table_name_split[0]."' AND table_name='".$table_name_split[1]."') OR ";
        }else{
            $where .= "(table_schema=DATABASE() AND table_name='".$table_name."') OR ";
        }
    }
    if($where != ""){ // Sanity check
        $where = substr($where,0,-4); // Remove the last "OR"
        $get_chksum = mysql_query("SELECT table_schema, table_name, rows, modified FROM information_schema.innodb_table_stats WHERE ".$where);
        while($row = mysql_fetch_assoc($get_chksum)){
            if($tables_indexed[$row[table_name]]){ // Not entirely foolproof, but saves some queries like "SELECT DATABASE()" to find out the current database
                $found_tables[$row[table_name]] = true;
            }elseif($tables_indexed[$row[table_schema].".".$row[table_name]]){
                $found_tables[$row[table_schema].".".$row[table_name]] = true;
            }
            $checksum .= "_".$row[rows]."_".$row[modified]."_";
        }
    }

    foreach($tables as $table_name){
        if(!$found_tables[$table_name]){ // Table is not found in information_schema.innodb_table_stats (Probably not InnoDB table or not using Percona Server)
            $get_chksum = mysql_query("CHECKSUM TABLE ".$table_name); // Checksuming the old-fashioned way
            $chksum = mysql_fetch_assoc($get_chksum);
            $checksum .= "_".$chksum[Checksum]."_";
        }
    }

    $checksum = sprintf("%s",crc32($checksum)); // Using crc32 because it's faster than md5(). Must be returned as string to prevent PHPs signed integer problems.

    return $checksum;
}

You can use it like this:
// checksum a signle table in the current db
$checksum = checksum_table("test_table");

// checksum a signle table in db other than the current
$checksum = checksum_table("other_db.test_table");

// checksum multiple tables at once. It's faster when using Percona server, because all tables are checksummed via one select.
$checksum = checksum_table(array("test_table, "other_db.test_table"));

I hope this saves some trouble to other people having the same problem.
Comment: Further story development for those who are interested: http://forum.percona.com/index.php?t=msg&th=2060&goto=7785&
Answer: You should update to Mysql v5.6+ at that version innodb also has support for checksum table.
http://dev.mysql.com/doc/refman/5.6/en/checksum-table.html
other then that, the ideal solution would be if your client wasn't polling for result's constantly, but instead you where pushing new and changed data when and if it was available. It would be faster and less load would be on the server.
if you are using web based gui, you should look into APE http://ape-project.org/ or other similar projects.
Comment: Unfortunately, this is a performance killer. Checksum is made up by hashing **all the rows one by one**. From the docs: "This row-by-row calculation is what you get with the EXTENDED clause, with InnoDB and all other storage engines other than MyISAM, and with MyISAM tables not created with the CHECKSUM=1 clause" :-(
Answer: If you're mostly adding to a table, you can hook on AUTO_INCREMENT as a measure of updatetness.
SELECT `AUTO_INCREMENT` FROM `information_schema`.`tables`
WHERE `table_schema` = DATABASE() AND `table_name` = 'YOUR_TABLE';

But I'd prefer to refer to an otside source like a counter in Memcached which you will increment every time you change something in the database.
Answer: You could try to do the following:
SELECT rows_changed
FROM information_schema.table_statistics
WHERE table_schema = 'mydb' AND table_name='mytable';

This returns a number that increases with each table update, keeping track of it will allow to to detect change.
Important note: the value is changed immediately after an UPDATE, not after COMMIT. So you may not see the changes if the modifications were made inside another transaction that didn't finish.
Answer: This answer has nothing to do with mysql database versions or types, I wanted to know if update statements were making changes AND to do this in my php code..

Created a dummy table with one record and one field which I would query to get the value of mysql's  current_timestamp.
To the data table being updated, added a timestamp field and used the mysql option "ON UPDATE CURRENT_TIMESTAMP"
Compared #1 and #2

This will not work 100% of the time but for my application it was a simple and great solution.   Hope this helps somebody
Answer: In case you want to check if a view has changed, you can check the most recent change among the tables involved in the view:
select max(t.update_time) last_involved_table_update
from view_table_usage vtu
join tables t on (t.table_name=vtu.table_name and t.table_schema=vtu.table_schema)
where vtu.view_name='name_of_view' and vtu.view_schema='schema_name_of_view';

Note that there may be some false positives, e.g. in case a column of a table(included in the view) has been updated without the column itself being a part of the view. In that case the view will show as updated in the above query.


Prefrerred channel in journey

Question: Just setting up our first multichannel campaign. Basically our clients could get messages from their preferred channel Mobile, SMS or Email (default).
I'm currently adding a decision split before each interaction with three options (mobile, SMS, email).
Is this really the common way, or are there any best practices without a need to always create a decision split before each interaction?
Answer: Yep - this is the common way, as after your decision you decide what communication activity to send (email, SMS etc)

Prefrerred channel in journey


FFT of channel impulse response in python

Question: I have this channel impulse response. $h = [1,\,0.5,\,0.3+0.3j]$
The channel is like this by doing a FFT for h.

I resample (up-sample) my OFDM symbol to have smaller path delays and convolve it with my channel impulse response h. In the receiver side I estimate channel with my pilots and everything is Ok.
when I want to see exact channel in frequency domain. So I do a FFT for h and the result is different from what I estimated from pilots.

The orange one is estimated channel. How can I have correct channel from h with doing a FFT?
Answer: To go from your four-tap channel to a frequency-continuous plot, you had to do some interpolation. I would check whether the assumptions for that really hold; lest you're literally zero-padding to the size of the FFT done in your FFT system, it won't.


Is the composition of two mixing CPTP maps a mixing CPTP map?

Question: A CPTP map $T$ is called mixing if and only if it has a single fixed point $\rho^*\in S(\mathcal{H})$ (where $S(\mathcal{H})$ is the convex subset of density matrix operators) to which it converges after repeated applications:
$$
\lim_{n\rightarrow \infty}||T^n(\rho)-\rho^*||_1=0,\ \forall\rho\in S(\mathcal{H}),
$$
where $||\cdot||_1$ denotes the trace norm. My question is: is the composition of two mixing CPTP maps a mixing CPTP map? My main concern comes from the fact that a CPTP map is mixing if and only if $\lambda=1$ (the eigenvalue of $\rho^*$) is the unique peripheral eigenvalue of the map (peripheral eigenvalues of CPTP maps are those which fulfill $|\lambda|=1$). See for instance Theorem 7 of https://dx.doi.org/10.1088/1367-2630/9/5/150 for a proof. Then, the rest of eigenvalues fulfill $|\lambda|<1$. So I don't know if the composition of two mixing channels can preserve this later condition. What I know is that this is true for strictly contractive channels, but I would like to know if there is a more general statement, or find at least a counterexample.
Comment: Is there nothing on that in Michael Wolf's lecture notes? One thought is that if you can show that if the operator norm of $T$ is one, you are done, as the operator norm is submultiplicative and it bounds the largest eigenvalue.
Comment: @NorbertSchuch I haven't seen anything in the Wolf's notes that could give me some hint... Respect to the bound of the largest eigenvalue, it's already true that $\lambda_{max}=1$ because the composition of two CPTP maps is a CPTP map (so the spectral radius is 1). The key of the question is to find $|\lambda|<1$ in the traceless hyperplane (for eigenvalues different from $\lambda=1$, trace-preservation of $T$ imply that the rest of eigenvectors live in the traceless hyperplane). But the operator norm could only yield $\leq$.
Comment: Won't the proof of the operator norm inequality also yield sth. about the degeneracy of the leading eigenvalue? I'd think it would. -- What is not clear to me on the spot is why $\lambda_{\max}=1$ would imply that the operator norm is also $1$ (as it is the largest *singular value*), though it might of course be sth. which holds for CP maps. If this is true, I'm confident that the fact that the composed map has only one largest eigenvalue can be proven.
Answer: The composition of two mixing channels need not be mixing anymore, which can be related to the fact that the spectral radius can fail to be sub-multiplicative for non-normal matrices (more on this at the end).
To give an explicit counterexample, consider the linear maps
$$
\Phi_1\begin{pmatrix}\rho_{11}&\rho_{12}\\ \rho_{21}&\rho_{22}\end{pmatrix}:=\begin{pmatrix}
 \frac{1}{2} (\rho_{11}+i (\rho_{12}-\rho_{21})+\rho_{22}) & 0 \\
 0 & \frac{1}{2} (\rho_{11}-i \rho_{12}+i \rho_{21}+\rho_{22})
\end{pmatrix}
$$
and
$$
\Phi_2\begin{pmatrix}\rho_{11}&\rho_{12}\\\rho_{21}&\rho_{22}\end{pmatrix}:=\begin{pmatrix}
 \frac{\rho_{11}+\rho_{22}}{2} & -\frac{1}{2} i (\rho_{11}-\rho_{22}) \\
 \frac{1}{2} i (\rho_{11}-\rho_{22}) & \frac{\rho_{11}+\rho_{22}}{2}
\end{pmatrix}\,.
$$
These maps are obviously trace-preserving, and their respective Choi matrices
$$
\mathsf C(\Phi_1)= \begin{pmatrix}
 \frac{1}{2} & 0 & \frac{i}{2} & 0 \\
 0 & \frac{1}{2} & 0 & -\frac{i}{2} \\
 -\frac{i}{2} & 0 & \frac{1}{2} & 0 \\
 0 & \frac{i}{2} & 0 & \frac{1}{2}\end{pmatrix}\simeq \omega\oplus\omega^\top \qquad \mathsf C(\Phi_2)= \begin{pmatrix}
 \frac{1}{2} & -\frac{i}{2} & 0 & 0 \\
 \frac{i}{2} & \frac{1}{2} & 0 & 0 \\
 0 & 0 & \frac{1}{2} & \frac{i}{2} \\
 0 & 0 & -\frac{i}{2} & \frac{1}{2} \end{pmatrix}=\omega^\top\oplus\omega
$$
are positive semi-definite because
$$
\omega:=\begin{pmatrix}
\frac{1}{2} & \frac{i}{2}\\
- \frac{i}{2} & \frac{1}{2}
\end{pmatrix}\geq 0\,.
$$
There are multiple ways to see that these channels are mixing, the easiest one being to check that their squares $\Phi_1(\Phi_1(\rho))={\rm tr}(\rho)\frac{\bf1}2=\Phi_2(\Phi_2(\rho))$ are a reset-channel, hence they are mixing with respect to the maximally mixed state $\frac{\bf1}2$.
Similarly, one can check the respective Pauli transfer matrix $\mathsf P(\Phi_j)$---which is the representation matrix of $\Phi_j$ w.r.t. the orthonormal basis $\{\frac1{\sqrt2}{\bf1},\frac1{\sqrt2}\sigma_x,\frac1{\sqrt2}\sigma_y,\frac1{\sqrt2}\sigma_z\}$, meaning it has the same spectrum as $\Phi_j$---
$$
\mathsf P(\Phi_1)=\begin{pmatrix}
 1 & 0 & 0 & 0 \\
 0 & 0 & 0 & 0 \\
 0 & 0 & 0 & 0 \\
 0 & 0 & 1 & 0 \end{pmatrix}\qquad \mathsf P(\Phi_2)=\begin{pmatrix}
 1 & 0 & 0 & 0 \\
 0 & 0 & 0 & 0 \\
 0 & 0 & 0 & 1 \\
 0 & 0 & 0 & 0 \end{pmatrix}
$$
to see that both channels have simple eigenvalue $1$ and threefold eigenvalue $0$, hence they satisfy the mixing criterion you cited.
However, the composition of these channels is the dephasing channel
$$
\Phi_1\Big(\Phi_2\begin{pmatrix}\rho_{11}&\rho_{12}\\\rho_{21}&\rho_{22}\end{pmatrix}  \Big)=\begin{pmatrix}\rho_{11}&0\\0&\rho_{22}\end{pmatrix}
$$
as is readily verified (e.g., via
$$
\mathsf P(\Phi_1\Phi_2)=\mathsf P(\Phi_1)\mathsf P(\Phi_2)=\begin{pmatrix}1&0&0&0\\0&0&0&0\\0&0&0&0\\0&0&0&1\end{pmatrix}\,).
$$
Thus $\Phi_1\Phi_2$ has twofold eigenvalue $1$ as every diagonal state is a fixed point; in particular, $\Phi_1\Phi_2$ is obviously not mixing anymore.
To get back to the underlying mathematics, the problem here is that the sub-matrices
$$
\begin{pmatrix}
0&0\\1&0
\end{pmatrix}\,,\,\begin{pmatrix}
0&1\\0&0
\end{pmatrix}
$$
of $\mathsf P(\Phi_1),\mathsf P(\Phi_2)$ have spectral radius (largest mod of eigenvalue) $0$, but their product $=|1\rangle\langle 1|$ has spectral radius $1$.


What is electron-wrapped process?

Question: I found this process today but I don't recognize it.
Searching i found that is a tool but I haven't installed it.(directly)
Can it be a problem to consider?
Thank you!
Answer: As muru said this is probably an application like VSCode, Slack, Insomnia, Element, ...
Electron is a framework based on the Chrome Javascript Engine, to either run Websites/Webapplications in their own programs locally, or to just write an app in javascript/typescript.
It is, basically its own little browser.

What is electron-wrapped process?


Clutch fluid, DOT 4 Brake Fluid

Question: 1999 Honda Civic, 5-speed.  Don't have manual, yet. Is DOT 4 Brake Fluid recommended?
Comment: Welcome to Motor Vehicle Maintenance & Repair!
Comment: What do you mean with clutch fluid?
Answer: The Honda Operator's Manual states:

Always use Honda DOT 3 brake fluid. If it is not available, you should use only DOT 3 or DOT 4 fluid, from a sealed container, as a temporary replacement. However, the use of
  any non-Honda brake fluid can cause corrosion and decrease the life of the system. Have the brake system flushed and refilled with Honda DOT 3 brake fluid as soon as possible.

However, brake fluid is pretty much brake fluid, whether Honda makes it or Prestone does. There are certain properties it has to have. If it doesn't have those properties, it's not brake fluid. That being said, you can use DOT3 or DOT4 or DOT3/4 (sometimes listed this way on the bottle). Do not, however, use DOT5, as this is silicon based brake fluid and should not be used in place of the regular. The only difference between DOT3 & DOT4 is the boiling points, both wet and dry. The general makeup of it is pretty much the same, though.

Clutch fluid, DOT 4 Brake Fluid


charge socket on a Fuel Cell car

Question: I was looking into Toyota Mirai and Huyndai Tuscon Fuel Cell cars and thought to myself wouldn't it be great if I can charge a car when there is not enough juice to make it to the nearest hydrogen station. Is it possible for fuel cell cars to have a charge socket for battery charging?
Comment: I guess what you're asking for is a "Plug-in Hybrid Fuel Cell" vehicle.  Current plug-in hybrids have a limited "battery only" range and are then supplemented with a small gas engine.
Answer: Interesting concept but I believe they generate electricity as-needed from the fuel cell and there is not much storage in a battery system. Just enough to start the reaction and maintain current to the traction motor. The fuel is in the hydrogen not a large battery. You would have to add a battery pack to the vehicle and at that point you might as well have an EV.Happy Day!

charge socket on a Fuel Cell car


Is there a way to execute javascript in QDomDocument?

Question: In QWebView i can execute javascript code.
But QWebView isn't for running in threads and i'd like to move the execution to threads.
Is there a way of executing a javascript inside a QDomDocument?
Answer: If you want to execute Javascript code in a thread different from the UI thread you might want to have a look at the WorkerScript QML element and this document which explains the relationship between Javascript and QML. I've never tried but it should be a correct way of doing what you're asking.
Answer: QDomDocument has nothing to do with Javascript, it's only used for manipulating XML documents.  You probably want to look at QScriptEngine.


How would I use GNU Parallel for this while loop?

Question: So I have a while loop:
cat live_hosts | while read host; do \
    sortstuff.sh -a "$host" > sortedstuff-"$host"; done

But this can take a long time. How would I use GNU Parallel for this while loop?
Answer: You don't use a while loop.
parallel "sortstuff.sh -a {} > sortedstuff-{}" <live_hosts

Note that this won't work if you have paths in your live_hosts (e.g. /some/dir/file) as it would expand to sortstuff.sh -a /some/dir/file > sortedstuff-/some/dir/file (resulting in no such file or directory); for those cases use {//} and {/} (see gnu-parallel manual for details):
parallel "sortstuff.sh -a {} > {//}/sortedstuff-{/}" <live_hosts

Comment: @Proletariat - you want to output to terminal too ? Just replace `>` with `| tee` e.g. the first command becomes  `parallel "sortstuff.sh -a {} | tee sortedstuff-{}" <live_hosts`
Comment: Is it possible to use `tee` with `parallel` when putting the output into `sortedstuff`? So I can see the output as it goes.
Answer: As an old-school "do one thing and do it well" Unix guy, I'd put the string substitution stuff into a wrapper script:
#!/bin/sh
sortstuff.sh -a "$1" > sortedstuff-"$1"

If you call it wrapper.sh, the parallel command to call it would be:
parallel wrapper.sh < live_hosts

Note that you don't need cat for this kind of thing, which saves an external program invocation.
Answer: You don't need parallel, since the body of the loop doesn't depend on previous iterations. Just start a new background process for each host.
while read host; do
    sortstuff.sh -a "$host" > sortedstuff-"$host" &
done < live_hosts
wait    # Optional, to block until the background tasks are done

parallel does make it easier to manage certain aspects, though; you can limit the number of jobs running in parallel more easily.
Comment: If `wc -l live_hosts` is more than the number of disk spindles or CPU cores — depending on whether the task is I/O or CPU-bound — you're going to eat up a lot of the advantage you get from parallelism with a solution like that. The ability of `parallel` to limit the number of jobs isn't just nice, it's near-essential, if processing speed is your goal.