Algorithms that are using John's ellipsoid

Question: The Lowner–John ellipsoid is a minimum volume enclosing ellipsoid of some convex body $K$. This ellipsoid is unique (as is the maximum volume ellipsoid contained in $K$). I'm looking for algorithms based on those ellipsoids, or any significant practical use that requires finding them explicitly.
Comment: This seems like a rather broad reference request, maybe too broad for this platform. Can you narrow it down, say algorithms in a specific field? (You give some tags that don't seem to relate to the question body at all.) What does Google Scholar give you, and why is that not what you want?
Answer: Rimon and Boyd use Lowner–John ellipsoids in their "...method for estimating the distance between a robot and its surrounding environment".
From the abstract:

First, approximate the detailed geometry of the robot and its
  environment by minimum-volume enclosing ellipsoids. ... Then
  compute a conservative distance estimate using ... [a] formula for the
  distance of a point from an n-dimensional ellipse.

E. Rimon and S Boyd. Obstacle Collision Detection Using Best Ellipsoid Fit. Journal of Intelligent and Robotic Systems, 1997 - Springer


Is inheritance in use case diagrams between actors limited to one specific diagram

Question:
Is inheritance in use case diagrams between actors limited to one specific diagram or is it applies to other diagrams too? e.g. I got 2 actors let's say Actor A, Actor B. I got also two use case diagrams lets say Foo and Bar that show some use cases (Foo got 3 different use cases than Bar, Bar got 3 different use cases than Foo). On Foo diagram I use inheritance between actors. On Bar diagram I connect Actor A with 1 use case and Actor B with 2 others. Does it mean that Actor B got access to that 1 use case that is connected with Actor A via inheritance (even if I dont use inheritance on that diagram but because I used inheritance in other diagram) or this does not work that way and inheritance is limited to specific diagram?
Answer: Inheritance relationships are directed. That's why they come with arrow heads. So saying "I connect Actor A ... and Actor B ... via inheritance" doesn't say enough. Leaves us with no idea which way the arrow head is pointing.

The behavior of the ancestor is inherited by the descendant. This is used when there is common behavior between two use cases and also specialized behavior specific to each use case.
creately.com - Use Case Diagram Relationships Explained with Examples

The arrow head should point from the descendant to the ancestor. Sort that out and you have your answer.
Comment: Imagine Actor B is the descendant of the Actor A in some Foo use case diagram that describes some part of my system so naturally Actor B has access to all use cases that has Actor A. Lets move to another use case diagram. Bar describes another part of my system. Here I placed Actor A and Actor B as well but I do not use inheritance. Actor A is realted with 1 use case, Actor B is related with some other two. Question: On Bar diagram is Actor B related to that one use case that is related Actor A or is not? Does one used inheritance work across all other use case diagrams or is limited?
Comment: I would hope it's limited. Because otherwise each actors name would need a namespace prefix to tell you when this is the same actor from some previous diagram. It's better when you can tell the whole story on one page.
Answer: In principle, every UML diagram shows a sub-set of a larger, overarching model (even if such a model is not explicitly created).
If you show a relation between two elements in a diagram, then that relation is part of the model and it will exist always, even if there is another diagram that shows the same elements but not the relation between them.
To go with your specific example, if you have a diagram showing Actor B is a more specific version of Actor A (Actor B inherits from Actor A), then that relation between the actors also applies to other diagrams, where you don't show the inheritance explicitly.
Actually, with the inheritance of Actor B from Actor A, you are telling that Actor B can do everything that Actor A can, plus some Actor B-specific things.


Blender 2.8 - default tab is empty

Question: i recently started using blender 2.8 (was previously using 2.79), and out of the sudden my default tab goes empty. i can't find my objects anywhere. however, if i go any other tab - animation, uv editing... - it's all there! i've already tried deleting the Blender Foundation folder, but had no luck. anyone knows what i did wrong and how i can fix this? thanks!
Comment: Does pressing `home` with the cursor over the 3D view do anything?
Comment: YES, thank you!!!
Answer: Sounds like the view has gotten lost in space somehow. You can try pressing Home to zoom the view to the currently visible objects (where "visible" means not hidden or in a hidden collection), or you could use A and Numpad . to select everything and then zoom the view on the selection.

Blender 2.8 - default tab is empty


What is the percentage of loan words in Classical Latin?

Question: I want to know the percentages of loanwords in Classical Latin (maybe including Old Latin but NOT post-classical Latin), including native terms and words, for example:
90% Native
7% Greek
1% Etruscan
?% etc...
Comment: One way to try to answer this might be to go through a sample of Latin words and see how many have entries in de Vaan's etymological dictionary, since that dictionary only lists native Latin words. (@BenCrowell, cases of the kind you describe will be rare because most native Latin words will have undergone Latin-specific sound changes.)
Comment: Wouldn't there be cases where we couldn't be able to tell whether a particular word was a Greek loan-word, a word that appeared in both Latin and Greek as a loan from some third language, or a PIE word? For instance, Troy is Τροία in Greek and Troia in Latin. How would we know whether this came to Latin through Greek or directly from Anatolia? I'm also not sure it makes sense to ask for a percentage. The percentage would be higher in fancy educated usage, lower in the vernacular.
Comment: It doesn't include a percentage, but @Cerberus answered a similar question on the Linguistics SE about [how many Latin words are of Greek origin](https://linguistics.stackexchange.com/questions/3707/how-many-of-latin-words-have-greek-roots).
Comment: @Adam Thank you, but I also want to know about non-greek loanwords.
Comment: Ben Crowell yes there are PIE words, but I still need those percentages.
Comment: Ok, I will wait for a professional to answer my question (thanks for your help :D).
Comment: @TKR Contrary to his stated policy, De Vaan actually includes a good number of words that aren't (likely to be) native; he mainly excludes very transparent loans from Greek. I once went through a list of the 2000 most common words (based mainly on the Perseus corpus), and only about forty weren't in De Vaan, and of those, only *persona* and *titulus* weren't Greek. Some other high-profile non-Greek loans like *ave* and *mappa* (both from Punic) are also out, but e.g. *harena* is in, as well as any number of etymology-unknown certain loans.
Answer: The following is from Loan-words in Latin (1888) by Edward R. Wharton.
He counted a total of 16,900 words from the following authors: Plautus, Terence, Cicero Caesar, Catullus, Lucretius, Sallust, Vergil, Horace, Livy, Tibullus, Propertius, Ovid, Persius, Tacitus, Juvenal.
Out of that total, he classified 92.43% of the words as natively Latin, and the breakdown of loan-words is as follows:

Words
Group / Family
Language
Percentage

1080
Greek
Greek
6.39%

21
Aryan
Umbro-Sabellian
0.12%

43
Aryan
Celtic
0.25%

5
Aryan
Teutonic
0.03%

13
non-Aryan
Etruscan
0.08%

1
non-Aryan
Basque
< 0.01%

13
non-Aryan
Phoenician
0.08%

4
non-Aryan
African
0.02%

1
non-Aryan
Indian
< 0.01%

90
Unknown
Unknown
0.53%
Comment: @Draconis Probably same from which the old name for IE, Indo-Aryan, comes, with Greek as a special category. Given that it's 1888, he should have made Indo-Aryan the category. I can't see why he would break it down this way.
Comment: @cmw I'm aware of early philologists using Aryan for IE, but I've never heard of them using Indo-Aryan that way (rather than for the family of languages still refered to as Indo-Aryan)
Comment: Terminology aside, it looks like Wharton is way too eager to call native Latin words Greek. This works as an upper bound (and it's probably the best answer possible without some serious legwork of our own, unless there's some other study out there), but it's a significant overestimate.
Comment: What definition is Wharton using for "Aryan" here?


my first custom view is not scrolling

Question: I had a text view and i was taking chat that came in from the internet and was printing it but i wanted more colors than a textview had to format the chat.
I replaced the textview with a scrollview and in viewdidload i attempted ( seemed to work) to attach my view class to it.
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    _myconsoleview = [[ConsoleView alloc] initWithFrame:[self._scview bounds]];
    [_myconsoleview setBackgroundColor: [UIColor yellowColor]];
    [self._scview addSubview:_myconsoleview];
    [self._scview setNeedsDisplay];
}

well as text got to the bottom it didn't scroll ( i tried dragging the text are with the mouse and looked for scroll bars).
so this example core text program says oh thats easy to get scrolling. just make my custom view (ConsoleView) inherit the scroll view itself. So i try this and add this now:
@interface ConsoleView :UIScrollView<UIScrollViewDelegate>

still no scrolling. no scroll bars. no indication and i'm using the ipad simulator so far, of any kind of scrolling.  In ConsoleView i want to do something very polished eventually but for now i'm just printing a single string. But the string gets longer as i get more text as i'm appending to it.
i tried this in my sendtext method. this hits when they hit a button to send the text they type in this textfield to the server:
   [myconsoleviewid addNewText:newText];
    [_scview scrollRectToVisible:[_scview bounds] animated: TRUE];
    [_scview setNeedsDisplay];

I honestly am not sure i can claim the above would work but i figured something might work. any ideas? I'm fairly new to ios programming having started about 2 months ago and worked on it off and on so far. In java or android there doesn't seem to be much more to getting like a console to scroll than to add it to some scroll control. But IOS is proving trickier.
Mike
edit. this is my draw rectangle which is suppose to print the string which gets longer and longer. its in consoleview:
- (void)drawRect:(CGRect)rect
{
    [super drawRect:rect];
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetTextMatrix(context, CGAffineTransformIdentity);
    CGContextTranslateCTM(context, 0, self.bounds.size.height);
    CGContextScaleCTM(context, 1.0, -1.0);    CGMutablePathRef path = CGPathCreateMutable(); //1
    CGPathAddRect(path, NULL, self.bounds );

    CTFramesetterRef framesetter =
    CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)attString); //3
    CTFrameRef frame =
    CTFramesetterCreateFrame(framesetter,
                             CFRangeMake(0, [attString length]), path, NULL);

    CTFrameDraw(frame, context); //4

    CFRelease(frame); //5
    CFRelease(path);
    CFRelease(framesetter);
}

Answer: You need to set scrollView.contentSize with proper size of scrollable area.
scrollView.contentSize = CGSizeMake(640, 320); // if you are in full screen and have two view one to other in horizontal
// for vertical scrolling you need to do
scrollView.contentSize = CGSizeMake(320, 640);
This examples are only for one way scrolling horizontal or vertical if you set the contentSize bigger than view frame size if will be scrollable.
Comment: if i'm simply printing a long string how do i know the size? String just has text and it has \n characters in it. Also at this point i've got two scroll views i guess. the one i dragged on to the storyboard and hte view i attached to it which is a scrollview too. does it matter which one i set the size of?
Comment: You need to set the contentSize of the scrollView and to be scrollable  contentSize must be bigger that UIView frame size. Because that scrollView is in UIView.
Comment: i just want vertical scrolling so i added _scview.contentSize = CGSizeMake(320, 1040);. i did this to my overall scroll view.  i made my view i attached to it just a UIView.  well i have a yellow background on my view and when i scroll now the background changes to white and there is no text . did i attach the view wrong?  when i set the contents size of my consoleView before i made it a uiview, i   also got some scrolling but still no new text printed below the initial stop point of text or one screen.
Comment: Your ViewController have view, after that you add your scrollView to that view. What you use about displaying the text UITextView?
Answer: The ScrollView's contentSize must be larger than the ScrollView's frame in order to allow scrolling. Set this property correctly and you should be fine.
Comment: if i set the overall scroll view content size to like 20000 vertical, my yellow background stops at one page so this seems wrong. If i set my view which is a scroll view to like 2000 vertical, it scrolls, i see my yellow background my view has persist, but text still stops showing after the last line of page one.
Comment: I saw I had not accepted an answer.  I wound up changing the core text code, but with the scrolling issue still, I found that this was the trick, contentsize being at least one larger, accepting this answer.

my first custom view is not scrolling


Composition Flowchart in After Effects

Question: Need your expertise. I can't seem to figure out how to delete Scene 07 in Media 3.3 and to reference it to another Media. Is there a way to edit the composition flowchart? Thank you
Answer: You can't edit the flow chart directly, but you can duplicate any comp from the project window, then replace another comp with your duplicate - see this answer: How to duplicate composition and subcompositions?

Composition Flowchart in After Effects


LaTeX 3D PDF with U3D file and media9: add a view at runtime

Question: I am wondering if I could hack media9 package to achieve such a feature: end-users should be able to add a new view of an animated U3D file at runtime. So I'll be editing the VIEWS FILE from a Javascript callback.
Do you think it is feasible for a person with intermediate knowledge level of TeX?
Thanks
Comment: Welcome to TeX.SX! You can have a look on [our starter guide](http://meta.tex.stackexchange.com/q/1436) to familiarize yourself further with our format.
Answer: Update:
Current versions of Acrobat Reader DC allow users to add new 3D views at runtime and to save them with the PDF file. Adding new 3D views does not require recompilation of the PDF from the TeX source anymore.

No, this is not possible in AdobeReader.
At runtime, a user may manipulate the 3D object in AdobeReader and produce new VIEW sections via the context menu (mouse right click), provided the 3Dmenu option was set during compilation of the PDF. He can add VIEW sections to an existing or to a blank new views-file (via copy/paste from the JavaScript console) and associate the modified views-file with the u3d/prc file via option 3Dviews during the next LaTeX run.
Thus, the user needs the complete LaTeX document source plus the u3d/prc files to be embedded and recompile the whole thing with the new view added.
Note that JavaScript cannot write to files directly, for security reasons.
The views-file is not embedded verbatim into the document, but parsed by LaTeX and translated into PDF objects when compiling the LaTeX document source.


BlazeDS Servlet not responding through Proxy

Question: I have a problem using Flex with BlazeDS on a Tomcat 5.5 through a Proxy (Apache). I already searched for it but didn't find answers which solved my problem. I hope you guys can help me out. :-)
Our scenario is the following:
Flex-App using BlazeDS to communicate with our Dataservice on a Tomcat 5.5. The Webapp is balze enabled and the services config contains channel definitions like the following:
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
    <endpoint url="http://xxx.xxx.xxx.xxx:8180/myDataService/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint">
</channel-definition>

I set the Flex Server Root URL to http://xxx.xxx.xxx.xxx:8180/myDataService (Context Root: /myDataService) and compile my flex application against this services-config.
After that I deploy my flex application and my dataservice on a server with some ip address xxx.xxx.xxx.xxx. The two applications are available after that
using http://xxx.xxx.xxx.xxx:8180/myFlexApp or for the dataservice: http://xxx.xxx.xxx.xxx:8180/myDataservice
The tomcat is listening on port 8180.
If I open my flex application using the URL with the ip address everything is working fine. My application is receiving data perfectly.
Ok. Everything fine so far.
Now I want to use a proxy server (via apache http server) to hide the ip and use a domain name.
I do the following changes to my services-config:
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
    <endpoint url="http://mydomain.com/data/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint">
</channel-definition>

I set the Flex Server Root URL to http://mydomain.com/data (Context Root /data) and compile my flex application against this services-config.
I deploy the applications again on the same tomcat as before.
Now I create an entry in the sites-available (sites-enabled) folder of my apache directory (etc/apache2/sites-available/) called mydomain.com
I create a Virtual Host with ServerName www.mydomain.com and ServerAlias mydomain.com. I also add the neccessary rules in the Proxy block and the other stuff neccessary for the virtual host definition.
The following ProxyPass/ProxyPassReverse entries are contained in this file:
ProxyPass /flexApp http://xxx.xxx.xxx.xxx:8180/myFlexApp
ProxyPassReverse /flexApp http://xxx.xxx.xxx.xxx:8180/myFlexApp

ProxyPass /data http://220.127.116.11:8180/myDataservice
ProxyPassReverse /data http://22.214.171.124:80/myDataservice

After that I can open the flex Application with http://www.mydomain.com/flexApp in the browser and it loads. But an error message is thrown when it tries to contact the dataservice using blazeds.
I even can't open the URL http://mydomain.com/data/messagebroker/amf. A 404 Error is displayed. Before - using the ip address - a blank page was displayed.
The weird thing is, that the non-blaze Servlets are working fine. e.G. I can open http://mydomain.com/data/myServlet and it works. Only Blaze doesn't work.
Do you have any ideas why this problem occurs and how i may solve it. Thanks a lot in advance. You're really helping me out!!!
Henrik
Answer: Both BlazeDS and the Flex app are using the URL in the channel-definition's endpoint.  But the URLs actually need to be different.  BlazeDS needs to use the myDataservice/messagebroker/amf URL while the Flex app needs to use the data/messagebroker/amf URL.  So you can either make both URLs the same, ie. myDataservice
 instead of data.  Or you can manually set the channel information in the Flex app instead of having it read the services-config file.
Answer: I'm using AJP for the request redirection:
// enable mod_proxy_ajp
a2enmod proxy_ajp

The proxy configuration looks like this:
ProxyPass /flexApp/messagebroker/ ajp://localhost:8009/flexApp/messagebroker/


Troubleshooting a hanging `list-processes`

Question: Normally I'd use M-x list-processes to see what Emacs is running in the background. But in this case list-processes itself hangs. What is the right thing to do in this situation?
Comment: If your OS has a task manager, you can see what subprocess are running.  E.g., on Windows it is called Task Manager (or it least that was its name in the old days); OSX 10.6.8 has Activity Monitor.app; Linux has ....???
Answer: If this happens it means that Emacs is having trouble communicating with some subprocess. It is a good idea to leave Emacs and look at its subprocesses from the hosting operating system.
For example, on Unix this may be done with pstree $(pidof emacs). This won't show which process is causing the problem, but can at least serve as a kind of sanity check.
You can also send Emacs a SIGUSR2 signal, which will stop it from hanging and kick it into a debugger.


immediate number test in llvm

Question: In LLVM, I'd like to test whether the trip count obtained by LoopInfo pass is an immediate
number. For example, the following loop
for(i=0; i<10; i++) { ... }

has a trip count of 10, and it's an immediate number. The member function getTripCount() of Loop can be called to get a Value representing the trip count. How can I decide this value is an immediate number or not?
Comment: You could try to `dyn_cast` to `ConstantInt`, cf. http://stackoverflow.com/questions/5315176/llvm-get-constant-integer-back-from-value .
Answer: Use the following getter provided by the Scalar Evolution analysis:
unsigned ScalarEvolution::getSmallConstantTripCount(Loop *L, BasicBlock *ExitingBlock)

/// getSmallConstantTripCount - Returns the maximum trip count of this loop as a
/// normal unsigned value. Returns 0 if the trip count is unknown or not
/// constant. Will also return 0 if the maximum trip count is very large (>=
/// 2^32).
///
/// This "trip count" assumes that control exits via ExitingBlock. More
/// precisely, it is the number of times that control may reach ExitingBlock
/// before taking the branch. For loops with multiple exits, it may not be the
/// number times that the loop header executes because the loop may exit
/// prematurely via another branch.

immediate number test in llvm


Access denied unless I add trailing /

Question: I am trying to add wordpress as a subdirectory into rails, If I try to access the blog root page without trailing / or adding /index.php I get access denied.
https://example.com/blog 403

https://example.com/blog/ 200

https://example.com/blog/index.php 200

here is my conf:
location /blog {
  root /var/www/example/current;

  fastcgi_intercept_errors on;
  include fastcgi_params;
  fastcgi_index  index.php;
  fastcgi_param   PATH_INFO         $fastcgi_path_info;
  fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

location ~* \.(?:css|js|map|jpe?g|gif|png)$ { }
  index  index.html index.htm index.php;
  try_files $uri $uri/ /index.php?$args;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}

nginx error log:
Access to the script '/var/www/example/current/blog' has been denied (see security.limit_extensions)" while reading response header from upstream

/etc/php/7.2/fpm/pool.d/www.conf:
security.limit_extensions = .php .php3 .php4 .php5 .php7 .js .css

any idea?
Answer: I found the answer, I am putting it here incase it might be useful for someone:
change: location /blog into location /blog/

Access denied unless I add trailing /


Four 3x3 semimagic squares in a 5x5 grid

Question: Can you place every number from 1 to 25 in a 5x5 grid such that it contains four 3x3 semimagic squares? A semimagic square is a square whose rows and columns all sum to the same number. This is intended to be solved with a computer.
Comment: Can a semimagic square be composed of any 3-subset of rows and any 3-subset of columns?
Comment: @RobPratt no they need to be contiguous subsets, ie. next to each other.
Comment: So there are nine 3x3 squares and you want four of them to be semimagic?
Comment: yes that's correct
Answer:
 Yes, $4$ is the most possible (take the subsquares with $12$, $3$, $18$, and $13$ in their top-left corners as the semi-magic squares).

 \begin{matrix} 12& 24& 3& 25& 11 \\ 9& 7& 23& 10& 6 \\18& 8& 13& 4& 22 \\20& 14& 5& 19& 15 \\1& 17& 21& 16& 2 \\\end{matrix}
Comment: I just finished some Python code to enumerate the examples. Up to the various symmetries (rotation, reflection, inversion through 13, and permuting the first and second or fourth and fifth rows and/or columns), this square and RobPratt's square are the only solutions.
Comment: Yes you got it! I am very impressed at how fast you got that. Interestingly it is a variant of the same square that I found. I wonder if there are other examples? Also I would be keen to see your approach.
Answer:
 Here's a different one, obtained via integer linear programming:

 18 19  1 12 25
 17  5 16 20  2
  3 14 21  6 11
 13 15 10 24  4
 22  9  7  8 23
Comment: Fun fact: exchanging the first two rows adds a magic antidiagonal in the top left, and it's the only way to make a magic diagonal.
Answer: Logic underpinning the other answers:

 If two subsquares share a full row and/or column, their semimagic sums are equal. Consequently, no two subsquares share two full rows and/or columns, because their third rows/columns would be forced to be equal. We are left with three possible configurations, up to rotation: Zero Corners (top), Three Corners (left), and Four Corners (right), where subsquares of the same color have the same sum.

 Four Corners is the only valid configuration.
 In the Zero Corners configuration, R1C2-4 must have the same sum as R4C2-4, but R1Cn differs from R4Cn by the difference in sum between the green and red squares. Consequently, the green and red sums are equal, and identical numbers abound.
 In the Three Corners configuration, R2C5 and R5C2 are equal*, being both different from R2C2 by the difference between the red and green sums. Likewise for R1C4 and R4C1 (via R4C4).
 *(R1C1 is the top left.)

 The central cell is congruent to 5 modulo 8 (i.e. 5, 13, or 21).
 In the Four Corners configuration, the values of the entire 5×5 square are determined by the central 3×3 as follows, where $S$ is the magic sum:
\begin{array}{ccccc} a+b+d+e-S & S-a-d & S-b-e & S-c-f & b+c+e+f-S\\ S-a-b & a & b & c & S-b-c\\ S-d-e & d & e & f & S-e-f\\ S-g-h & g & h & i & S-h-i\\ d+e+g+h-S & S-d-g & S-e-h & S-f-i & e+f+h+i-S \end{array}
 Summing the entries yields $325 = 8S+e$ and reducing modulo 8 yields the claim.

 The number of solutions is divisible by 128.
 The Four Corners configuration has five validity-preserving symmetries due to its structure:
 - Rotation and reflection (order 8)
 - Interchanging rows 1 and 2 (order 2)
 - Interchanging rows 4 and 5 (order 2)
 - Interchanging columns 1 and 2 (order 2)
 - Interchanging columns 4 and 5 (order 2)
 In fact, there are exactly four solutions up to these symmetries (i.e. 512 in total) - user1502040's, RobPratt's, and the squares formed by replacing each x with 26-x in either of those squares.
Comment: Thanks for that interesting insight!


Can a single point be considered a function?

Question: A relation is defined as a set of ordered pairs. A set can include a single point. A function is a relation. Does that mean a single point can be considered a function? Say you have the point (1,0). There is a unique output for the input, but does there need to be multiple inputs and multiple outputs?
Comment: I just want to tweak your terminology a bit.  A set can include a single element.  A single ordered pair can be considered a function.  This includes the ordered pair $(1, 0)$, which maps the element $1$ to the element $0$.
Answer: Yes, $\{(1,0)\}$ is a function. For that matter, $\emptyset$ is a function. A function can have a domain of any size, including $1$ and $0$.
Comment: Thank you for the answer! Since ∅ is a function, that means it's a relation as well, correct? Or does a relation have to be between multiple sets?
Comment: @NiehlsIngram Yes, the empty function is also the empty relation.
Comment: Great, thank you for the help!
Answer: In my view, any point can be considered function. Specifically, any function with a single answer and a single element may be a function.
For example, {{1},{0}} can be Considered a function if the answer for f{1}~ {0} and the set contains the single element. Thank you for the cooperation.
A function can also have a single element.


Type inference in compiler is context sensitive?

Question: Have read in Compiler textbook that type inference is context sensitive. Can anyone explain why is it so? This means that we need context sensitive grammar in semantic analysis phase of a compiler with this feature? How is it done in popular programming languages like C?
Answer: The context that is needed tells us the types of known variables. Suppose We want to infer the type of
if b or 2 = x then a else b

To make sense of this we need to

Check that the type of b is bool
That the type of x is numeric
That a and b have the same type.

To answer these three questions, we look up information about variables in a typing context, which is a mapping from variables to their types. Furthermore, the result is context-sensitive, as the type of the whole expression is the type of a (and b), which is given by the information in the context.
Now you are also mentioning grammars. These are not really relevant here, because we are talking about a stage of compilation which comes after parsing. I think you just got confused by the word "context" being used outside of the subject of grammars. Or you are reading a very strange book. By the way, there is a reason scientists want other scientists to give precise references to their sources. So instead of saying "I read a compiler book", you should have given the author and the title. Now I am just guessing.
Comment: I was referring `Engineering a Compiler` by Keith D Cooper


What makes for a good pre-schooler educational toy?

Question: I'm looking for ideas for an educational toy for a 4-year-old girl. What factors should I look for?
Comment: The answer depends on what you want to achieve; what you mean by "educational". Alphabet? Geometry? Language? Physical education, like balance and motor control? Should it be in book form, or plastic stuff, or wood, or...?
I've downvoted the question to motivate you to edit and improve it :-) then I'll turn the downvote into an upvote.
Comment: This is too brief for a an answer - Will she actually play with it?
Answer: I'll try to answer, although the question might get rephrased:
You need to take several factors into account. Consider these aspects, and they might help you narrow down your quest into something that is specific enough that you can search for items on Amazon and read some reviews.

What is the goal you want to achieve with this toy? Do you want to train the alphabet, or numerical skills, or musical abilities, or body control, etc.?
What is the level of interaction you're looking for? Should it be wooden building-blocks, or should it be a laptop-style kid's computer or other electrical/digital device?
How should your daughter use the toy? Should she be able to figure it all out herself, or are you planning to act as a guide and playmate?

Perhaps a small easel or blackboard is the thing. I think it encourages artistic play. I've also seen lots of wannabe-laptops for kids which I personally wouldn't buy, but obviously many people do. You could even be very advanced and get the child a small real laptop (a netbook costs around €250 these days) with childrens' programs on it (I think Ubuntu is a Linux flavor that is very well suited for this).
I do encourage you to clarify your question - perhaps this is way off the mark.

Comment: +1 for taking into consideration "should she be able to figure it out by herself".
Answer: Educational toy is something which makes the child learn through play. A pre-schooler will not feel engaged if the toy only focuses on education. The type of educational toy which will be good for a preschooler depends on his or her age. There are a variety of educational toys which cater to different age groups. There are several factors to be kept in mind regarding educational toys :

Aim of the toy: One should be aware of the need of the child. Whether the child should be learning alphabets or maths or motor skills.
Directional or open-ended- Decide if you want the child to learn and play independently developing social skills. Or direction generated toys where he or she follows the rules.


When moving current directory I get "mv: cannot move `.' to `../dir/.': Device or resource busy"

Question: $ mv . ../general/
mv: cannot move `.' to `../general/.': Device or resource busy

Does it mean that the current directory is a busy device or resource, and can't be moved away? Why is it?
Answer: You can't move the directory you're current in. The current process is the one that's keeping it busy.
Instead, go up one level and name the previously-current directory to move it to the target.
Answer: It is not possible to move a dot .. The dot is not the same as current directory name. You can think about . as a pointer to the directory, but not the directory itself, therefore,
$ pwd && echo $PWD && realpath .
/home/jimmij/tmp
/home/jimmij/tmp
/home/jimmij/tmp
$ mkdir tmp1 tmp2
$ mv tmp1/. tmp2/
mv: cannot move 'tmp1/.' to 'tmp2/.': Device or resource busy

doesn't work, but
cd tmp1
mv ../tmp1 ../tmp2

works fine, so actually you can move current directory, although some commands can be confused after this operation:
$ pwd && echo $PWD && realpath .
/home/jimmij/tmp/tmp1
/home/jimmij/tmp/tmp1
/home/jimmij/tmp/tmp2/tmp1
$ cd .
$ pwd && echo $PWD && realpath .
/home/jimmij/tmp/tmp2/tmp1
/home/jimmij/tmp/tmp2/tmp1
/home/jimmij/tmp/tmp2/tmp1

Similar story with .., i.e. parent directory.
In other words each directory must contain at least two elements: . and ... You cannot move or delete them.
Answer: The reason you're getting the message:

mv: cannot move .' to../general/.': Device or resource busy

is due to how the ., and .. work in addition to mv. When you move something in Unix, the mv command attempts to unlink everything that references the inode of the item that you're attempting to move. In this case that would be the inode of whatever the directory is that . is referencing.
The "symbols/links" . and .. are linking to inodes and are in a sense special. You can read about their history here in the U&L Q&A titled: Why does a new directory have a hard link count of 2 before anything is added to it? If you've ever looked at a newly created directory, you'll notice that it always starts with a linked count of 2. The reason is due to the existence of the . and ...
$ mkdir adir

$ ls -l | grep adir
drwxrwxr-x. 2 saml saml 4096 Oct  5 08:02 adir

$ ls -la adir/
total 8
drwxrwxr-x. 2 saml saml 4096 Oct  5 08:02 .
drwxrwxr-x. 3 saml saml 4096 Oct  5 08:02 ..

NOTE: Reference for ls output if you're unclear is here in this U&L Q&A titled: What do the fields in ls -al output mean?
So they aren't names of actual directories, but are "symbols/links" that are linking to them. Therefore they meed to be unlinked prior to being able to mv.
Well since your command is using the ., it cannot be unlinked by the mv command, hence the msg: "Device or resource busy".
References

The Unix File System Hierarchy
Answer: Linux forbids renaming any path that ends in the component . or .., returning the error EBUSY; the following will also fail:
$ mkdir a a/aa
$ mv a/aa/.. b
mv: cannot move 'a/aa/..' to 'b/..': Device or resource busy

The code for this is in namei.c::renameat. The last component of the pathname when passed to various functions needs to be of type LAST_NORM, not LAST_DOT or LAST_DOTDOT.
FreeBSD returns the error EINVAL in each of these cases.

We can only guess as to why there is this restriction.

The POSIX standard for rename states that

The rename() function shall fail if:
  ...
  [EBUSY] The directory named by old or new is currently in use by the system or another process, and the implementation considers this an error.

One could consider . to currently be in use by the process. But note that Linux allows the following, so a directory merely being in use by some process is not sufficient for rename to fail:
$ mkdir /tmp/t
$ cd /tmp/t
$ mv /tmp/t /tmp/t1
$ /bin/pwd
/tmp/t1

The reason for forbidding the renaming of . and .. is probably "leads to less user confusion".

. is typically a hard link to the directory's entry in its parent, and is somewhat special in that a process can always open . to access its current working directory. Being able to rename it would be counterproductive.
.. is typically a hard link to the directory's parent, and is somewhat special in that a process opening .. will get the parent directory (or the directory itself, if it's a mount point). Being able to rename it would be counterproductive.

Linux also forbids rmdir of a path whose last component is .. (ENOTEMPTY) or . (EINVAL). FreeBSD returns the error EINVAL for each of these.
The POSIX standard for rmdir has this:

The rmdir() function shall fail if:
  ...
  [EINVAL] The path argument contains a last component that is dot.


what will i loose during the root process?

Question: when i root my device what will i loose ?? will rooting wipe my device ?? i don't care about contacts nor applications data the most important this is my media !!! it means a lot for me no just media !! PDF files and everything else i added to the phone storage other then the application ??? please can somebody help because i want to root my phone to use titanium backup so i can have access to all my backup data anywhere ??
Answer: Let's get it straight. I'm aware of two techniques that can root an Android device. Both has merits and demerits.

Unlock Bootloader →install a custom Recovery → root device using custom Recovery
This method will definitely wipe every thing because it resets the phone back to a state you received from your OEM (OTA update is exception). So if your rooting method requires unlocking Bootloader then do consider taking a backup of your Internal SD card.
Merit: Clean, easy, and you're aware of what's going on at any stage.
Demerit: Because of security concerns data is lost for good.
Using an app on Android or PC
There are Android apps like Framaroot (see Methods/apps here), or PC apps like Kingoroot which can root your device without caring for the state of the Bootloader. They rely on an un-patched vulnerability in your Android device. Here is a good answer that explains the working of such apps.
Merit: Device rooted without data loss (usually).
Demerit: If the app isn't open source then you're at the mercy of the app since you don't know what's going on.

Now that an understanding is developed for what will be lost or saved in each method, we will now proceed for backup of Internal SD card.
Consider this rule
Always take backup  before tinkering with /system (rooting affects it) or any other uncommon firmware partition.
About Backup
Taking backup of Internal SD card is trivial. Plug your device into your PC and do a copy-paste of all the content (or your important content) from Internal SD card into PC. I prefer to take backup by running a file server  and  USB tethering on Android but you may use MTP or any other technique like adb pull <SOURCE> <TARGET>.
Comment: Losing your warranty depends upon your country's law and OEM's policy. Mostly, you will lose the warranty once the device is rooted but I've noted that EU has a law which protects your warranty even if you root your device.
Answer: When you root your android device you will loose nothing except your warranty. On some devices there are still tricks to get your warranty back by resetting the flash counter etc.
You will loose nothing by the rooting process. However, there always is a slight chance that there goes something wrong and you may loose your data. I never had it myself, but I suggest you to make a backup of all your data. Most of the data should be synced automatically with Google servers, but you still need to back up your photos, documents etc.
When you are rooted there are better ways to backup your data with apps like titanium backup, ROM toolbox etc.
Hope my answer helps!
Answer: Use this App - http://www.moborobo.com/products/ to make a decent backup of everything including your installed Apps. Then also copy both SD CARD and Internal Memory contents to a backup location then try your rooting. I rooted a phone and the worst happened. But i restored everything except my active chats in WhatsApp.
Good luck!
Comment: Are you affiliated to the product?
Answer: You will lose nothing except your warranty.
Comment: Man guys if you downvote someone for answering then tell him why you downvotedthe post. You WONT lose anything by rooting but you will lose data by flashing wrong images, autoroots etc.
Comment: Maybe the guys who downvoted this answer owns a [OnePlus device](https://oneplus.net/support/answer/will-rooting-or-unlocking-the-bootloader-void-my-warranty).
Comment: Maybe, maybe not. if this would e answered correctly by the guy who ones that specific device i would understand the downvote. but I remember that there is some rule here prohibiting posts based personal opinion.


Does the integral $\int_{a}^{b}\frac{dx}{\sqrt{(x-a)(x-b)}}$ exist?

Question: What is the result of this integral $\displaystyle\int_{a}^{b}\dfrac{dx}{\sqrt{(x-a)(x-b)}}$ ? I have tried many possibilities like letting $\sqrt{(x-a)(x-b)}$=u or trying to make the denominator express as a difference of two sqares but nothing worked.
Comment: First: Note that as stated the integral (if it exists) must be imaginary owing to the denominator. To get rid of that, change the square root to $\sqrt{(x-a)(b-x)}$. Second: Try a simpler case first---say, $a=-b=1$. Do you see a useful transformation?
Comment: Assuming $a\leq b$, the argument of the square root is negative for any $x\in(a,b)$, hence the integrand is not a real function. Regarding the integrand function as a complex-valued function, you have to choice a determination for the square root.
Comment: Try the substitution $x=a\sin^2y+b\cos^2y$. I think it will work.
Answer: We first show that the integral is independent of $a$ and $b$, and then let $a=-1$ and $b=1$ to get the result that $$\int_a^b\frac{dx}{\sqrt{(x-a)(b-x)}}=\pi$$
For the first part, use the substitution $x=a+t(b-a)$
$$\int_a^b\frac{dx}{\sqrt{(x-a)(b-x)}}=\int_0^1\frac{(b-a)dt}{\sqrt{t(b-a)(1-t)(b-a)}}=\int_0^1\frac{dt}{\sqrt{t(1-t)}}$$
For the second part,
$$\int_{-1}^1\frac{dt}{\sqrt{(t+1)(1-t)}}=\int_{-1}^1\frac{dt}{\sqrt{1-t^2}}=\arcsin t\Big|_{-1}^1=\pi$$
They can be combined into one step, but the rescaling substitution to [0,1] is easier to write down.
Answer: Here is an intuitive approach which may or may not be helpful, depending on how rigorous a solution you need.
First I will assume that you want a real integral, and that the question should be
$$\int_a^b\frac{dx}{\sqrt{(x-a)(b-x)}}$$
as various people have suggested in comments.  Note that we have two problems (though they are both of the same kind) since the integrand is unbounded as $x\to a^+$ and as $x\to b^-$.
If $x\to a^+$ then $1/\sqrt{b-x}$ is more or less a (finite, non-zero) constant.  So we can tell whether the integral converges or not by considering
$$\int_a^{a+\varepsilon}\frac{dx}{\sqrt{x-a}}
  =\lim_{c\to a^+}\int_c^{a+\varepsilon}(x-a)^{-1/2}\,dx
  =\lim_{c\to a^+}\bigl(2\sqrt{\varepsilon}-2\sqrt{c-a}\bigr)
  =2\sqrt{\varepsilon}\,.$$
Since the limit exists, the integral converges.  You can deal with the problem as $x\to b^-$ in the same way.
Answer: Setting $a=0$ and $b=1$, then
\begin{align}
\int_0^1 {{x^{ - {\textstyle{1 \over 2}}}}{{\left( {1 - x} \right)}^{ - {\textstyle{1 \over 2}}}}dx}  = \int_0^1 {{x^{{\textstyle{1 \over 2}} - 1}}{{\left( {1 - x} \right)}^{{\textstyle{1 \over 2}} - 1}}dx}  = B\left( {\frac{1}{2},\frac{1}{2}} \right) = {\Gamma ^2}\left( {\frac{1}{2}} \right) = \pi
\end{align}


Is it possible to install a frost-proof sillcock on a steel plate?

Question: Is it possible to install a frost-proof sillcock on a steel plate?
Comment: How thick is the steel? In general it's not too difficult to drill through plate steel with a good strong drill.
Comment: Welcome to DIY.SE. Shopping recommendations are off topic here, since prices and availability are too variable to be useful for future askers. If you could clarify your installation question a bit, we may be able to help with that.
Answer: Sure. You can install a spigot on virtually any solid surface. If you can't drill fasteners into the material, it may be feasible to use silicone, spray foam, or another substance to anchor the pipe in the hole, making for a solid installation.


How to add new item like "Create New" to the dropdown in Jquery Autocomplete when typed string does not match

Question: If the item does not match, I want "Create New" appear as an item in the dropdown, or "Create New" can appear everytime when user starts typing. Either way would work. Any ideas? Thanks!
Answer: Without seeing any code or more details, you best bet is to just add some code to append the "Create New" item to the dropdown. Probably after the post/fetch code that triggers on users typing.
If you post code we can help more by modifying it. The above responses are kinda vague and generally more advice due to the lack of description/code. Do I need to say again more description and code? :)


Visualizing lat/lon pairs on a map, locally

Question: I have a sensitive list of coordinates that I've already managed to geocode locally and now need to visualize on an interactive map. They're all contained within a particular neighborhood of the same city, so I'm hoping there's a way to display these on a map as pins, like one would do with the Google Maps API, but by downloading the map of the area and then adding the pins rather than sending the list of the pins and their data over the Internet. How might I get these points visualized on a map in a way that preserves the privacy of the coordinates?
Answer: Leaflet will render your map markers locally.


How do you design for a fast paced environment?

Question: I'm designing a restaurant management app. Customers are coming in, orders are being taken, deliveries are going out, not mention reservations. So a lot is happening and its happening constantly. There are supporting personas, but the main one is the restaurant manager. How can I approach this ? What patterns/solutions have you found useful ?
Comment: I'm not sure if the question is clear. Are you asking for examples of restaurant management apps? Or are you asking how to approach different persona's? Could you be more specific?
Answer: The main thing in this case is going to be to test, test, test.
It sounds like you're already well aware of the personas, so I'd suggest that you determine what the main guiding priorities need to be for those personas and design for those.
Once you have your priorities, you'll want to look for metrics that are good indicators of how you're doing against them... then prototype as early as possible, measure the performance of those prototypes against the metrics you've chosen.
As an example, from what you've written:

a lot is happening and its happening constantly

So one of the metrics needs to be around speed & accuracy of input and rapid error detection & correction (because mistakes will be made, minds will be changed, etc...)
Another needs to be about accuracy of information exchange - when one person puts an order in and another needs to read it back, it needs to be clear and unambiguous.
It's hard to give more suggestions based on the small amount of detail given, but I think choosing priorities, metrics to match priorities and looking at stats from those metrics will tell you a lot about what your next steps should be.
Answer: It sounds like you are already on the right track by getting to know the people who will eventually use your solution and their working environment.
Once you have the insights from watching the potential users in their environment it should be fairly straight forward to work through creating a design, which you should regularly validate with your potential users.


Sauce bubbling out of jar

Question: I successfully canned one batch of roasted red pepper pasta sauce but had to step away from the kitchen for a half hour. When I came back the sauce was still warm so I heated it a bit more while I boiled my next set of jars. Everything looked good going into the water bath canner, but when I started to pull them out sauce started bubbling out of the jars. Did I somehow ruin the sauce by letting it cool then reheat? Can I somehow save it and re-can or should I bag and freeze it. Thanks all.
Comment: If sauce is coming out of the jars, you likely overfilled. With my pressure cooker, liquid in a sealed jar will continue boiling for up to 30 minutes after I set a jar aside to cool. There's a vacuum in the jar, and water boils in a vacuum. It takes a while for things to cool, and a non-boiling equilibrium to set in.
Comment: Could also be that it got superheated and started boiling, but I think this unlikely as the sauce most likely has plenty of nucleation points.
Answer: A few questions to consider:

Were you following a recipe that used an additional acid (like citric acid or lemon juice) in addition to tomatoes and peppers?
Does your recipe include significant amounts of garlic or onion?
Does your recipe specifically call for water bath canning?
How many years old is your recipe?

The reason I ask these questions is that most modern-day tomatoes grown for conventional stores do not have the PH levels that our grandmother's tomatoes did, making most canning recipes for tomato sauces unsafe for traditional water-bath canning methods, unless you are adding an acid like lemon juice or citric acid.
Likewise, large amounts of garlic or onion will also affect the PH in a way that makes them less safe for water bath canning.
I tend to agree that your bubbling is likely from over-filling the jars.
To be absolutely sure and on the safe side, boil the sauce from those jars again - bring to a boil, then simmer for 10-12 mins., then can again, leaving approx. 3/4" minimum of headspace at the top of your jars.
I wouldn't recommend leaving the cans as-is that bubbled over, as it indicates the seal is broken or a strong, clean seal was not created in the first place.
Good luck with your canning adventures!
Comment: Why do you need acid for canning tomato sauces? Jellies and other canned goods aren't particularly acidic.

Sauce bubbling out of jar


What to claim on w-4 for a second job?

Question: I am a single mom with 2 kids and work #1 job that pays 23,000 per year and I have just picked up a #2 job that will pay 21,000 per year. I don't want to owe taxes at the end of the year. What should I claim on my w-4 for the 2nd job?
Answer: The W-4 should have a worksheet for multiple jobs, so you could start with that.  Then after you get a paycheck, see how much tax will be taken out for the year and compare it to an estimate of your tax liability for the year.
According to this basic tax estimator, with a $46,000 income and 3 exemptions, your annual tax liability would be about $2,600. (this assumes no other income and no itemized deductions for mortgage interest, charities, medical expenses, etc.)  If you don't want to be surprised with a tax bill at the end of the year you could be conservative and withhold enough to cover that with some extra cushion.
Comment: I'm getting less liability. Just checking, did you use head of household?
Comment: I may have used Single, but the principle is the same - if you want to avoid a tax bill make sure you withhold enough to cover your expected tax bill for the _year_.  It may take a few paychecks and tweaking of the exemptions to get it right.
Answer: The general rule of thumb on a second job is to take zero exemptions.  So if you follow the worksheet, it might tell you to mark in 4 or 3.  However, you already marked those on your first job.  So put in 0 for the second job.
You can double check this with the tax estimator posted in the other answer.  $44,000 income, 3 exemptions, 2 dependent children as head of household gave $720 as your total liability.  Putting in $23,000 income with the 3 exemptions and 2 dependent children gave zero liability for the first job.  Putting in $21,000 with zero exemptions gives $1170 from the second job.  So if their withholding matches that, you'd get a refund of around $450.
Another way of looking at it is that you need to withhold about $14 a week.  If you're withholding more than that between the two jobs, you could cut back.  If you're withholding less, then you should add more if you don't want to owe anything.
I think that you have extra exemptions after your first job.  So two exemptions on your second job will probably produce the correct result.  Then you wouldn't get much of a refund.  However, as I said, you should verify this on your actual paychecks.
The safest way is to do the zero exemptions on the second job's W-4.  Worst case, you overwithold and get a refund.  You'll lose out on a bit of interest income, but interest rates suck anyway.  Losing $5 for peace of mind may be worth it.
Comment: "You'll lose out on a bit of interest income" or ability to pay off debt, set up emergency fund, etc.  Not refuting your answer but overwithholding can cause other issues.

What to claim on w-4 for a second job?


Confusion About Triangle Mask in Transformer Decoder

Question: I have some confusion about the implementation of the triangle mask in the transformer decoder. I understand the reasoning for the mask, it prevents the network from 'cheating' by looking ahead at the next token, but the way it's implemented seems strange. First of all, why do we apply the mask to the product $QK^T$? Why not just set the rows representing unseen tokens to zero or some special token before sending the matrix to the transformer? Also, I don't understand the reasoning of a triangle mask in general. Suppose we are training with a sequence of length $\ell_s$, and we are trying to predict token $k$ with $k < \ell_s$. Why don't we have to mask all entries $QK^T_{i,j}$ if $i > k$ or $j > k$? With a standard triangle mask it seems like we still incorporate information computed from 'unseen' tokens.
Answer: During training you use teacher forcing. This means that you feed the entire $tgt$ sequence to the decoder. You want the decoder to look only at $tgt[:i]$ when predicting $y[i]$. You then use $y[i]$ only to compare it with $tgt[i+1]$ to compute the loss. Thus for computing the output at position $i$ you want all the future tokens to be masked, but not erased. So when you calculate the attention scores between $tgt[i]$ and all the rest you want to zero the attention scores with the future tokens.
The attention scores is a square matrix of shape $l_s \times l_s$, where $l_s$ is the length of the target sequence. The entry $A_{i,j}$ gives the attention score between $tgt[i]$ and $tgt[j]$. Basically, row $i$ gives you the attention scores for token $tgt[i]$. So you want to zero out the scores when $i>j$. That is the reason why we use a triangular mask - simply zero out the upper triangular part of the attention scores matrix.
If you want to read a very detailed blog post about the Transformer model in general that I wrote, feel free to check this out:
https://pi-tau.github.io/posts/transformer


Example of curved spacetime with flat space layers

Question: curved spacetime is a famous geometrical and physical object. on the other hand there are debates on if space itself is curved or not. but is it really possible to a curved spacetime that all of its spatial layers be flat?
more precisely: every freely falling observer at every instance sees a 3-dimensional space. is it possible that all of this 3-dimensional spaces are flat while spacetime itself is curved?
is there a any explicit metric by this property?
Comment: I don't know about the plural of "layers".  I believe that there could be just a single layer of space.  I've seen it plausibly claimed, on this site, that gravity itself is only dependent on the curvature of time, and, given the fact that even a plane or cube can rotate, it seems like it would be technically possible, although a rectilinear universe would seem so unnaturally artificial that objections raised against the acceptance of infinity within physics (as by Hossenfelder at https://www.youtube.com/watch?v=Bq9xR5PUs6s ) might seem implausible until hearing her video.
Comment: Physicists like Hilbert, and even Godel, have objected to the inclusion of infinity in physics, but I don't think anyone's objected to eternality, at least in one temporal "direction" (the past-to-future one).
Comment: There does seem to be one tiny flaw in Hossenfelder's video, 8 min. into it:  A laser beam being swung back & forth while directed at a section of a distant wall might, when the wall would be rotated so that the beam would be striking an edge of its surface, appear to be travelling at infinite speed, "except that the wall would not have a perfectly flat surface".  The circumvention would require the wall to be formed of an exotic non-particulate substance (or of a substance made with rectilinear particles), although only as a smooth wall might've been pictured before microscopes were invented.
Comment: Re my previous comment, some acceptability of physical singularities would have to be implied by Roger Penrose's receipt of a Nobel Price for his 1970 singularity theorem, late in 2020.
Answer: The Friedmann metric with $k=0$ is spatially flat. It is consistent with current cosmological observations.
Comment: @Edouard [Wikipedia](https://en.wikipedia.org/wiki/Inflation_(cosmology)#Observational_status) :"detailed observations of the cosmic microwave background made by the Planck spacecraft [between 2009 and 2013] ... [show] that the Universe is flat to within 0.5 percent"
Comment: @Edouard Note that the [parameters](https://en.wikipedia.org/wiki/Lambda-CDM_model#Parameters) for the current cosmological model have $\Omega_\Lambda$ and $\Omega_m$ adding to 1.0000, the critical value for flatness. But the two values do have errors of 0.0062.
Comment: At https://www.gresham.ac.uk/lecture/transcript/print/to-infinity-and-beyond/ , in a paragraph headed "How dark matter affects the CMB", it was claimed that satellite observations show the observable region to be flat only to within 1% or 2% of perfection, which sounds more like what Charles Francis said, and is more consistent with the mishmash of spatial and temporal terminology which has characterized the verbiage of physics for a century. (If I sound bitter, it's becuz I'm lame at math.)
The data, however, is from 1992.  Is there something more recent, or has matter thrown things off?
Answer:
is it possible that all of this 3-dimensional spaces are flat while spacetime itself is curved?
is there a any explicit metric by this property?

Sure, it's called the Friedman-Robertson-Walker metric and it describes the large-scale evolution of our Universe:
$$
ds^2 = -dt^2 + a^2(t) (dx^2 + dy^2 + dz^2)
$$
On any surface of constant $t$, the metric is that of flat Euclidean space.  The Einstein equation gives an equation of motion for the so-called scale factor $a(t)$.
(Technically, this is only one of three possible forms of the FRW metric;  there are also versions where the surfaces of constant $t$ are curved.  But the version above is the simplest one, and also appears to be the one that describes our Universe.)
Comment: as it could be seen an observer who sees the metric similar to what you have written sees spatial layers flat. but what about other observers? an observer who is falling freely by this metric slices the spacetime to different layers, are you sure these layers are also flat?  @Michael
Answer: As @G. Smith said,

The Friedmann metric with $k=0$ is spatially flat,

but it is worth noting that this is an idealisation which depends on a perfectly uniform matter distribution. As such, we know it is an approximation to reality. It is only flat on a slice of constant cosmic time, which means it is only flat for observers with constant position in comoving coordinates (i.e. stationary in the CMB frame). For moving observers it would not be flat.
Also, when we consider observers in free fall, we are likely to be talking of observers in the vicinity of a gravitating body. Space in the vicinity of a gravitating body cannot be perfectly flat, although typically space curvature is so small that it is not directly measurable.
So when we debate whether space may be flat, we mean flat on cosmological scales. We know it is not perfectly flat.
Comment: please for the moment forget source of curvature and consider spacetime as a curved geometric manifold by (-1,1,1,1) metric. is it true that every freely falling observer slices this spacetime to flat spatial slices (at every instance of time) or it is false almost for every observer? (I mean rather than very rare observers who see metric of spacetime as standard form of Freidmann metric. am I correct that they are very rare?) @Charles
Comment: @G.Smith, I beg your pardon
Comment: @CharlesFrancis --Well, couldn't space be Friedmanniacally flat if every object had a double that, whenever the object would go left, would go right, etc.?  The gravitating bodies might also have remote twins (perhaps necessarily in separate observable regions, with their separations evolved to prevent interference by malignant species) to balance their effects.  In fact, that's sounding too much like the effects of quantum entanglement to be true, unless maybe such entanglement is that source of time which Ekaterina Moreva & other quantum physicists have considered that it might be.
Answer: A simple example of "spatial" slices not sharing the curvature of the background space is Euclidean space sliced into concentric spheres. This is similar to what happens in FLRW geometries. Like the spheres, the FLRW spatial slices are generally extrinsically curved (lines in them aren't geodesics).
I can't think of an example of a curved space with flat slices that is so easy to visualize, because it would need to be three-dimensional and to be easily visualizable it would need to be embedded in a flat background of four or more dimensions. But you could think of a conformally flat space with a metric of $a(z)^2(dx^2+dy^2+dz^2)$ or $a(t)^2(dx^2+dy^2-dt^2)$. It's obvious that slices of constant $z$ or $t$ are flat, and pretty easy to see that they are extrinsically curved iff $a'\ne0$ (because parallel paths on opposite sides of the surface have different lengths). Spatially flat FLRW cosmologies can be written in this form. The time coordinate is called conformal (cosmological) time, and is usually written with $η$ rather than $t$.
Comment: @moshtaba I think you're trying to port the special-relativistic concept of "observers" to general relativity where it doesn't work very well. Human cosmologists use FLRW coordinates even though Earth's velocity in those coordinates is nonzero, because any other coordinates would be incredibly inconvenient. Even in SR you don't need to use coordinates in which you're at rest, it's just less inconvenient than in GR. But if you did slice the FLRW spacetime differently, indeed those slices would not be flat.
Comment: @moshtaba A single clock doesn't define a surface of simultaneity. You need a family of clocks. In SR you can imagine an implicit family of Einstein-synchronized clocks but in GR there's no way to do that, you need to specify where the clocks are and how they're synchronized. Here's [another answer I wrote about this](/a/504054).
Comment: as it could be seen an observer who sees the metric similar to what you have written sees spatial layers flat. but what about other observers? an observer who is falling freely by this metric slices the spacetime to different spatial layers (for every instance), are you sure these layers are also flat?
Comment: you mean even following question doesn't work very well in GR: a freely falling observer records all events of spacetime which are Simultaneous by time 0 of his clock. this is a 3dimensional manifold. it is flat of not? (for a given metric)
Answer: Schwarzschild metric describing an isolated non-rotating black hole (and also spacetime outside isolated spherically symmetric body) admits "slicing" of spacetime in flat spatial layers with the help of Gullstrand–Painlevé coordinates:
$$
g = \left(1-\frac{2M}{r} \right)\, dt^2- 2\sqrt{\frac{2M}{r}} dt dr - dr^2-r^2 \, d\theta^2-r^2\sin^2\theta \, d\phi^2.
$$
The geometry of a slice $t=\text{const}$ is a flat 3D space in spherical coordinates:
$$
dl^2=dr^2+r^2 \, d\theta^2+r^2\sin^2\theta \, d\phi^2.
$$
Metric of rotating black hole (Kerr metric), however, does not admit spatially flat slicing.
Note, that there seems to be some misconceptions that this question displays:

more precisely: every freely falling observer at every instance sees a 3-dimensional space. is it possible that all of this 3-dimensional spaces are flat while spacetime itself is curved?

Slicing of spacetime into spatial layers by itself does not have anything to do with observers. If we consider observers staying at the fixed values of spatial coordinates as metric evolves with time (so-called fiducial observers), then such observers generally would not be free-falling.

What an individual observer sees is not the geometry of spatial slice. Instead one should remember that light propagates with a finite velocity, so the light rays arriving to observer at a specific moment $t=t_0$ carry information from the past slices. Moreover, these light rays would generally be bent by gravitational field (even when spatial geometry is perfectly flat).


Is it poor etiquette to submit "good question" seeking same info as a "held" question?

Question: I've sometimes seen questions that are on hold, where the topic interests me and I think I can get one in under the wire.   Is it unfriendly to the O.P. to write a new question immediately?
Answer: Yes, it is unfriendly.
Questions are on hold pending improvement. You have recognised that there is the kernel of a good question. If you can improve a question without destroying it completely you should suggest a revision (that is, edit it; edits from users with less than 2000 rep are reviewed rather than accepted immediately).
Once the question is edited, it goes into a queue for review and potential re-opening. If it's reopened, you can answer it.
This is exactly the same method as for a question which isn't "on hold" — if the question can be improved, improve it. And, indeed, it's the same for a question which has moved from "on hold" to "closed": if it can be improved and re-opened, improve it.
If a question has been closed because it wasn't improved, and it's unlikely that it could be edited to be better, then by all means ask a better question.
Quite what would happen if you were unfriendly and pre-empted the holding pattern, I'm not sure. You could find that the original question is edited to be better and reopened, and then your question is marked as a duplicate.
Answer: By default yes I think this is an unfriendly thing to do. However there are two relatively common factors that can turn things around.
Before we look at those, let's note that the goal of asking a question should never be to "get one in under the wire". We're not just trying to get by. The goal should always be the most constructive well scoped expert level questions on the internet. Obviously everything is going to miss that mark, but lets not forget that that is the mark. Lets not aim for passable.
Now, should you ask another question?

Are you actually asking the same thing?
If you are really looking for the "same info", then probably not. The best thing to do is not snipe the topic with a new question but fix the existing one. If you can think of a way to make the question constructive, edit away. On closed questions it is not nearly so critical that you preserve the authors original intent. Common courtesy says you should try, but sometimes their intent will be outside the scope of this site and their choices will be between their pet question staying closed and a modified question that can actually contribute to the site. The author can always rollback and other community editors can even try taking it different directions until one finds a way to get it re-opened. Once the question is opened, major changes of direction should be minimized again.
On the other hand if you are actually looking for something a bit different that might stand up as a unique question because it has its own scope and focus even though the overall topic might be related, it is perfectly acceptable to ask another question. In this case it is usually useful to throw up a cross-linking set of comments on each of the related posts. The original questioners might be interested in the other question and anybody answering might be interested in addressing one or both questions keeping in mind the specific scope.
Is the author of the original question playing along?
Again, if they are willing to work with us to make their question appropriate for the site it is best to help them get their question opened.
Unfortunately some of the time nonconstructive questions come from nonconstructive attitudes. If constructive feedback has been given and refused* on the original question — or there is sigificant indication that the question is asked in bad-faith — then it might be time for somebody else to ask the same question in good-faith.

* No reply to comments is generally not the same as a refusal. That usually means the question is fair game for editing. An edit reversal or an explicit comment would count as a refusal.
Comment: In this case I waited a few days, and think my question is only superficially similar


Some questions about "inspecting" the boundary of a closed ball in Hilbert space

Question: Let H be a separable Hilbert space and suppose that H is infinite dimensional. Let B be a closed ball of H-which has a positive radius-and let S be the boundary of B. A non-empty subset C of H is an "inspection set for S" just in case (1) C and B are disjoint and (2) If p is any point of S, there exists a point q of C such that the straight line segment whose end points are p and q, contains no interior point of B. In other words, it should be possible to "see" each point of S from at least one point of C. ...... My questions are about the kind of subset C of H that can be an "inspection set for S". Can C be a simple closed curve? Can C be compact? Can C be a homeomorphic image of a sraight line? I suspect that the answer to all these questions is negative and not difficult to prove (although I have gotten nowhere trying to prove it myself). The answers are, of course, clearly positive when H is finite dimensional, since we can then consider H to be a finite dimensional Euclidean space.
Comment: An idea: Assume $B$ is centered at the origin and consider a two-dimensional subspace $P\subset H$. If $C$ is a spiral on $P$ (it has points arbitrarily far in every direction), then the only points of $S$ that are not visible from $C$ are those which are orthogonal to the plane $P$. Now if you add suitable wiggles to $C$ in directions orthogonal to $P$, you might be able to see all of $S$. If this construction works in the infinite dimensional setting (it works in Euclidean spaces), you could get $C$ homeomorphic to a line.
Answer: (I'll do this for real Hilbert spaces, which seems natural here.) Just as in finitely many dimensions, a point $x\in H$ sees exactly the subset
$$
A(x)=\{ s\in S: \langle x, s\rangle \ge 1\} .
$$
Since we cannot cover $S$ by finitely many sets of the type $\bigcup A(x)$, with the union taken over $x$ from a small ball, say, it follows that $C$ can not be compact.
On the other hand, covering $S$ with countably many sets $A(x_j)$ is no problem, so $C$ can be homeomorphic to a line. More explicitly, fix $x_1,x_2,\ldots$ such that every point on $S$ is seen by an $x_j$. We can also insist that $\|x_{n+1}\|\ge \|x_n\|+1$, say. Then define a bijective continuous function $f:\mathbb R\to H$ that satisfies $f(n)=x_n$.
Comment: Your nice covering certainly shows that C can be the homeomorphic image of a straight line-which I had thought to be impossible. In fact C can be the homeomorphic image of a ray. You also point out that C must be an infinite set and can be countable. But how, then, to show that C cannot be an infinite compact set, does not seem so obvious-although I think I can see a way.
Comment: @GarabedGulbenkian: If $C$ were compact, then I could cover $C$ by finitely many small balls, but this would lead to the scenario that I refute in the first paragraph ("Since we cannot cover $S$ ...").
Comment: I see what you are saying. A compact subset of any metric space M, is always a subset of a finite union of arbitrarily small balls of M. If H is the metric space and U is any finite union of sufficiently small balls of H, then it is easy to see that there exist points of S which are not "visible" from any point of U. I was confused by the (irrelevant) fact that-since H is infinite dimensional-no ball of H, however small, can be compact.


Get the total mapping and reducing times in hadoop programmatically

Question: I am trying to calculate the individual total times of Mapping, Shuffling and Reducing by all tasks in my MR code.
I need help retrieving that information for each MapReduce Job.
Can someone post any code snippet that does that calculation?
Answer: You need to use the JobClient API as shown below:
There are however some quirks to the API. Try it let me know i will help you out.
<code>    JobClient client = null;

         Configuration configuration = new Configuration();

        configuration.set("mapred.job.tracker", jobTrackerURL);
        client = new JobClient(new JobConf(configuration));

        while (true) {

            List<JobStatus> jobEntries = getTrackerEntries(jobName,
                        client);

                    for (JobStatus jobStatus : jobEntries) {

                        JobID jobId = jobStatus.getJobID();
                        String trackerJobName = client.getJob(jobId)
                                .getJobName();
                        TaskReport[] mapReports = client
                                .getMapTaskReports(jobId);
                        TaskReport[] reduceReports = client
                                .getReduceTaskReports(jobId);
                        client.getJob(jobId).getJobStatus().getStartTime();

                        int jobMapper = mapReports.length;
                        mapNumber = +jobMapper;
                        int jobReducers = reduceReports.length;
                        reduceNumber = +jobReducers;

                    }
                }
</code>


When the site does go live, what exactly will change?

Question: From the Android Enthusiasts Beta to the actual implementation, what changes will exactly be taking place?
Answer: Let's see -- what happens when a site goes public:

the site gets a custom design and favicon (no more generic sketchy-beta)
it is eligible to have questions migrated to and from it from other sites
the site will be promoted by sister sites in the network, through house ads and question migrations
the reputation levels increase to standard, instead of the relaxed levels that are in place now.

I might have forgotten something, but I believe that's the major points.
Comment: Also on my list: **"Lock in."** A graduated site has progressed past the *trials* of a probationary period. As a fully-fledged site, it is much less likely to be cited for problems and shut down.


Migrating from remote-state to backend in Terraform 0.9

Question: I downloaded terraform 0.9 and tried to follow the migration guide to move from remote-state to backend
But it doesn't seem to work. I replaced:
data "terraform_remote_state" "state" {
  backend = "s3"
  config {
    bucket = "terraform-state-${var.environment}"
    key = "network/terraform.tfstate"
    region = "${var.aws_region}"
  }
}

with
terraform {
  backend "s3" {
    bucket = "terraform-backend"
    key = "network/terraform.tfstate"
    region = "us-west-2"
  }
}

yet when I run terraform init in one of my environment folders, I get:

Deprecation warning: This environment is configured to use legacy
  remote state. Remote state changed significantly in Terraform 0.9.
  Please update your remote state configuration to use the new 'backend'
  settings. For now, Terraform will continue to use your existing
  settings. Legacy remote state support will be removed in Terraform
  0.11.
You can find a guide for upgrading here:
https://www.terraform.io/docs/backends/legacy-0-8.html

I also had to drop the variable interpolation since this is not allowed anymore. Does that mean that one S3 Bucket is used for multiple environments? What have I missed here?
Answer: Per upgrade guide (https://www.terraform.io/docs/backends/legacy-0-8.html) after terraform init you also have to run terraform plan to finalize the migration, which will update the remote state file at s3.
As for configuring for multiple environments we ended up using a wrapper shell script with passing in parameters for ${application_name}/${env}/${project}, and using partial configuration.
For a project structure like this:
├── projects
│   └── application-name
│       ├── dev
│       │   ├── bastion
│       │   ├── db
│       │   ├── vpc
│       │   └── web-cluster
│       ├── prod
│       │   ├── bastion
│       │   ├── db
│       │   ├── vpc
│       │   └── web-cluster
│       └── backend.config
└── run-tf.sh

for each application_name/env/component = folder (i.e. dev/vpc) we added a placeholder backend configuration file like this:
backend.tf:
terraform {
    backend "s3" {
    }
}

Where the folder content for each component will look like this:
│       ├── prod
│       │   ├── vpc
│       │   │   ├── backend.tf
│       │   │   ├── main.tf
│       │   │   ├── outputs.tf
│       │   │   └── variables.tf

At "application_name/" or "application_name/env" level we added a backend.config file, like this:
bucket     = "BUCKET_NAME"
region     = "region_name"
lock       = true
lock_table = "lock_table_name"
encrypt    = true

Our wrapper shell script expects parameters application-name, environment, component, and the actual terraform cmd to run.
The content of run-tf.sh script (simplified):
#!/bin/bash

application=$1
envir=$2
component=$3
cmd=$4

tf_backend_config="root_path/$application/$envir/$component/backend.config"

terraform init -backend=true -backend-config="$tf_backend_config" -backend-config="key=tfstate/${application}/${envir}/${component}.json"

terraform get

terraform $cmd

Here is how a typical run-tf.sh invocation looks like:
$ run-tf.sh application_name dev vpc plan

$ run-tf.sh application_name prod bastion apply

Answer: You got confused with terraform remote command with remote-state. You dont have to change any remote-state things you have in your tf files.
Instead of configuring your remote state with terraform remote command and use backend config file mentioned in the migration link.
See the second github comment in this link. It has nice step by step procedure on what he did to migrate.
https://github.com/hashicorp/terraform/issues/12792


Surfing web anonymously on a mac using Firefox SSH and Tor

Question: I want to download and upload to the internet anonymously. I have successfully configured Forefox to access internet through a secure SSH tunnel service (and remote server). I use 'SSH Tunnel Manager' app to do this (like PuTty for Windows).I also access the Tor network using the Tor Browser Bundle. But I can't figure out how to essentially chain the two together so that Firefox -> SSH server -> Tor -> web and then return back to Firefox. Since I'm only interested in anonymizing web/browser traffic I could use Privoxy (or FreeCap) to socksify SSH Tunnel Manager and maybe integrate a download manager into this mix. I've tried a number of different configurations but have not been successful. What am I missing? I can use 'Terminal' to do a command line configuration. Or preferably an explanation of how to configure Firefox, Tor Browser and SSH Tunnel Manager to allow this traffic route.
Answer: If you want "Firefox -> SSH server -> Tor -> web", you need to start a SOCKS5 proxy through your SSH server, and then tell Tor to connect through that. How to do that is described here.
SSH connections aren't very stable long term, however. A far more reliable approach involves running Whonix connecting through a VPN on the host machine.


Over the past/last decade or during the past/last decade

Question: Which is the correct usage: over the past/last decade or during the past/last decade?
Comment: Over and during are both acceptable. The *past* decade means the previous 10 years from today. The *last* decade means the last nominal decade (eg the *last decade* in 2015 is the years 2000-2009).
Answer: Though often used interchangeably, there are subtle differences in meaning between "over" and "during."  You might also consider using "throughout."
Something that happened at a specific time will generally be described with "during."  E.g.: "During the last decade, scientists discovered life on Mars."  Both "during" and "over" can be used for something that may have spanned the entire period.  E.g.: The earth's population increased 5% over/during the last decade.
A good discussion of the usage of over, during and throughout is in S. Lindstromberg's English Prepositions Explained.  ([Link to Google Books][1])

(Edited to delete the following discussion of an issue you didn't ask about.)
In most contexts, "past decade" and "last decade" have the same meaning.  The exception is when you are using "last" as a synonym for "final".  For example: "The last decade of the 20th Century."
Perhaps to avoid ambiguity, the "style guides" of some publications sometimes require the use of "past" except when being used synonymously with "final."


How do you counter getting zoned?

Question: Lets say that you're a melee champion against a ranged a champion top and they are harassing you every time you get near your creeps and you can't farm. How do you counter this other than having your jungler come and help?
Answer: Normally at the point you are zoned out it is too late to do much besides last hit under your tower. Because they are ranged, they can continue to harass even as you pick up those last-hits.
At that point my preferred method (without jungler help) is to back away (recall) if they are zoning me away from me turret.  Buy some items and if you are not too far behind you can take the advantage.  In particular and if things are very dire, buy a fortitude elixir!
I think a key point here is that against ranged champions, melee have an advantage once they get within  melee range. So you really just have to pick and choose your battles and ensure you win the early exchanges as taking too much harass will just snowball the lane against you.
Remember good match ups are key so always consider that in champion select if you are running draft mode!
Answer: If you are getting zoned and cannot receive help from your team (in the form of a gank or a lane swap), you have a few options:
Aggression
If your melee champion has a slow or gap closer (or you took a summoner spell that helps you close gaps), make the ranged opponent pay for their pokes.
The key things to keep in mind if you are going to be aggressive:

Ward any approach vectors that someone who would gank you would likely take (river, ti-bush.
Expect that when you go to last hit a minion, you will get poked.
Immediately slow/close the gap when you see the approach for the poke and get a few swings in yourself.

Because of game balance, your melee champ will usually hit a bit harder than the ranged champ early game. If you make them pay for their pokes, you'll make them think twice about moving in to hit or zone you.
This will take some getting used to, of course. The natural inclination is to be cautious so you don't give up a kill. Once you practice the counter-poke with your melee champion of choice, however, it's very effective.
Defense
If you have no easy way to trade the poke, you'll need to let the lane push to your tower to increase the size of your effective zone. Once you do that, you'll be safe. Then, you have to learn how to work with your tower such that you get all the last hits on minions.
This will vary by champion and throughout the game, but the general rules are:

Melee minions take 2 tower hits and 1 champion hit to kill.
Spellcaster minions take 2 champion hits and 1 tower hit to kill.

So, you'll want to wait for the tower to hit a melee minion it is targeting twice (assuming it was at full health), then get the last hit. For spellcaster minions, hit it once yourself, let the tower hit it once, then hit it again for the kill.
It can take some getting used to at first, but one you master last-hitting under a tower, you'll find that you do not fall behind on farm. In addition, you're safe from ganks and you're putting the opponent in a position that makes them much more easy to gank when your team can provide assistance.
Answer: This is a rough situation, because the clearest and BEST solution is to have your jungler come gank. Ganks in this position are easy because the enemy has to put themselves in or past the creep wave in order to zone you and are thus very vulnerable.
Without a gank, the best you can do is to farm at turret until you are in a position where you can close the distance to the enemy laner and kill them or force them to recall. If you engage a fight and get low but don't kill or force them back, you will just be zoned again.
There are a few match ups which can out-sustain harass like old-school Tryndamere, Warwick, or Udyr, but this requires constant auto-attacking and risks pushing the lane and exposing yourself to ganks from the enemy jungler.
Comment: Don't forget the option of losing a lane gracefully and *slowly*. All else being equal, your champion can be countered. While you'll be underfarmed, sometimes the best choice is to let the tower fall to give you safer farming options and your jungler better ganking options since it forces them to leave lane *or* overextend.

How do you counter getting zoned?


Mirage formation in deserts

Question: Why does a person sees water in the desert even then when no water is present there at that time?
How does this happens?
Answer: Ideal conditions for a mirage  are layers of air in contact with ground   that  has been heated by the sun .
As one goes up from the ground  the temperature  slowly decreases. this gradient of temperature  changes the density of air .  The layer closer to the ground  is rarer and upper layers are  denser .
Thus refraction of light from rarer to denser medium takes place and the light coming from sky takes a curved path to reach a person's eyes.
The illusion  of water as mirage  comes from the fact that  the human brain assumes that light travels in a straight line.
A person   looking at the road ahead on a hot, still, day will see the sky because light  from the sky is taking the curved path .
The human brain interprets this as water on the road because water would reflect light from the sky in much the same way that a vertical temperature gradient in the layers of air does.
On hot sunny  days even the car-drivers in the city highways see water ahead at the road (mirage) as the road gets hot and then  a vertical temperature gradient  (just like desert condition )  produce  the above mentioned  effect.

Mirage formation in deserts


What's the right way of uploading to FTP with retries with commons-net?

Question: I'm having issues dealing with a server which would close my FTP control connection in spite of me sending keep alive requests with ftpClient.setControlKeepAliveTimeout(CONTROL_CONNECTION_KEEP_ALIVE_INTERVAL_SECONDS);
Also sometimes it just dies out of SocketException and not the normal FTPConnectionClosedException. All in all, FTP is a very dodgy protocol I'm using a lot and each server I connect requires a bit of tweaking, however this one is giving a very hard time.
I know there's a million things I could be doing wrong, my question is, is there some solution with retries already implemented on FTP in case you lose the control connection, since is not something that should be shocking (proxies / firewalls sometimes just randomly lose your connection). Or is there some more elegant way of solving this problem.
I have something like this.
<code>public void store(File fileToUpload) throws IOException, InterruptedException {
    String filename = fileToUpload.getName();
    int retries = 0;
    while (true) {
        try {
            ftpClient.storeFile(filename, inputStreamFactory.getInputStream(fileToUpload));
        } catch (FTPConnectionClosedException | SocketException exception) {
            LOGGER.debug("Control connection lost uploading {}, continuing.", filename);
        }

        // This sleep is because there's an anti-malware in the servers which makes the file not to appear
        // available immediately after an upload
        LOGGER.debug("Waiting {} milliseconds for anti-malware protection to process file", WAIT_AFTER_UPLOAD_MILLISECONDS);
        threadWrapper.sleep(WAIT_AFTER_UPLOAD_MILLISECONDS);
        if (!ftpClient.isConnected()) {
            connect();
        }

        LOGGER.debug("Checking if {} is already uploaded", filename);
        if (ftpFileChecker.isFileCompleted(listFiles(null), filename, fileToUpload.length())) {
            // Note this is likely to happen every time since their server will close the control
            // connection quite fast and FTPClient uses it at the end of storeFile
            LOGGER.debug("File {} was uploaded correctly", filename);
            break;
        } else {
            if (++retries > MAX_RETRIES) {
                throw new RemoteTimeoutException("Could not upload file, max retries exceeded");
            } else {
                LOGGER.info("File {} was not uploaded, retrying", filename);
            }
        }
    }
}

public void connect() throws IOException, InterruptedException {
    int retries = 0;
    while (true) {
        try {
            ftpClient = ftpClientFactory.createFtpClient();
            ftpClient.connect(server, FTP_PORT);
            if (!ftpClient.login(username, password)) {
                LOGGER.error("Login to FTP failed");
                throw new ConfigurationException("Login to FTP failed");
            }
            ftpClient.enterLocalPassiveMode();
            ftpClient.setControlKeepAliveTimeout(CONTROL_CONNECTION_KEEP_ALIVE_INTERVAL_SECONDS);
            ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
            ftpClient.changeWorkingDirectory(uploadDir);
            break;
        } catch (FTPConnectionClosedException | SocketException exception) {
            if (++retries > MAX_RETRIES) {
                throw new RemoteTimeoutException("Could not upload file, max retries exceeded", exception);
            } else {
                LOGGER.info("Could not login, retrying");
            }
        }
        LOGGER.debug("Sleeping {} milliseconds before trying to reconnect", WAIT_BETWEEN_CONNECT_RETRIES_MILLISECONDS);
        threadWrapper.sleep(WAIT_BETWEEN_CONNECT_RETRIES_MILLISECONDS);
    }
}

public FTPFile[] listFiles(String directory) throws IOException, InterruptedException {
    int retries = 0;
    while (true) {
        try {
            return ftpClient.listFiles(directory);
        } catch (FTPConnectionClosedException exception) {
            LOGGER.debug("Control connection lost when listing files, continuing");
        } catch (SocketException exception) {
            LOGGER.debug("Socket exception when listing files, continuing");
        }
        if (!ftpClient.isConnected()) {
            connect();
        }
        if (++retries > MAX_RETRIES) {
            throw new RemoteTimeoutException("Could not list files, max retries exceeded");
        } else {
            LOGGER.info("Could not list files, retrying");
        }
    }
}
</code>
Now I'm getting SocketException Broken Pipe on listFiles, and I can't figure it out anymore since in my local server it works perfect, but in this particular one (hint it runs on Windows NT - :( - it runs some malware protection which prevents the files to appear on the server immediately and is apparently behind some very strange firewalls, and it drops idle connections after about 5 seconds, and they won't change the configuration cause they are a big company and claim it works for everyone else).
I tried VFS and investigated over other FTP clients but none I found seem to solve the problem, even more unhelpful, most of them (like ftp4j) are not in maven central which really puts me off trying them unless there's a guarantee it will solve my problems.
Any help is welcome.
Edit: Code given reflects the starting complexity of this, my current solution is more stable with quite a lot more complexity, but it's not elegant at all, so I leave the question open in case someone cares to contribute a nice solution.
Answer: If using Spring, then consider Spring Retry. I believe the latest Maven version is:
<code>    <dependency>
        <groupId>org.springframework.retry</groupId>
        <artifactId>spring-retry</artifactId>
        <version>1.1.2.RELEASE</version>
    </dependency>
</code>
Comment: if it were as simple as a retry wrapper I wouldn't have made a post for this, this project where this code was on already have retry utilities similar to what spring has released, it's not good for FTP though


How do we express the Schrödinger wave function using the Hankel transform instead of Fourier transform?

Question: What if we use the Hankel transform instead of the Fourier transform?
$$\Psi(x)=a\int_{-\infty }^{\infty }\Phi(k) e^{ikx} dk $$
$$\Phi(k)=b\int_{-\infty }^{\infty }\Psi(x) e^{-ikx} dx .$$
How would the probability density function of the Schrödinger wave be, would it give us the same results as the Schrödinger wave using the Fourier transform?
$$\Psi_{n}(x)=a\int_{0 }^{\infty }\Phi(k) J_{n}(kx)k  dk $$
$$\Phi(k)=b\int_{0 }^{\infty }\Psi_{n}(x) J_{n}(kx)x dx .$$
The reason for this question is that I can express any wave as a continuous sum of Henkel functions and this is very similar to the continuous Fourier transform.
Answer: Your formulas for Hankel transform make no sense. You can compare them with those at  https://en.wikipedia.org/wiki/Hankel_transform
In general, you can use the Hankel transform, but only for $x>0$, unless you redefine the Hankel transform somehow. So you can use it, e.g., in a cylindrical system of coordinates for the radius.


what version of visual studio is needed for sharepoint 2010

Question: what version of visual studio is needed for sharepoint 2010 besides VS2010? My question is whether or not a sharepoint 2010 server can support newer versions of VS?
Comment: Hello @Vusi45 , Your feedback is very important 1. Are the below answers didn't helped you? 2. do you need any further clarifications? if yes, please comment to the provided answers with your clarifications to can help you or edit your question with these clarifications, else please upvote and mark the correct answer that helped you as accepted to close this question. Also, please check [Tour](https://sharepoint.stackexchange.com/tour) to know how can you accept the correct answer! Thanks!
Answer: The below are the supported/unsupported Visual Studio versions for SharePoint 2010

Visual Studio 2017: No.

Visual Studio 2017 is supported for SharePoint 2016, SharePoint 2013 and Office 365 for more details, check Install Office / SharePoint Developer Tools for Visual Studio 2017

Visual Studio 2015: Yes.

For more details check Missing SharePoint 2016 Project Template in Visual Studio 2015.

Visual Studio 2013: Yes.

For more details check Couldn't find office/SharePoint template in Visual Studio Community 2013.
Answer: Refer to the flloiwng article about Availability of Features in Visual Studio Versions:
https://msdn.microsoft.com/en-us/library/ee519072.aspx


What is a word describing a "long-lasting memory" of someone?

Question: What noun in English is the best for describing the essence of a long-lasting memory that some person (e.g. spiritual leader or famous musician) leaves after himself? Is it perpetuation, or commemoration, or maybe heritage, or record, or some other word? I know the word notoriety meaning ill fame, but I don't know any word for the good one.
Answer: Legacy

something transmitted by or received from an ancestor or predecessor or from the past (m-w)

"To leave a legacy" is a common way to refer to an individual having a great impact on future generations.  Unqualified it connotes a positive impact, but it can be modified with a negative term (like "legacy of conflict") to refer to a negative impact as well.
Answer: "immortality" comes to mind. In addition to "the quality or state of being immortal" it also means:

enduring fame. TFD, "lasting fame" MW, the quality or state of someone that will never be forgotten.

He found immortality through his films.
Some people want to achieve immortality through their works.
Answer: "indelible" meaning something that cannot be erased (by the passage of time.)
A synonom would be "ineffaceable"  (edit - which is unrelated to "ineffable" .)
Comment: And erring and learning, when they travel together, need no apology.
Comment: No, *ineffable* is a separate word; but *indelible* is an excellent thought. All three are adjectives, and *indelible* and *ineffaceable* might modify *memory* to the proper effect.
Comment: You are correct - I have learned something, my apologies.    Is it permitted to edit my answer and remove the incorrect details?  Not sure of the board's etiquette.
Comment: @Criggie Yes, please do; that's perfectly fine.
Answer: Photographic memory or  eidetic memory is the word you're looking for.
Comment: The Q asked: *What noun in English is the best for describing the essence of* ***a long-lasting memory*** that some person ***leaves*** *after himself?* It is nothing to do with the ability to memorize names, lists, details or events.

What is a word describing a “long-lasting memory” of someone?


Cannot overclock AMD GPU on Ubuntu 18.04 LTS

Question: I am trying to overclock the memory on my GPU with AMDGPU Pro 18.40 driver.
Nonetheless, /sys/class/drm/card0/device/pp_od_clk_voltage is an empty file and I cannot write to it.
When I try
echo "m 2 1600 950" > /sys/class/drm/card0/device/pp_od_clk_voltage

as root it produces the following error:
-bash: echo: write error: Invalid argument

I have amdgpu.ppfeaturemask=0xffffffff in GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub.
I have also tried running:
echo manual | sudo tee /sys/class/drm/card0/device/power_dpm_force_performance_level

My question is based on the answer to the following question: Can't overclock GPU using amdgpu driver on archlinux
The author claims that this method works, however it obviously does not.
Answer: I had to install this:
https://github.com/BoukeHaarsma23/WattmanGTK
and then I ran it, and it told me the value I needed to pass to amdgpu.ppfeaturemask.
In my case on a Vega 64 the value is 0xfffd7fff
And yea you add that to grub :)