How to convert std::chrono::time_point to string

Question: How to convert std::chrono::time_point to string?
For example: "201601161125".
Comment: See:  http://howardhinnant.github.io/date_v2.html  Section "What about a date-time type?"
Comment: Have you tried inserting it in `std::stringstream` and then converting it to string using stringstream's member function `.str()`?
Comment: No, I didn't. I'll do that. If your tip works, I'll let you know.
Answer: Update for C++20:
This can now easily be done in C++20:
#include <chrono>
#include <format>
#include <iostream>
#include <string>

int
main()
{
    using namespace std::chrono_literals;
    std::chrono::time_point tp = std::chrono::sys_days{2016y/1/16} + 11h + 25min;
    std::string s = std::format("{:%Y%m%d%H%M}", tp);
    std::cout << s << '\n';
}

Output:
201601161125

Demo.
Original Answer:
Howard Hinnant's free, open source, header-only, portable date/time library is a modern way to do this that doesn't traffic through the old C API, and doesn't require that you discard all of your sub-second information.  This library is also being proposed for standardization.
There is a lot of flexibility in formatting.  The easiest way is to just stream out:
#include "date.h"
#include <iostream>

int
main()
{
    using namespace date;
    std::cout << std::chrono::system_clock::now() << '\n';
}

This just output for me:
2017-09-15 13:11:34.356648

The using namespace date; is required in order to find the streaming operator for the system_clock::time_point (it isn't legal for my lib to insert it into namespace std::chrono).  No information is lost in this format:  the full precision of your system_clock::time_point will be output (microseconds where I ran this on macOS).
The full suite of strftime-like formatting flags is available for other formats, with minor extensions to handle things like fractional seconds.  Here is another example that outputs with millisecond precision:
#include "date.h"
#include <iostream>

int
main()
{
    using namespace date;
    using namespace std::chrono;
    std::cout << format("%D %T %Z\n", floor<milliseconds>(system_clock::now()));
}

which just output for me:
09/15/17 13:17:40.466 UTC

Comment: I think it's better to have the examples here not `using namespace whatever`, so that it's clearer which functions and types come from which namespace.
Comment: One of the problems is that the namespaces are changing with time:  `floor` was in namespace `date`, but starting with C++17 is in namespace `std::chrono`.  By C++20, everything will be in `std::chrono`.
Comment: @HowardHinnant Is there an easy way to discard trailing zeroes (and `.`, if necessary) in sub-second part of string produced by `date::format("%FT%TZ", p)` where `p` is a `system_clock::time_point`?
Comment: The best way to control the precision of the output is to truncate the precision of the input to `format`, such as the truncation to `milliseconds` in the example above.  There is no automatic way to detect trailing zeroes at run-time.  the only way to do so is to do custom post-processing on the generated string (reverse searching for zeroes).
Answer: The most flexible way to do so is to convert it to struct tm and then use strftime (it's like sprintf for time). Something like:
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
std::time_t now_c = std::chrono::system_clock::to_time_t(now);
std::tm now_tm = *std::localtime(&now_c);
/// now you can format the string as you like with `strftime`

Look up the documentation for strftime here.
If you have localtime_s or localtime_r available you should use either in preference to localtime.
There are many other ways to do this, but, while mostly easier to use, these result in some predefined string representation. You could just "hide" all of the above in a function for ease of use.
Comment: Mr. Hinnant's library is not part of the C++ standard yet, while `strftime()` has been a part of C standard for a long time. It seems that in C++20 Mr. Hinnant's library will be a part of the C++ standard - when that happens, it will be hard to make a firm preference (it would depend on your needs and experience).
Comment: @EdwardFalk You are right, `struct tm` only has seconds, it does not include any smaller time unit measure.
Comment: Why is this preferable to using Mr. Hinnant's library?
Comment: localtime is not thread safe!
Comment: Correct me if I'm wrong, but is this not precise only to the nearest second?
Answer: Code solution
The following function converts from chrono time_point to string (serialization).
#include <chrono>
#include <iomanip>
#include <sstream>

using time_point = std::chrono::system_clock::time_point;
std::string serializeTimePoint( const time_point& time, const std::string& format)
{
    std::time_t tt = std::chrono::system_clock::to_time_t(time);
    std::tm tm = *std::gmtime(&tt); //GMT (UTC)
    //std::tm tm = *std::localtime(&tt); //Locale time-zone, usually UTC by default.
    std::stringstream ss;
    ss << std::put_time( &tm, format.c_str() );
    return ss.str();
}

// example
int main()
{
    time_point input = std::chrono::system_clock::now();
    std::cout << serializeTimePoint(input, "UTC: %Y-%m-%d %H:%M:%S") << std::endl;

}

Time zone
The time_point data-type has no internal representation for the time-zone, in consequence, the time-zone is aggregated by the conversion to std::tm (by the functions gmtime or localtime). It is not recommended to add/substract the time-zone from the input, because you would get an incorrect time-zone displayed with %Z, thus, it is better to set the correct local time (OS dependent) and use localtime().
Technical vs User-friendly serialization
For technical usage, hard-coded time format is a good solution. However, to display to users, one should use a locale to retrieve the user preference and show time-stamp in that format.
C++20
Since C++20, we have nice serialization and parsing functions for time_point and duration.

std::chrono::to_stream
std::chrono::format
Comment: Correct, if you have access to C++17, you can optimize this code with `std::string_view`, otherwise, `const char*` is also a possibility.
Comment: You create std::string from literal and then take c_str() from it => redundant malloc under hood. There is std::string_view for such purposes.
Comment: I replaced time_point with auto
Answer: A lot like Adrian's answer, but with (optional) milliseconds and GMT/localtime switch.
#include <chrono>
#include <iostream>
#include <iomanip>
#include <sstream>

using Clock = std::chrono::high_resolution_clock;
static std::string timePointToString(const Clock::time_point &tp, const std::string &format, bool withMs = true, bool utc = true)
{
    const Clock::time_point::duration tt = tp.time_since_epoch();
    const time_t durS = std::chrono::duration_cast<std::chrono::seconds>(tt).count();
    std::ostringstream ss;
    if (const std::tm *tm = (utc ? std::gmtime(&durS) : std::localtime(&durS))) {
        ss << std::put_time(tm, format.c_str());
        if (withMs) {
            const long long durMs = std::chrono::duration_cast<std::chrono::milliseconds>(tt).count();
            ss << std::setw(3) << std::setfill('0') << int(durMs - durS * 1000);
        }
    }
    // gmtime/localtime() returned null ?
    else {
        ss << "<FORMAT ERROR>";
    }
    return ss.str();
}

int main() {
    const auto tp = Clock::now();
    std::cout << timePointToString(tp, "%Z %Y-%m-%d %H:%M:%S.") << std::endl;
    return 0;
}

> GMT 2022-04-30 13:44:09.720
Test: https://www.mycompiler.io/view/43wsMbrMcmx
Granted it only appends the milliseconds and they're not part of the template... that would cost extra!
Answer: It will become easier with C++20 (as mentioned in
Adrian Maire's answer.)
#include <chrono>
#include <format>

#include <string>
#include <iostream>

int main()
{
  auto t = std::chrono::system_clock::now();
  std::string s = std::format("{0:%F %R %Z}", t);
  std::cout << s << '\n';
  return 0;
}

Note, As of now (February 2023) std::format is not implemented yet in most compiler releases, but hopefully will be soon in new releases. (You can check with preprocessor macros __has_include(<format>) and __cpp_lib_format.)
Docs on std::format: https://en.cppreference.com/w/cpp/utility/format/format
The format syntax ("%F %T %Z") is similar to strftime() or std::put_time() (haven't checked what the differences are, though) and documented at https://en.cppreference.com/w/cpp/chrono/system_clock/formatter.


How to deal with problems by changing the variables in wavefunctions?

Question: I found a problems where a particle was moving under a potential $V(r) = kr^2$ and with a wave function $ \psi(r,t) $. If the wave function is changed to  $ \psi(ar ,t) $, the ratio of average kinetic energy of final and initial is asked.
Now if I take $\psi$ to be linear and take the $a$ out and then find kinetic energy the answer comes out to be wrong. In the solution they have taken $ar$ to be some dummy variable and then changed r to the dummy variable and then integrated it. Is taking $\psi$ linear wrong?
And also what is the use of the potential given. Is it just to distract?
Comment: Why would you expect $\psi$ to be linear in $r$?
Comment: It looks like they're trying to prove the virial theorem. In that case you should get the same answer if you take $\psi$ to be linear (after all, they prove it to be true for *any* function of $ar$ so it should work for the specific case of it being lienar). So in general your method should get the correct answer, but is just not a general result.
Answer: I think to answer your question, the point of the $V(r) = kr^2$ is not to distract, but because in one of the integrals you will need to make a change of variables $R = ar$ and you will get an $a^{-2}$ factor from the $r^2$.
For the broader picture, this technique is often used to show the virial theorem from the variational method in quantum mechanics (and alot of this method will be identical to what is wanted in your question).
The general proof of the virial theorem for a quadratic harmonic oscillator potential $V(r) = kr^2$ should go something like this:
Suppose an exact eigenstate of the system is $\psi(\vec{r})$ and consider a variational state $\psi(a\vec{r})$ (where we will set $a=1$ later but keep it general for now).
The expectation of the potential energy of the state in d-dimensions is given by:
$$\langle PE \rangle_{var} = \langle \psi|V(r)|\psi\rangle = \frac{\int d^d\vec{r} |\psi(a\vec{r})|^2 kr^2 }{\int d^d \vec{r} |\psi(a\vec{r})|^2}$$
(using the fact that $\psi(a\vec{r})$ will not be normalised so we must divide by its norm  square in order to normalise the 2 $\psi$'s in the expectation value).
Using a change of variables $\vec{R} = a\vec{r}$ we get:
$$\langle PE \rangle_{var} = a^{-2} \frac{\int d^d\vec{R} |\psi(a\vec{R})|^2 kR^2 }{\int d^d \vec{r} |\psi(a\vec{R})|^2} = a^{-2} \langle PE \rangle_{exact}$$
(where we have seen that the fraction is equal to $\langle PE \rangle_{exact}$ since it's nothing but the usual expectation of potential energy for $\psi(\vec{r})$ but using the symbol $\vec{R}$ instead of $\vec{r}$)
Similarly we can show $\langle KE \rangle_{var} = a^2 \langle KE \rangle_{exact}$.
So $\langle E \rangle_{var} =  a^2 \langle KE \rangle_{exact} + a^{-2} \langle PE \rangle_{exact}$
Therefore differentiating with respect to $a$ to find the optimum value of $a$ which minimises the total energy.
$2a \langle KE \rangle_{exact} -2a^{-3} \langle PE \rangle_{exact} = 0 $
But we know $a=1$ is optimal so:
$\langle KE \rangle_{exact} =  \langle PE \rangle_{exact}$
Answer: Try writing out the S.E.
\begin{equation}
\frac{-\hbar^2}{2m} \Delta\psi+kr^2\psi=E\psi
\end{equation}
although cumbersome, it may be helpful to just solve the equation outright. In general it is not a good idea to assume the wavefunction is linear (this would usually make the wavefunction impossible to normalize over).
Comment: Actually what they did was take the new wave function and operated on it using the H operator excluding the potential term which gives the final kinetic energy. I got the answer this way but I was confused because my first approach was to take it a linear function and take constant term out but I didn't understand why it was wrong.


How to find main() in binary?

Question: Given a binary and only using a tool like ndisasm, how can I find main()?
I don't want to use smart tools like IDA Pro because I'm doing this exercise to learn.
Comment: I believe I already gave an answer to this question in the answer of this question: [Reversing ELF 64-bit LSB executable, x86-64 ,gdb](http://reverseengineering.stackexchange.com/questions/3815/reversing-elf-64-bit-lsb-executable-x86-64-gdb/3816#3816). Feel free to modify your question in order to ask for more details if you miss somethings.
Comment: What platform/OS/compiler you want to handle? Give us some concrete examples.
Comment: @perror And a fantastic answer it was. It's a shame when people don't even pay attention to the help you've given them.
Comment: @perror Great answer. Would it be much difference in Windows? Also, is it impossible to tell the entry point without this piece of information?
Comment: Yes, it would be very different. In fact, what I describe in this answer is bind to the `gcc` compiler. So, if you consider a different compiler, the layout may be totally different. But, if you are look for the `main` function in a MS-Windows context, you need to edit your question to specify it. It will help to get a more accurate answer.
Comment: @perror I have to correct you on that one. It is not bound to the compiler, rather to the binary file format : `ELF`, `PE`, ... which the compiler has nothing to do with.
Comment: No, it is really bound to the compiler. I am not speaking about the entry point, but the location of the `main` procedure which takes place after the loading of the dynamic libraries. Each compiler has its own function to do this. So, it is bound to the compiler.
Comment: @perror  From that perspective I agree. But I suppose you should've specified it in your comment. Technically speaking the location of the `main` function isn't important as long as it exists & it is referenced. So, compilers can put it anywhere they want it will eventually be found. I didn't look at your first comment, I wouldn't have answered otherwise, nice job !
Answer: This is quite tricky and necessitates a LOT of patience. I'll assume here that you're trying to find the main function as it is defined in C and not as the entry point of your program. It's very hard to find what you're looking for by scanning the code with your eyes & brain. But here's a way. What you can do is first check the header of the binary file you're trying to disassemble. Below you'll find the output of readelf -h on a random file. If the file isn't damaged (on purpose or not) you'll be able to find the Entry point address.
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x400440
  Start of program headers:          64 (bytes into file)
  Start of section headers:          4680 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         8
  Size of section headers:           64 (bytes)
  Number of section headers:         35
  Section header string table index: 32

This address usually points to the location of the first chunk of code which will be executed at run time (_start function) and which will handle the main function parameters (or command line arguments) before calling the main function. Another technique would be to run your program under a debugger (GDB for instance) and go step by step.
I have to warn you though, if you're dealing with ELF binaries, things could turn out to be more complicated as they contain ctor and dtor tables which hold pointers to functions that are executed before and after the main function. You have also some undocumented weirdness going on when dealing with statically linked binaries. And of course, other programs can make do without a main function and call whatever they wish.
Comment: Well, most programmers have no clue how a binary file is structured. They make assumptions based on "high level"  programming models that could, and most likely will, end up to be wrong once you dig into the nitty gritty details of what is a computer program. That's why you shouldn't believe teachers or instructors and still RTFM yourself.
Comment: this example shows nicely that what we learn in programming class is wrong: a program starts at function _start , not main. in fact, you can do a LOT of stuff before main even gets called the first time

How to find main() in binary?


Making an ERD of a movie database

Question: I have a school project in which I have to design a database and my theme is Movie database of sorts. I created a basic ER diagram and I will post a picture here so you can tell me where are my mistakes (I know I have a lot of those)...
I also want to add some new entities like "Genre" but I have a M:M relationship between "Movie" and "Genre" and I'm not sure if I can leave a M:M relationship in a ER diagram. Any advice about what am I doing wrong or how to implement "Genre" entity would be helpful.
Answer: Can a Movie have > 1 director (like the Marvel movies and the brothers), if so this should be a many to many.
Can a movie win more than one award? If so it should be a many to many.
Can a move EVER be shot at > 1 studio? If so you need a many to many.
You solve the many-to-many by adding an intermediate table in the logical design phase. That new table has a composite key consisting of the foreign keys from the two tables participating in the relationship.
For example, for Movie and Director, you would have Move, MovieDirector, and Director. MovieDirector would have only 2 columns: MovieID and DirectorID.

Making an ERD of a movie database


How can I regulate lettuce indoors so it doesn't bolt/flower?

Question: Is there a science to regulating lettuce indoors in a way that prevents or minimizes bolting/flowering?
Answer: Control the lighting so it never exceeds 12 hrs. And keep it cool, below 70 degrees F if you can.
Why you growing it indoors though, that's not usually done.
Comment: @Ecnerwal probably, but it's the light that really tells a plant how to behave and when. The lower heat just helps some more, and the more your lower the heat in the summer, well...the greater the energy cost, which although his question doesn't ask it specifically, I know this guy is highly energy conscious.
Comment: I grow everything indoors. No bugs, no pesticides, easy access, 365 climate controls, etc.
Comment: Less than 65F/19C would be better, AFAIK.
Comment: Keep them cooler, no higher than 65F. If they start to bolt from that, keep them at 60F. Lettuce is a cool weather plant. Also, I grew lettuce hydroponically floating on my fish tanks. The seedlings got leggy because it wasn't cool enough in there.


Does anything need to be changed with cassette?

Question: I am looking at getting a new cassette for my mountain bike ,and wondering if i need to change anything else(derailleur,shifter,chain)?
Comment: As well as chain (see answers), if shifting a problem, think about a new shifter cable.
Comment: You need to narrow down the scope of this question with more explicit details on what your current drivetrain consists of and what you're looking to replace your cassette with.
Answer: If you're getting a new cassette because it is worn, then you should at least get a new chain at the same time. You should also inspect your chainrings for wear and change them if needed. The derailleurs/shifters would only need to be changed if you get a different number of cogs on the cassette. They can wear out, but it's not usually in sync with the other items.
Comment: While doing your inspection don't over look the derailleur pulleys. Most are  plastic with a simple sleeve bearing.
Answer: New cassette needs new chain, but not really necessary. If your chain is pretty new (2-3months), you can keep your chain but make sure to give it a good degrease and regrease!


Is there a python implementation of a Face shape detector?

Question: Is there an OpenCV-python, dlib or any python 3 implementation of a face shape detector (diamond, oblong, square)?
Comment: Have you checked this: http://hanzratech.in/2015/02/03/face-recognition-using-opencv.html
Comment: You can train a linear classifier for that. If the accuracy is good enough, cool . Else train a CNN. But first collect some labelled data. Let me know if you need an elaborate answer.
Comment: @RyanL link is broken
Answer: Dear past version of self. With Deep learning; Convolutional Neural Networks,  This becomes a trivial problem. You can retrain Google's inception V3 Model to classify faces into the the 5 face shapes you mentioned in your question. With Just 500 training images you can attain an accuracy of 98%.
Answer: If you just want an implementation, maybe you can check out the demo by Face++. They also present the keypoints in the form of a JSON.
https://www.faceplusplus.com/landmarks/
Also, check this out for additional links:
http://www.learnopencv.com/facial-landmark-detection/
Comment: Hi Ayush, I am looking for face shape detection and not face detection. A face shape detection classifies a person's face according to its face shape eg a square face, a diamond face and oblong face e.t.c
Comment: Oh! My bad. Didn't read the question properly. Let me get back to you.


Splitting of Poisson processes and Bernoulli trials

Question: When a Poisson process is split according to the results of independent Bernoulli trials, two Poisson processes are obtained. It is trivial to prove that these two processes are independent. I was examining the converse. If a Poisson process is split in two Poisson processes, is it necessary that the split takes place according to the results of Bernoulli trials? I was able to prove this on condition that the two processes are independent. Is it possible to prove this without the previous condition?
Comment: Split them by a method that is not independent of the counts of prior arrivals.
Comment: Are you thinking of a process such as a queue with arrival of men and women?
Comment: I am mainly interested in a theoretical result. I don't have anything particular in mind. Another relevant question is coming up with an example of a way to split a Poisson process that results in two processes that are not Poisson.
Answer: I think the following serves as a counterexample:
Let $N$ be a rate 2 Poisson process on $\bf{R}^+$.  Independently
within each unit interval $I=[k,k+1)$, split the process into $N=N_1+N_2$ by uniformly
randomly selecting $x$ of the $N(I)=n$ jumps to assign to $N_1$
with the remaining $n-x$ assigned to $N_2$ where $x$ is determined by
a conditional pdf $$f(x|n) = Pr(N_1(I)=x|N(I)=n)$$ as given below.
Note that, if we were to take $f(x|n)$ to be the binomial
distribution with parameters $n$ and $1/2$, we would have the "usual"
independent Bernoulli split.
Instead, let's take:
\begin{align}
    f(0|0) &= 1 \\
    f(0|1) &= 1/4, f(1|1) = 3/4 \\
    f(0|2) &= 1/2, f(1|2) = 1/2, f(2|2) = 0 \\
    f(0|3) &= 1/8, f(1|3) = 0, f(2|3) = 3/4, f(3|3) = 1/8 \\
    f(x|n) &= Binom(n,1/2) \hbox{ otherwise}
\end{align}
It should be clear that the resulting split is not generated by
independent Bernoullis.
I claim that $N_1$ and $N_2$ are Poisson processes of rate 1.  I think
it's clear that we need only establish, for an arbitrary interval $I=[k,k+1)$,
that $N_1(I)$ and $N_2(I)$ are Poisson r.v.s of mean 1, given the
nature of the rest of the construction (uniform random selection of
points from $N(I)$ conditioned on the total $N(I)=n$, and independent
construction within each interval $I$).
Write $g(x)$ for the marginal pdf of $N_1$, and $h(n)$ for the pdf of
$N$ and note:
$$g(0)=\sum_x f(0|n)h(n) = e^{-2} (1*1 + 1/4*2 + 1/2*4/2 + 1/8*8/3! +
1/16*16/4! + \cdots) = e^{-1}$$
It can similarly be shown that $g(1) = e^{-1}$, $g(2)=e^{-1}/2$, etc. and
$N_1(I)$ is Poisson with mean 1.  Similarly, it can be shown that $N_2(I)$ is Poisson with mean 1.  So, that should do it.
If you're curious how I constructed $f(x|n)$ above, I considered the infinite matrix for the joint distribution $f(x,y)$ of $N_1(I)$ and $N_2(I)$ under the usual Bernoulli split and realized that I could permute the top left corner by added the 3x3 matrix:
$$\begin{matrix}
0 & \epsilon & -\epsilon \\
-\epsilon & 0 & \epsilon \\
\epsilon & -\epsilon & 0
\end{matrix}$$
in such a way that the column and row totals (i.e., the marginal pdfs of $N_1(I)$ and $N_2(I)$) and all the secondary diagonals (those moving from lower left to upper right, corresponding to the pdf of $N(I)$) were unchanged.
Comment: I assume your construction results in two processes which are not independent. Because, splitting a Poisson process with rate $\lambda$ in two independent ones with respective rates $\lambda_1, \lambda_2$ would give: $$P[N_1(t) = n_1|N(t) = n_1 + n_2] = \frac{P[N_1(t) = n_1]P[N_2(t) = n_2]}{P[N(t) = n_1 + n_2]} = \frac{e^{- \lambda_1 t} \frac{(\lambda_1 t)^{n_1}}{n_1!} e^{-\lambda_2t}\frac{(\lambda_2 t)^{n_2}}{n_2!}}{e^{-(\lambda_1 + \lambda_2)t} \frac{(\lambda t)^{n_1 + n_2}}{(n_1 + n_2)!}} = \frac{(n_1 + n_2)!}{n_1! n_2!} (\frac{\lambda_1}{\lambda})^{n_1} (\frac{\lambda_2}{\lambda})^{n_2}$$.
Comment: Which implies that $N_1(t)|N(t) = n_1 + n_2$ ~ $bin(n_1 + n_2, \frac{\lambda_1}{\lambda})$, which is basically the proof relying on the independence condition I referred to in my original post.
Answer: If the two random variables $X_1 \sim Pois(rate = \lambda_1)$ and $X_2 \sim Pois(\lambda_2)$ are independent. Then $Y = X_1 + X_2 \sim Pois(\lambda_1 + \lambda_2).$
It matters that $X_1$ and $X_2$ are independent, but not the mechanism
by which either arose. The proof using moment generating functions is
easy.
Intuitively, suppose $X_1$ describes counts from a radioactive solution into
a counter and $X_2$ describes counts from another solution. Pour the two
solutions into the same beaker. Counts from that beaker will be described
by $Y.$
Here is a simulation by demonstration in R statistical software, using
a million realizations of each constituent random variable, where $\lambda_1 = 4$ and $\lambda_2 = 5:$
<code>m = 10^6;  x1 = rpois(m, 4);  x2 = rpois(m, 5);  y = x1 + x2
mean(x1);  mean(x2);  mean(y)
## 4.003022  # aprx 4,  consistent with POIS(4)
## 4.997015  # aprx 5,  POIS(5)
## 9.000037  # aprx 9,  and POIS(9)
var(x1);  var(x2);  var(y)
## 4.004901  # aprx 4
## 4.995319  # aprx 5
## 9.011688  # aprx 9
</code>
In the figure below, histograms show simulated distributions, and
dots atop histogram bars show exact Poisson probabilities.
Comment: Small detail: $Pois(\lambda_1 + \lambda_2)$ is missing the 1.
Comment: I don't see how this answers the original question. Unless there is some implicit step that I am missing, the connection between your answer (sum of independent Poisson RVs is Poisson) and the question (splitting of Poisson processes) is not quite clear to me.
Comment: Your poat has two question marks. The answers are **no** (Bernoulli split need not be the mechanism) and **no** (indep req'd, if that is 'prev cond'), as discussed in my first two paragraphs. As for the additional issue raised in your comment, I guess if the splitting mechanism were three events to process 1 then three to process 2, then three to process 1, and so on, then both processes have only counts divisible by 3, and so not Poisson for which the domain is all nonnegative integers. If the intuitive justification and the simulation thwart your theoretical mind set, just ignore them.
Comment: @O.VonSeckendorff: Thanks. Waited to proofread until simulation and plots were done. Hope all is OK now.
Answer: Arrivals in a Poisson process occur independently of any other arrivals, at a constant average rate, say $\lambda$.   If the arrivals are split into two categories according to the result of independent Bernoulli trials, with constant rate $p$, then you will have two independent Poisson processes with rates $p\lambda$ and $(1-p)\lambda$.
This can be shown by establishing that, if $X,Y$ are the count of arrivals of the two categories, then the conditional distribution of arrivals in a category among given count of total arrivals, will be Binomially distributed.   (Why?)   If that is so, then:
$$\begin{align} \mathsf P(X=k, Y=h) ~& =~ \mathsf P(X+Y=k+h)~\mathsf P(X=k\mid X+Y=k+h) \\[1ex] & =~ \dfrac{\lambda^{k+h}~\mathsf e^{-\lambda}}{(k+h)!}\cdotp\dfrac{(k+h)!~p^k~(1-p)^h}{k!~h!} \\[1ex] & =~ \dfrac{\lambda^{k+h}~\mathsf e^{-\lambda}~p^k~(1-p)^h}{k!~h!} \\[2ex] \mathsf P(X=k) ~&=~ \sum_{n=k}^\infty \mathsf P(X+Y=n)~\mathsf P(X=k\mid X+Y=n) \\[1ex] ~&=~ \sum_{n=k}^\infty \dfrac{\lambda^n~\mathsf e^{-\lambda}}{n!}\cdotp\dfrac{n!~p^k~(1-p)^{n-k}}{k!~(n-k)!} \\[1ex] & =~ \dfrac{(p\lambda)^k~\mathsf e^{-p\lambda}}{k!} \\[2ex]\mathsf P(Y=h) ~&=~ \dfrac{\bigl((1-p)\lambda\bigr)^h~\mathsf e^{-(1-p)\lambda}}{h!} \\[3ex] \therefore~\mathsf P(X=k,Y=h)~&=~ \mathsf P(X=k)~\mathsf P(Y=h) \end{align}$$
And we conclude that the Poisson processes are thus independent.


Would wrong antifreeze affect your truck if not driving it?

Question: It is cold, below freezing today and my husband wants the truck in the garage. If we aren't driving truck on the cold day, does it matter? He thinks the antifreeze may not have been strong enough for the weather here, as it was changed in a more warm state. Tomorrow will be above 40° .
Comment: Purchase an antifreeze tester and test it. With engine Cold, remove the radiator cap and suck some coolant into it,, the number of floating discs tells what the protection from freezing is. This is the one I like>>>>https://www.amazon.com/Thexton-THE106-Anti-Freeze-Tester/dp/B0002SRDF0/ref=sr_1_6?keywords=anti-freeze+tester&qid=1581698718&sr=8-6
Answer: Ice doesn't cause problems in itself, so long as you don't try to drive the car when the coolant can't circulate.
The problem with ice is that it occupies more volume than water, and if there is nowhere for the unfrozen water to get out of the way, the pressure is enough to break things.
Any reasonable concentration of antifreeze freezes gradually into a "mush" of solid and liquid, which can "flow" enough to equalize the pressure, and the radiator cap will blow to release the pressure before it gets high enough to damage anything.
So unless there was no antifreeze at all in the cooling system, you often get away with a car "freezing" gradually and thawing out naturally (i.e. not running the engine until it has thawed).
Answer: Anti-freeze is more accurately called coolant and as such is generally manufactured to provide protection from overheating, corrosion and of course, freezing. If properly mixed/installed, the protection from freezing will not be region specific.
Not driving the vehicle is a minor consideration. One can drive the vehicle to keep the coolant warm, but eventually you have to turn it off and it will cool to ambient temperature.
There are testing resources available. It's likely your local auto parts store will provide for you a testing of the coolant to determine the low temperature value that it can provide.
If water has been added to the system since the previous coolant replacement, the protection level will be reduced. There is no advantage to add more coolant to increase the percentage of protection, as the lower limit will not change appreciably. According to itstillruns, a ratio of 50:50 is typical, while the site recommends 70 percent anti-freeze to 30 percent water for extreme temperatures (like the arctic!) while recommending to keep the portion of anti-freeze above 40 percent.
Equally useful is the recommendation to consult the owner's manual for manufacturer's recommendation.
Answer: The coolant for a vehicle is specific to the vehicle itself, and is not normally changed to fit the area that the vehicle is serviced. If the coolant is new enough to not need service, it should quite easily withstand temperatures as low as -35 degrees fahrenheit.(37 degrees celsius.)  If you truly want to prove either side, coolant testers are very cheap, and very easy to use.


How does a liquidator set aside an attachment order during liquidation?

Question: How can a liquidator set aside an attachment order during a liquidation?
Please excuse the lack of specificity on this question; it's an issue I need to understand for a commercial transactions exam, but the lecturer is refusing to explain himself.
I understand this site is not directed specifically at South African law, but I'm looking for someone who can shed a little light on this with respect to the Insolvency Act and the Companies Act.
Answer: So I think perhaps the lecturer is referring to section 359(1)(b) of the Companies Act of 1973. It states:
"359. Legal proceedings suspended and attachments void.
(1) When the Court has made an order for the winding-up of a company
or a special resolution for the voluntary winding-up of a company has
been registered in terms of section 200-
(a) all civil proceedings by or against the company concerned
shall be suspended until the appointment of a liquidator; and
(b) any attachment or execution put in force against the estate or
assets of the company after the commencement of the
winding-up shall be void.
[Sub-s. (1) amended by s. 24 of Act 83 of 1981.] "
Comment: Thank you for your reply! In the final analysis, from the context in which this exam is taking place and the nature of the lecturer, it would seem as though the question on this topic will be much more manageable than the scope suggests. But thank you for bringing that section to my attention


Setting appropriate permissions on SU binary

Question: I recently found a way to maintain root access on my android device using a dropbear SSH server that I modified to run at boot as root using init.d, a lil scripting magic & some config scripts I made. If you want you can check it out here. Anyways for an experiment I removed the su binary and Superuser.apk from the system. I've managed to get them copied back to the system but I don't know the appropriate permissions for the su binary. If I look in Super User app on another rooted phone and go to update it shows -rwsr -sr-x as the permissions on the binary. How can I set these same permission manually & what do they mean?
Answer: For setting file permissions, you can use the chmod command. The permissions shown are basically split in 3 parts, each consisting of 3 chars: a triple for the owner, the group, and for "others". Usually, each triple holds definitions for reading, writing, and executing a file; so rwx means "can read, write, and execute", while r-- would say "can only read".
The resulting 9 chars are usually preceded by another one, giving information of the type of the "file": (d)irectory and (l)ink are the most common examples. Again, if no "special condition" matches, a leading - indicates a "normal file".
Based on that, let's take your input: -rwsr-sr-x obviously describes a "normal file" (starting with -), readable (r) by owner, group, and others, writable by owner only, and executable by "others" – while owner and group have a s instead the x for execute. This stands for "suid", elevate the caller to the level of the file owner/group.
Taking advantage of the fact permissions can be set "bit-wise" (x=1,w=2,r=4, suid user=4, group=2), after my long "rant" finally the command which should do the trick:
chmod 6774 su

Should set the permissions your question shows. If I "mis-calculated", you've got all information to re-calculate for yourself now :)

Additional hints from the comments:
Instead of calculating the "bitmask", one can also use symbolic names – as Dan Hulme pointed out, and as explained e.g. on the chmod manpage:

defining whom to grant to: (u)ser / (g)roup / (o)thers / (a)ll
defining what to grant: (r)ead / (w)rite / e(x)ecute / (s)uid
defining whether to (+)grant or (-)revoke

So the following two commands should be similar, provided there haven't been other things granted before:
chmod 6774 su
chmod u+rws g+rs o+rx su

The difference becomes clear in case e.g. before "others" had also write permission: while the first command (using a bitmask) sets the permission explicitly to match the "grants" defined (and thus would remove that write permission), the symbolic one "makes a diff" (in the example, it just adds the permissions specified to whatever was there before, so that write permission would not be removed).
Comment: You don't need to calculate the numbers for `chmod` yourself: `chmod u+rws g+rs a+rx su` will do exactly the right thing, and doesn't require you to count on your fingers.
Comment: Sure that it's not `chmod u+rws g+rs o+rx su` (not "all", but "o"thers, see [chmod manpage](http://www.ss64.com/bash/chmod.html))? I always mess that up thinking whether was it "owner" or "others", which is why I prefer using the bitwise stuff, except when only changing stuff for group ;)
Comment: @DanHulme checking with the manpage again, `a+rx` would set "rx" for "ugo" (user, group and others). I'm not sure which confuses me more: calculating the bit-set, or interpreting recursing symbols :P
Comment: Yes, using `a` would make the command shorter, but as you've noticed, it makes it a bit harder to see what is going on, so I almost never use `a`.
Comment: @DanHulme I didn't even know about the `a` symbol. But thanks for kicking me into checking the manpage again :D The `a` switch can be quite useful sometimes, for things like `chmod a+r public_info.txt`.
Comment: Sorry, I misunderstood what you were saying. Yes, when I wrote `a` in my first comment I meant `o` for others. I wondered why you brought it up!
Comment: Thanks for clarification, @DanHulme! With your permission (and credit given), I will include it with my answer, so nobody has to follow up all the comments for understanding.


How can thought vectors be used outside of an Artificial Neural Network (ANN) context?

Question: We hear a lot today about how thought vectors are the Next Big Thing in AI, and how they serve as the underlying representation of thought/knowledge in ANN's.  But how can one use thought vectors in other regimes, especially including symbolic logic / GOFAI?  Could thought vectors be the "substrate" that binds together probabilistic approaches to AI and approaches that are rooted in logic?
Answer: I'll take a shot at answering this, though I'm no expert in Neural Nets or Deep Learning.
Given that practical thought vectors (TVs) don't yet exist, and may be impractical or impossible, I think answering your question will require a lot of conjecture and speculation.  So here goes...
For thought vectors to be useful in or outside NNs, the vector values will have to be normalized, probably using the local context of the application problem's 'frame'.  Without a NN to create new baseline vector values (weights) and to normalize them to match each new context, any non-NN mechanistic alternative means of employing TVs will somehow have to fill that void.
Could vector values created by NNs be used by an alternative technique?  Could that technique also normalize them?  Sure.  We're just talking about turing-computable functions performed by NNs.  If NNs aren't magic, then there should exist other means to compute the same results -- creating or editing, or employing TVs.
What might such an alternative to NNs be?  Well, if its to shape vector weights, I suspect it too will have to learn those values through statistical iteration and feedback (as opposed to logical induction, say).  I doubt such a mechanism exists yet, since it'd probably resemble NNs in sufficiently many ways that, thus far, it would have seemed too derivative of NNs to gain acceptance as sufficiently novel.  Of course to be as powerful as deep nets, it too would have to propagate learning weights both forward and backward without incurring much error.  Not an easy thing to accomplish.
Less ambitiously, could TVs be simply interpreted by another technique usefully?  I think so.  I can see several existing techniques, like decision trees or even expert systems, importing thought vectors and being shaped by them, and then function in accordance.  But could these same techniques create or revise TVs usefully?  Beyond a trivial extent, I'm doubtful.  I think TVs are too complex a knowledge representation format for most general learning methods to both use and create/modify them, unless they employ an iterative statistical and feedback-based learning process, like those of NNs, which would allow novel and complex features to be learned and integrated into the vectors.
Comment: `But could these same techniques create or revise TVs usefully? Beyond a trivial extent, I'm doubtful. I think TVs are too complex a knowledge representation format for most general learning methods to both use and create/modify them`

Yeah, I think that's the real question.  If the answer is "yes" then thought vectors could really be the unifying layer where automated reasoning meets statistical pattern matching.   Personally I *hope* the answer to that turns out to be "yes", but I'm not convinced one way or the other yet.


US term for potential increase in earnings from employer?

Question: What term(s) do Americans use when an employee might get more money from their employer, usually happening on a yearly basis?  Perhaps Wage review?  Salary review?  Or even a more generic Annual review?  However, the latter doesn't emphasize money so I'd rather have term(s) that do.
Comment: This really too broad, as it varies with company and industry. I have usually seen "Performance Reviews", which includes both performance and compensation, when compensation is based on performance. On the other hand, union workers may have an increase in compensation based on contractual agreements.
Answer: An increase in salary is called a raise; a one-time extra payment is called a bonus. The review itself can have different names at different organizations, but in my experience, it's most typically called an "annual review."
Comment: Welcome to ELL. Nice first answer! it would help if you add links to references, for example dictionary definitions of the words raise and bonus.
Comment: It's always a review; if your procedures seperate things you may have a preformance review and a salary review semi-independantly, or they might be lumped together as annual review or even performance review. There are probably other terms used at specific companies but these will be understood by anyone with office experience.


Should I use "shall", or "let's"?

Question: Today when it was about time to go home, my English teacher asked me to lead my friends to pray in English. I led them by saying "Let's pray together!" However, my teacher told me that I was wrong and I should've just said "Shall we pray together.". Despite that, I'm unsure whether I was wrong. So, was I really wrong to say "Let's pray together"?
Comment: _Tidak apa2_ would translate nicely into many English lects with that same sense. And _shall_ is rarely used in modern English. In America, there are only two constructions it occurs in. One is _Shall we `VP`?_ which is an invitation, as noted. The other is _Shall I `VP`?_ which is an offer. Both are rare and limited to special occasions. _Let's_, on the other hand, is very common and completely grammatical. It's a fixed contraction, like _tak_ for _tidak_, and has almost as many uses.
Comment: He said: " There are  just some things which can not be translated literally.". He compared it to "tidak apa-apa" in Bahasa, which is if we literally translate it to English will be "no what what" which doesn't make sense, and it should have been translated to "it's okay".
Answer: No you was not wrong to say let's pray together.
let's --> let us
let us pray together
It makes perfect sense grammatically. It's an invitation to pray together. Maybe find a new English teacher!
Answer: The teacher has given an instruction as an elderly man.
"Let's pray" is rather an order like, "shall we pray" is like a request, implying we shall pray only with your concurrence.

Should I use "shall", or "let's"?


My ps3 isn't staying on

Question: I've tried doing the things said on the same question, but it isn't working for me. I had tried keeping my finger on the power button until three beeps happened, but all it was beep once then did three really fast beeps, I don't know what to do. Help?
Comment: Welcome to the site! what do you mean by "on the same question?" is there another question you would like to link?
Comment: What I mean by that is, that there was a question that is very similar to mine. I didn't want to comment on it and mix up our answers with the similar question. They didn't have the yellow light like I did, but their ps3 wan't working as turning it on, same as me. Sorry for rambling, but thank you for the welcome.
Comment: If you can link the question you're talking about, it does help. If the questions are similar, we can link the two together, to help others find a solution faster.
Answer: This is what people like to call the "Yellow Light Of Death" - similar to the PC's "Blue Screen of Death" or the Xbox's "Red Ring of Death". Basically, it means there is a hardware fault on your PS3's motherboard, causing it to fail to boot/operate properly, forcing an immediate power-down.
As the name suggests, the "YLoD" is usually accompanied by a flashing Yellow Light. If you don't see one, unplug the power cable for a short time (at least 30 seconds), plug it back in, and try again.
Alternatively, repairs are possible, but if you don't know what you're doing, this can lead to more problems than solutions.
Comment: Yellow does appear, and I have planned to repair the PS3 myself, the link you put does show me how to do it, since my own searches were futile of proper answers. Thanks for the help!
Comment: @AJCans if this answer solved your problem you should consider accepting it, you can do that by hitting the little Check mark under the voting numbers

My ps3 isn't staying on


knitr example doesn't produce graphics

Question: I tried compiling the given MWE for testing knitr:
%% LyX 2.1.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass{article}
\usepackage[sc]{mathpazo}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\usepackage{url}
\usepackage[unicode=true,pdfusetitle,
 bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2,
 breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
 {hyperref}
\hypersetup{
 pdfstartview={XYZ null null 1}}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<setup, include=FALSE, cache=FALSE>>=
library(knitr)
# set global chunk options
opts_chunk$set(fig.path='figure/minimal-', fig.align='center', fig.show='hold')
options(formatR.arrow=TRUE,width=90)
@

\title{A Minimal Demo of knitr}

\author{Yihui Xie}

\maketitle
You can test if \textbf{knitr} works with this minimal demo. OK, let's
get started with some boring random numbers:

<<boring-random>>=
set.seed(1121)
(x=rnorm(20))
mean(x);var(x)
@

The first element of \texttt{x} is \Sexpr{x[1]}. Boring boxplots
and histograms recorded by the PDF device:

<<boring-plots, fig.width=4, fig.height=4, out.width='.4\\linewidth'>>=
## two plots side by side (option fig.show='hold')
par(mar=c(4,4,.1,.1),cex.lab=.95,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3,las=1)
boxplot(x)
hist(x,main='')
@

Do the above chunks work? You should be able to compile the \TeX{}
document and get a PDF file like this one: \url{https://github.com/yihui/knitr/releases/download/doc/knitr-minimal.pdf}.
The Rnw source of this document is at \url{https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rnw}.
\end{document}

I copied the code into a Sweave document in RStudio and clicked "Compile PDF." The resulting PDF looks kind of like this (2 pages placed side-by-side):

What's wrong?
Comment: This is the hazard of using a template without reading the supporting manuals.  The code  `knitr-minimal.Rnw` is written in `knitr` complaint syntax and it preprocesses-compiles-views correctly using the knit-command then pdflatex then view-pdf.  However, you added line 18,   `\SweaveOpts{concordance=TRUE}` which is a Sweave specific command requiring the Sweave preprocessor.  The end result is not the expected output.   Remove line 18.
Comment: You have to compile it with knitr and not with Sweave. With Sweave I get your result and with knitr (if you omit the line with sweaveopts), you should obtain the desired result
Answer: RStudio by default uses Sweave for .Rnw files and adds the line \SweaveOpts{concordance=TRUE} after \begin{document}. Set "Sweave" from Global or Project Options (from the Tool menu) to specify knitr processing instead of Sweave.
Comment: Go here and see how to change the RStudio default. http://yihui.name/knitr/demo/rstudio/.  Or, you will have to do a bit of rewriting as Sweave does not handle graphics as cleanly as knitr.  In Sweave, to get two graphics side by side you have to set up a dual pane graphic window in R and manage all the labels, etc in R.  Knitr allows you to take more advantage of the control of structure offered by LaTeX.

knitr example doesn't produce graphics


Tips to do another repetition?

Question: To gain strength the last repetitions are the most important ones. Depending on my mood I find it hard to do the last reps. Before I used caffeine to enhance my exercise routine, however I stopped using caffeine. I now listed to motivating music, also I try to let the arm hang without dropping the weight and then do another repetition. What are other tips to push yourself to do the last repetitions?
Comment: Isn't the last repetition always the last repetition no matter how many you do?
Comment: Just popping in here to point out that the axiom "the last repetitions are the most important" is, at best, a half-truth if talking about hypertrophy. Using weights at 15RM or heavier, leaving a few reps in the tank is just as effective as going to failure, generates less fatigue, and will keep your form from deteriorating. Not saying you shouldn't ever go to failure, but it's not necessary for effective training and perhaps best left for isolation exercises. As for strength, you probably _shouldn't_ go to failure: https://link.springer.com/article/10.1007/s40279-015-0451-3
Answer: Reduce the weight.
If you're supposed to do 12 reps and you can only do 10, you've loaded to heavy. Reduce the weight so you can complete the number of reps and sets you need to.
Comment: Problem is my ability to do the last reps depends on my mood and exhaustion level. So on a good day, I easily accomplish my goal. On a bad day I'm only able to do 80% of the reps required.
Comment: @Rubus Then adjust the weight so that you do the prescribed number of reps at a similar perceived level of effort every day. Allow your load selection to meet you where you are on any given day.
Answer: Considering one of the tags in this question is "sports psychology", I'm assuming the question is actually asking "How do I motivate myself to work toward failure to get the most out of my set?". That is a very valid question considering daily motivation is the most variable thing that can mean the difference between failing at 8 reps versus failing at 10 reps. Unfortunately it's also something that's different for everyone and can't be answered with one single "Do this" style suggestion.  Though I can give tips that you can try to see if they help.
In General
Get Sleep
This one seems obvious, but not sleeping enough can be pretty demotivating. Ensure that you're getting enough sleep to power through your day and your workouts.
Change workout times
If you're not a morning person, then there's no reason to believe you can force yourself to become one by working out in the morning.  Likewise, if the stress of daily life leaves you exhausted in the afternoon, then it would be better to choose a time earlier in the day. Choose a time that has the least amount of stress in order to keep your motivation levels at their max.
Eat well
Try to make sure you're getting enough nutrition throughout the day. Preferably from more whole foods. This can be a big mood elevator which will translate will in to performance.
Eat properly before the workout
Some people like to be full. Some people like to be fasted. Some people like that goldilocks feeling in between. Make sure you eat well enough prior to the workout to make sure you feel comfortable enough to workout to your maximum potential. This would preferably be from carbohydrate sources, but it's personal preference at the end of the day. Forcing yourself to do something you don't like because someone on the internet says you should do it is not "motivating".
At the Gym
Develop a set routine
This one may seem odd, but it can help to develop some kind of habit that you do before a set to get your mind focused. A lot of people have small routines or rituals they do just before a hard set. I, for example, always drink some water before performing the set. It helps me get in to a mindset of "Ok. It's time to go!". I also have other things that I do depending on how hard the set is. Some people shake out their arms and legs. Some people crack their knuckles.  It doesn't matter what it is. The goal is to get you in to the mindset between rest and work.
Track
Track your progress and try to match or surpass yourself over time. Sometimes this can be motivating enough to just get that one last rep.
Increase rest between sets
This isn't cardio. Your goal in resistance training is to get the most out of your set. Resting at least 2-3 minutes or even 5 minutes depending on the intensity of the exercise will allow you to push a lot harder than 30-60 second rests.
Intra-workout nutrition
Whether it's BCAAs, pre-workout, gummy bears, or even just cold water, sometimes having something small within the workout can bring up your motivation to workout harder. There's a lot of debate questioning the efficacy of these things. However, in this case it doesn't matter if they work. What matters is that you believe they work. Sometimes placebo is all you really need.
Gym Buddy
A good gym buddy can really be motivating. Lifting can be quite communal, and sometimes having someone there to push yourself can be quite beneficial.
Go at it solo
People are also distracting. They talk too much. Maybe they discourage training in some way. In this case it may be best to go at it alone.
Answer: One of my old Muay Thai boxing coaches would tell students "you can do anything for 30 seconds".
He would tell us this after we had finished 2.5 minutes of a 3 minute training round involving the performance an extremely strenuous exercise.
After 2.5 minutes, most students would want to quit, but his words encouraged people to finish the training round.
We trained heavy 3-4 days/week, and he would do this during almost every training session.  One might think it would get old, but it was actually quite effective.

Tips to do another repetition?


My research supervisor is asking me to fake results, what do I do?

Question: My research supervisor wanted to produce a cost-benefit analysis for an infrastructure project (civil engineering). First he had someone else work on it, then he involved me. When I got involved, I noticed that the benefits were inflated and the costs downplayed to convince the reader of a massive benefit-cost ratio. I do not know if he stands to personally gain from this. I discussed it with him a few times, he pushed back with "I am experienced and I know I am right", and eventually in the final revision of the paper he changed my numbers. The way he changed the numbers is not even smart, he just changed the text, he didn't redo the calculations. Now I fear that if I bend under pressure, these bad numbers will be out there, forever! I am sure he will take the published paper and send it to every politician in the country trying to get this project approved. What can I do? I am still his PhD student so I can't get too confrontational.
Comment: Are you completely sure that your conclusions are correct? Dishonest supervisors certainly exist, but if this is your first project / proposal in this domain, it's also possible that your supervisor's guesstimates are more accurate than your calculations.
Comment: Possibly related: https://academia.stackexchange.com/q/31265/19627
Comment: What is an *"infrastructure project"*? Is it about civil engineering? Or something else? Please respond by [editing (changing) your question](https://academia.stackexchange.com/posts/175962/edit), not here in comments (***without*** "Edit:", "Update:", or similar - the question should appear as if it was written right now).
Comment: Your title seems somewhat inappropriate. Where are the results?
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/130140/discussion-on-question-by-ifeelexploited-my-research-supervisor-is-asking-me-to).
Comment: One word answer here -- don't.  Seriously, read some of the other answers, however
Answer: Make absolutely sure you understand the numbers correctly before suspecting, or even worse, accusing your advisor of dishonesty.
The following text only applies if you have satisfied yourself that there is no way these numbers could have been reached in an honest way.
If you are absolutely convinced of this, get out of there, under whatever pretext. You do not need to confront your supervisor, for which you have little power at this stage; but get out.
You are not only in danger of damaging your academic reputation. If the study enters policy, you may be indirectly or directly made responsible for wastage of public money and could face potential legal consequences stemming from that.
If your supervisor is really into shady practices, he may even deflect any potential fallout that might transpire to his "dishonest" student coauthor; i.e. you.
Do not accuse him of that. You have no proof and it is almost impossible to establish facts in the constellation you are in. Just get out of the paper, and ideally, out of the PhD relation. Find an excuse.
You have my sympathies for a situation which no one should be ever be in.
Comment: +1 for "he may even deflect any potential fallout...to...you". If he is dishonest as it sounds like he is, he almost certainly will do this. Honorable leaders shield their teams. Dishonest ones park the bus on top of them to save themselves.
Comment: @Alexis I refrain from suggesting self-sacrificing steps to vulnerable OPs; I feel I do not have the right to demand or even suggest such action from them. If undertaken, I would recommend OP to trigger investigations only after OP has secured their future. And OP should also first check with a third party whether their advisor's handling of the matter really constitutes misconduct or is just a misinterpretation on the OP's side.
Comment: Your first sentence is critical, but "get out of there" should be coupled with (1) "Write a letter to the paper's publisher/journal/sponsor asking to be dropped as author, and expressing concern about academic dishonesty in the fabrication of data and results by remaining author(s)," and (2) "Notify your university's office of research integrity (however it is named) of your professor's academic dishonesty in the fabrication of data and results." If he is intentionally fabricating data, the dude should never publish again. CAVEAT: **Only** if you are certain he is fabricating.
Comment: One does not have to make any explicit accusations of malfeasance to insist one's name be taken off the analysis. Saying that you do not have enough experience to verify the numbers should be enough if everything really is above board (where I am using 'should' in its ethical sense, not as a prediction of the outcome, unfortunately.)
Comment: @CaptainEmacs I appreciate the perspective. Let me add: this OP is not not only one vulnerable. If their advisor is indeed fabricating, future students and collaborators are also vulnerable, as are those downstream of any policy decisions made based on fraudulent research. 100% agree with third party reality check.
Comment: @Alexis Vulnerability: True, but everyone has to balance for themselves whether they are ready to re-enter a burning house to save other souls. And, in all likelihood, OP might end up being burned for good, but the politically adept advisor might survive with only scratches. This has to be factored in in the decision.
Answer: First off, I'm sorry you were put in this position. I know you don't want to get confrontational but your supervisor crossed a line. I don't know how far along you are in your PhD but I think it's time to look for another supervisor (could be a different university). Here's what I would do:

Stall this publication to give you some time
Quietly look for another supervisor
Once you have a back-up plan, confront your current supervisor
If he agrees to keep the real numbers, great, go ahead and submit and then change supervisor
If he refuses, demand not to be listed as an author, and then change supervisor. DO NOT ACCEPT TO BE A PART OF THIS

In my opinion, you have to cut your ties with this guy as soon as possible (even if he agrees not to change the numbers). He might already have done the same before and his publications could be a ticking time bomb until someone figures it out and his reputation collapses. He might also already have a shady reputation to begin with.
Comment: I've seen transfers before for much more benign reasons, without any fuss. You just have to frame it in a positive light. EDIT: Of course it might mean giving up on some research material that might have been completed yet.
Comment: Step 2 may well be problematic - to say the least. I know that so much depends on the department and indeed the university but it's a fact of life that institutions seek to preserve themselves at the expense of the victim in this kind of situation. What on earth do you mean by "could be a different university" ? Isn't there going to be "embarrassment" and "outrage" at @IfeelExploited's "disloyalty" and "ingratude" from the pompous asses' association if a program started at UoX is  transferred to a supervisor at UoY ?
Comment: @HairyBlob The OP has clarified subsequently that, for example, the prof used actual quotes whereas the OP tried to deduce costs from other papers. Suppose the Prof's costs were greater and the OP's were lower, who would more likely be considered unreliable or dishonest? I feel your answer is a bit strong considering you don't have the full information to go on.
Comment: See, for example, Pyrotechnical's excellent answer for some expertise on the subject!
Answer: You need to make sure your understanding of cost-benefit analyses is on solid ground before anything else
So this is this is my first time answering a question on Academia, but given this situation is based within my area of expertise as a Professional Civil Engineer, I think it's appropriate to provide input on how difficult it is to 'accurately' put together a cost/benefit analysis.
Costs - From your question, you had indicated that your advisor had utilized the costs of a local contractor while you were depending upon published numbers from similar papers/reports. Consider a few things with the sources you're using, if you're relying upon RSMeans for example, you're going to need to consider that the costs of all work will vary considerably between Oregon, Texas, and New Jersey. Furthermore, you must further break those costs down to consider the cost of material, labor, and overhead/profit. Greater union participation in the northeast results in labor costs being higher than the national average.
In addition, you need to consider the local economic climate. Estimates I prepared prior to Covid are completely worthless today due to massive supply chain disruptions which have invalidated my previously reliable material costs.
What I can tell you from my work experience handling asset management planning for municipalities is that I don't rely upon published numbers for asset valuation and maintenance if I can help it. I'd much rather get my information from the people that work in the area and adjusting for CPI because when it comes time for that maintenance to be done, they'll be the ones performing it.
Additionally, you should be aware that there are definitely some costs which are very difficult to account for and it's not unreasonable for a civil engineer to just throw a dollar amount and justify it with 'professional judgement'. I don't think I've ever issued a formal estimate that I didn't slap an additional 20% onto the back-end for 'contingency', because the amount of times we open the ground and it's not identical to the survey is just about 100%.
Benefits - So this is where things get a little bit hazy. You have to consider who the audience is. From your question it doesn't sound like the target audience is another engineer, rather it's political in nature and to that end they may've hired your advisor to put together an analysis which depicts this project in an extremely favorable way. I want to make clear that this is not automatically unethical, there are a lot of gray areas in civil engineering and if you elect to pursue this as a career you will find yourself in them often.
ESPECIALLY for infrastructure projects. They are costly to perform, they result in traffic, they often require tax increases, and a bunch of other politically unpopular things. But the reality is, very often municipalities aren't setting money aside to maintain infrastructure because otherwise that political victory might happen in a different administration and the current politician loses their re-election bid because they're 'wasting' money on infrastructure projects and maintenance that 'definitely isn't needed'.
As for accounting for benefits due to increased economic activity not being 'actual dollars related to the project', are you sure? Would that increased activity have occurred without it? If you are trying to justify installing a new tide gate to mitigate flooding issues caused by worsening climate change, you may need to include in the benefits all the flood damage you don't have to account for. As a whole, the general public doesn't appreciate money that wasn't spent on things that didn't happen, so your advisor might be trying to show this ratio to help them see that benefit in a different way.
Recommendations

Ensure you understand the goals of the client on this. Bear in mind that as a civil engineer, you will occasionally be in ethically ambiguous situations, but you do have an ethical obligation to represent your client's interest. This doesn't mean that you lie, but there are lots of ways to present technical information that makes something look more appealing. If you're unsure if you're going too far, consider the key tenets from ASCE's Code of Ethics, which require you to hold paramount the health and safety of the public. As a reminder, the public often won't understand why they need to pay more in taxes, so it can sometimes be your job to present data in a way to persuade them.
Have a discussion with a colleague (not your advisor) about the ethics of the situation. Ethics is always hazy and having another person to discuss things with can help a great deal. If your colleague considers the matter to be unethical, or bordering along there, then request a meeting with your advisor and ask for their input on the ethical implications. It may be that the paper should have some kind of disclosure included; this is akin to a City Engineer disclosing to the City Council about some kind of conflict of interest they may have relating to a project they're responsible for inspecting. The Council can elect to replace the engineer for that project or acknowledge the conflict and elect to allow things to proceed based on their trust of the engineer.
Document everything. Hopefully your advisor's word-of-mouth cost estimate is backed up in writing in some fashion, because that's going to need to be an appendix. For most projects, it's very common a ratio on the order of a 20 page narrative and 200 pages of appendices, so don't be shy on providing them.

UPDATE
Practical Engineering released a video specifically on engineer estimates. I'd encourage you to watch it to provide further context on this answer.
https://www.youtube.com/watch?v=dOe_6vuaR_s
Comment: I think this is a great perspective.
Answer: Every cost benefit analysis includes assumptions. There will always be pieces that are a bit ambiguous and can be done several ways. Based on your edit, the items you are disagreeing about would not be a case of fraud, but of judgement (and the supervisor's judgment does not seem unreasonable on the face of it here).
The correct thing to do is to be very clear about the assumptions and where the numbers you are using are coming from. Ideally, you would also be transparent about the other options you did not choose and how they would affect your results in the paper, but that does not always happen.
At this stage, I would suggest you do two things. First, add text around assumptions made to the paper. This may be an appendix. This will not change the overall cost-benefit "answer", but will at least allow a careful reader to ascertain what is being included and left out. It should also be okay with the supervisor since it is not affecting the paper's takeaway "sound bite."
Second, if there is really no justifiable way to defend some of the calculations, suggest an alternative with the justification that "readers may find this number to be a problem" or "people will attack our overall conclusion as being biased if we include this number." The key is to put your objections "in the mouths of the reviewers" and therefore not make it about your inexperience vs. your supervisor's experience. If the supervisor won't budge, just continue to document heavily in the appendix.
Answer: I do not understand why none of the other answers may consider the case that there is no ulterior motives here. Especially in the case of engineering, academic calculations are based on ideal situations (none of which are in the real world) modeled after conditions which are not well understood. Actual estimates from industrial sources (the alleged source of the professor) are closer to reality when looking good data to use. The professor is presumably more experienced in the field than a PhD student and likely has a better idea than a PhD student on the reliability of sources iif information in the real world.
In addition, the subject matter is a cost/benefit scenario, a question of economics; riddled with assumptions based on an economic model that doesn't fit reality that requires predictions of the future (something which is somewhat of an art) so I wouldn't even take a subject matter expert's likely facetious statement like "Just trust me I'm right" offensively as their best guess (a core engineering skill) is likely better than a student's just ftom experience.
Just to offer a different perspective, if the proffesor says his information is more reliable, just try to understand the underlying reason for determining the reliability of the data. That said, you should absolutely point out that the calculations are inaccurate if they aren't rerun with the new data presented.
Comment: "I do not understand why none of the other answers may consider the case that there is no ulterior motives here." - actually several of the other answers/comments insist that OP should verify that there is explicit malicious intent. They specifically base their answer strictly on the condition that malicious intent has been unambiguously established. It's ok for you to give a detailed alternate perspective, but not good form to diss them for failing to include something you miss. Especially as they answered the OPs question rather than posing a frame challenge. Not downvoted yours though.
Answer: If I want to get a new roof next week, which cost is more relevant?
A) A published average for roof replacement, or
B) The estimate a local contractor gives me to do the work next week.
Surely, you can find pros and cons to each: published numbers aren't for my roof, so they're biased if my roof isn't a typical one. Published numbers might be based on costs for materials and labor when the previous study was done, possibly a year or decade ago, and not apply to next week (even straightforward adjustments like accounting for inflation may not be representative, since inflation doesn't affect prices of everything equally).
On the other hand, the contractor I got an estimate for may be cheaper or more expensive than average. Their estimate may not include cost overruns that are typical for a project like this.
Neither A nor B is fake, and probably most people would be offended and insulted if they used either estimate A or estimate B and you called them a fraud, or told other people they were a fraud. It seems your advisor is leaning towards using an estimate like B, and they feel their expertise gives them a better judgment than you in that decision. Maybe they're right, maybe not; we don't have enough information here to know.
It's fine for you to argue for the benefits of (A) over (B), but I would keep out any accusations of serious misconduct until you have strong evidence of them. The most important thing for your paper is to be clear in your methodology. If your cost estimate is based on an estimate given by a local contractor, you need to write that in your paper and explain how that estimate was reached.
If your benefits estimate includes secondary economic benefits, then explain clearly what those secondary economic benefits are: what are they based on, how does the methodology used to reach those numbers compare to other literature, etc.
You certainly should not be basing your final judgment of the estimate on whether the number "seems reasonable". Sure, it's a bit of a red flag to investigate if your numbers are far from what you expect, but ultimately the best answer is the answer you get with the methodology you justify. If that number is cost:benefit of 20:1, then that's the answer. It doesn't matter if 20:1 is "reasonable" itself or not, if all your assumptions to get there are reasonable then the answer is, too.
I'd also echo a comment by @a.t. - when there are multiple ways to answer an estimation problem, one solution is to provide a range of answers. If you can demonstrate how different assumptions lead to different answers, your reader can be better informed, can better understand the levels of uncertainty, and can possibly use their own judgment of what circumstances are most likely closest to the truth.
Comment: +100 for "be clear in your methodology" - excellent answer.
Answer: Cost Benefit Analysis is not an exact science and all benefits cannot be accurately quantified. The key is to understand if the revised calculations are transparent and defendable. Let your supervisor know you still don't understand how he has come up with his numbers and what his assumptions are. Also ask him who the audience for the analysis and what he expects they are looking for.
It's likely your supervisor has one foot in industry and one foot in academia. Large infrastructure programs, where CBA is used, generally do not show strong returns when initially calculated on base assumptions. Some of the benefits need to be padded a little, and this is where your supervisor will be relying on his experience. His padding will need to be supported by his assumptions.
Politics are also heavily intertwined with infrastructure in the public space. Politicians will expect, because they think something is a good idea, that it will be supported regardless of the result of the analysis. There are surely cases where the benefits will never stack up, such as a monorail, and others that, although the benefit can never be shown on paper are generally considered good ideas with significant public benefit.
Answer: I am not a civil engineer, so it's totally impossible for me to judge what you are saying based on the merits. So, this is some general advice.
I think, as others have said, a cost-benefit analysis is not something that has a right answer. I think the main requirement should be that the numbers are justifiable and source-able, and there is a reproducible way to get from your assumptions to the results of your analysis.
The differences of opinion in the "Note" part of your answer, to me, are difficult to parse for correctness. For example:

he wants to rely on word-of-mouth cost estimates by a local contractor instead of my idea which is to use published numbers in similar papers/reports.

The details really matter here. How "similar" are the papers and reports to the actual costs the project will incur? How reliable are the local contractors? Based only on what you have written, the truth could really be on either side... it could be that you are estimating costs for some very specialized task that local contractors don't have experience with, and that you found some papers/reports covering essentially the same project that are very reliable. Or, it could be that the papers/reports are similar but different in some crucial aspects and include some extra elements that are not necessary for the project you are working on, and the contractors can give a better estimate for the specific tasks you need.
Given the murkiness, I would generally advise against thinking of this situation in black and white ethical terms. If you were very experienced in this field and could prove your advisor's estimates were going to miss the mark by a factor of 20, then it might be a different situation, but I suspect this isn't the case as you are a research student and were pulled onto this project at the last minute.
Instead, I would focus on trying to understand what assumptions your advisor is making and how they derives their results from their assumptions.  Unless your advisor is totally incompetent or a fraud, both of which are unlikely, there is some path that you can follow to derive the results. Even if you don't agree with the assumptions, if the assumptions are clearly stated and the main results can be reproduced, then I would classify this as a difference of opinion, and not an ethical dilemma. You may indeed learn something from understanding your advisor's reasoning or why they trust their source of information over the sources you are using. Again, you might learn something, even if you don't agree with the methods in the end. And it won't ruin your career to be associated with this analysis. You will gain experience, have a paper, and as you progress you'll have more opportunities to do things your way.
In the event that you are 100% sure there really is no way to justify the analysis, either because the assumptions are objectively wrong or the analysis is bogus, and after discussing your concerns with your advisor they aren't willing to correct demonstrably false statements, then I agree you need to get out. To be clear, I think being 100% sure is a pretty high bar here, because a cost-benefit analysis is going to be murky and you are not an expert with a lot of experience. But if you are really sure that this is what is happening, talk to someone senior in your department that you trust (like a grad chair), explain the situation, and try to get away from this advisor.
Answer: Look, you have to get your good name out of this thing. You are being used as a frontman at best and a patsy at worst by this professor for a dodgy study. Your professor is an old dog who knows how the dark trade-offs work. If he gets a "result" from this "study" there will be more and more "consultancy".
I assume you have had a look at similar studies during your initial reading into the programme. It might be helpful to find some past projects that were over optimistic in their B/C and the consequences to that country's exchequer from all that goof-up. Spain has done a lot of infrastructure projects in the last 40 years and their construction cost-control processes are well-regarded. I'd expect that their vision of B/C would be pretty clear by now, especially w.r.t. local economy benefits.
Beyond that I can only suggest gently sounding out the postgraduate studies dean or HoD - or any sympathetic professor - to get ideas on all this. In talking to these people, do not adopt a pitiful oh-my-career or aggressive damn-your-corruption manner. Just be quite cool and matter-of-fact about it all and clarify the long-term danger to a department's reputation by association with a dubious study in support of a huge public investment. Impartiality and objectivity are all the more essential when glory-hole projects are touted. It's one thing to support a local authority in a relatively small but socially beneficial project for the city: a department without a heart is one without a head. But it's quite another thing to put the department's stamp (not just yours) on a study potentially instrumental in guiding a decision on massive public spending. Rehearse your lines with someone trustworthy at home before going to speak to anyone and note their comments.
If this fails, you have to extricate yourself academically from your supervisor even at the risk of a career detour out of academia for a while. You can plead "personal reasons" (e.g. need extra income, desire to be closer to ill parent, wife's career/personal choice, etc) for this detour.


Banana taking very long time to grow

Question: I planted banana plants (gifted by my neighbor who harvests bananas ever 6 to eight months) in my backyard. They are alive and growing for over 7 years at the rate of about 2 - 4 inches a year for the last 9 years. When I planted it was about 3 ft and now it is about 5 ft. my neighbor is astonished but could not find one good reason for this. He again gave me few more plants to grow in my backyard two years ago and these plants are relatively fast-growing (4 to 6 inches per year).  Can someone suggest a reason for the extraordinarily slow growth?
Answer: It may depend on where you are. In E TX , zone 8, they grew almost a foot per month ( in summer). Although I had small stalks of small bananas , We never had the 14 months of warm (or not cold), weather it took to ripen them. It was an interesting plant for conversation.It should send up at least two new plants each year as the original tree will die after producing fruit.
Comment: Could it be some nutrient deficiency?
Comment: I am in Planting Zone 10a
Answer: I have bananas. Gran Naine (Chiquita). 2-4 inches seems remarkably slow to me for growth. I would check the soil pH first. Like citrus, bananas like 5.5-6.5 of well-draining soil. If it's too wet, or the pH is too high, you won't be able to absorb certain nutrients. If your leaves have purple regions between the veins, your plant is not absorbing phosphorus because of one of the above.
My bananas are nutrient hogs, especially if I don't prune away the babies (but who wants to kill a cute little baby banana plant still attached to its mommy). High potassium food specifically for bananas is readily available.

Banana taking very long time to grow


How to show a comfirmation dialog when a batch file window is closed

Question: When users click the close (X) button of a batch file window, I want it to show a confirmation dialog asking "Are you sure want to close this batch file?" with Yes/No options. How can I do this?
Comment: [How to run a batch command when closing a batch script by clicking close button](http://stackoverflow.com/q/11967419)
Comment: So if you already have a batch that does what you want to make a batch do, the answer is right there in the batch that you have.
Comment: @EBGreen I meant when the user clicks the "X" button
Comment: See **pause** and **choice** for the CMD prompt.
Comment: @DrMoishePippik You when the user presses the red "X" button on the top right corner of the batch file, I want the batch file to comfirm the closing of the batch file.
Comment: Not possible. See the SO post linked to above.
Answer: There are other great options than using a batch file for your purpose, but since you want it that way, here is the code
@echo off
Call :YesNoBox "Are you sure you want to do that?"
if "%YesNo%"=="7" (
Call :MessageBox "You answered NO" "Heading"
exit /b
)
Code for invoking the message box
exit /b
:YesNoBox
REM returns 6 = Yes, 7 = No. Type=4 = Yes/No
set YesNo=
set MsgType=4
set heading=%~2
set message=%~1
echo wscript.echo msgbox(WScript.Arguments(0),%MsgType%,WScript.Arguments(1)) >"%temp%\input.vbs"
for /f "tokens=* delims=" %%a in ('cscript //nologo "%temp%\input.vbs" "%message%" "%heading%"') do set YesNo=%%a
exit /b
The above code is for programming the YesNo Options
:MessageBox
set heading=%~2
set message=%~1
echo msgbox WScript.Arguments(0),0,WScript.Arguments(1) >"%temp%\input.vbs"
cscript //nologo "%temp%\input.vbs" "%message%" "%heading%"
exit /b
The above code is for setting up and programming the Message Window
Hope it helps, but if you further want to refer for your purpose you should visit these links :  1st Link, 2nd Link
Thanks!!!
Comment: How will this help if the user closes the cmd window by clicking the 'X' button?
Comment: This is definitely not the idea in the code.. The code is solely aimed at creating a window which prompts the user for the option for closing the batch operation
Comment: I know, but that's not the OP's requirement so this clearly won't help.
Comment: Ya, you are right. Thats why I have provided a similar code not the exact working one and backed them up with references so that if the links die the code will be there for reference. Although I am working on the exact solution, will be posting it soon.
Comment: mistakenly posted as an aswer from the android app. Will delete it soon Sorry
Comment: If you know of an actual solution, do share it with all of us.
Comment: definitely will do.. Working on it


network scanner installation

Question: I have Canon IR 2200 network multi functional device (MFD). I have installed printer but not able to scan. canon provide network scangear utility for windows. I have also installed this utility with wine but still I am able to scan with the help of third party sofware i.e faststone image viewer. I was using faststone image viewer on windows for network scanning. our network MFD IP is 192.168.1.250 & my ubuntu desktop IP is 192.168.1.19. Please suggest.
Answer: You've to install XSane pacages for use your scanner device
sudo apt-get install xsane

or the gnome pacage for scanner:
sudo apt-get install gnome-scan

network scanner installation


Switch play store account without accepting ToS?

Question: I accidentally swapped accounts(to Account2) on the play store and now I cannot switch back to the original account(Account1) without accepting the ToS for Account2. Is there any way to switch back to Account1 or is Google forcing me to accept the play store ToS for Account2 in order to get back to Account1?
Answer: No, unless you either accept the ToS, or remove the account, you're unable to access the Play Store's interface therefore not allowing you to switch accounts.
Answer: Having recently run into the same issue, I found another solution:
Assuming "Account1" is the first Google account on the device, you should also be able to switch back to it by uninstalling updates to the Play Store app.
Updates can be uninstalled using the Settings app by navigating to Apps > Google Play Store, tapping the overflow menu, and selecting Uninstall updates.
At this point you'll be running an older version of the store, but it should take care of updating itself in the background.  If it seems to be taking a while, you may be able to hasten the update by opening the Play Store's in-app Settings menu and tapping on Build version at the bottom.
Answer: Another solution I found was to go into application manager and clear data. Reverted back to original account.
Answer: The best option would be:

Force stop the application
  Clear the data
  Clear the cache

It worked for me and hope will for you.


What are the recommended approaches to internationalization fallbacks?

Question: I'm currently laying the groundwork for internationalizing a web application. I'm torn between falling back to using asterisks or just the default English text for missing translations. Using asterisks, while annoying, would make it quite obvious that there is no text available, and would prompt the user, or ourselves, to fill it in. Using English when a user has explicitly selected an alternative language seems disrespectful of their wishes, but also gives them, if they're bilingual, something to work with. Are their any recommended approaches that apply generally, or is this heavily dependent on context?
Comment: 1. If you're able to detect an untranslated, why wouldn't you just make sure you complete all translations to begin with? 2. I assume that if you use a fallback language there may be circumstances where there is both [Swahili] and [English] on the same page?
Comment: 1. I have prior experience working on an internationalized application. It happens quite often that some translations lag behind feature development, especially for languages no one on the team speaks. We made a point of constantly keeping the translations up to date on those we did as we built the software, but with short release cycles, you're not always going to get professionals who are available to tweak things as you go. Ideal, but not realistic in all contexts.
2. Yeah, that would likely happen, and may be disorienting. But asterisks would probably be even more disorienting.
Answer: Firstly, I would say it's really bad form to inflict your problems on the user - never mark the text just because it will make it obvious to you that something needs to be done.
When it comes to missing translations, I'd suggest that a real language fallback is always preferable to a non-language fallback - At least it may be translated by the user if they wish. Whereas a non-language fallback does not allow user translation.
Comment: Fair points, all. Not fully convinced a real language, which could be gibberish to a user, is any better than, you know, actual gibberish. But you make a good point that they can run this through a translator, which isn't an option with asterisks, or whatever other mark.
Answer: Observations:

Asterisks can be really frustrating if there is no obvious meaning and there is no legend or interaction to reveal meaning.
Mixed languages on a page obviously causes confusion too.  But at least with another language the intent is clear to the user even if the meaning isn't.

Therefore:

A fallback language makes sense.  We just need to design to ensure that users understand why the translation is missing.
The fallback language should be differentiated from the normal language.  This provides an acknowledgement to the user that we are aware of the dissonance.
The user should have ability to find out more about the untranslated word(s).

One resulting approach
This example is an Italian app translated into English, with one missing translation. Here are two possible layouts:

When a user clicks on the asterisk/info icon, she's presented with something like this:

This approach:

Clearly differentiates/acknowledges untranslated terms.
Provides users with a way to find out more.
Provides users with a stopgap solution (Google translate) until the term is fixed.
Communicates that you are going to fix the problem in the future.
Assures users that there is no impact on the performance on the app.
Comment: This is fantastic. I think this might be the approach to take. Thank you.


How long should I keep my old passport?

Question: How long do I need to keep my old Pakistani passport with me when travelling to Germany? I have a valid visa for Germany and my new passport number is mentioned on the visa card as well. The old passport expired in 2013. Would an immigration official still ask for it?
Comment: It's still good to have it around somewhere safe, like a safety deposit box or in an actual safe - even in your home country. While you don't ever need it at the airport, there are times (such as if you naturalize or get a permanent residence status) when they might ask for it to see evidence of long term travel. So don't ever throw it away.
Answer: You only need to present an expired passport if it contains a visa that is not expired and is still valid for entry into Germany. You still need a separate currently valid passport.
If you are carrying a new currently valid passport which contains a valid visa, there is no reason to carry the expired passport as well.

How long should I keep my old passport?