Why didn't Japanese attack Soviet Union simultaneously as the Germans?

Question: As everyone knows, the Japanese went south, conquering most of the Pacific and attacking Pearl Harbour. But why didn't the Japanese wait until Hitler went on the eastern campaign (attacking the Soviet Union in 1941) and then attack the SU from their side? They must have known Hitler's plans of going east, since minimal diplomatic relations between the two existed? I know the two were allies more on paper then in reality, but still. Also I am aware of various Soviet Union and Japanese border skirmishes, like Khalkhin Got and etc.
Comment: The Japanese went south for resources.  All else aside, what did Siberia have that the Japanese would want?
Comment: jamesqf Siberia did have natural resourses, plenty actually, near Irkutsk, also to the north of China.
Comment: congusbongus not really, I am asking about the coordinated effort, not about picking South or North strategy.
Comment: It's worded differently, but it's functionally the exact same question I'm afraid. If your question focused on the lack of German-Japanese cooperation that would be different.
Comment: that's closer, its somewhere in between.
Answer: Japan could expand in two directions: west and northwest or south. First they wanted to go west (China) and northwest (Siberia). China wasn't a problem, but going northwest was. The soviet army was much better than the Japanese expected. They were soundly defeated in the battles of Khalkin Gol. One of the commanders on the USSR side was Georgy Zhukov.
Those battles were extended border clashes, but more than enough to show the Japanese army it wouldn't be a walk over. So they stopped there and then. One of the reasons likely was that Siberia had a lot of minerals, but you need to extract them. That's pretty hard, and would take many years.
As to the Axis treaty: it was a very nominal treaty. Just about nothing was done in cooperation. All they shared were some signatures on paper. There was no coordination, conflicting interests and very little else. The Japanese attack on Pearl Harbour was as much as a surprise to Hitler as it was to Roosevelt. A bigger surprise for Hitler, because the Americans could read the Japanese code.
Going south was much more profitable for the Japanese. The oilfields in the Dutch Indies were huge and in production. Malaysian and Thai rubber were for the taking. All they had to do was knock out the US fleet in Pearl Harbor.
Yamamoto warned against it, but not so wise heads prevailed. With hindsight you can win any war, this is a clear example. It's even worse for the Axis. Richard Sorge was a Soviet spy in Japan. He could conclusively prove to Stalin that Japan wasn't going to attack in Siberia, and he could safely withdraw the Siberian troops and use them for the defense of Moscow. That was even worse than not cooperating and not supporting each other.
Comment: And also they can't fight at all without oil, which they were fast running out of, and which Siberia didn't have as far as they knew.
Comment: Nice answer Jos!
Comment: "So they stopped there and then" - no; it took them almost two years to completely abandon hokushin-ron. The last straw was the US oil embargo.
Answer: Summary:
Japan couldn't wait
So the Japanese were all fired up to fight. They decided to split the Soviet Union with the Germans, right? Met with the Germans in November 25, 1936 and were ready to fight.
The smart thing would have been to wait until the Germans were ready. However, Germany still had to annex eastern Europe first, and the Japanese Army was unwilling to wait a few years. It was a function of the Japanese power structure; they had to fight.
Comment: @Gintas You might tour the [Help Center](https://history.stackexchange.com/help) to see how Stack Exchange works - you can up-vote answers that you like.
Comment: nice answer too!
Comment: I can't since I don't have enough reputation.
Answer: The Japanese emperor said that Japan received an elementary school on Hassan and a secondary school on Khalkhin Gol. For this reason, the Japanese were in no hurry to receive a "higher education". Japan decided to start a war against the USSR if it was occupied by Leningrad and Moscow. Guaranteed victory.
Comment: What do you mean by "Japan decided to start a war afainst USSr if it was occupied by Leningrand and Moscow". You mean if Hitler would've occupied these two cities then the Japanese would have declared war?


why the sweep phase of cms does not have to stop the world?

Question: I have a question on cms sweep phase,  the sweep phase will not stop the world ,considering the below case , a pointer c is null which will not be marked as reachable , after remark phase , the c pointer is modified to be a new object,or do the things like c=b, b is unreachable ,but if c points the it ,it becomes reachable, for these two cases ,will the c will be collected? it is not marked on remark phase ,so if it is collected, i think it is wrong.
Answer: There's a huge misconception in your question. Garbage collectors collect objects, i.e. the memory occupied by them, not pointers.
Pointers are traversed in the marking phase to determine, which objects are reachable. When your pointer c is null, it doesn't point to any object and there is nothing to traverse. Whether there are unreachable objects can't be determined from c, it just doesn't contribute to this process. All that matters, is which pointers do point to an object, as these objects are reachable. All objects not encountered during the traversal are unreachable.
Since being unreachable implies that no pointer to the object exists, no subsequent pointer assignment can make an unreachable object reachable. When you do c = b, there are only two possible scenarios, 1) b is null, hence c will be null too after the assignment or 2) b points to an object which, of course, has been marked as reachable during the marking phase, so now there's one more pointer to that reachable object, which doesn't change its reachable nature.
The only change that may happen during a concurrent sweeping phase, is that an object marked as reachable may become unreachable concurrently, e.g. if c was the only pointer to an object, a concurrent c = b makes that object unreachable. This, however, just implies that this object is still treated like being reachable in this sweeping phase and needs to be collected in the next garbage collection cycle.
Comment: Thank you for your reply, is it possible that an obj in new generation points to an obj in old generation after remark phase? there are two cases, one of which is that obj in old has already been marked, this case ,it has no problem,what if the obj in old is not marked ? will this happen?
Comment: To assign a reference to an old object to a field of a new object, you need to have the reference before the operation. So you could do something like `newObj.field = oldRef; oldRef = null;` to only have the new object pointing to the old object, but note that at any time, there is at least one reference to the old object (and the marking phase stops the world). So the old object will always be marked as reachable.


Foundation 6 Installed with bower-rails Sass::SyntaxError

Question: I installed foundation 6 using bower-rails on a Rails app (Rails v4.2.6).

Imported it in my css via
@import 'foundation-sites/scss/settings/settings';
@import 'foundation-sites/scss/foundation';

I get this error when I load the page
Sass::SyntaxError in Controller#action
Invalid CSS after "...-flexbox: true ": expected "}", was "!global;"

When I import the plain css files, it works but displays this error when I import the sass files.
Am I missing something?
Answer: Foundation 6 uses latest Sass syntax like '!global'.
Updating sass to the latest version should do the trick.
$ gem update sass
Hope that helps.


What are "tan" and "atan"?

Question: As the title says, I'm confused on what tan and atan are. I'm writing a program in Java and I came across these two mathematical functions. I know tan stands for tangent but if possible could someone please explain this to me. I have not taken triginomotry yet (I've taken up to Algebra 1) so I don't really need a very in depth explanation since i wouldnt understand but just a simple one so i could move on with my program would be great! Thanks in advanced. Also if possible could someone possibly give me a link to an image/example of a tangent and atan.
Comment: I will preserve this piece of information from my deleted answer; when programming you should be careful to check the precise conventions. Especially as regards the range  of `atan` and the usage of radians vs. degrees.
Comment: @quid, I don't get why your answer was downvoted.
Comment: Why not simply youtube "tan"?
Comment: did that, went to the website khanaccademy.com which usually has some very helpful videos but I needed further information still so I asked here.
Comment: see also atan2 http://www.w3schools.com/jsref/jsref_atan2.asp
Answer: A quick google search of "java atan"  would tell you that it stands for "arctangent", which is the inverse of tangent.  Tangent is first understood as a ratio of non-hypotenuse sides of a right triangle. Given a non-right angle $x$ of a right triangle, $\tan(x)$ is the ratio $\frac{o}{a}$ where $o$ is the length of the leg of the triangle opposite $x$ and $a$ is the length of the leg adjacent to $x$. Arctangent takes the ratio as an input and returns the angle.
I don't think any single answer to your post will give you a complete understanding of tangent and arctangent. To get that, I recommend spending some time with sine, cosine, tangent and the unit circle. Here is a link to an image http://www.emanueleferonato.com/images/trigo.png   that uses an angle $A$ and triangle sides $a,o,h$. In the context of that photo, $\arctan\left(\frac{\text{opposite}}{\text{adjacent}}\right) = A$
Comment: Okay thank you, and thanks to everyone else who answered,this is basically what i needed to see, I will do further research at this point!
Comment: @AshwinGupta good luck to you! I am happy to answer any other questions should you have any. A solid understanding of trigonometry will take you far in mathematics.
Answer: I think the following picture is useful [from Wikipedia]:

The tangent of a number $0<\theta<\pi/2$ is constructed by

taking a circle of radius 1, centered at the origin
drawing the tangent at the point on positive $x$-axis
drawing the line (ray) at an angle of $\theta$ from the origin
constructing the intersection of these two lines
measuring the distance between the intersection and the positive $x$-axis.

The final distance is the tangent  of $\theta$, denoted $\tan\theta$.
As others have mentioned, the arctangent of a number $0<d<\infty$ is the number $\theta$ for which $\tan\theta=d$. In other words, it is the angle for which, after performing the described procedure above, you get a distance of $d$. It is denoted in many ways, including atan $\theta$, arctan $\theta$, and $\tan^{-1}\theta$.
Note that I've only defined $\tan\theta$ for a limited collection of $\theta$: to get other values, you can use the identities $\tan(-\theta)=-\tan(\theta)$ and $\tan(\pi+\theta)=\tan\theta$. So for instance, if you knew that $\tan(\pi/4)=1$, then you would also know that
$$\tan\left(-\frac{7\pi}{4}\right)
=-\tan\left(\frac{7\pi}{4}\right)
=-\tan\left(\frac{3\pi}{4}\right)
=-\tan\left(-\frac{\pi}{4}\right)
=\tan\left(\frac{\pi}{4}\right)
=1$$
From these facts you can also derive the rest of the arctangent values: it turns out that atan $-d$ = $-$atan $d$.
(This is not entirely true: the arctangent is technically a multivalued function, so you have to make some arbitrary choice of how to extend it to negative numbers. But the choice above is the most common one.)
Comment: thanks for such a through answer! Im going to do some research on sin, cosine, ect like the answer above told me to than come back to this one.
Comment: Also nice picture this helped
Answer: atan stands for "arc tangent." It is the inverse function of tangent - this means it undoes the tangent function. So atan(tan(30)) = 30.
Comment: But the OP doesn't know what tangent is.
Comment: @Eff yes thanks. Although, with the knowledge from the other answers, this does have some use. (It should just be a comment though..)

What are "tan" and "atan"?


Is rejecting a Promise only for error cases?

Question: Let's say I have this function authenticate that returns a promise. The promise then resolves with the result. False and true are expected outcomes, as I see it, and rejections should only occur in an error case. Or, is a failure in authentication considered something you would reject a promise for?
Comment: another way to think about it - if this were a synchronous method call, would you treat regular authentication failure (bad username/password) as returning `false` or as throwing an exception?
Comment: The [Fetch API](https://fetch.spec.whatwg.org/) is a good example of this. It always triggers `then` when the server responds - even if an error code is returned - and you must check the `response.ok`. The `catch` handler is only triggered for *unexpected* errors.
Comment: I'd say that *resolving* means using the response and continuing your application, while *rejecting* means canceling the current operation (and possibly try again or do something else).
Comment: This is a good question. It touches on one of the failures of the promise design. There are two types of errors, expected failures, such as when a user provides bad input (such as failing to log in), and unexpected failures, which are bugs in code. The promise design merges the two concepts into a single flow making it difficult to distinguish the two for handling.
Comment: If authentication failed, you should `reject` and not return false, but if you are expecting the value to be a `Bool`, then you _were_ successful and you should resolve with the Bool regardless of the value. Promises are sort of proxies for values - they store the returned value, so only if the value could not be obtained should you `reject`. Otherwise you should `resolve`.
Comment: I would reject in that case. Reject will propagate the rejection and bypass execution of any 'then' chains attached to that promise which handle success. For authentication failure, I'd want to make sure that nobody tries to continuation off of that and do something it shouldn't. [Be careful about how you implement reject handlers though](https://jsfiddle.net/bLyqdxtw/).
Answer: Good question! There is no hard answer. It depends on what you consider to be exceptional at that specific point of the flow.
Rejecting a Promise is the same a raising an exception. Not all undesired results are exceptional, the result of errors. You could argue your case both ways:

Failed authentication should reject the Promise, because the caller is expecting a User object in return, and anything else is an exception to this flow.
Failed authentication should resolve the Promise, albeit to null, since providing the wrong credentials is not really an exceptional case, and the caller should not expect the flow to always result in a User.

Note that I'm looking at the issue from the caller's side. In the flow of information, does the caller expect his actions to result in a User (and anything else is an error), or does it make sense for this particular caller to handle other results?
In a multi-layered system, the answer may change as the data flows through the layers. For example:

HTTP layer says RESOLVE! The request was sent, the socket closed cleanly, and the server emitted a valid response. The Fetch API does this.
Protocol layer then says REJECT! The status code in the response was 401, which is ok for HTTP, but not for the protocol!
Authentication layer says NO, RESOLVE! It catches the error, since 401 is the expected status for a wrong password, and resolves to a null user.
Interface controller says NONE OF THAT, REJECT! The modal showing on screen was expecting a username and an avatar, and anything other than that information is an error at this point.

This 4-point example is obviously complicated, but it illustrates 2 points:

Whether something is an exception/rejection or not depends on the surrounding flow and the expectations
Different layers of your program may treat the same result differently, as they are located in varying stages of the flow

So again, no hard answer. Time to think and design!
Comment: That 4-point example is excellent! Thank you for your insightful answer.
Answer: So Promises have a nice property that they bring JS from functional languages, which is that they indeed implement this Either type-constructor that glues together two other types, the Left type and the Right type, by forcing the logic to either take the one branch or the other branch.
data Either x y = Left x | Right y

Now you're noticing indeed that the type on the left-hand-side is ambiguous for promises; you can reject with anything. This is true because JS is weakly typed, but you want to be cautious if you're programming defensively.
The reason is that JS will take throw statements from promise-handling code and bundle it up into the Left side of that too. Technically in JS you can throw everything, including true/false or a string or a number: but JavaScript code also throws things without throw (when you do things like trying to access properties on nulls) and there is a settled API for this (the Error object). So when you get around to catching, it's usually nice to be able to assume that those errors are Error objects. And since the reject for the promise will agglomerate in any errors from any of the above bugs, you generally want to only throw other errors, to make your catch statement have a simple, consistent logic.
Therefore although you can put an if-conditional in your catch and look for false errors, in which case the truth case is trivial,
Either (Either Error ()) ()

you will probably prefer the logic structure, at least for what comes immediately out of the authenticator, of a simpler boolean:
Either Error Bool

In fact the next level of authentication logic is probably to return some sort of User object containing the authenticated user, so that this becomes:
Either Error (Maybe User)

and this is more or less what I'd expect: return null in the case where the user is not defined, otherwise return {user_id: <number>, permission_to_launch_missiles: <boolean>}. I'd expect that the general case of not being logged in is salvageable, for example if we're in some sort of "demo to new clients" mode, and should not be mixed in with bugs where I accidentally called object.doStuff() when object.doStuff was undefined.
Now with that said, what you may want to do is to define a NotLoggedIn or PermissionError exception which derives from Error. Then in the things which really need it you want to write:
function launchMissiles() {
    function actuallyLaunchThem() {
        // stub
    }
    return getAuth().then(auth => {
        if (auth === null) {
            throw new PermissionError('Cannot launch missiles without permission, cannot have permission if not logged in.');
        } else if (auth.permission_to_launch_missiles) {
            return actuallyLaunchThem();
        } else {
            throw new PermissionError(`User ${auth.user_id} does not have permission to launch the missiles.`);
        }
    });
}

Answer: Errors
Let's talk about errors.
There are two types of errors:

expected errors
unexpected errors
off-by-one errors

Expected Errors
Expected errors are states where the wrong thing happens but you know that it might, so you deal with it.
These are things like user input or server requests. You know the user might make a mistake or that the server might be down, so you write some checking code to make sure that the program asks for input again, or displays a message, or whatever other behavior is appropriate.
These are recoverable when handled. If left uhandled, they become unexpected errors.
Unexpected Errors
Unexpected errors (bugs) are states where the wrong thing happens because the code is wrong. You know that they'll eventually happen, but there's no way to know where or how to deal with them because, by definition, they're unexpected.
These are things like syntax and logic errors. You may have a typo in your code, you may have called a function with the wrong parameters. These aren't typically recoverable.
try..catch
Let's talk about try..catch.
In JavaScript, throw isn't commonly used. If you look around for examples in code they're going to be few and far between, and usually structured along the lines of
function example(param) {
  if (!Array.isArray(param) {
    throw new TypeError('"param" should be an array!');
  }
  ...
}

Because of this, try..catch blocks aren't all that common for control flow either. It's usually pretty easy to add some checks before calling methods to avoid expected errors.
JavaScript environments are pretty forgiving as well, so unexpected errors are often left uncaught as well.
try..catch doesn't have to be uncommon. There are some nice use cases, which are more common in languages such as Java and C#. Java and C# have the advantage of typed catch constructs, so that you can differentiate between expected and unexpected errors:
C#:
try
{
  var example = DoSomething();
}
catch (ExpectedException e)
{
  DoSomethingElse(e);
}

This example allows other unexpected exceptions to flow up and be handled elsewhere (such as by being logged and closing the program).
In JavaScript, this construct can be replicated via:
try {
  let example = doSomething();
} catch (e) {
  if (e instanceOf ExpectedError) {
    DoSomethingElse(e);
  } else {
    throw e;
  }
}

Not as elegant, which is part of the reason why it's uncommon.
Functions
Let's talk about functions.
If you use the single responsibility principle, each class and function should serve a singular purpose.
For example authenticate() might authenticate a user.
This might be written as:
const user = authenticate();
if (user == null) {
  // keep doing stuff
} else {
  // handle expected error
}

Alternatively it might be written as:
try {
  const user = authenticate();
  // keep doing stuff
} catch (e) {
  if (e instanceOf AuthenticationError) {
    // handle expected error
  } else {
    throw e;
  }
}

Both are acceptible.
Promises
Let's talk about promises.
Promises are an asynchronous form of try..catch. Calling new Promise or Promise.resolve starts your try code. Calling throw or Promise.reject sends you to the catch code.
Promise.resolve(value)   // try
  .then(doSomething)     // try
  .then(doSomethingElse) // try
  .catch(handleError)    // catch

If you have an asynchronous function to authenticate a user, you might write it as:
authenticate()
  .then((user) => {
    if (user == null) {
      // keep doing stuff
    } else {
      // handle expected error
    }
  });

Alternatively it might be written as:
authenticate()
  .then((user) => {
    // keep doing stuff
  })
  .catch((e) => {
    if (e instanceOf AuthenticationError) {
      // handle expected error
    } else {
      throw e;
    }
  });

Both are acceptible.
Nesting
Let's talk about nesting.
try..catch can be nested. Your authenticate() method might internally have a try..catch block such as:
try {
  const credentials = requestCredentialsFromUser();
  const user = getUserFromServer(credentials);
} catch (e) {
  if (e instanceOf CredentialsError) {
    // handle failure to request credentials
  } else if (e instanceOf ServerError) {
    // handle failure to get data from server
  } else {
    throw e; // no idea what happened
  }
}

Likewise promises can be nested. Your async authenticate() method might internally use promises:
requestCredentialsFromUser()
  .then(getUserFromServer)
  .catch((e) => {
    if (e instanceOf CredentialsError) {
      // handle failure to request credentials
    } else if (e instanceOf ServerError) {
      // handle failure to get data from server
    } else {
      throw e; // no idea what happened
    }
  });

So what's the answer?
Ok, I think it's time for me to actually answer the question:

Is a failure in authentication considered something you would reject a promise for?

The simplest answer I can give is that you should reject a promise anywhere you would otherwise want to throw an exception if it were synchronous code.
If your control flow is simpler by having a few if checks in your then statements, there's no need to reject a promise.
If your control flow is simpler by rejecting a promise and then checking for types of errors in your error handling code, then do that instead.
Answer: Handling a promise is more or less like "if" condition. It's up to you whether you want to "resolve" or "reject" if authentication failed.
Comment: promise is an asynchronous `try..catch`, not `if`.
Comment: @zzzBox so by that logic, you should use a Promise as a asynchronous `try...catch` and simply say that if you were able to complete and get a result, you should resolve regardless of the value that was received, otherwise you should reject?
Comment: @zzzzBov I got that in all fairness :) I like the analogy. But my logic is simply that if `doSomething()` fails, then it will throw, but if not it could contain the value you need (your `if` above is slightly confusing as its _not_ part of your idea here :)). You should only reject if there is a reason to throw (in the analogy), so if the test failed. If the test succeeded you should always resolve, regardless of whether its value is positive, right?
Comment: @somethinghere, no, you've misconstrued my argument. `try { if (!doSomething()) throw whatever; doSomethingElse() } catch { ... }` is perfectly fine, but the construct that a `Promise` represents is the `try..catch` part, not the `if` part.
Comment: @somethinghere, I've decided to write up an answer (assuming this stays open long enough), because comments are not enough for expressing my thoughts.
Answer: I've used the "reject" branch of a Promise to represent the "cancel" action of jQuery UI dialog boxes.  It seemed more natural than using the "resolve" branch, not least because there's often multiple "close" options on a dialog box.
Comment: Most purists I know would disagree with you.


RTOS in a virtual machine

Question: Are there any opensource/free Unix like RTOS that can run a virtual machine like QNX Neutrino RTOS (http://www.qnx.com/products/evaluation/eval-target.html)?
Comment: Ah, so you're looking for an alternative to QNX? Why the reference to a virtual machine: do you need real-time operation inside the VM? Usually real-time behavior is on real hardware, VMs are only for testing.
Comment: Do you need to run QNX (presumably a copy of QNX that you've purchased) in a virtual machine? Or are you looking for an OS to run some QNX programs? What are your realtime expectations — virtual machines make realtime difficult? If you want to run the evaluation version that you linked to, why not just install VirtualBox or VMWare on any of the Unix variants that they support?
Comment: I want to run an opensource or free OS like linux RTLinux. I wanted to know if someone who has tested something like this extensively and could recommend something because a lot of these OSes are not very stable even when run natively.
Comment: I first want to test it in a VM before my eventual goal is to have something like VxWin (http://www.acontis.com/eng/products/windows-real-time-hypervisor/vxwin/index.php) but with an open RTOS instead of VxWorks. So an OS that can work well in a VM would most likely be a better candidate than one that does not.
Answer: RIOT is a good option. Its a microkernel based operating system highly designed for IoT applications. Few commands on your mac / linux terminal and you are into RIOT shell.
Please follow below links for more details:

RIOT-OS : Their official Website
RIOT-on-Git : RIOT on github

RTOS in a virtual machine


How to control Brightness on Acer Laptop

Question: I've installed Ubuntu 12.04 in an Acer Timeline X 5830TG and brightness controls were not working (Fn + Key), even the Ubuntu's one.
Answer: Solution:
Edit GRUB:
sudo nano /etc/default/grub

change GRUB_CMDLINE_LINUX_DEFAULT to
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi=Linux acpi_backlight=vendor"

then:
sudo update-grub

Reboot.
Controls are working.
Comment: Works on #! Crunchbang Waldorf too on a native install to Aspire S5
Comment: YEEES! thank you! so many brightness ubuntu issues, so many posts... finally I found the one for me! after monnnths!
Comment: Didn't work for me sadly on Linux Mint 19.1 with an Acer Aspire 5810TG.
Answer: Most simple and fast way to do this....
Use this command
xrandr --output LVDS1 --brightness 0.5

Set the value in between 0 to 1 like in this case it is 0.5
This works for me
Try this !!!
Comment: But this is for manual bright up with console? My answer is to enable the buttons of the keyboard


Which of these two sentences is grammatically correct?

Question:
He begins to know his surroundings.
I have begun understanding this lesson since first session.
Comment: They're both grammatical, but that's as far as it goes. They both sound like they would require some very special circumstances to be idiomatic, or else something a non-native speaker might say.
Comment: @Robusto, in the 2nd example, you agree with using no article with "session"? It sounds wrong to me.
Comment: @ThePhoton: It's a normal elision. You will often hear constructions like "I've had a headache since first period," etc. It's not much of a stretch to substitute *session* for period there.
Comment: To this US English speaker, using *session* without an article sounds a little odd, but not impossible, for the reason Robusto says.
Answer:
He begins to know his surroundings.

is grammatically correct, but native speakers would not use this construction. In the present tense, He is beginning to know his surroundings would be normal phrasing.
That construction would normally only be found as a clause in a larger context, in a conditional or some other sentence with additional components, for example:

When he begins to know his surroundings, then ...
  As he begins to know his surroundings, ...

The second sentence

I have begun understanding this lesson since first session.

is not grammatically correct - first session requires the definite article (the).

I have begun understanding this lesson since the first session.

However, this construction is also not normal phrasing. A more typical phrasing would be

I have understood this lesson since the first session.

but given that the question seems to be around the use of begin, to emphasize that the commencement of understanding of the lesson is linked to the first session, use the imperfect form began:

I began understanding this lesson in the first session.
Answer: "Begin to do" is used for a specific situation.
"Begin doing" is usually used to make a general statement, in which the action that is done is repeated or regular or habitual.
So the first sentence would sound a little bit weird to me, because it miss the part that specify its meaning.
For example "As he begins to wake up, he can hear people talking all around him."
And for the second one, it seems correct both grammatically and situationally
"I have begun understanding this lesson since first session". (= I began understanding the lesson as an activity or skill, that is, as something i did regularly and repeatedly since first session.)


Inject lines to bash history

Question: By default bash loads lines from ~/.bash_history to history. Is it possible to add custom file to be also loaded? I want to inject file containing commands I frequently use and access them it via built-in search.
Comment: You would have to cron out some kind of file modification, which sounds rather crazy and may not work. Just make your long commands a shell script that accepts arguments and drop it in `/usr/local/bin` or something
Comment: Typically people add aliases for frequently used commands...
Comment: That's great. But that's not the case - I use aliases for commands I use constantly but I have a lots of commands that have big number of arguments that I want to modify based on circumstances.
Comment: If you use them frequently, wouldn't they be in your history anyway?
Comment: Declare functions in `.bashrc`?
Answer: I keep it simple with an alias h='history|grep' loaded into my Bash profile.
So my workflow is h command, for example: h hpssa
#  h hpssa
  202  05-28-2015 11:54:33  hpssacli
  217  05-28-2015 11:54:33  hpssa -start
  225  05-28-2015 11:54:33  hpssacli -stop
  226  05-28-2015 11:54:33  hpssa -stop
  228  05-28-2015 11:54:33  hpssa -start

If I want to run "hpssa -stop",  I'd simply type !226

This is just my approach, but maybe you could modify how you're recalling history items. I don't think it makes sense to actually inject data into the history file.
Comment: @CameronKerr Have a look at the answer just below this one (http://serverfault.com/a/695115/120438 ).The downside to using Ctrl+R in this particular case is that it gives you the relevant commands one at a time, while ewwhite's approach returns a list of all relevant commands.
Comment: nice trick, stealing that one
Comment: Suggest you may want to have a look at what Ctrl-R does for searching back  in your history. Prepare to have your mind blown...
Comment: Although this is a great trick, it doesn't answer the question at all. I fail to understand as to how this is the highest voted answer. My usecase is that I have a docker image which keeps losing it's history when I exit it. I thought it'd be nice if I could pass a history file via the command line to `docker run ...`
Comment: @kumar_harsh Hard to please.
Answer: I used to be very reliant on Ctrl-R (reverse-search-history Readline command) which searches backward through the history to retrieve previously entered long commands but I now prefer to use aliases and shell scripts / functions. Anyhow, the Bash history builtin command can be used to load a list of custom commands into your current history.
history -r [filename]

From the bash man page:

Read the contents of the history file and append them to the current history list.

Start-up automation
I just tried launching this command automatically by adding it as the last line in my .bashrc. However, the commands from my custom history file were not available when I started a new shell. It seems that the shell history is only loaded from the default .bash_history file: after the start-up files have been processed and just before the prompt is presented for the interactive shell. Unfortunately, it seems there isn't an easy way to automate this.
Answer: As @AnthonyGeoghegan observed, the history is loaded after startup files are processed.  That offers a different way to pre-load the desired history in a startup file:
mv .bash_history .bash_history.tmp
cat .extra_hist .bash_history.tmp > .bash_history
# or swap them, to put the extra stuff at the end of the history, for
# quicker ^R access.

Note that this approach could result in multiple copies of your special commands being added to your .bash_history, over time.  You could wrap your special commands with comment lines, so you can easily find and remove them (via, e.g., sed) as part of filling the .bash_history file.  Something like:
cp .extra_hist .bash_history
sed '/: remove from here/,/:remove to here/d' .bash_history >> .bash_history

Inject lines to bash history


How to enable qiskit logging? Where is the log file?

Question: I'm trying to debug a qiskit circuit that won't "unroll." Looking at the source code, there are a log of logging calls but they aren't enabled. How can I enable logging in qiskit? Where is the log written?
Comment: Could you maybe provide some example code of the circuit you're working with and what you've tried so far?
Answer: Qiskit uses standard Python logging which means all the logging calls you see in the source code go to Python's built-in logging infrastructure and how those get written out or displayed is configurable. The details on how to use it are documented here: https://docs.python.org/3/howto/logging.html
By default only log messages at the WARNING level or above will be displayed. If you'd like to see more of the logging messages you can run something like:
import logging

logging.basicConfig(level="DEBUG")

and that will print all the log messages to your console. If you'd like to write
the log messages to a file you can run this instead:
import logging

logging.basicConfig(level="DEBUG", filename="output.log")

Nte you can only call basicConfig once as it sets the handler on the root logger and it won't override that by default, unless you set the argument force=True.
More details on the specifics of this around Qiskit's transpiler are documented here: https://qiskit.org/documentation/tutorials/circuits_advanced/04_transpiler_passes_and_passmanager.html#Transpiler-Logging


Does this count as suicide?

Question: Does it count as suicide if one asks someone else to kill them since they can't do it themself? Would that person still go to hell?
Answer: Without a doubt, as the intention is the same (i.e. ending his own life).. Either by the hands of oneself or any other tool/hand.. recall what prophet (Peace be upon him) said:

إنما الأعمال بالنّيّات

That means: Acts are judged by what we meant to accomplish through them.

Does this count as suicide?


Is "sit high" a set phrase?

Question: Someone who is annoyed at the  coverage of her scandalous story in a news broadcasting tv programme (like bbc or cnn) is having a argument with director of the news network channel as to why she run the story.she says" it is sitting very high on her(the director) half hour".
Comment: Have you looked for the expression (or at least string) in a dictionary?
Comment: @Edwin Ashworth Yes, I have. it is not in the dictionaries.What is string?
Comment: I would say it's a "sit phrase".
Comment: A 'string' is any sequence of words found in a text, sentence .... It covers accidental juxtapositions as well as weak collocations / strong collocations ... / phrases / clauses .... //// ELU requires that basic research be done and presented (with links and attributions) where reasonably possible. Even "I found no evidence of 'sit high' in Lexico or AHD" is useful, showing where contributors may be better advised to check.
Answer: Cambridge dictionary has
sit = "to be in a particular position"
"The town sits at/in the bottom of a valley".
The verb is used in the same way to describe the position of items in an agenda. Those that sit high are those near the top of the agenda. Because a program has a similar list (schedule) of items to be considered during the broadcast, some items may be described as sitting high on the schedule (for "the half hour" of broadcast). The implication is sometimes that those items considered first in any such list (agenda or program schedule) are the most important.
Answer: "Sit high" is a metaphor that derives from several sources.  In one sense it can simply refer to physical position ("The house sits high on a hill"), but it can also (presumably by analogy to a king's throne, etc) refer to one's social position or position of authority.
But in the referenced piece it sounds like "high" simply refers to the position of the piece in the broadcast schedule or list of priorities.

Is "sit high" a set phrase?


White LED lights come out purple in iPhone photos

Question: I purchased an LED lighted display stand. When I take a photo with my iPhone the white stand is now lit in purple?
Answer: Most natural light sources emit a broad spectrum of the wavelengths of visible light. The dominant color of that light is also usually very close to a range of colors emitted by "black body radiators" at various temperatures. Stars, for instance, are black body radiators. So are most metals when they are heated enough to glow. Regardless of the chemical makeup of many metals, they all glow at the same color when raised to the same temperature. Thus we define "color temperature" as the corresponding temperature, expressed on the Kelvin scale that begins at absolute zero (-273°C or -460°F), of black body radiators that radiate specific colors.
The Sun may be centered on about 5500 K, but there is a little bit of the entire visible spectrum in sunlight. That's generally because a black body radiator is not the exact same temperature over the entire surface that is emitting light. It's also because the Earth's atmosphere absorbs some of the energy radiated by our sun, and lets what we call visible light pass more easily. (Of course the reason we call it "visible light" is because we have evolved to be visually sensitive to the wavelengths of electromagnetic radiation that the atmosphere we evolved in allows to pass most easily!)
LEDs are not natural light sources. The light they emit is not usually broad spectrum. There are parts of the visible spectrum missing from the light they emit. The dominant color they emit is also usually not along the axis of color we call "color temperature." It may be more magnta or it may be more green. The green ←→ magenta axis is more or less orthogonal/perpendicular to the blue ←→ amber color temperature axis. In order to adjust for this nontypical light, we adjust what is known as the camera's "white balance". This adjustment can take place along the blue ←→ amber "color temperature" axis, the green ←→ magenta "tint" axis, or both.

If your phone allows you to alter color temperature and white balance correction, play around with it until the light from your display stand looks more natural. Since your current results have a purple (blue + magenta) tint to them, I'd start by adjusting in the green and amber directions. Just don't forget to set it back to "auto" or "normal" when you are done! If your phone has no such control, but you can save images in "raw" format, do so and then adjust white balance using a raw convertor application. They all should allow you to adjust both "color temperature" and "tint".
Because the light that illuminated the photo is not fuller spectrum, you may also need to use a selective color tool, often called an HSL, HSV, or HSB tool (for Hue - Saturation - Luminance/Value/Brightness) that allows adjusting the hue, saturation, and brightness of different colors independently, to remove color casts that remain after white balance correction.
The type of lighting is different in the examples in this answer to How to edit photos shot in fluorescent light, but the methodology of correction is the same. Obviously the direction and amounts of the various color adjustments would need to be suited to the light illuminating the scene.
Answer: Choose a manual white balance (WB) in your camera app.
Seemingly, your app's auto WB does not work all too well in this setup, so all you can do is to set it manually.

Composite of a "proper" WB (left) and the same picture with thrown-off WB (right). "proper" = "most probably not 100% accurate, but to my personal liking".


Install libusb 1.0.9 on Arch Linux

Question: I am not sure how to install libusb 1.0.9 on Arch Linux. pacman does not offer it and the package seems to have been deleted from the repository. I tried compiling from source but it does not seem to be picked up correctly.
Comment: Is there some reason you need 1.0.9 instead of [the current version](https://www.archlinux.org/packages/core/i686/libusb/)?
Comment: Libusb has been replaced by libusbx as beeing out of date.
Comment: https://github.com/nonolith/node-usb/issues/34
Answer: You are looking for a package that no longer exists.
Arch doesn't work like that: it is a rolling release so, as newer packages are pushed to the mirrors (on a daily basis), the older ones are removed: attempting to download one will typically throw a 404 error.
If you must build a package from source (to make customizations, for example); make sure your machine is fully up-to-date (pacman -Syyu) and use either a PKGBUILD from ABS or, if the package is not in Arch's official repositiories, the AUR.
This way you can be sure1 that you will be building a package with the correct dependency versions and pacman will manage the final installation (and eventual removal, if you decide to do that).
You should only really use the traditional compilation method and bypass pacman if you really are confident you know exactly what you are doing.
1. Assuming, of course, the AUR packager knows what they are doing; it is, after all, an unsupported repsitory so use with caution.
Comment: Right. I'm not used to arch. I'm used to installing rpms on CentOs and then installing what I need using yum

Install libusb 1.0.9 on Arch Linux


Finding the random uncertainty of a set of values

Question: Ok, for the switch-on voltage of a red LED I have the readings as follows, all in volts:
$$
1.45, 1.46, 1.46, 1.44, 1.45
$$
The mean of these readings, in volts, is $1.45$ (I rounded up to $2$ decimal places as my scale reading uncertainty was $\pm 0.01\,\mathrm{V}$, and my teacher told me to round them up since to state my scale reading uncertainty for the mean the mean will have to have the same number of decimal places as the scale reading uncertainty). Now, my random uncertainty for these values is $\pm 0.004\,\mathrm{V}$, which is not to $2$ decimal places (it's to $1$ significant figure). So, I was wondering if I would have to make my random uncertainty have $3$ significant figures ($\pm 0.00400\,\mathrm{V}$?) to express the random uncertainty in absolute form (Mean Value $\pm$ Random Uncertainty). And if I did so, would it be, in terms of physics, correct?
Comment: I believe it should be $\frac{max.-min.}{2}$, but this may not be what you are asked to do.
Comment: How did you calculate "random uncertainty"?
Comment: (Max.-Min)/No. of Results
Comment: Why 2? Is it not divided by the number of readings? That is the formula we have to use for our course anyway (the one I stated above).
Comment: More on [significant figures](http://physics.stackexchange.com/search?q=is%3Aq+significant+figures).
Answer: I believe in this case you should round your uncertainty to 0.01, in addition to the convention where it is better to give your results "the benefit of the doubt", if your digital measurement tool (your voltmeter) only had up to two decimal places, the smallest measurable value (0.01) would be uncertainty inherent in the measurement tool.
Comment: So, are you saying I should round the random uncertainty to 0.01? Would that be, in physics terms, correct since obviously a 4 round down to a 0 and not to a 1.
Comment: conventionally, you can not have an uncertainty of zero, so in order to make the decimal places consistent, that is to be done.
Answer: About significant figures in mesured values and uncertainties you can check chapter 2 of "An Introduction of Error Analysis" by John R. Taylor. It's a simple book about something any science student should know and that is not systematicly taught. Give it a look, it's worth the reading.
Two rules he sets for the writing of uncertainties are:

1) Rule for stating uncertainties:
Experimental uncertainties should amolst always be rounded to one significant figure
2) Rule for stating answers:
The last significant figure in any stated answer should usually beof the same order of magnitude (in the same decimal position) as the uncertainty

That is to say, without any reference to the measurment apparel, it's clearly unconvenient to write values such as (let's say for a speed I take this example from the book itself):$$90\ m.s^{-1}\pm30$$
which is not of any use except if you can explain why you can tolerate a $30\%$ error, or $$90\ m.s^{-1}\pm 0.234325$$
which is of no use as the error can be rounded to $0.2$ whithout any prejudice.
In case your error is clearly inferior to the actual measured value, it's still convenient to use the scientific notation. In your case, I guess that
$$1.45\ V\pm 4\cdot10^{-3}$$ would still be accepted, yet I would hold still to the rounding to $10^{-2}$.
Answer: The point of doing multiple measurements is to get a value that is more accurate than any single measurement. In this case the mean of your five measurements is $1.452$. I didn't check the standard deviation, but assuming your value of $0.004$ is correct you should state your final result as:
$$ \text{V}_\text{on} = 1.452 \pm 0.004 \text{V} $$


Org chart web part for SharePoint Online?

Question: I am a beginner at O365 Sharepoint Online and I have to add an organization chart representing the organizational hierarchy of the members of the society but I cannot find a solution for this. Help me please!
Answer: SharePoint Online does not have a out of the box org chart web part. You can check the organization chart when you click on the user name in a person and group field. It is from the Delve and you can go here for more information.
Also there is a org chart tab in MS teams which shall be integrated with your SharePoint Online site.
There are also 3rd party web org chart webs which you can turn to.


Calculation of angles in regular polyhedrons

Question: For any regular polyhedron (tetrahedron, cube, octahedron, dodecahedron, icosahedron, ...), how do I calculate an angle from the center of the regular polyhedron to the center of each face? Obviously, the angle decreases with the increasing number of faces. What is the formula, when the number of faces n is the variable?

For cube, n= 6, the angle is 90 degrees:
Answer: Théophile's answer is probably the more practical one, but here is a nice technique that works for all regular polytopes in all dimension:
If $P$ is a regular polytope, let $G^\circ$ be the edge-graph of its polar dual (e.g., if $P$ is the cube, then $G^\circ$ is the edge-graph of the octahedron).
Alternatively, $G^\circ$ is the graph in which the vertices are the facets of $P$, and two are adjacent in $G^\circ$ if they are incident.
Let $\theta_2$ be the second-largest eigenvalue of the adjacency matrix of $G^\circ$, then the desired angle $\alpha$ is
$$\alpha=\cos^{-1}\!\Big(\frac{\theta_2}{\mathrm{deg}(G^\circ)}\Big),$$
where $\mathrm{deg}(G^\circ)$ is the vertex-degree of $G^\circ$.
Answer: What you're describing is the supplementary angle of the dihedral angle of the solid. This latter angle $\theta$ is the interior angle between two connected faces, with
$$\sin\frac\theta2 = \frac{\cos\frac\pi q}{\sin\frac\pi p}$$
for a solid with Schläfli symbol $\{p,q\}$. See the full chart in the Wikipedia article on Platonic solids.
Therefore, taking the supplement, you're looking for
$$2\pi - \theta.$$
Comment: I think the OP is referring to the supplementary of the dihedral angle.
Comment: @Intelligentipauca Ah, of course. Thanks; edited.
Answer: A full outline on corner angles of polygons, dihedral angles of polyhedra, and dihedral angles of polychora can be found here: https://bendwavy.org/klitzing/explain/dihedral.htm
It also includes the asked for supplements as well as an explicite listing of all relevant cases, even the acrons.
--- rk


The best way to manage zend roles for various user roles

Question: I have resources to which I want to bind visibility for many roles of user. How can I bind the Zend_Auth with the Zend_ACL and get resources from the database.
Answer: There are more than plenty of ways to accomplish what your doing... Presuming you already have an ACL class created in your library and another class that does the actual verifying, I like to store the actual roles/resources in a config file and just load it in during bootstrap, then using the ACL class to iterate through and create the roles and resources.
Like I said there's plenty of places to find this, one would be here on SO Need guidance to start with Zend ACL
I would also suggest, that with any site you find info or a tutorial on - start with the actual documentation first: http://framework.zend.com/manual/en/learning.multiuser.html
The learning curve is the hardest boundary with it, but once your past it gets simpler.
I hope that helps even slightly.


How do bug reports factor in to a sprint?

Question: I've been reading up on Scrum recently. From my understanding, a meeting is held before the sprint starts, to decide what gets moved from the product backlog to the upcoming sprint backlog. Once a feature is completed in the current sprint, it will go into the "Ready to QA" bucket, and it's at this point that I'm getting confused. Do bug reports go back into the product backlog? I assume they can't go back into the sprint backlog as we've already decided what work will be done for this cycle? What happens when QA finds a bug? Where does it go?
Comment: Fixing a bug is a change. Implementing a feature is a change. There is no fundamental difference between the two: you estimate the effort, you have the changes prioritized, you schedule them into an iteration, you implement them. Whether you label them "bugs" or "features" isn't really all that relevant.
Comment: Are your QA activities happening concurrently with and continuously throughout your sprint or do you have QA activities scheduled toward the end? Are these bug reports coming from a previous release or are they found in the middle of your sprint?
Comment: Beware of the bug reporting process becoming a political problem within your organization. If poorly integrated or constantly bypassed, it can disrupt Agile/Scrum processes, create morale problems within the team and lead to project failure.
Comment: Ideally (project hasn't started yet), I imagine the bug reports will be reported during the current sprint, they'll go into our bug tracker, then we will work out which ones to fix. My current thoughts are that bugs will be fixed in the following sprint cycle (i.e. if bugs are reported in sprint 1, we can choose to fix them in sprint 2, if the backlog is clear). As I've never done agile / scrum before, I want to check whether this is sensible.
Comment: When you say "bug reports", do you mean bug reports against the code you are developing in that sprint, or all bug reports for your product as a whole?
Comment: Both I guess. I would like to be able to schedule external bug reports in the same way as a feature would be scheduled, but then what about the current sprint's bugs? Do they get put into the next sprint? If they're sufficiently high priority?
Comment: possible duplicate of [How to account for a bug fixing iteration?](http://programmers.stackexchange.com/questions/115929/how-to-account-for-a-bug-fixing-iteration)
Answer: The way I see it there are two main solutions to this:

Don't allocate 100% of your time to the current sprint. Allow 10-15% of your time for bug fixing and other support activities that will come up during the sprint. Then if a blocking bug comes up you have the time to fix it in the current sprint.
If a non blocking bug comes up you can either fix it at the end of the current sprint if you have the time left over or it goes into the "pot" for the next sprint.

Have a "bug fixing" sprint every so often. Probably just before the next major release. You can use this to "mop up" as many bugs as you can/want to fix for the next release.

Neither of these solutions is probably true to "pure" Scrum, but they work in the real world.
During a "regular" sprint you can still include tasks to fix specific bugs, treating them as you would a piece of new functionality.
Comment: One way I've handled Option 1 is to set aside a block of points, in the backlog for bug fixing.  It makes planning a little easier and gives visibility to priority etc. along with other work items.  Of course you wouldn't include these "bug fixing points" in with your velocity since you're not adding any value...
Comment: I want to avoid having a specific sprint for bug fixing, as that seems to be closer to waterfall methodology, than agile.
Comment: @MarkIngram - Perhaps it does. In that case you need to have something like option 1. Explicitly schedule bug fixes as part of each sprint but allow slack to cope with blocking issues.
Answer: In an ideal scrum world, there is no "Ready for QA" bucket (at least not visible outside the team), as a feature is not completed until the QA activities are finished and the bugs fixed. This means that there should be people in the team that can take on the QA activities.
In the real world, you might have a separate QA/test team that works in parallel with the scrum (development) team. In that case, the following approach might work well:

Just before a feature is put in the "Ready for QA" bucket, the (main) developer of that feature and the QA representative who will (likely) take it over sit together and walk through the feature. Any issues found at that time are solved before the feature is put in the "Ready for QA" bucket.
Note that this is not an early part of a sprint demo. It is meant to get the low hanging fruit in the issues solves as soon as possible.
Any issues found after the handover to QA should be placed on the product backlog as stories, to be taken into account in the next planning meeting.
For show-stopper bugs, reserve a fixed amount of time each sprint. If, near the end of the sprint, there is time left in this buffer, it could be filled with issues of lower priority.
Answer: Based on how you're describing your workflow from a story, with a product backlog, a sprint backlog, and other buckets (I'm assuming they look something like "in progress/in development", "ready for QA", "finished"), it sounds like you're adding some elements of Kanban to Scrum - a not uncommon combination sometimes called Scrumban. The notion of Kanban adds limits to the size of each bucket to prevent your developers from having too many stories in progress or your testers from testing too much. It's similar to velocity for moving items from your product backlog into your sprint backlog, but within a sprint.
I would approach the problem by having your tasks be the user stories, with your user stories moving from the product backlog to the sprint backlog to the in progress bucket to the ready for QA bucket to the finished bucket. After the developer finishes the story (based on your definition of finished), he would move it into the "ready for QA" bucket where the next person would pull it out and work on it. If there are any problems with it, a defect would be entered in your tracking system and the user story would be moved into the finished bucket since it's been implemented and tested. If there are no problems with it, it moves right into the finished bucket.
When the defect comes from within your sprint, there's no problem with putting it back into the sprint backlog (or perhaps some kind of "in progress" bucket). A story with known defects is usually considered to be unfinished. If it's determined that there's insufficient time to finish the story or the defects are attributed to not understanding the story, an option might be to descope it from the sprint entirely until you can better understand the need - in this case, I'd recommend not including the defective implementation in your released product.
If, due to your defect, the story doesn't get finished in your sprint, this will come out in your velocity calculations for future sprints. Unfinished stories (defective stories) don't get you any story points, so you'll plan for smaller sprints. Fewer complex stories will lead to more time in testing and will encourage you to spent more effort finding defects early - preventing defects is not only cheaper, but takes less time than the sum of the time spent to identify that a problem exists, find the problem in the design or implementation, fix the problem, and retest to ensure the problem has been solved without any other negative impacts on the system. Since the timebox is key, the ability to prevent defects leads to more productive sprints in the future.
Regardless of what you do, you should involve the Product Owner (who is hopefully a customer/user representative) when it comes to deciding how to prioritize defects. Some defects might be acceptable to be put into a release if there are workarounds or they are rare, meaning the defect would show up as a story in a future sprint. Other defects might be urgent and "showstoppers" - these must be addressed immediately and a product can't be used if they exist.
Answer: If the time spent on defect is fairly consistent from one spring to another, then you don't really need to manage it - your team velocity is going to reflect that.
Otherwise, if defects fixing can be planned (i.e. you can postpone fixing them for the duration of a sprint), then do so.
Otherwise, Scrum doesn't have a good answer - defects are going to be an unplanned sprint content change in the middle of a sprint, which means you'll need to renegociate your commitments.
Answer: A sprint should be self contained.  That means all activities, including QA, bug fixing, and documentation, should be completed before the end of the sprint.  Pre-deployment activities should also take place before the sprint is over.
The problem with not finishing is that you get distracted in the next sprint.
If, in sprint B, you have to turn your attention back to the code from sprint A so that you can fix bugs, then your ability to focus on the tasks in sprint B goes out the window.  So does your forward velocity.
Answer: At my last job, sprints were scheduled based on the "ideal hours" concept; of an 8-hour developer-day, 5 hours were head-down TDDing new features that never existed before. The other three were doing everything else; e-mails, meetings, compiling/committing/updating code, refactoring work, and yes, bug fixes.
We considered a job that was done but had bugs to still count towards team velocity; however, bugs were technical debt that had to be paid off when it accrued, and therefore obviously to be avoided. We never had a real problem with people doing sloppy work; nobody wanted to have to backtrack.
Every now and again, we'd also have bug-fixing sprints. We had the dubious good fortune to have a client that couldn't deliver requirements at the pace we could consume them, so to let the backlog build up a bit, we often scheduled two weeks where the object was to "kill as many defects and pay off as much technical debt as you can". Technically, velocity for such a sprint is zero, but this is work that needs to be done and which makes the client happy, so it's worthwhile.


RabbitMQ with mirrored queues: Failover support

Question: I am trying to set up a RabbitMQ cluster with mirrored queues (nevermind if u don't know what that is, it MIGHT NOT affect the answer). Long story short, I have N RabbitMQ instances joined together in a cluster. One of the instances is the master, the remaining are slaves  - sorry about the terminology but thats what is on the RabbitMQ docs - but they are active. However, I need to come up with a proxying solution that does the following

Route ALL TCP connections to the master.
Should the master fail, reroute all TCP connections to a new master - one of the slaves will be promoted to master in that scenario.
No load balancing - all connections MUST go to the master (original or new).

Trouble is HAProxy seems to always work as a load balancer which is not applicable here, it is just here to provide failover support. How can I turn load balancing off but still keep failover support on?
Answer: Here is a solution that tackles the exact problem that you describe.


How can you calculate the thrust-to-weight ratio of a gun?

Question: Is there some formula I can apply to the weight of a gun, along with the force of thrust it creates, and calculate if it will be able to lift itself off the ground or not? Without actually handling the gun, of course.
Comment: The same way you do with a rocket, actually. You just through the fuel overboard in discrete lumps instead of continuously. (Of course, any engineer in the room will tell you that batch processes often suffer in overall throughput compared to continuous ones...)
Comment: What kind of "gun" are we talking about? Weapons? How about projectile velocity times mass as a first order estimate (discounting for the momentum of the escaping gas).
Answer: Given the pieces mentioned in your question: the weight of the gun and force it creates, the answer is a trivial yes.  If the force is greater than the weight, it could lift.
The problem is in calculating that force.  A rocket is designed to produce force continuously for a period, and given the fuel and some other parameters makes it possible to calculate the average thrust over that period.  The gun produces force only for a short period of time.  As an example, it might generate a force in excess of its weight for only a couple hundredths of a second because the forces diminish as the gas in the firing chamber expands.
Comment: You can ask the question about a fully automatic firearm which is a kind of batch-mode rocket. Bit the results are generally disappointing.
Comment: @dmckee That's an excellent idea.  Yes, then calculating an average force (over one cycle of firing) becomes useful.


Is Min Min's Final Smash Pre-rendered?

Question: If you slow down and look at Min Min's Final Smash (video) frame by frame, it's easy to spot that all the other ARMS characters are just 2D sprites. No doubt here.
However, in the final part of the Final Smash, you can observe that the ARMS gloves are 3D and some even have a curve.
Are these "hands" actual 3D models being rendered real-time in Smash Ultimate? or is the sequence pre-rendered and layered on top of and beneath the player?
Answer: I think I found some evidence for the hands being 3D models rendered in real time.
Notice how Ninjara's ARMS "go through" Ike's cape:

If someone has a technical answer from the game's source, that would be great :)

Is Min Min's Final Smash Pre-rendered?


Data recovery fantom external hard drive 6 TB ( two 3TB drives on raid 0)

Question: I have a Fantom 6TB external hard drive that uses two 3TB hard drives. On the back it has two switches for setting up RAID. I have it set to RAID 0 so I can use the full 6TB. The problem with it is that it won't power on. So I pulled the hard drives out to get to the data. And for those of you wondering I did buy a new power supply and I changed the cooling fan inside it and still no power.
I put the two 3TB hard drives in my computer then went into the bios and whiched the SATA controller to RAID. After that I booted into to Ubuntu 12.04 and I noticed that they weren't mounted. So I opened Disk Utility and  I can see the two drives there but I can not mount them. I assume the reason is that the two drives were previously being used in RAID 0 and I need to set up the RAID array in Disk Utility but I don't quite know what I am doing and I don't want to lose the data.
Oh and yes my motherboard does support 3TB.
Answer: You can set up RAID 0 with mdadm. For example, I made it visible in both Windows and Ubuntu using --build command:
# mknod /dev/md1 b 9 1
# sudo mdadm --build --verbose --chunk=64K /dev/md1 --level=0 --raid-devices=2 /dev/sdh /dev/sdi

Do not use --create command, because it will destroy your array. And remember that you should build array on every system startup. Also, set chunk size according to your array chunk size, else results will be unpredictable.
OK, mdadm is the software application and is placed inside the package of the same name. To 'enable' it you should install it:
sudo apt-get install mdadm

Chunk size is the size of the blocks on which data are divided to fit on both RAID drives. You can retrieve it from your Fantom storage settings.
And, the last: you can build your array during installation, then install Ubuntu, reboot and it should work! At least, if you have only 2 internal drives... Because drive order can change if you have > 2 drives. I'm suffering from this effect. But I found solution: run the command before mount -a runs. This should be done by runlevel injection.
But you do not need to do this, because you just have to build array once, retrieve the data and put the drives back, right? And when array is built, there will be nodes:
$ ls -l /dev/md1*
brw-rw---- 1 root disk   9, 1 sept. 10 05:30 /dev/md1
brw-rw---- 1 root disk 259, 0 sept. 10 05:30 /dev/md1p1
brw-rw---- 1 root disk 259, 1 sept. 10 05:48 /dev/md1p2

Comment: terminal says sudo: mdadm: command not found.
Comment: Also I don't understand "set chunk size according to your array chunk size". And yes I understand the importance of setting up the array on a system startup but for now I am trying to recover data.
Comment: Okay so as I think more about you are saying "And remember that you should build array on every system startup". Do you think I can do a fresh install using a 120GB solid state hd with the two 3TB hd's also and put the install on the 120GB hd without erasing any of the data on the 3TB hd's.  If so please give me a little direction so that I feel confident that I'm doing it write
Comment: I changed my answer, check it.


Weird markdown rendering

Question: The rendering for <code>**t**op</code> in the answer in Two-column itemization with title in each column appeared as top. Is this a known bug in this site?
Comment: I just found this post: [Where to report bugs about this site?](http://meta.tex.stackexchange.com/q/1456). So my follow-up question is a duplicate. *This* is the right place to ask. `:)`
Answer: Intra-word emphasis by Markdown is not supported, by design:

Three Markdown Gotchas (SO blog post)
WMD unable to render markup inside words (meta.SO)
Similar: Markdown handles inline bold text (within a word) incorrectly

Weird markdown rendering


Road Bike £600 or under

Question: I've been serious about riding for the last year however have taken a while to save up. I want a bike that I can rely on. I ride on average 7/8 hours a session.
I'm 20 year old male and 182cm.
Answer: Last seasons models usually go for a big discount so its worth trying to find one, are you prepared to wait if needed. Consider the used bike market if you know what you are looking at, or have a mate that can help out. Even if you don't have the skills, a LBS might have used bikes. Best bike for buck for someone who is not familiar with bikes is to buy used from the LBS.
Any bike in that price bracket will be reliable. They get reliable as soon as you leave the department stores and go to a bike shop.
For those hours in the saddle, far more important that any bits of paper describing the will tell you is the bike fit. Most important is go to a real bike shop, not a department store. I would recommend a cheaper bike and paying for a proper bike fitting session, decent shoes and pedals, and good bike shorts/bibs. No point spending all your money on the bike and having a poor fit and uncomfortable cloths.
Comment: Just curious:  Did you vote to close and then answer or the other way around?  ;-)
Comment: As a side note, the type of bike you buy is highly dependent on riding style (and terrain - for example, rough terrain may dictate having clearance for fat tires and a touring bike for doing time trials doesn't really make sense). You will find different geometries and accessories (e.g. bottle mounts) when buying a bike which must be taken into account before purchasing, so talking to someone at a good bike shop can point you to the type of bike you want (and fit is critical).
Comment: Voted to close, but immediately thought an equally broad but still helpful answer was possible...

Road Bike £600 or under


Why does Julie always sneak into Jamie's room by ladder?

Question: In 20th Century Women (2016), why does Julie always sneak into Jamie's room by ladder?
Comment: I'm confused by the question.  Is it 'why is she sneaking in' or specifically 'why a ladder'? She's actually using a tree and scaffolding combo, incidentally.
Answer: She's sneaking in because she doesn't want Jamie's mother to know that she occasionally spends the night with him.
As for how she gets in...it's scaffolding not a ladder as such although there would be a standard 'ladder' portion of the scaffolding to make it easier to climb.


How are signs affected without swords?

Question: I've found online that apparently your signs deal a lot more damage if you don't have any sword equipped or you have your sword sheathed. But does it also affect the power of your Quen shield for example? And what about other signs? Does having no swords for example simulate a double sign intensity maybe? Does anybody know this?
Answer: It affects every sign. Tested on Alt Yerden. It does appear to be about double intensity.
Since you mentioned Quen specifically, yes, it does get the increase, but quen doesnt scale well with intensity, so you might not notice.
Comment: And is this only a damage increase or also slowdown and duration? Basically what I'm asking is whether having no swords only increases damage or increases overall sign intensity?
Comment: It increases intensity

How are signs affected without swords?


Finding the anti-derivative of $ \frac{e^{-c y^2 }}{y\sqrt{y^2-1}}$

Question: I am trying to evaluate the integral
\begin{align}
\frac{1}{2\sqrt{2}\pi}\int_{0^{-}}^{t} ds \ \frac{e^{-x^2/2S^2(t,s) }}{\Sigma(s) S(t,s)}
\end{align}
where $S(t, s) = 2D(t-s)+\frac{\Sigma(s)}{2}$ and $\Sigma(s)= \sigma^2+2Ds$. I found a rather neat change of variable by taking $\xi=S^{-1}(t,s)$ so that
\begin{align}
\Sigma(s)&=\sqrt{2} \ \xi^{-1}\sqrt{\xi^2\Sigma^2(t)-1}\\
2D(t-s)&=2 \ \xi^{-2}-\Sigma^2(t)\\
ds&=\frac{2}{D\xi^3}\ d\xi
\end{align}
Applying this to the integral gives the result
\begin{align}
\frac{1}{2 \pi D}\int_{\sqrt{2}/\Sigma (2 t)}^{\sqrt{2}/\Sigma (t)} d{\xi} \ \frac{e^{-x^2 \ \xi^2/2 }}{\xi\sqrt{\Sigma^2(t)\xi^2-1}}=\frac{1}{2 \pi D}{\int_{\xi_L}^{\xi_H} d{\xi} \frac{e^{-x^2 \ \xi^2/2 }}{\xi\sqrt{\Sigma^2(t)\xi^2-1}}}.
\end{align}
and at last applying the change of variable $y=\Sigma(t)\xi$ gives
\begin{align}
\frac{1}{2 \pi D}{\int_{\xi_L}^{\xi_H} d{\xi} \frac{e^{-x^2 \ \xi^2/2 }}{\xi\sqrt{\Sigma^2(t)\xi^2-1}}} = \frac{1}{2 \pi D}{\int_{\sqrt{2}\Sigma(t)/\Sigma(2t)}^{\sqrt{2}} d{y} \frac{e^{-(x^2/2\Sigma^2(t)) y^2 }}{y\sqrt{y^2-1}}} =\frac{1}{2 \pi D}\color{blue}{\int_{a}^{b} d{y} \frac{e^{-c y^2 }}{y\sqrt{y^2-1}}}
\end{align}
Above calculation indeed check out numerically.

It seems the integral in blue could have an anti-derivative. However, no luck just yet!  Someone who knows a way forward? Many thanks in advance!
Comment: @drandran12 By no closed form I mean it can't be represented using elementary functions. Another way to look at it is to rewrite the integral problem as the solution of the DE $f'(x)=e^{-cx^2}/(x\sqrt{x-1})$. Writing $f(x)=e^{-cx^2}\sqrt{x-1}g(x)$ yields the ODE $$(x^2-x)g'(x)+(-2cx^3+2cx^2+x/2)g(x)=1$$ where the high-order polynomial terms strongly indicate a lack of a closed form (even more so when $c$ is arbitrary).
Comment: Evaluating the integral , there is nothing to solve
Comment: There is no closed form even in the case $a=0$ and $b=\infty$ as the integral becomes the Laplace transform of $1/(t\sqrt{\sqrt t-1})$.
Comment: @TheSimpliFire thanks for the answer! Do you have a prove or source to support the claim? Or do you know of a method to prove an integral has no closed form? Many thanks in advance!
Comment: @TheSimpliFire I know what you meant by "no closed form" :) However, why does the high-order polynomial terms strongly indicate a lack of a closed form? Sorry for the maybe stupid question :/
Comment: @drandran12 In general integrating reciprocals of high-order polynomials isn't exactly a nice process.
Answer: As others have pointed out, no closed-form solution in terms of elementary functions can be found. However, if you can live with the error function and the Owen T function then a closed-form solution can be found in terms of these special functions.
I will assume the error function $\operatorname{erf} (x)$ is well known to you. An integral representation for the Owen T function we intent to use can be found here. It is
$$\operatorname{T}(h,a) = \frac{1}{2\sqrt{2\pi}} \int_h^\infty e^{-x^2/2} \operatorname{erf} \left (\frac{ax}{\sqrt{2}} \right )\, dx.$$
Enforcing a substitution of $x \mapsto x \sqrt{2}$ gives the following form that will be found most convenient for the integral considered here:
$$\int_z^\infty e^{-x^2} \operatorname{erf}(ax) \, dx = 2 \sqrt{\pi} \operatorname{T}(z \sqrt{2}, a). \tag1$$
Now let us look at the integral in question. Let
$$I(t) = \int_a^b \frac{e^{-tx^2}}{x\sqrt{x^2 - 1}} \, dx, \quad t > 0.$$
I will assume $1 < a < b = \sqrt{2}$. Note that $I(\infty) = 0$ and we are required to find $I(c)$ where $c > 0$. Using Feynman's trick of differentiating under the integral sign with respect to $t$ gives
$$I'(t) = - \int_a^b \frac{x e^{-tx^2}}{\sqrt{x^2 - 1}} \, dx.$$
Enforcing a substitution of $u^2 = x^2 - 1$ yields
\begin{align*}
I'(t) &= e^{-t} \int_{\alpha_1}^{\alpha_2} e^{-tu^2} \, du = -\frac{\sqrt{\pi} e^{-t}}{2\sqrt{t}} \operatorname{erf}(u\sqrt{t}) \Big{|}_{\alpha_1}^{\alpha_2}\\
&= -\frac{\sqrt{\pi} e^{-t}}{2\sqrt{t}} \left [\operatorname{erf}(\alpha_2 \sqrt{t}) - \operatorname{erf}(\alpha_1 \sqrt{t}) \right ].
\end{align*}
Here $\alpha_1 = \sqrt{a^2 - 1}$ and $\alpha_2 = \sqrt{b^2 - 1}$.
Now, as
$$\int_c^\infty I'(t) \, dt = I(\infty) - I(c) = -I(c),$$
since $I(\infty) = 0$, we have
$$I(c) = -\frac{\sqrt{\pi}}{2} \int_c^\infty \frac{e^{-t}}{\sqrt{t}} \left [\operatorname{erf} \left (\alpha_2 \sqrt{t} \right ) - \operatorname{erf} \left (\alpha_1 \sqrt{t} \right ) \right ] \, dt.$$
On enforcing a substitution of $t \mapsto t^2$ one obtains
$$I(c) = \sqrt{\pi} \int_{\sqrt{c}}^\infty e^{-t^2} \left [\operatorname{erf}(\alpha_2 t) - \operatorname{erf}(\alpha_1 t) \right ] \, dt.$$
Evaluating this integral in terms of the Owen T function, from (1) one immediately sees that
$$I(c) = 2\pi \left (\operatorname{T} \left (\sqrt{2c}, \alpha_2 \right ) - \operatorname{T} \left (\sqrt{2c}, \alpha_1 \right ) \right ),$$
or
$$\int_a^b \frac{e^{-cy^2}}{y\sqrt{y^2 - 1}} \, dy = 2\pi \left (\operatorname{T} \left (\sqrt{2c}, \sqrt{b^2 - 1} \right ) - \operatorname{T} \left (\sqrt{2c}, \sqrt{a^2 - 1} \right ) \right ),$$
the required closed-form expression for our integral.
Note, if $b = \sqrt{2}$, as it appears to be from the question, further simplification of one of the Owen T functions is possible. As can be seen here when the right argument of the Owen T function is unity
$$\operatorname{T} \left (\sqrt{2c}, \sqrt{b^2 - 1} \right ) = \operatorname{T} \left (\sqrt{2c}, 1 \right ) = \frac{1}{8} \left [1 - \operatorname{erf}^2 \left (\sqrt{c} \right ) \right ],$$
allowing one to write
$$\int_a^{\sqrt{2}} \frac{e^{-cy^2}}{y\sqrt{y^2 - 1}} \, dy = -\frac{\pi}{4} \left [8 \operatorname{T} \left (\sqrt{2c}, \sqrt{a^2 - 1} \right ) + \operatorname{erf}^2 \left (\sqrt{c} \right ) - 1 \right ].$$
Comment: Wow, thank you very much! As you can see from my previous questions, I am very familiar with the error and Owen T function. So I am very happy with the solution you found!
Answer: If $$f(x)=\frac{e^{-x^2}}{x\sqrt{x^2-1}}$$ then the integral $I=\int_a^bf(x)dx, b>a$ is not only convergent for all $a>a_0$ where $a_0$ is the root of $1/x=f(x)$, but  also $f(x)\in[0,1)$, which gives a hope of some closed form of the definite integral. At least, a very close approximant. Like, the transformation $x=\sec t$ gives for the integral $$\int_\alpha^\beta e^{-\sec^2t}dt$$. A silver lining of hope.
EDIT
If we consider $E(x)=\int_0^x e^{-\sec^2t}dt$, although the Taylor expansion is a little hopeless:
$$
e^{-\sec^2x} = \frac{1}{e} \left( 1 - x^2 - \frac{1}{6}x^4 + \frac {11}{90}x^6+O (x^8)\right)
$$
The denominators are the sequence $$a_n = \frac{(2n)!}{2^n} $$, and I'm not sure of the numerators. Yet, via some graphing it can be seen that the following is approximately correct.
$$
e^{-\sec^2x} \approx e^{-1-x^2}(1-\alpha x^4), \text{where } \alpha \in \left[ \frac{2}{3},\frac{5}{6} \right]
$$
Therefore, a crude approximation,
$$E(x)=\frac {\sqrt\pi}{8e}(4-3\alpha) \text{erf} (x) + e^{-1-x^2} \left( \frac{x^3}{2} +\frac{3x}{4} \right) $$
Comment: The integral of $e^{-\sec^2t}$ isn't elementary, as far as I'm aware.
Answer: The integral in question doesn't have an elementary anti-derivative for all $c$. For example, consider the case where $c=1$:
$$I = \int_1^{\sec{x}} \dfrac{e^{-y^2}}{y\sqrt{y^2-1}} \textrm{d}y$$
By making the substitution $y=\sec{t}$, we may observe the following:
$$I = \int_0^x e^{-\sec^2t} \textrm{d}t$$
Now, I don't know much about this new integral, but I do know that $$I = \int_0^{\frac{\pi}{2}n} e^{-\sec^2t} \textrm{d}t = \dfrac{\pi}{2}n \left(1-\textrm{erf}(1)\right)$$
which gives me the feeling that the integral which you are trying to solve is non-elementary.
Answer: Firstly,
$$I(z,c)=\int\limits_z^{\sqrt2} \dfrac{e^{-cy^2}\,\text dy}{y\sqrt{y^2-1}}
=e^{-c}\int\limits_z^{\sqrt2}\dfrac{e^{-c(y^2-1)}}{y^2}\,\text d\sqrt{y^2-1}
= e^{-c}\int\limits_{\sqrt{z^2-1}}^1 \dfrac{e^{-ct^2}\,\text dt}{t^2+1}.\tag1$$
At the second, are known the integrals
$$\int\limits_0^\infty \dfrac{e^{-ct^2}\,\text dt}{t^2+1}\,\text dt
= \dfrac\pi2 e^c\operatorname{erfc}\sqrt c,\tag2$$
$$\int\limits_0^1 \dfrac{e^{-ct^2}\,\text dt}{t^2+1}\,\text dt
= \dfrac\pi4 e^c\left(1-\operatorname{erfc}^2\sqrt c\right),\tag3$$
with the closed form of
$$I(1,c)=\dfrac\pi4\left(1-\operatorname{erfc}^2\sqrt c\right).\tag4$$
Besides,
$$\int\limits_0^a \dfrac{t^{2k}\,\text dt}{t^2+1}\,\text dt
= -\dfrac i2 (-1)^k \operatorname{B}\left(-a^2,k+\dfrac12,0\right),\tag5$$

$$\int\limits_0^a \dfrac{e^{-ct^2}\,\text dt}{t^2+1}\,\text dt
= \sum\limits_{k=0}^\infty (-c)^k\int\limits_0^a \dfrac{t^{2k}\,\text dt}{t^2+1}\,\text dt
=-\dfrac i2 \sum_{k=0}^\infty c^k\operatorname{B}\left(-a^2,k+\dfrac12,0\right),\tag6$$
$$I(z,c)=I(1,c)-e^{-c}\int\limits_0^{\sqrt{z^2-1}} \dfrac{e^{-ct^2}\,\text dt}{t^2+1}\,\text dt,\tag7$$
$$I(z,c)=I(1,c) + \dfrac i2 e^{-c} \sum_{k=0}^\infty c^k \operatorname{B}\left(1-z^2,k+\dfrac12,0\right).\tag8$$
Therefore, in the common case the given integral $(1)$ can be presented by the series $(8),$ which is not a closed form.
Comment: Thank you, Yuri! I gave the bounty to Omegadot, since the answer is easier to work with for me in the future. Nevertheless, I want to personally acknowledge and credit you for this nice result!
Comment: @drandran12 Thank you too. Of course, closed form is better.


How can we use a IP to get the Geolocation Data using Here API

Question: I was looking at the Here Documentation to convert the IP to Geo data but all the links Correspond to having Geo data from Lat and Long is anything am i missing.
Comment: Just to clarify you want to use IP to get geolocation data instead of lat long?
Answer: HERE doesn't have a product like IP Geolocation API (get geo-coordinate by only IP-address).
You need to use a third party API for that.(E.g.: commercial http://www.ip2location.com/ or Free http://search.cpan.org/dist/GeoIP2/)
HERE has the product Positioning API
The HERE Positioning API enables developers to build applications that require location estimates based on radio network measurement data. The supported measurement data includes 2G, 3G, 4G, and WLAN measurements.


Temperature lag forecasting

Question: I am working on a data science project on an industrial machine. This machine has two heating infrastructures. (fuel and electricity). It uses these two heatings at the same time, and I am trying to estimate the temperature value that occurs in the thermocouple as a result of this heating. However, this heating process takes place with some delay/lag. In other words, the one-unit change I have made in fuel and electrical heating is reflected in the thermocouple hours later. I want to find these hours, i.e. I'm trying to calculate the temperature change delay time on the thermocouple for the change in fuel and electricity. These three data are non-stationary time series data. I have data in frequency per second. I thought of using cross correlation but having two different heat sources confuses me. Which method do you think is better to use? Also, should I keep them in units like kwh/m3 or convert them to heat calorie units?
Answer: Time series in an industrial environment might be difficult, as there could be several external features (such as the ambient temperature that might change with seasons), in addition to the heat sources you've mentionned.
Consequently I would suggest to modelize the heat conduction with a thermal physics library (ex: https://github.com/ElsevierSoftwareX/SOFTX_2018_105) in order to have an accurate understanding of the influence of each heat source, and not doing mistakes mixing impacts on the system.
Then, it should be much easier to evaluate the impact of each source and make reliable time series predictions, as you can accurately estimate the heat impact later on the system.
This conduction heat modelling doesn't need to be very detailled: as long as the conductive components can be represented in a simple way and be able to make accurate results, it is good enough.
However, in order to modelize the impact of the heat source, it would be better to know the influence of each heat source separatelly, and then evaluate the impact using both sources at the same time: the physical behavior is generally not linear when there are 2 different sources in parallel.

Temperature lag forecasting


File upload php with file array

Question: i try to upload files into my server also to my database.
However, i cannot upload them.
I can see my two files with below code,
echo $_FILES['file']['name'][0];
echo $_FILES['file']['name'][1];

$fileName = $_FILES['file']['name'][0];
$add = "img01.imgsinemalar.com/images/haber_anasayfa/" . $fileName;

if (move_uploaded_file($_FILES[file_up][tmp_name], $add)) {
    NCore::db('NEWS')->insertAsArray(array('CONTENT' => $_POST['TvSpotdesc'], 'ADD_DATE' => $date, 'TITLE' => $_POST['newsTitle'],IMAGE_MAIN => $add))->execute();
    echo "Haber başarıyla gönderildi.";
} else {
    echo "Failed to upload file Contact Site admin to fix the problem";
}else {
    echo $msg;
}

But above code does not upload my files, it goes directly to the else statement, why?

Failed to upload file Contact Site admin to fix the problem
Answer: Your code should be outputting two notices and a warning from this line:
if (move_uploaded_file($_FILES[file_up][tmp_name], $add)) {

The two notices would be because you have not quoted file_up and tmp_name and the warning to inform you of the reason move_uploaded_file has failed, as documented. You should check out the logs to see these for yourself (development without seeing any error messages is not fun).
The reason it fails is that you cannot move a file to a remote server -- $add is not a local path.
Answer: Rename $_FILES[file_up][tmp_name] to $_FILES['file']['tmp_name']
There is no such variable as file_up as per the code you pasted. Also, files can only be stored on the same server. so gove relative path like /home/www/myapp/images/ instead of server name.

File upload php with file array


Master Detail Relationship question

Question: i have master-detail relationship between A&B object where A is master and B is child. Now when a record is created in object B by a user, it is visible by other user also. Is their any way to stop the visibility of a user record to other user.
Answer: Go to Setup / Sharing Settings / find your child object, and set its default visibility to "private" .
Comment: Child object is controlled by parent therefore  am not able to set to private
Answer: Visibility is usually managed by sharings. If you set the sharing of the Master object to private in Organization-Wide Sharing Defaults, only the owner of the record and people in roles above could see the record. There are plenty of ways to configure visibility.
Comment: If we set set the visibility of master to private then users will not be able to see master object records. Actually records in master object is created by admin. users should not touch master object records(but they need to see) whereas they need to work only on child object. since one field is master detail in child object, all users can each other record(need to stop this).

Master Detail Relationship question


What is the earliest work to have a species deliberately falsify its level of technology?

Question: I am looking for the earliest example of a work where a species pretends to be at a much lower or higher level of technology than the one it has achieved. An example of this would be the Organians in Star Trek, who initially pretend to be at a medieval level of technology but are actually extremely advanced aliens who have become pure energy. For clarification purposes, there has to be more than one member of the species falsifying the technology level and the contact has to be the first one.
Comment: David and Goliath. David pretends to be a meek shepherd with no weaponry but actually has a powerful sling.
Comment: Perhaps surprisingly, this does not actually occur in the *True History* by Lucian of Samosata.
Comment: I meant that the species as a whole is falsifying their overall level of technology, not just one member.
Comment: @Valorum but the Federation and Klingons both seem to think they are representative of the level of technology of "Organians" in general, so whatever contact they've had in the past must have been with ones putting on the same pretense
Comment: We only see a few Organians..
Comment: The "Rhthians" (far future Earthians) of Campbell's 1937 novelette ["Forgetfulness"](https://archive.org/details/Astounding_v19n04_1937-06_-ibcbc_fiche-paper/page/n53/mode/2up) are not nearly so harmless or vulnerable as they appear to the would-be colonizers from Pareeth, but I'm not sure you would call their powers "technology" nor that they are guilty of "deliberate falsification".
Comment: Does it have to be aliens pretending to be lower tech?  There are a bunch of stories where humans (try to) disguise their technology from aliens.
Comment: @DavidW Both are okay. It is also okay for the species to pretend to have a technology that it does not have.
Comment: So, effectively, "what's the first work where human explorers disguise themselves as natives for first contact, or aliens disguise themselves as human?"
Comment: ["Mars is Heaven!"](https://en.wikipedia.org/wiki/Mars_Is_Heaven!) by Ray Bradbury sort of fits and was originally published in 1948, though perhaps it's ambiguous since we only see the Captain's theory that the Martians deceived the crew with telepathy which might be a natural ability, and their actual technology level isn't revealed (but then the Star Trek episode "Errand of Mercy" doesn't show the Organian transformation into powerful energy beings was due to technology either, Spock just says they are "far above us on the evolutionary scale")
Comment: @DavidW I just used the Organians as an example for familiarity. A better example of what I intended is Poul Anderson's "Question and Answer" in which the Rorvans pretend to be natives at an Industrial Revolution level when they are actually equal to the humans in their technology.
Answer: The same novel as my most recent answer, Isaac Asimov's Second Foundation  is a good candidate. Second Foundation is a fixup of two novellas serialized in Astounding Science Fiction between 1948 and 1950.
During the Mule's search for the Second Foundation in the first half of the novel, he visits Hari Seldon's homeworld Trantor in an attempt to discover information about the SF's whereabouts.
The Mule and his companion/captives are confronted by some rustic farmers, the "Hamish-folk", in an area of Trantor cleared of buildings. There is a lot of bluster about not knowing about any "scowlers".
But at the end of the novel we discover that these rustic farmers

 are actually the Second Foundation, secretly guiding the Galaxy back towards civilization according to Hari Seldon's plan.  They have developed the science of psychohistory and their mental abilities to the point they can control things from  subsistence farms on a ruined planet. They were, in fact, the reason for the Mule's losing his ability to mentally control others (and thus his power) at the end of the first part of the novel.
Comment: *Second Foundation* consists of two novellas originally published serially between 1948 and 1950, making it even earlier.
Comment: @KlausÆ.Mogensen If it's  OK with you, I'll put that in the answer.
Comment: Quite OK. Specifically, "Part II: Search by the Foundation" was originally published in the November and December 1949 and January 1950 issues of *Astounding Science Fiction* under the title "...And Now You Don't".
Answer: Around the same time-frame as @Spencer's answer, the Lensman series by E. E. Smith, the first novel (Triplanetary) of which was published in 1948, but initially serialized in 1934, has not just one, but 3 species that present on lower technological scales than they really are.
The first (and as shown in Triplanetary) has humans presenting as lower technological capability than the Nevians - the main protagonist of much of this novel is Conway Costigan, who after being captured by the Nevians, pretends that he can't even do simple chemistry, while manufacturing poisons to enable him to escape captivity. He also uses "sub-etheric spy-rays" and is communicating with other captured humans without the Nevians knowing.
Triplanetary also has an Eddorian (overall bad guys), known as "Grey Roger", who are amoeba-like creatures of immense mental and physical powers, presenting as a human controlling a space-station sized warcraft via buttons and switches etc, rather than by his mental powers, as he is fully capable of doing.
The titular Lensmen get their powers from lens devices given to them by Arisians (overall good guys). The Arisians are vastly capable mental beings - capable of visualizing the cosmic all, but pretend that they are incapable of damaging even one of the Eddorians to lull the Eddorians into a false sense of security, so that they can be eventually overcome and won't develop technology to prevent this. I think this event happens in the second novel First Lensman, which was published in 1950.


How to describe a contained map in UML class diagram?

Question: I have a MyServer class that contains a Map whose keys are MyClientType objects and whose values are MyClient objects. I'd like to depict this relationship in a class diagram but I can't figure out a clean way to do that.
Answer: You can use a qualified association:
┌──────────┐             1 ┌───────┐
│ MyServer │Key│───────────│ Value │
└──────────┘               └───────┘

See: http://etutorials.org/Programming/UML/Chapter+6.+Class+Diagrams+Advanced+Concepts/Qualified+Associations/ (cause it is hard to draw using ASCII)
Note also that a qualified association changes the multiplicity:
┌──────────┐          0..* ┌───────┐
│ MyServer │───────────────│ Value │
└──────────┘               └───────┘

┌──────────┐             1 ┌───────┐
│ MyServer │Key│───────────│ Value │
└──────────┘               └───────┘

The top illustrates an association from a server to 0-n values.  By contrast, the qualified association says that any given key will be associated with only one value, and that you can't have a key an absent value.
Comment: If MyServer was "expanded" to show operations and attributes, what would go inside the attribute compartment of MyServer to model the map relationship?
Answer: I would just show an association from MyServer to MyClient with a multiplicity of 0..* at the MyClient end. Everything else is implementation detail and can be left to the programmer.
Comment: I upvoted solely because the username is chimp ... not. Nice name AND nice answer.
Answer:            MyServer
               |
               |*
            T1toT2
            /    \
          1/      \1
         Key     Value

The difference to Mark's solution is that the server has a many-relation to the containers. That's also how the Eclipse Modeling Framework (EMF) proposes to implement maps.
You might also throw in some more UML-specific things, like specifying that the keys have to be unique (through stereotypes).
Answer: First of all I and some others think, UML should contain some basic collection types as it did in some earlier versions. They could be taken for example from the OCL...
The "EMF way" seems right, however it gives imho too much importance to the to type, which is really unimportant imho, so I would model it just as an association class. This will enable you to capture all map specific constraints (as e.g. multiplicity) which can be captured using regular class, but won't make that class as important as the other ones.
Answer:              MyServer
                 |
                 |
                 |
                Map
                 |
                | |
               |   |
  MyClientTypeKey   MyClientType

Should it not be quite simple like above?

MyServer has a one to one assoication with the Map
The Map has 1 to many associations with both the keys and values.
Comment: That's the first thing that came to my mind as well, but it feels the map doesn't deserve to be a class. It's just a method of containment. I don't know, just doesn't feel right.
Comment: But then just, say, having the key and type classes directly associated with MyServer doesn't show how they are related. The Map is a container but also shows the relationship between the key and type.
Answer: Kru's answer is the best, but it still only hints at a Map.
I would argue it depends on the level of abstraction at which your diagram sits.  If it's relatively high, I'd go with chimp's response.  If it's relatively low and you really need to show a map, intentionally showing implementation-related detail, I'd go with the following:
           MyServer
               |
               |
              Map
               |
               |*
            T1toT2
            /    \
          1/      \1
         Key     Value

How the map is then implemented in code is totally irrelevant (T1toT2 run-time objects might not actually come to be).
As mentioned by Gabreil, this could be also be modelled using an association class
           MyServer
               |
               |
              Map
               |
               |*
            T1toT2
               |
               |
          1--------1
         Key     Value

Of course is only matters if you really really need to show or specify a map.