Present simple with the future meaning

Question: Recently I saw the movie Kung Fu panda, and there was one interesting sentence with the present simple tense. Can it be called a diary future? Oogway summons Master Shifu and tells him, that he has had a vision and that Tai Lung will return. Master Shifu says that it is impossible because TAi Lung  is in prison.Oogway says that nothing is impossible. Then Master Shifu sends Zeng to prison, asking to double the guard. Then he adds: 'Tai Lung does not return'. Doesn't it resemble the use of threatening shall?
Answer: The language in Kung Fu Panda does not reflect actual English usage.
The dialogue veers erratically between colloquial American speech, the stilted  diction of old-fashioned translations and imitations of Chinese classics, and the imaginary dialect of bad ELL textbooks.
It's a deliberate attempt to reproduce the inadvertent comic effect of the subtitles in many American releases of Chinese action movies.
So it's really a waste of time trying to discern an underlying rationality or pattern in utterances like Tai Lung does not return: it's a joke, whose point is that nobody talks like this except characters in Kung Fu movies.
Comment: Maybe, it is so.But this cartoon has very positive characteristics in the respect of the plot in Russia. And I wouldn't say that the grammar of this cartoon is very bad. Of course I am not a native speaker. Your point of view was interesting for me. Maybe I will find another sentence with the same usage.
Comment: @Fatimahon I'm not suggesting that the dialogue is bad--quite the contrary, it's a very artful mixture of registers. But it's an artificial dialect, not "real" English.
Comment: It is stylistcs, then. That sounds quite interesting. And why do you think he uses here present simple, not shall or will? Every grammatical structure used with some stylistical intentention can be explained. I am really interested in your opinion.I hope my English does not offend your feelings.
Comment: @Fatimahon In that particular instance I'd say the simple present mostly represents subtitle-style "learner's English" -- Like the Russified English in your question about *Guardians*, this is a playful **misuse** of English. These movies are sources to be enjoyed, not sources from which any knowledge of standard English usage can be derived without very careful attention to dramatic context.
Comment: I understand what you mean, these sentences attracted my attention because they were not grammatical compared to 'classical' English grammar. Anyhow I find cartoons more interesting to watch than other films. But I've got one question from Battleship and Kung Fu Panda. The structures used in them are identical. I will try to post tomorrow.
Comment: @Fatimahon I look forward to your questions. You have already directed my attention to two works with very interesting unconventional uses of English.
Comment: Thank you, I thought my questions were not very useful.
Answer: Indeed it's possible that he means:

Tai Lung shall not return. (I will not let him.)

But I'm not sure as he could also mean:

No I do not believe that Tai Lung will return.

And to convey this he can use the present tense as an emphatic denial. An analogous example would be:

He does not know. He cannot possibly know. How can it be? Who could have told him?
Comment: Can emphatic denial be conveyed with Present  Simple, if the meaning is future? where is your example taken from?
Comment: In your sentence Does not know is obviously present, unlike my sentence which is future in meaning.
Comment: @Fatimahon: My example was completely made up. But I'm a native speaker so I'm certain there are examples in the literature. Generally such unusual usages of tenses are found in first-person narratives.
Comment: @Fatimahon: I agree that in my example the intended time is different from in your example, but it's really the same explanation, because the present tense is used in narrative simply to pull the audience into the scene to view it as if it is occurring right there and then. It is sometimes called the vivid/dramatic present, describing its purpose. But in my view it is nothing more than the bare verb, which is used whenever we just want to present the event all by itself. Consider "Everything that goes up must come down." where the use of the present tense is sometimes called gnomic/generic.
Comment: Yes, it is similar to your last example, and the term gnomic present simple is excellent. Though in the cartoon it is rather difficult to perceive the sentence in such a way. I also thought about narrative present simple, but for me it was difficult to sense this sentence in such a way. Thank you for a very full and interesting answer.

Present simple with the future meaning


Is it possible to export an org table into an interactive table?

Question: Org-mode can nicely export tables into html customly. However, these exported tables cannot be sorted or filtered (i.e. are not interactive). Would it be possible to make these tables sortable and filterable?
Comment: AFAIK, these things are all provided by CSS and Javascript which is orthogonal to what Org mode provides. You can use things like `#+HTML_HEAD: ` to link in arbitrary CSS and JS to your exported HTML file, but you'll have to write the CSS and JS yourself (or more likely, crib from one of the many examples on the web - see e.g. [How to sort a table](https://www.w3schools.com/howto/howto_js_sort_table.asp)).
Comment: Indeed the job would have to be done by CSS or JS. Some JS libraries like https://slickgrid.net/ turn data sources into interactive tables. I was wondering if someone did provide such a way of exporting org mode tables. I may be could have done it myself if I did know a bit JS.
Comment: Meanwhile someone finds a solution to this I thought about converting org tables into csv and then turn the csv into interactive tables with Python (like this for example : https://dash.plotly.com/datatable/interactivity).
Comment: If you want to go the usual Org mode --> HTML way, you might also need to tweak the exporter (or write a filter, or write a derived exporter) that will add the decorations needed to the table headers (e.g. the `Name` stuff in the link I provided).
Comment: I'm trying to enable sorting through the js code you mentioned and `#+HTML_HEAD:` but it doesn't work. Could you provide me with extended explanations?
Comment: You need to modify the HTML code as well, as I pointed out in my previous comment: it's a small change, but it has to be done by hand for now (unless you implement a filter or a derived exporter that tweaks the handlings of table headers appropriately).
Comment: Even by hand, I couldn't do it, my knowledge of HTML is too poor. I'll use the CSV/python procedure meanwhile. I hope someone will be interested in developing this functionality at some point. Thx for your help.
Answer: The standard HTML table is not interactive, you need JavaScript to add these interactive features.
The following uses the DataTables JS library to add search and filter. Save it to an org file then C-c C-e h o to view the HTML in browser.
#+HTML_HEAD: <link rel="stylesheet" href="https://cdn.datatables.net/1.10.22/css/jquery.dataTables.min.css">

#+NAME: several emacs packages
| Name               |       Version | Status    | Source | Summary                                        |
|--------------------+---------------+-----------+--------+------------------------------------------------|
| origami            | 20200331.1019 | available | melpa  | Flexible text folding                          |
| number             | 20170901.1312 | available | melpa  | Working with numbers at point.                 |
| helm-lib-babel     | 20180510.1324 | available | melpa  | helm insertion of babel function references    |
| org-snooze         | 20181229.1424 | available | melpa  | Snooze your code, doc and feed                 |
| assess             | 20200211.1817 | installed | n/a    | Test support functions                         |
| mocker             |  20150917.154 | available | melpa  | mocking framework for emacs                    |
| mediawiki          | 20200718.1529 | installed | n/a    | mediawiki frontend                             |
| unicode-math-input | 20190813.1436 | available | melpa  | Insert Unicode math symbols using TeX notation |
| hgrc-mode          | 20150409.2043 | available | melpa  | major mode for editing hgrc files              |
| abs-mode           |  20201021.958 | available | melpa  | Major mode for the modeling language Abs       |

#+begin_export html

#+end_export

You need basic HTML and JS knowledge to know how to use the library.

the link tag is to load CSS, and the first two script tags are to load JS.
$("table") is a JS function call which selects all HTML tables, and .DataTable() is to initialize Datatable.

Customization is performed by defining options in the $().DataTable() constructor - for example, in the following code the pageLength and order options are used to show 18 rows per page and the default sorting to have the 2d column sorted in ascending order.
$('table').DataTable({
"pageLength": 18,
"order": [1,'asc']
});

Full range of options is documented here.
Comment: Thanks, your solution works perfectly. But what worries me is that I can't make it work when I try to store the CSS and JS files locally. So how is one supposed to modify the JS or CSS code if the files aren't editable (besides their poor readability)?
Comment: @crocefisso You need to change the href (for css) and src (for js) attributes to point to your file. The "min" in jquery.min.js means it is minified, remove it from the filename, you'll get the pretty version, i.e., https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js. You're not supposed to edit them directly, you can write your own CSS and JS code to overwrite their behavior.
Comment: everything works fine now thanks, no more worries :-)
Answer: Here's a proof of concept, along the lines described in the comments. There are several things that need to be done to it in order to turn it into a "real" solution, which I will describe at the end of the answer. In particular, it is NOT a complete solution: it's missing the part where Org mode produces the HTML that is needed for this functionality. Instead, this last part requires manual tweaking of the HTML - for now.
Here's the Org mode file I used:
#+HTML_HEAD:

* foo

#+name: myTable
| name  | city          | state          |
|-------+---------------+----------------|
| Alice | Boston        | Massachussetts |
| Bob   | San Francisco | California     |
| Ted   | Chicago       | Illinois       |
| Carol | New York      | New York       |

There are two things of note here that I will explain in the rest of the post:

the #+HTML_HEAD:  line
the #+name:  line

If you start with just the table and none of the extra stuff and you export to HTML, you will find the following HTML in the output file (with most of it elided to save space):
...

<colgroup>
<col  class="org-left" />

<col  class="org-left" />

<col  class="org-left" />
</colgroup>

name
city
state

...

The first problem here is that in order to manipulate the table you need to be able to get a handle on it. The Document Object Model (DOM) specifies these things and you'll need to learn a bit about it in order to understand JS code that manipulates elements (e.g. tables), but it's beyond what I can cover here. Suffice it to say that the table should have an id property which will allow a JS program to get a handle on it.
We can get an id tacked on if we name the table: that's what the #+name:  line does. If you add that line to the file  and export again, you will see that the
 tag has changed:

We get an id but it's something that Org mode produces and there is no easy way to predict what it is going to be. We need the id to be something well-known that we can use in other contexts, e.g. the name we gave to the table: myTable. Fortunately, there is an option for that: org-html-prefer-user-labels which, if set to t, produces an id with the actual value of the #+name:  keyword. You can customize the variable - or you can  set it in your init file:
(eval-after-load "ox-html" (setq org-html-prefer-user-labels t))

Restart your emacs and check the value with C-h v org-html-prefer-user-labels to make sure it is set.
If you now export again, the
 line looks like this:

and we can get to the the table using the id myTable.

Now for the #+HTML_HEAD:  line which addresses the second problem: providing a JS file containing the sorting function to be used for sorting the table by column.
The #+HTML_HEAD:  keyword adds its value literally into the HTML file's header, so when the HTML file is transferred from the server to the browser, the  line will be part of it. When the browser parses the file it will download the file foo.js from the same directory as the HTML file and have its JS engine compile it and remember the function(s) defined in it.
In this case, foo.js contains a single function, sortTable, cribbed from the  How to sort a table link I mentioned in a comment. I just cut-and-pasted the definition of it into a local file foo.js: it's the one from the Sort Table by Clicking the Headers section of that link.
The sortTable function takes a single argument, the column number n, and sorts the table by that column, alternating ascending and descending order on every click. It needs to know which table it applies to and if you look at the function, it hardwires the name in its implementation (I changed it from their myTable2 to myTable to match the name of the table above).

Finally, here comes the manual tweaking that is required to tie the clicks on the table header with the sorting function. In the exported HTML file, find the part that looks like this:
name
city
state

and modify it to look like this:
name
city
state

Save the file and then visit it in the browser, using a file:///..../foo.html URL. Or you can copy the HTML file AND the JS file to some place on the server and use an http://.../foo.html URL. Then click on each column of the table header and watch it sort.

OK, this is a proof-of-concept, so manual tweaking of the output is allowed :-), but in general you will want that to happen automatically. I hope the exercise above is useful, so you can understand what you need to do.
There is one change that is easy to make: modify the sortTable function to take the id of the table as an argument, so that the name of the table is not hardwired into the function. Instead, you specify the table when you set the onclick handler:
name

That way, you can use the same function for any table.
The final piece needed is to have Org mode produce the  tags without you having to manually add them. That can be done by using a filter to postprocess the HTML output, but if I had to do it, I think I would it with a derived exporter: start with the HTML exporter and then modify the org-html-table function to add the onclick property appropriately. For now, that's left as an exercise for the interested reader.
Comment: Thanks a lot, very illuminating. I'll try to do the exercise and post the solution if I find it.


Why do we treat molecular vibrations as linear harmonic oscillations and not 3D isotropic?

Question: Born-Oppenheimer approximation leads to this equation for the eigenfunctions and eigenvalues describing molecular vibrations: $$\left[-\frac{\hbar^2}{2\mu}\frac{1}{R^2}\frac{\partial}{\partial R}\left(R^2\frac{\partial}{\partial R}\right)+\frac{\langle\Phi_s|\mathbf{N^2}|\Phi_s\rangle}{2\mu R^2}+E_s(R)-E\right]F_s(R)=0$$
(faithfully copied from page 484, Physics of Atoms and Molecules, Bransden & Joachain 2003). Assuming that we are dealing with a molecule which is not rotating (i.e. $\mathbf{N}=0)$, and approximating the curve $E_s(R)$ with the harmonic potential $\frac{1}{2}k(R-R_0)^2$ in the vicinity of its point of minimum, the B.O. equation above is totally equal to that of a 3D isotropic harmonic oscillator with null angular momentum. Therefore, its solutions should be given by associated Laguerre polynomials times some stuff. Turns out that Hermite polinomials are used instead. Why? The idea that a 3d harmonic oscillator which does not rotate should boil down to a linear harmonic oscillator makes total sense to me. But the equations give these two different polynomials and there's no way to say that $L_n^{1/2}(x^2)\propto H_n(x)$ (namely that associated Laguerre polynomials for null angular momentum case are proportional to Hermite p. of the same degree to make sure that eigenfunctions for 3d and 1d are the same). What am I doing wrong?
Comment: A  3D isotropic harmonic oscillator with null angular momentum is just a 1 DOF harmonic oscillator.
Comment: @ArnoldNeumaier not quite: the kinetic energy operator is very different.
Answer: For the radial part of the Schrödinger equation for 3D harmonic oscillator with $l=0$,
$$-\frac1{r^2}\frac{\mathrm d}{\mathrm d r}\left(r^2f'(r)\right)+Ar^2 f(r)=Ef(r),$$
one can use the substitution
$$f(r)\to \frac{g(r)}r,$$
which will lead to the equation
$$-g''(r)+Ar^2g(r)=Eg(r),$$
which is isomorphic to the Schrödinger equation of 1D harmonic oscillator. Thus, the solutions of Schrödinger equations for both 1D and (the radial part of) 3D harmonic oscillators are expressible in terms of the same kind of functions.
Interestingly, this works only in number of dimensions $n=1$ or $n=3$ (with generalized substitution $f(r)\to g(r)r^{\frac{1-n}2}$). For any other $n$, you'll get additional terms in the ODE for $g$ that will require Laguerre polynomials instead of Hermite ones.
Comment: Thanks! Now I understand why the book uses Hermite polynomials for calculating the expectation values of $\textit{R}$, the internuclear distance, on vibrational states with null angular momentum. The expval integral would read $$\int \frac{g_n(R)}{R}R\frac{g_n(R)}{R} Y_0^0(\Theta,\Phi)R^2sin\Theta dRd\Theta d\Phi$$ where the $g_n(R)$ are the 1D harmonic oscillator eigenfunctions. This amounts to calculating an expectation value on 1D oscillator states: $$\int g_n(R)R g_n(R) dR$$. I obtained different results with Laguerre polinomials of grade $n$, probably I goofed or used wrong formulae
Answer: I think Ruslan gave an excellent answer, and I thought I could add a bit of intuition from another perspective. Now, maybe I'm completely wrong about this because currently I don't deal with molecules, but in the field of optics, one encounters the equations that deal with diffraction of a laser beam (Fresnel diffraction) which lead to eigen modes who obey the 2D quantum harmonic oscillator equation.
These can be described with Hermite-Gauss modes when working in cartesian coordinates:
$$I(x,y,z)\propto H_n \left(\frac{x}{\frac{w}{\sqrt{2}}}\right ) H_m \left(\frac{y}{\frac{w}{\sqrt{2}}}\right ) \exp(-\frac{x^2+y^2}{2q^2}) $$
where q,w are parameters related to the size and divergence of the beam and $n,m$ are the quantum numbers of the mode (and z is the direction the beam is propagating in). See image taken from Wikipedia:

and in cylindrical coordinates the modes can be described with Laguerre-Gauss modes, where instead of Hermite polynomials as functions of x,y one encounters a generalized Laguerre polynomial as function of r and another $\exp (i m \varphi)$ term giving the beam "orbital angular momentum". (Image taken from this site)

As you can see, due to "degeneracy", the modes with $l>0$ can be represented both by LG modes and both by HG modes (their both valid bases to describe the propagation of the beam). However, $l=0$ is the same at both situations, because Hermite and Laguerre 0's polynomial are both constants.
What I'm trying to say is: you're doing nothing wrong, just working in a different, equivalent base, which for $l=0$ also give exactly the same modes.
Comment: Well one can indeed rewrite any polynomial as a finite sum of either Hermite or Laguerre or even Chebyshev polynomials, but is the expansion in LG basis "natural" for the QHO? Particularly, are the general expressions in terms of Laguerre polynomials similarly simple to those in terms of Hermite polynomials?
Comment: @Ruslan , I think so, because the Laguerre polynomials are not only solving the equation of a QHO in polar coordinates, they also commute with the angular momentum operator!  (I didn't check that but from my experience in Optics and from what I understand when I think about it, I think I'm correct), meaning that in a way, they are a "better" base for a 2D QHO than multiplying hermite gauss in each cartesian coordinate.

Again I want to express that because I didn't do any calculation or dealt with the material in this context, I may be wrong. It would be nice if someone could verify :)
Comment: Actually, the Hermite polynomials appear to only work for 1D and 3D cases. In 2D and 4D+ one needs Laguerre polynomials. I've edited my answer with this.
Comment: @Ruslan what do you mean by saying the Hermite polynomials work only for 1D and 3D? Here in 2D I just showed you it works as well, but just not as good :)
Comment: I mean that the natural solution of the _radial_ equation is in terms of Laguerre polynomials in 2D and 4D+, and in terms of Hermite ones in 1D and 3D. Of course, the separable solutions along Cartesian axes will be different, since the ODEs will be different.
Comment: @Ruslan , Great! We agree. I'm happy that I got to add to your answer


Whats does this command mean in Unix?

Question: What does it mean in Unix when you use . ./<filename>?
Thanks for the help
Answer: ". ./?" would try and run a program called '?' which would reside in the current directory and it would be run in the current shell.
The first dot means 'run in current shell' (rather than spawning a new one)., the './' means 'current directory' and '?' would mean an executable file called '?' would have to exist.
Comment: Note that a file does not need to be executable to be sourced by `.`. And it must be a shell script (i.e. you can't source a compiled executable).
Answer: Running . on a filename runs the commands in the file as though you typed them at the shell command prompt.  Unlike a shell script, environment variable (and similar) changes produced by the file persist beyond running the file; the changes made by a shell script are reverted when the script finishes.
Answer: The . or source command reads the given file into the current shell. I.e. basically the given file is a shellscript which is run by typing . filename, however using . (or source, which is equivalent) differs from running the file ordinarily as a shell script in that it doesn't spawn a subshell and thus retains variables that are exported by the script. So if the script sets and exports variables, they will still be set when the script finishes.
Answer: source or . take a file as parameter. Every line of code in that file is executed. So I don't think that
. ./

would work.
$ . ./
-bash: .: ./: is a directory
$ echo "echo Hello" > out
$ . out
Hello
$ source out
Hello

Whats does this command mean in Unix?


how can I see if my cron is running and doing the job?

Question: how can I see if my backups is saved after the minute assigned? how can I test it if it's ok?
Comment: you've posted an illegible screenshot with what looks like it might be an ftp session in the background and a terminal in the fg with fuzzy, unreadable text of what may be a crontab loaded in nano.  is it supposed to give useful information?  It doesn't.  Don't post images when text will do.  especially don't post screenshot images of text.  Images can't be searched, edited, copy-pasted or even viewed on screens with higher resolution than yours (or by sight-impaired users dependent on screen-reading software).  Delete the image, then copy and paste the TEXT from your shell into the question.
Comment: i'm on no gui to copy the text
Comment: can you translate that into english?
Answer: You have a couple of options here:

Check the modification date of the file to see if it's being updated:

ls -l /var/backups/your-file.sql

If you haven't quite migrated over to systemd yet, cron should be logging to /var/log/syslog, in which case you can do something like this and check the timestamps:

cat /var/log/syslog | grep -i cron

If you are on systemd though, you'll need to use this command:

sudo systemctl status cron
And look for something along the lines of this for your user:
Jun 28 17:44:01 openSUSE cron[1865]: pam_unix(crond:session): session opened for user billy by (uid=0)
Alternatively, you could put that command into a script that logs the outcome for you:
#!/bin/bash

# It's good practice to include the full path to the executable when calling it in a script, especially from cron
DATE=/usr/bin/date
MYSQLDUMP=/usr/bin/mysqldump

# Run your backup command here
$MYSQLDUMP -u user -p password database > /var/backups/backup.sql

# Then check to make sure it executed successfully
if [[ $? -eq 0 ]]; then
    echo "$DATE - Backup saved"
else
    echo "$DATE - Backup failed"
fi

Save that as a file called say db-backup.sh, give it execute permissions, and then set that as the cron job instead.Just remember to use the full path to the script since cron may have a different PATH than you do.
Answer: You can check for your logs, you can see if cron job executes:
Jun 24 12:42:01 serversuit CROND[24483]: (root) CMD (echo "hello" > /tmp/testfile)

Also you can send all output to some file:
/scripts/testscript.sh &> /logs/testscript.log

Take a look here for more examples of cron job troubleshooting.


how does Ping resolve website

Question: When I do ping stackoverflow.com from command window in Windows, how does it get the ip address of stackoverflow. Basically how does the entire thing work ?
Comment: Isn't anybody going to start w/ the keyboard controller and work out from there? He did say "the entire thing"...
Comment: Heh, I was thinking about it, Evan, but then realized it would be a big pain in the rear to explain. :)
Comment: Sometimes the time and effort is not deserved.
Comment: Evan, I would have thought you could explain all of it, including the keyboard controller within 5 mins of the question being asked!
Comment: @Evan Anderson = sic
Comment: The *entire* thing? Don't forget the CS, EE and Physics guys over on the Area51 SE site.
Comment: @Evan I gave it my best shot :) @ErikA & @Warner Aww common the effort is almost always worth it :)
Comment: Although it made me a little sad to cast a close to SU vote after i wrote it.
Comment: @Zypher - we appreciate your contribution on SU too.
Answer: For @Evan (because I'm waiting for rm -rf to finish before i can do work):
Here is the process of ping resolving a website:

An electrical signal in your brain generates what is known as an idea.
This idea is converted to another electrical signal, that travels from your brain, down your spine and into the nerves in your hands where it is processed by the muscles in your fingers.
Your fingers convert this electrical energy into mechanical energy which forces the proper key down on your keyboard.
The depression of the switch on the keyboard triggers another electrical signal to travel down the wire (or over the airwaves) from your keyboard which triggers an interrupt at the hardware level.
This interrupt alerts the operating system of a pending action it needs to take.
The kernel process the signal from the keyboard and outputs feed back to the screen
the light energy on the screen is converted into electrical energy by your eye and sent to the brain for processing
Once the brain has processed and confirmed the readout from the screen is what you want, repeat steps 1-8 until you send the signal to depress the "enter" key
The ping command then takes the input - in this case ping serverfault.com - and sends a signal to the Operating system to do a DNS LOOKUP
The operating system sends a signal to the DNS subsystem, which generates a packet and sends it down the OSI model until it reaches the hardware
an electrical signal is generated on the nic and sent out the ethernet cable (or whatever physical connectivity if fiber s/electrical/optical )
The signal goes through intermediary network connectivity (switches/routes/etc) until it reaches the DNS SERVER
The DNS SERVER processes the request and reverses steps 10-11 to get back to your machines where it is processed by the OS and passed back to ping.

(I skimped on a couple of places mostly because i ran out of juice and only have 1/2 a cup of coffee in me)
Comment: Skimping or no skimping, that was impressive considering it's not even Friday.
Comment: @Zypher = > was a great answer. Though when I said the entire thing I did not expect electric signal from brain in the answer :).
Answer: It is called DNS.
Comment: and http://en.wikipedia.org/wiki/Ping
Comment: If I wouldn't have hit the captcha, it would have been a simul-post. :)  +1.
Comment: Yah damn thing! hahaha. I think you beat me.. +1 for you too!
Answer: First it uses your local host file then it uses your primary dns server, if that fails it goes to the secondary dns server.
Comment: Why others forget the host file.
Answer: Take a look at the following...
http://en.wikipedia.org/wiki/Routing_table
http://compnetworking.about.com/od/hardwarenetworkgear/f/routing_table.htm
Also look up routing metric's
These are some fundemental networking
Comment: Although these links may answer the question, it is preferred for you to summarize the links so we have a actual answer here

how does Ping resolve website


Robust Optimization and Supplier Selection

Question: I would like to incorporate a constraint to my model, this constraint is related to supplier quality or/ reliability selection  with respect to efficiency, furthermore, I would like to make the parameter $ q_{s} $ as an uncertain and deal with it using robust optimization where $ {1}\geq  q_{s}\geq {0} $ and $ \varepsilon _{s} $ is a lower bound parameter, for instance 0.95.So I am wondering if the below constraint is correct? I would like also to know if considering the parameter $q_{s}$ as an uncertain parameter in robust optimization is a valid assumption ?
 S : Set of suppliers.
W : Set of warehouses
C : Set of customers.
$ Q{sw}$ : decision variable: amount of product shipped from s to w.
$ Q{wc}$ : decision variable: amount of product shipped from w to c.
 $ q_{s}$ : non-defective rate of ssuplier.
 $ \varepsilon _{s} $ : minimum acceptable non defective rate.
 Constraint:
$ q_{s}* \sum_{s}\left(Q_{sw} \right) \geq \sum_{s}\left(Q_{wc} \right)* \varepsilon _{s} $ for all s
 The original constraint was nonlinear given as;
$ \frac{q_{s}* \sum_{s}\left(Q_{sw} \right)}{\sum_{s}\left(Q_{wc} \right)} \geq  \varepsilon _{s} $ for all s
Comment: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Comment: Thank you for the feedback, I have updated my questions clearly, hope this help get feedback.
Answer: RO is still in academic research area and several methods have been proposed. What I would do is this( not using any math programming model as you have already formulated already)

Solve for q=0
Solve for q=1: in other words best and worst case scenario.
Use max (or min) of the two optimal values
Or
Then use the values of the decision variables as bounds and re-solve without q.
Or
Goal programming: use the optimal values of the above two cases as constraint ( upper and lower bound), on the objective function with slack variables ($s^+$,$s^-$): max and min deviation and solve with objective as min ($s^++s^-$).
You can use both 4&5.
Below are couple of materials. I'd add one more that I found in this forum couple of days back.

Reading 1
Reading 2 as mentioned here
Reading 3
Comment: Understood, its a box set. Added one more reading. Hope it's helpful.
Comment: In the 2nd paper from pages (3-5) using Box set (Table 1) I'd try a Robust counterpart as $ \sum_s Q_{wc}\epsilon - \sum_s Q_{sw} \vert q_s \vert_{2}  $
Comment: Linearization is correct. That's how you avoid division to make it convex. As for the forms to use, couple of papers should be useful to determine the robust counterpart.
Comment: Thank Sutanu for your feedback, my point is I am planning to utilize RO in my model, which does consist of uncertain parameters already, however, I would like to extend it a little bit more, because it seems little bit trivial. I am planning to apply RO, with interval, ellipsoid and polyhedral sets, so I am wondering, if adding this constraint, and do some analysis on the supplier selection along with other parameter may be valid .
Comment: The constraint is saying, if the some over all the suppliers non defective rate of the shipped amount is less than the lower bound epsilon (i.e minimum acceptable non defective rate).
Comment: Thank you for the links, my question is about the constraint it self, if it is correct or not ?
Comment: Thank you so much, first the constraint was  nonlinear, $\frac{q_{s}* \sum_{s}\left(Q_{sw} \right)}{\sum_{s}\left(Q_{sw} \right)} \geq  \varepsilon _{s}$, then, I linearize it like that,
$ q_{s}* \sum_{s}\left(Q_{sw} \right) \geq \sum_{s}\left(Q_{sw} \right)* \varepsilon _{s}$ which I am not sure if it is correct, and then if the constraint is correct, is it safe to handle $q_{s}$ as uncertain param utilizing RO ?
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/142560/discussion-between-abde-and-sutanu).


Hotels and code requirements for living space

Question: Do hotels in the United States in New York City for example have to uphold code requirements for living space?
If they don't couldn't someone just open up a couple of sheds in their backyard call it a hotel and rent them out?
Answer: This question is controlled almost entirely by local municipal and county ordinances. It is not a question of federal law that is uniform across the U.S. and in most cases it is not even a question of state law. So, there is no single answer to your question.
Most localities regulate this with some combination of hotel specific building codes (usually incorporated by reference from a uniform building code promulgated by a private non-profit organization as a model building code provision) and hotel specific local zoning ordinances.
Answer: washington
Hotels are regulated, my neighbor's house is not. A 'hotel' is defined in RCW 19.48.010:

Any building held out to the public to be an inn, hotel or public
lodging house or place where sleeping accommodations, whether with or
without meals, or the facilities for preparing the same, are furnished
for hire to transient guests, in which three or more rooms are used
for the accommodation of such guests, shall for the purposes of this
chapter and chapter 60.64 RCW, or any amendment thereof, only, be
defined to be a hotel, and whenever the word hotel shall occur in this
chapter and chapter 60.64 RCW, or any amendment thereof, it shall be
construed to mean a hotel as herein described.

My neighbor does not call it a hotel, and there is only a single room occasionally rented out as a sleeping accommodation.
RCW Chapter 79.62 addresses safety laws, this time referring to "transient accommodation" which means

any facility such as a hotel, motel, condominium, resort, or any other
facility or place offering three or more lodging units to travelers
and transient guests

and note that it doesn't have to be a building. Also, this definition does not include "for hire". Most of the implementational details are spelled out in the regulations administratively written to say exactly what one must do, in 246-260 WAC, which covers "facilities offering three or more lodging units to guests for periods of less than thirty days", including "rustic resorts" and B&Bs. As you can see, it depends on how many sheds or how big a shed you have.
Rustic resorts typically fail to be "up to code", in fact many buildings are not up to current code. "Code" is a concept that applies to construction: you can be up to code in 1947 and totally out of code 60 years later. There can, then, be specific requirements of particular establishments – hotels – regarding safety and sanitation. 246-260 WAC says what you have to do in that respect.
The government has regulatory discretion to waive requirements if you can devise a decent argument for doing so. An example is that any such facility has to have electricity, water, sewer etc. and that is an unreasonable requirement for a cabin in the mountains that you hike to. It is hard to predict when they will consider exemption to be reasonable vs. unreasonable, but as far as an urban tool shed is concerned, it would be unreasonable to suspend the health and safety regulations.
Before you decide to start renting your tool shed out, you should also consult municipal ordinances. Seattle also regulates businesses and has ordinances related to operating B&Bs, which were recently made more draconian to cut back on the number of B&Bs. The ordinance uses the expression "dwelling units or portions thereof", and does not specify a threshold of three as per state law. The trigger is being "occupied by a person for less than 30 days". Therefore, in Seattle, your shed-motel is regulated.


How to ensure a user doesn't miss a webpage crucial for constructive usage of another webpage?

Question: I have a problem of the need to ensure that a user doesn't miss a webpage crucial for what I assume as a constructive usage of another web page.
Personal example of this problem
My website contains a pricelist webpage and a contact webpage containing a simple contact form, which contains the following mandatory fields:

Name
Email
Type of service in which the inquirer is interested (selected from a selection list of up to five options)

Possible solutions for this problem
1. Noting that prices are available in pricelist before each form submission
This is the simplest solution I know of and took it so far:
Each selection option in the select list of my contact form contains a parenthesis note according to which price is available in price list:
VARIABLE message = "price is available in price list"

Per variable call in each job description line:

Job 1 (price is available in price list)
Job 2 (price is available in price list)
Job 3 (price is available in price list)
Job 4 (price is available in price list)
Job 5 (price is available in price list)

The main problem with this approach is that it might feel absurd to a customer although I personally assume a customer who really needs some proposed job wouldn't care from it much and would inquire anyway but I have no objective evidence for this assumption

2. Uniting two webpages
Similar to what I understood from Stephen Ostermiller's comments, this is problematic in this case, because, even if the contact form is under the pricelist:

A potential customer might want to know prices without contacting → not knowing prices are in the contact webpage which may cause stress when visiting that web page.
If a potential customer clicked on a contact and then percepted a pricelist it might confuse that potential customer
A link such as "prices and contact is quite long and possible very not intuitive

Notes

My pricelist page contains notes about international payment options and some other notes which makes the page a bit longer than just a table of prices and is also splitted to three chapters, each one dealing with another type of service; henceforth, I consider it a crucial webpage and would like any potential customer to use it
Setphen Ostermiller commented:

Somebody could explain how to pull information from a centralized
  database into two different pages or say how to set up AJAX calls to
  get the information from one page to the other.

If this is still relevant after the massive edit of this question, I would welcome an answer further explaining what is proposed to be done --- what is proposed to be presented in two different ways for a potential customer, via two different Ajax calls, as a solution to the problem.
My question
How to ensure a user doesn't miss a webpage crucial for constructive usage of another webpage?
Comment: Yes, that sounds like a good summary.
Comment: What is somebody wants to see prices but doesn't want to contact you?  Do they have to look at your contact page to find out prices?  How would they know to do that?   If they got there by clicking on "price list", wouldn't the contact form confuse them?  Would they know to look past it?
Comment: @StephenOstermiller sorry if I am nuddgy about this but `A potential customer might want to know prices without contacting → not knowing prices are in the "contact us" webpage which may cause stress when visiting that web page.` AND `If a potential customer clicked on a "contact us" and then percepted a pricelist it might confuse that potential customer` aren't a good summary of your above comment?
Answer: I'm curious how the OP resolved the issue presented....
I think they should have developed 5 separate pages: one for each job level. Each page would have contained information about the specified job level itself, estimated price range, and a short form to request additional information.
My solution would have combined the information, price, and contact on each page, all with a similar format. This would allow the site visitor to focus specifically on what they were looking for without a lot of hunting. And it would allow the site owner to treat each job level as a separate "landing page" for SEO purposes.


How can we find all the subgroups?

Question: I want to find all the normal subgroups of $D_n$.
We have that $K$ is a normal subgroup of $D_n$ iff $$gkg^{-1}=k\in K, \forall g\in D_n \text{ and } \forall k\in K$$ right?
Could you give me some hints how we could find all these subgroups?
Comment: Are you familiar with the fact that $s$ and $r$ generate $D_{2n}$ where, $s^2=r^n=e$ and $srs^{-1}=r^{-1}$.
Comment: Yes. How can we use this fact? @AnuragA
Answer: A good place to start is to determine the conjugacy classes of $D_n$. Since a subgroup $H$ is normal in $G$ iff $H$ is the union of some conjugacy classes of $G$, you can try to union two or more conjugacy classes and see if the order of the resulting potential subgroup divides $|G|$. This approach usually narrows down your research quite a bit.
Comment: Why is a subgroup $H$ normal in $G$ iff $H$ is the union of some conjugacy classes of $G$ ? Is this equivalent to $$gkg^{-1}\in K, \forall g\in D_n \text{ and } \forall k\in K$$ ?
Answer: You will likely need to distinguish the cases when $n$ is even and when $n$ is odd. To start off, try finding the conjugacy classes of $D_n$, and then take unions of these classes to see if they form subgroups of $D_n$ (because normal subgroups are those which are the union of conjugacy classes).
Let us take $D_4$ as a concrete example. We want to find the conjugacy classes of the elements of $D_4$, which can be split into two sets: the set of elements of the form $r^a$ and the set of elements of the form $r^as$ (for $0 \leq a \leq 3$).
To find the conjugacy class of $r^a$, we need to take elements of $D_4$, conjugate them with $r^a$, and see what results you have. The set of results you obtain is your conjugacy class of $r^a$. There are two cases for this arbitrary element: either it is in the form $r^b$ or $r^bs$ (again, for $0 \leq b \leq 3$). If we take an element of form $r^b$, we have $(r^b)r^a(r^b)^{-1}=r^br^ar^{n-b}=r^{b+a+n-b}=r^a$, so $r^a$ conjugates with $r^b$ to give back $r^a$. If we take an element of form $r^bs$, we have $(r^bs)r^a(r^bs)^{-1}=r^b(sr^a)(sr^{n-b})=r^br^{n-a}(ss)r^{n-b}=r^{b+n-a+n-b}=r^{n-a}$. Therefore, our set of results is $\{r^a,r^{n-a}\}$, so the conjugacy class of $r^a$ is $\{r^a,r^{n-a}\}$. If we go over all values of $a$, our distinct conjugacy classes are $\{\varepsilon\}$, $\{r,r^3\}$, and $\{r^2\}$.
We repeat this process for the element $r^as$. We have $(r^b)r^as(r^b)^{-1}=r^br^asr^{n-b}=r^br^ar^bs=r^{2b+a}s$, and $(r^bs)r^as(r^bs)^{-1}=r^bsr^a(ss)r^{n-b}=r^br^{n-a}sr^{n-b}=r^br^{n-a}r^bs=r^{b+n-a+b}s=r^{2b-a}s$. This is a bit more complicated since we ended up with a conjugacy class $\{r^{2b+a}s,r^{2b-a}s\}$, where $b$ can take on multiple values. What you will find is that since $2b$ is even, $2b+a$ and $2b-a$ are even when $a$ is even, and odd when $a$ is odd. And since $0 \leq b \leq 3$, the possible values of $2b+a$ (mod 4) for even $a$ are {0,2}, and the possible values of $2b+a$ (mod 4) for odd $a$ are {1,3}. Therefore, the conjugacy class of $r^as$ where $a$ is odd is $\{rs,r^3s\}$, and the conjugacy class of $r^as$ where $a$ is even is $\{s,r^2s\}$.
Now, you have all conjugacy classes of $D_4$: $\{\varepsilon\}$, $\{r,r^3\}$, $\{r^2\}$, $\{rs,r^3s\}$, and $\{s,r^2s\}$. Now you can try to find which unions of these classes produce a subgroup, in which case it must be normal. In this particular example, there are precisely 6 normal subgroups: $\{\varepsilon\}$, $\{\varepsilon, r^2\}$, $\{\varepsilon, r, r^2, r^3\}$, $\{\varepsilon, r^2, rs, r^3s\}$, $\{\varepsilon, r^2, s, r^2s\}$ and $D_4$ itself.
The calculation is the same for odd $n$, but the subgroups will come out differently. Try repeating this procedure for a small odd $n$, and you will see that there is a pattern in the subgroups of $D_n$. Then, you will be able to generalize about the subgroups of $D_n$.
Hope this helped.

How can we find all the subgroups?


Why do Perl's logical operators &&, ||, ! take precedence over and, or, and not?

Question: This is probably a minor point, but I was wondering why Perl's logical operators (&&, ||, and !) take precedence over the easily understandable "English" logical operators (and, or and not). Is there any advantage of using the former set and any disadvantage of using the latter set in a script?
Comment: If they were identical in preference, it would not be necessary to keep both versions - only one would be enough to keep. Since Larry is a linguist and liked to use plain English words across his new language, he introduced these (alongside with `unless` and others). And of course, he assigned meaning to these words that he liked better (and still different from C-style operators)
Comment: Because Larry Wall liked it that way?
Answer: The original &&, || and ! operators are high precedence to match the C language.
The newer (but still old) and, or and not operators were added to simplify some common constructs.  For example, compare:
open my $fh, '<', $filename || die "A horrible death!";
open my $fh, '<', $filename or die "A horrible death!";

The first of these is incorrect; the high priority || binds with $filename and die which is not what you want.  The second is correct; the low priority or means that the missing parentheses do not lead to ambiguity.
Comment: +1 because this is the actual reason Larry Wall gives in *Programming Perl*.
Answer: If || and or had the same precedence, then
return some_func $test1 || $test2;

would mean
return some_func($test1) || $test2;

instead of
return some_func($test1 || $test2);

or
some_func $test1 or die;

would mean
some_func($test1 or die);

instead of
some_func($test1) or die;

Neither of those changes are desirable.
And while one could debate or is more easily understood than ||, it's harder to read. It's easier to read code when the operators don't look like their operands.
Answer: Logical Precedence and Clarity
While I have no idea whether this was the reason that got them in the language, they're incredibly useful for writing clear code,
## Some sample data...
my ($foo, $bar, $baz) = (0,1,1);

## Different results..
say ( $foo && $bar || $baz );
say ( $foo and $bar || $baz );

We can use this in code, even with \n. No noisy parens needed.
## When would you use this...
if (
  $cache->is_outdated
  and $db_master->has_connection || $db_slave->has_connection
) {
  $cache->refresh
}

This would otherwise have to be,
  $cache->is_outdated
  && ( $db_master->has_connection || $db_slave->has_connection )

But, perl doesn't like all that line-noise that other languages force upon its users.
Answer: converting comment to an answer:
If these operators were identical in preference, it would not be necessary to keep both versions - having only one version would be enough.
But Larry Wall is a linguist, and he really liked to use plain English words across his new language. So, he introduced these English-style operators (alongside with unless and others).
To keep C-style operators and their classic meaning, he needed to make new keywords not redundant. Because of that he assigned slightly different meaning to these operators that he liked better. So that difference turned out to be operator precedence.
Comment: No it's not what you said. *"[Larry Wall] really liked to use plain English words across his new language. So, he introduced these English-style operators...He needed to make new keywords not redundant \[so\] he assigned slightly different meaning to these operators that he liked better."* is fairy tale nonsense.
Comment: That isn't true: it is nothing to do with Larry's predilection for English words. `and` and `or` were included in addition to `&&` and `||` purely to offer identical operators with a lower binding priority. They are particularly useful in Perl because function calls don't require parentheses around the parameters.
Comment: Isn't that what I said? If they were identical in priority, `and` and `or` would not exist today. And English-style constructs certainly do offer more flexibility, I am not disputing that either
Comment: The only person who can tell this for certain is Larry Wall himself


How to stop threads of a Java program?

Question: I have made a java program with GUI and have placed a "stop" button on it. When I start the program, the main thread starts 10 threads. Now I want that whenever a user click on "stop" button, all the threads should terminate first, then the main thread should terminate. How can I do that.
Comment: I think you need to supply some code with your question, as this could have something to do with your initialization of the threads.
Answer: It depends on how you want to the 10 threads to "terminate", and how you are running the threads.
I recommend creating an ExecutorService, and writing your "threads" as Runnable implementations. These Runnable objects should respond to calls to interrupt() on their thread of execution by aborting their task, cleaning up, and exiting the run method as quickly as possible.
Submit these Runnable tasks to an ExecutorService then call awaitTermination, all in the main thread. When the user presses the "stop" button, call shutdown or shutdownNow as desired on the ExecutorService (from the event dispatch thread).
If you call shutdownNow on the executor service, it will notify the running tasks by interrupting their threads. If you call shutdown, it will allow the tasks to complete without interruption. Regardless, your main thread will block on awaitTermination until all of the tasks have completed (or the time limit runs out).
You can, of course, create and manage of all of the threads yourself, using join. The key is to make the threads interruptible if you want to be able to stop them prematurely.
Answer: Firstly, let me note that there is a tempting method on the Thread class called stop(). Do not use it, it is dangerous.
One way of doing this is to code your 10 threads to check the interrupted status of the thread.
e.g.
while (! Thread.interrupted())
{
     // Do your thread's work
}

You can interrupt each worker thread by calling the interrupt() method on the Thread object, and then calling join() to wait for the thread to actually finish.
Answer: Give all Threads a shared instance of a Boolean and let them check periodically if it is true. If it's true the Thread should return from its run method. Set this Boolean to true if the user presses the stop button and then use Thread.join() to wait for all Threads.
Comment: Why on earth would you flip the boolean with b=!b?  It would be terminate=true or running=false.  any =! would just be opening you up for a bug.
Comment: And what would happen if the flipping would be done in the traditional b=!b; way and two separate threads would try to flip the controller boolean? :) Certainly can be worked around but not the solution I'd prefer.
Comment: In the question there is only a stop button that sets this Boolean. No danger. It's only set once.
Comment: That said, by the way, calling interrupt on each thread probably makes more sense.
Comment: Is this interrupt not just a boolean in disguise? It is still no real interrupt since it inside the thread you need to check if the thread is interrupted.
Answer: Thread.stop() is deprecated, and it's adviced that you use a 'running' flag that is periodically checked by the Thread so it can terminate itself when you set the the flag to false. If the Thread has long wait phases, you can interrupt() it to wake it up from a wait() state.
-> Thread.stop() int he Java API doc
After terminating your Threads by setting the running condition to false, you can have your main Thread join() the other Threads sequentially to wait for their termination.
Answer: The suspend() and resume() methods on the Thread class are deprecated because they are inherently unsave.  Look at this article for information on why they were deprecated and techniques to stop threads:
http://java.sun.com/j2se/1.5.0/docs/guide/misc/threadPrimitiveDeprecation.html
Answer: If your threads are waiting on an InputStream then just add some boolean flag to threads and close the stream. Threads will wakeup, check the flag and exit. Same if they are waiting on a Condition (Object.wait()), use notifyAll() and set the flag. If your threads are constantly looping (which is BAD), just set the flag :)

How to stop threads of a Java program?


How do you connect ADB to a Nook on a Mac?

Question: adb devices returns nothing when I connect my Mac to the Nook.
Does it need a special driver or some configuration setting?
Answer: To get a NOOK into developer mode, you have to join the NOOK Developer program at http://nookdeveloper.com and then upgrade to NOOK App Developer. The Developer Mode tool will create a provision.cmd file for you to download to your NOOK and then it will be fully accessible to adb, ddms, etc.
Tom
Answer: Make sure your Nook is in Debugging mode.


Do centralized exchanges misrepresent their Bitcoin holdings?

Question: For example, would an exchange of Bitcoin hold accounts for 100,000 customers, and they collective have 8000 bitcoins, but the exchange itself does not hold 8000 bitcoin, but only 1600 for customers to redeem (to transfer to their own wallet if they want to), and therefore, inflating the bitcoin supply by 6400 bitcoins?
Answer: It's certainly happened before when there was less regulation or among the smaller, less-regulated exchanges. Whenever an exchange disables withdrawals for everyone, it could be due to them running into liquidity issues like that.
Large exchanges are now regulated by various money services authorities in part to prevent this exact scenario.
Comment: @ieatpizza: I think there is very little oversight of cryptocurrency businesses. For example see https://www.fca.org.uk/consumers/cryptoassets which says *"most cryptoassets/services are not regulated"*. Even the more tightly regulated UK banks only have to meet a minimum reserve ratio of 12%.
Comment: how is it prevented? what is regulated? It would take a 1 to 1 requirement so that it is not inflated: if all customers have 8000 bitcoins, then the exchange must hold 8000 bitcoins
Comment: @nonopolarity Financial audits by regulators and such as a condition of maintaining a license. The requirements are different for every state/jurisdiction, but regulated exchanges should hold 1 bitcoin for every 1 bitcoin owned by its customers.
Comment: "regulated exchanges should hold 1 bitcoin for every 1 bitcoin owned by its customers." Is that an opinion or hope, or is it a fact? You are saying an exchange in US or in Canada or South America or Asia may vary too?
Comment: @nonopolarity That's the goal of properly designed regulation. The exact specifics of how that regulation is implemented is jurisdiction specific.


Can a physican website be on a non-HIPAA server?

Question: I'm starting my first website for a doctor's office and I'm wondering if the website needs to be on a HIPAA compliant server, even if no patient health information is collected or stored on the server? There would be no storing or even collecting of any patient health information.
Answer: An ordinary website, such as one advertising office hours, contact information and related media should be fine, so long as it is completely separate from the HIPAA-compliant network & systems that serve the doctor's office.
This also means that you cannot use this webserver for any remote-access services (ie: VPN portal), regardless of the fact that the webserver itself will not be "storing" any PII.
Comment: Very welcome! Cheers.
Answer: To add some additional info. I would post a warning on the contact us section that no medical information is to be transmitted and provide a safe method if one exists.  Also, the practice's Notice of Privacy Practices has to be posted on the site per HIPAA requirements.


Q-learning with 100-500 discrete actions

Question: I've a Reinforcement Learning problem where I want to learn the Q function. For action space of size in the order of 100s is Q learning a good option? Will it converge?
Answer: Yes, Q learning will work, but the problem is the size of the state-action space. Tabulating the Q function for each state-action pair is infeasible, so you'd need to use function approximation methods. Check out Lecture 6 of David Silver's course notes for details: http://www0.cs.ucl.ac.uk/staff/d.silver/web/Teaching.html
Answer: Are all actions feasible at each step? If there is some feedback that allows you to determine quickly that an action is suboptimal, you can learn to eliminate it - https://openreview.net/forum?id=HyejB4J2xX
Maybe there is an updated version on arXiv