Is it possible to use HKDF in the TPM?

Question: Is it possible to use HKDF in the TPM?  My goal is to load in a master symmetric key and derive keys from that using HKDF.  I see there are other KDF functions available, but no mention of HKDF.
Answer: If it isn't in the spec it isn't in there. The question is if you need it if e.g. the NIST SP 800-108 KDF in counter mode is present. That's a fine KDF even if it lacks explicit extract / expand steps and salt. So I think you are only in big trouble if you need

extract functionality;
HKDF because of protocol compatibility.

There seems to be HMAC, but that is of little consolation: if you wanted to have the output key material as message outside of the TPM, then you wouldn't be needing the TPM. Furthermore, the Input Key Material (IKM) is used as HMAC message in HKDF-extract, so even the IKM won't be protected.
PS If you want to look for yourself: you find the algorithms in the document "Part 2: Structures", of all places:

Algorithm Name
Value
Reference
Comments

PM_ALG_KDF1_SP800_56A
0x0020
NIST SP800-56A
concatenation key derivation function (approved alternative 1) section 5.8.1

TPM_ALG_KDF2
0x0021
IEEE Std 1363a-2004
key derivation function KDF2 section 13.2

TPM_ALG_KDF1_SP800_108
0x0022
NIST SP800-108
a key derivation method Section 5.1 KDF in Counter Mode
Comment: One of the problems with HKDF is that it uses the IKM, the input keying material in the message part of HMAC. So if you have a hardware implementation of HMAC where the key is protected, it will probably only protect the input key, which - for HKDF extract - would be the salt. At that point you might as well use software. Sorry, I can only point out when I think it is not possible with version 2 of the TPM...
Comment: Thanks for the answer.  Unfortunately, I do need HKDF for protocol compatibility, which also implies that I need the extract functionality.  Since the extract operation is only a single HMAC calculation, I was hoping there would be a way to achieve the same calculation without explicitly using a built-in HKDF command.
Comment: That is the exact issue that I'm running into.  I thought there might be a way to work around it.  One thought was to load the master key into an NV register and then use TPM2_NV_Extend to perform the HMAC steps.  However, I'm not finding any way to load an NV register with an existing symmetric key.  Are there any other roundabout ways you can think of to make this work, @Maarten?
Comment: I'm not that deep into TPM yet, but in general it seems that you are trying to do exactly the thing that any hardware key store / TPM is trying to defend against (other than leaking the key values, of course). For that reason I would be extremely surprised if there was a solution to this problem - but I've been surprised before.
Comment: That makes sense.  I really appreciate your help with this, but am wondering if this question might have a better chance of reaching a TPM expert if it was migrated to the Information Security site.  I see you are moderator - would you be willing to do that @Maarten?

Is it possible to use HKDF in the TPM?


How to batch import images as brush textures?

Question: I have a folder with some b&w images that I want to use as brushes textures while sculpting.
Is there a way to automatically load these images as brush textures, or do I have to do it one by one?
Answer: There is an addon just for this, Import BrushSet. You can download the addon from here.
After you have it installed, simply click on File > Import > Brush Set.

You have to choose a folder (don't pick any images, just the folder) and the addon will import all the images in that folder and set them up as brush textures. (It would be a good idea to make a separate folder with only the images you want to import)
It's as simple as that.
Comment: Also another addon that is similar but supplies a way to determine the fiel location and also enables deleting any brush images not currently in use, clearing the cache is load_alphas at https://github.com/amb/blender-scripts/blob/master/load_alphas.py


Running a application made for Ubuntu 12, 14 or Windows on a Raspberry Pi

Question: I need to install an ebeam edge which need driver. It only works on Windows / Ubuntu. How do I know if I can make it run on Ubuntu Mate or Windows IOT on my Raspberry Pi? Do you think it is possible?
Comment: I don't suppose you've got the Bluetooth version?
Comment: Is the source code available ? I guess not. There is no chance this software runs on the Pi at all. Linux != x86_64 , my friends.
Answer: The short answer is no, you can't install this application to run on a Raspberry Pi, regardless of which OS you decide to put on it.
As far as I can tell from their website, their applications require an x86 processor to run. Unfortunately, for your project, all current models of the RPi have an ARM processor. They're fundamentally different, and are not compatible.
We have a blog post that gives a fairly broad explanation of the idea.


Phusion Passenger 4 & nginx cannot see environment variables in Ubuntu Linux

Question: According to the documentation at https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#env_vars_passenger_apps 15.3.5 Phusion Passenger should be reading environmental variables from .bashrc. I am trying to run a rails 4.2 application from a user account named rails using nginx and Phusion passenger and get a 502 bad gateway error when I try to load it in the browser. The process operates under the correct user. When I open a ruby console in the rails app directory I see the environment variables from my bashrc including secret_key_base. However when I tail my nginx log the error I get is that it is not able to find secret_key_base. I have tried adding this elsewhere including /etc/bash.bashrc and /etc/nginx.conf.
Comment: For what it's worth, it's quite common that you have to specify the path of the ruby executable in the server configuration. I don't know offhand how that is done with nginx, but I have been required to do it while configuring apache servers.
Answer: I have found the answer to this horrible question. The answer is at https://github.com/phusion/passenger/wiki/Debugging-application-startup-problems under the heading "Early Termination in Bash". It turns out that the Ubuntu .bashrc does not run if the shell is not interactive. Phusion Passenger does not run in an interactive shell. Therefore we do not load these environment variables for the Phusion Passenger process.
Mike's comment was on track. If you are using rvm then nginx points to a ruby script that you can put the environment variables in before ruby starts.
<code>passenger_ruby /home/rails/.rvm/gems/ruby-2.2.1@was_i_towed/wrappers/ruby;
</code>
Is a line in my nginx.conf file. If I open this wrapper in vi or nano then I can add the EXPORT SECRET= to the top of the file and it works.
Other literature suggests that setting the environment variables in /etc/environment should also work.
This issue should also be rendered moot when upgrading to Phusion Passenger 5 which has a facility for specifying environment variables in nginx.conf.
Comment: Thanks a lot for posting back the answer, definitely this is not something very easy to figure out, just for future reference I'm on RHEL 7 and my vars are declared on /etc/environment and still it didn't work. Adding the command source /etc/environment from within the wrapper as you described did the trick.
Comment: A bad news is Passenger 5 on Apache still has the problem.


XNA seams between 3d primitives in tiled terrain

Question: Every time I draw two primitives side by side, in this case two quads, I always get this seam-like tearing effect right along the sides of them. I'd like to think there is just an easy fix, but the only way I can think of would be reworking my indices, which I think would compromise my ability to draw textures. If anyone reading this can think of any fix, that would be great. Thanks in advance.
Answer: There's two ways you can fix this.

You can apply a half pixel offset to the corners, to make sure you have UVs that point to the center of a texel.
You can change your sampling mode to POINT sampling, for Mag, Min, Mip, AddressU and AddressV sampler states, like "untitled" mentioned.
Comment: See this SO post for more details http://gamedev.stackexchange.com/questions/46963/how-can-i-avoid-sampling-artifacts-from-adjacent-tiles-in-my-texture-atlas/49585#49585
Answer: That looks more like a graphical artifact stemming from the texture that you are applying. It would be good if you gave some more information about how you are defining the quads, what vertex structure you are using and what effect you are using to render the quads.
Answer: If you're using a texture atlas, What sampler states are you using?
Try using magfilter = POINT, minfilter = POINT, mipfilter = POINT, AddressU = WRAP, AddressV = WRAP


Is Saturday night before or after Saturday?

Question: People sometimes write something like "let's finish this work by Saturday night" or "let's meet on Saturday night". Which day and time do they mean? Is it short for tonight, and then it's on Saturday somewhere between 6pm and 11:59pm, just before Sunday starts? Or is it after midnight, which is after Friday evening, when Saturday just starts?
Comment: Technically, after midnight is early Saturday _morning_, not Saturday night, although some people might refer to those wee hours of the morning as a continuation of Friday night. (I can say, "Last night, we went to the concert, and then I crashed at Tony house," even if we didn't get to Tony's until 1 o'clock in the morning). But this question is so basic I'm afraid I'll have to vote to close – people simply don't refer to after midnight Friday as "Saturday night."
Comment: Saturday night comes between Saturday and Sunday.
Comment: @tchrist: In some contexts, 6PM is indeed the boundary between "afternoon" and "evening". (I believe TV listings use that convention, for example.) That said, I agree with you, 6PM is hardly an official start of "night" in all contexts.
Comment: Who told you that "night" begins at 6pm?  That would be unusual, for twilight to end at 6pm exactly.  The sun is rarely so punctual. Also, when people talk about daytime and nighttime, they pay no heed to this 11:59 thing.
Comment: Re closing comment " It can be definitively and permanently answered by a single link to a standard internet reference source designed specifically to find that type of information." No. It can not. It's one of those "tricky little question" that does NOT have an exact answer (see my answer) and is worth exploring philosophically.
Comment: Here again 8 years on - the close reason is STILL wrong. My answer just received a "Lifejacket badge" - question previously -2 or less, now +2 or more, answer +5 or more.
Answer: This is trickier than most admit. Some answers say Saturday night stops at midnight BUT do not properly consider the early hours of Saturday.
"Saturday night" when used without special explanation or if not in an understood special context will be taken to mean the period from approximately sunset onwards on Saturday. Whether it stops at midnight depends on context.
If you are only referring to a period of time somewhere between midnight and dawn on Saturday you would definitely call it "Saturday morning" or early morning or similar. So too you'd call the 1st 6 hours or so "Sunday morning".
BUT if you worked from 7pm Saturday to say 6am Sunday you might say "I worked all Saturday night", or "I worked all Saturday night- right through to morning".
You could say "... Sunday morning..." in that context but if you did not, nobody would feel you had said something wrong and all would understand what you meant.

If you are Orthodox Jewish then each day ends at 6pm, so Sunday begins at 6pm on week-day-Saturday. How they  define "Saturday night" is unknown to me. Properly there is no night at the end of Saturday so arguably all the night period is at the start of the day, so "Saturday night" starts at week-day-Friday 6pm.
In dealing with the Jewish holy day of Saturday, Wikipedia - Shabbat says

According to halakha, Shabbat is observed from a few minutes before sunset on Friday evening until the appearance of three stars in the sky on Saturday night.[1]
Answer: Saturday night is the night before Sunday or Sunday morning. So if you have already entered Saturday, you could say tonight is Saturday night, which is the start of Sunday.
Answer:
"let's finish this work by Saturday night" would be some time between the time said and midnight Saturday.
"let's meet on Saturday night" would be after dusk and before midnight Saturday.
Comment: I don't agree with the implied midnight deadline; certainly not in all cases. (I could see finishing a project at 12:45 AM, and thinking I had accomplished my goal – only a pedant would argue that we hadn't completed the work "by Saturday night" simply because our efforts extended past midnight). "By Saturday night" can mean "before we go to bed on Saturday" as easily as "before midnight on Saturday."


what is the probability of a couple who has four girls and is trying again for a boy. what is the probability that the next kid will be a girl?

Question: A couple has four kids already, all girls. the couple would like to have a son and would like to give it another try. what is the probability that the next kid will be a girl?
Comment: half because it's independent of the gender of the previous 4 kids
Comment: Be sure to condition the probability on the husband being Henry VIII.
Comment: On the assumption of independence, the events are independent. Parenthetically, even without sex determination interference, more boys are born than girls. (But quite soon there are more girls: males are more fragile.)
Comment: With data, we could verify if events are really independent. It is not obvious to me
Comment: This is actually a somewhat profound question, 18th century mathematician Pierre-Simon Laplace put it in another context: http://en.wikipedia.org/wiki/Sunrise_problem
Answer: If we presume that we know nothing about the actual probability of having a girl, $p$, then we can use Hinkley's predictive likelihood for the binomial to predict the probability that the next birth will also be a girl, assuming births are conditionally independent, given $p$. This is sensible, since the probability that a couple will have a girl or boy is affected primarily by the X/Y ratio of the male gametes, and to some extent selective factors in the female. Therefore, while overall the bias is slightly toward male births, there will be overdispersion around this mean due to individual propensities that are at odds with the overall average.
Let $g$ be the number of girls born to date and $n$ be the number of children born to-date. For general prediction, we want to know the probability that there will be $r$ girls in the next $s\geq r$ births.
$P(r|g,n,s) = K\frac{{n \choose g}{s \choose r}}{n+s\choose g+r}$, where $K$ is a normalizing constant to make $\sum\limits_{r=0}^s\frac{{n \choose g}{s \choose r}}{n+s\choose g+r} = 1$
In your case, we are dealing with $s=1$ and $n=g=4$, which greatly simplifies things, since  there are only two outcomes ($r=0,r=1$) and ${1\choose 0} = {1 \choose 1} = 1$.
The simplified formula is:
$P(r|4,4,1) = K\frac{{4 \choose 4}{1 \choose r}}{5\choose 4+r}= K\frac{(4+r)!(r)!}{120} = K\left( \frac{1}{5}+\frac{4r}{5}\right)$, (since $r$ can only be $1$ or $0$)
In this case, there are only two values of $r$ so getting $K$ is easy:
$P(r=0|4,4,1) + P(r=1|4,4,1) = 1 \rightarrow K \left( \frac{1}{5} + 1\right) = 1 \therefore K=\frac{5}{6}$
Given the above, the probability that the next child is a girl, given that all 4 previous children were girls, is: $P(r=1|4,4,1)=\frac{5}{6} \approx 83\%$
A more detailed exposition using more sophisticated models can be found here - it studies possible models for the overdispersion of actual sex ratios in the human population, which lends evidence that the probability of having a girl can vary either between families or even within a single family over time.
Comment: How could meiosis possibly be changed to produce a different X/Y ratio? That alters the fundamental aspects of the process.
Comment: @gina If you are indeed using a textbook problem, then I'd suggest qwr's answer, as it uses the prior knowldge that births are likely to be near 50% boys. Mine makes no prior assumptions and so has the potential for more variability.
Comment: $\frac 5 6$ is the answer you get if you assume a uniform distribution of bias towards sex, but here you seem to assume a binomial distribution.  Is that a coincidence or just two different ways of saying the same thing?
Comment: @qwr I don't know the mechanism or why this happens, but the link I showed you observed overdispersion in the intra-family sex ratios, hence there is some sort of pair-effect happening. If there werent, then the undispersed binomial model would do just fine.
Comment: @DanielV you are referring to the Bayesian formulation. Hinkley used a pure likelihood approach, which does not use a prior, but it give you the same answer as a Bayesian estimate with a uniform prior.
Comment: Thanks, this is where the problem I am familiar with solving: http://en.wikipedia.org/wiki/Sunrise_problem
Comment: @Eupraxis1981   While your answer might be correct, I find it very unlikely that there could be an $83\%$ ratio, that X/Y distribution could be so far from normal and no extra info about the family is given in the problem. This answer will probably end up confusing an intro statistics student or someone like that.
Comment: @qwr When it comes to statistics, confusion might be better than incorrect confidence.  I like how Expraxis clearly lays out his assumptions; that isn't done often enough in statistics imho.
Comment: @qwr Of course, this article from chance magazine argues against any special genetic or environmental factors, so the jury is still out. http://www.isds.duke.edu/~dalene/chance/chanceweb/144.rodgers.pdf . Our exchange shows how ambiguous even a simple problem can be.
Answer: i agree. having the 4 girls in the beginning means nothing: it does not affect if the next child will be a girl or a boy. So it is independent from everything and the chances is 50%
Answer: This problem seems to be homework, so I assume the problem is not a complex biology problem and there's a 50/50 chance of boy or girl. We can assume the probabilities are independent to each other, so the probability is $50\%$.
Notes: The average male/female ratio in the world is about $1:1$, and it's safe to assume half of sperm contain an X chromosome and other half contain Y from meiosis. I think it's also safe to assume fertilization is independent.


Any ideas why REITS seem to be headed to zero?

Question: Being old I have/had much of my 401 K in REITS for income. I specifically avoided mall and retail.  Most imply that they are mostly residential mortgages. All are down substantially more than market averages. I am hoping they can still pay some, if not all, dividends as an offset to the capital losses. What may happen?
Answer: Mortgage-REITs are highly leveraged. They are much more leveraged than closed-end-funds. Well, take a look at ticker BKT and it's only down about 8%. But mortgage investments in general are down on mortgage refinancings but also down on de-leveraging by institutional investors due to impending recession. In other words, institutional investors had to sell to raise cash and make margin calls.
Property-REITs are just leveraged by ordinary bank loans. But also property-REITs partially run on short-term credit such that they benefit from low short-term interest rates. But now property-REITs are down on de-leveraging by institutional investors due to impending recession.
The good news is that the FRB just took steps to alleviate a credit-freeze.
Another point is that a diversified stock portfolio has about as much bounce-back potential as anything else. So consider taking the capital loss on the taxes and putting the funds into a diversified stock portfolio.
Oh, a capital loss in a 401K is limited on the taxes. So possibly just stay with the current holdings. Then more investment put-in, if possible and if risked, averages the cost basis downward.
And now mortgage defaults are in the news as a fundamental that could grow with recession. So that's leveraged mortgage-REITs, leveraged institutional investors holding the leveraged mortgage-REITs, previous mortgage refinancings, and soon-to-be growing mortgage defaults.
Comment: Does not look promising , I will sell while I can get a few cents.
Comment: Well, the FRB is going to buy Treasuries, mortgages, and corporate bonds. But it would take a good amount of expertise to understand the overall effect. Then LQD is up and trading at a premium. But the entire stock market is up on this day. Basically, make a list of the stock sectors to avoid.
Comment: Regular REITS are down today.  PEAK ( specialized REIT) is not down so I just put in a tight stop.
Comment: Ticker IVR is a mortgage-REIT in the news as unable to sell mortgage bonds to meet margin calls. Ticker NLY was looking for mortgage bond buyers on Sunday. This is obviously a mark-to-market portfolio valuation problem. The mortgage bond market might have improved today.
Answer: This article gives a good explanation of what a Mortgage REIT is:

Mortgage REITs are essentially leveraged bond or loan funds that invest primarily in real estate debt, making them more similar to fixed-income funds than to standard REITs, which own properties such as shopping malls, office towers and apartment buildings.
Mortgage REITs use short-term financing to buy commercial and residential mortgage securities, then add borrowed money -- typically about three to nine times the amount of their own capital -- to boost returns. Like other REITs, they must pay out at least 90% of their taxable earnings to shareholders as dividends and, in exchange, don't have to pay federal income taxes on those earnings.

The fact that they borrow money in several multiples of their initial capital makes them leveraged.  Leveraging means that they start with, say, $1 million, and then borrow another $9 million, then investing the resulting $10 million in mortgage notes (to simplify, this is basically like them buying up the rights to collect on mortgage debt).
This leverage means they're able to make more money per dollar invested - for example, if they're able to make 2% annual return (net) on each dollar invested, then on $10 million they will make $200k per year.  However, that's not a 2% return on your investment - it's a 20% return, because they only capitalized $1 million!
However, leverage means they also take a bigger hit in a recession.  It doesn't take too long for that $10MM to drop by far more than $1 million, when the market crashes.  That means not only are they moving up by more than the market, but they're also moving down by more than the market - and can easily be forced into selling at lower prices due to that leverage, due to margin calls.
The Wall Street Journal has a good explanation of what's happening there right now (no paywall, at least for me); for example:

Mortgage REITs, which typically use borrowed money to juice their returns, have been particularly susceptible investments as mortgage-backed securities sold off in recent weeks. Analysts at JPMorgan estimate that mortgage REITs need to sell between $40 billion and $80 billion of mortgage-backed securities to reduce leverage, or nearly one-quarter of their holdings. Their share prices have in some cases dropped more than double the broader market, with some down more than 60% so far this year.

From the same article, it looks like some Mortgage REITs are not going to be able to make those margin calls even by selling significant amounts:

On Friday evening, the company "notified its financing counterparties that it doesn't expect to be in a position to fund the anticipated volume of future margin calls under its financing arrangements in the near term," AG Mortgage said in its statement, which added the company is in discussions with its lenders "with regard to entering into forbearance agreements."
Over the weekend, hedge funds, insurance companies and private-equity firms examined AG's holdings, according to people close to the matter. It isn't clear if a sale of any assets will take place. The firm's market capital, above $700 million before the coronavirus crisis, is down to $150 million.

That significant of a drop will have impacts on other funds as well, of course.
Some investors believe this is temporary, and will rebound; certainly lower leveraged Mortgage REITs with safer securities will likely do better, relatively speaking, than more leveraged REITs.  However, as with anything in this market, it largely depends on how long the current recession (or whatever this turns out to be) lasts.  The higher the unemployment rate and the longer the stay-at-home orders last, the harder it will be for any fund to be productive.


HBase project - Technologies and Architectures

Question: I want to develop an application to learn how to use HBase. What technologies can I use to develop a good learning project using HBase? I want to use for instance something like Ruby on Rails or Java EE or Spring. What architecture could I do?
Answer: As you might know HBase is built on the top of the HDFS (Hadoop Distributed File System), it is expected that it would be used to store a very large (TB or PB) data set. So, using HBase from normal applications (Console or Desktop or Web applications) would not be a good idea because it would be able to do the processing on the data set in parallel which is needed if we want to have a good performance and scalability over such large data set. Without parallel processing it might take many days to complete a single job on such large data. Hadoop's MapReduce framework provides solution exactly to this problem. You can use MapReduce to read/write to HBase. This would make the application be high performance (jobs will decrease to minutes or hours from days).
So, IMO, better to start with using MapReduce framework with HBase. You can use Java or RoR for this. Although, MapReduce framework is developed in Java, it can be used from other languages too via Streaming API. RoR also have better integration with Hadoop.
Answer: I think it is not a matter of technology of the application working with HBase. The main learning curve (aside of the Hadoop and HBase administration) is understanding the paradigm shift between RDBMS and HBase.
So as a main excesise I would suggest is to take some exsisting RDBMS design you have (or can imegine) and map it into HBASE. The main test you have to pass - to see that all queries you used to execute on RDMS are possible with resonable efficiency. Doing this you will understand the conceptual difference between HBase and relational databases.


A logic problem. No need for calculation

Question: Three people were told to go to a cave and each pick up a hat in pitch dark. The three then came out of the cave with the hat on their heads. There were five hats in the cave. Three of them are black, the rest is white. When the first one is asked to tell the color of his hat, he said that he doesn't know. The second person told then same. But the third person said he knows. Why does he know the color of his hat based on what he heard from the other two persons? And how?
Comment: I first saw this problem (with different narrative) in "The Man Who Counted" by Malba Tahan (pseudonym of Júlio César de Mello e Souza). An amazing book of puzzles with delightful stories, great for the young mind and adults alike. It has wide distribution in Latin America, but is mostly unknown in the US. I wonder if it's frowned upon in the US because it's viewed as promoting religion (Muslim); it doesn't, not by a long shot.
Answer: Person $1$ states that he does not see $2$ white hats.
If Person $2$ sees a white hat on Person $3$, then he knows that his hat is black, because there must be at least $1$ black hat between $2$ and $3$.
So Person $2$ must have seen a black hat on Person $3$, leading to his uncertainty.
Comment: I guess it depends on your definition of simple.  Short isn't the same as simple.  In my opinion, mine is the "epiphany solution", and the straightforward enumeration of states answers of the other posters is simpler.  For someone learning to solve this kind of problem, the other answers are probably better learning tools than mine.  But thanks for the vote ^_^
Comment: I think it should be noted that not only does the third person know his hat is black, so do we who have seen nothing. In particular the third person did not have to see the other two, just to be seen by them. I think the story could be somehow improved to make this aspect come out better.
Comment: We who has seen nothing, ?
Comment: After the announcements of persons 1 and 2, [that person 3 has a black hat] becomes _common knowledge_. Neither we nor person 3 has to see anything because the epistemic space is such that all possibilities have person 3 wearing a black hat. I'd work Marc's wonderful suggestion into the question by adding the condition: person 3 is blind (and still says that he knows).
Comment: Interesting observation, but I think red herrings are what make puzzles more interesting, as long as they are not artificially added to the problem, and it leaves behind the gem of finding this observation for yourself if you don't try to "improve" the question.
Answer: Initially there are $7$ possibilities:
$$
\begin{array}{|c|c|c|c|}
\hline
1 & 2 & 3 \\ \hline
B & B & B \\ \hline
B & B & W  \\ \hline
B & W & B \\ \hline
B & W & W \\ \hline
W & B & B \\ \hline
W & B & W \\ \hline
W & W & B \\ \hline
\hline
\end{array}
$$
First says that he doesn't know, so one of $2-3$ has a black, that leaves us with:
$$
\begin{array}{|c|c|c|c|}
\hline
1 & 2 & 3 \\ \hline
B & B & B \\ \hline
B & B & W  \\ \hline
B & W & B \\ \hline
W & B & B \\ \hline
W & B & W \\ \hline
W & W & B \\ \hline
\hline
\end{array}
$$
Second says he doesn't know, that means one of the others has a black, which leaves us with:
$$
\begin{array}{|c|c|c|c|}
\hline
1 & 2 & 3 \\ \hline
B & B & B \\ \hline
B & B & W  \\ \hline
B & W & B \\ \hline
W & B & B \\ \hline
W & W & B \\ \hline
\hline
\end{array}
$$
Moreover, the second knows that the first has seen a black among $2$ or $3$ and he sees that $3$ has white in row $2$, so if row two is the case then the second actually does know his color, so row $2$ gets eliminated:
$$
\begin{array}{|c|c|c|c|}
\hline
1 & 2 & 3 \\ \hline
B & B & B \\ \hline
B & W & B \\ \hline
W & B & B \\ \hline
W & W & B \\ \hline
\hline
\end{array}
$$
The third knows that his color is black, because in all remaining worlds that's the case.
Comment: What if the second person is blind?
Comment: Then wouldn't there be two different cases? Since he always say idk.
Comment: That changes the problem. Since person 2 is blind, his announcements don't update the epistemic state at all. So the situation reduces to this. Person 1 says 'idk' means that at least one of 2 or 3 is wearing black. Person 3 cannot know whether the person wearing black is him or person 2. There isn't enough information to eliminate possibilities.
Comment: It is now one of the possibilities for a total of five
Comment: Should be six (the two new possibilities being: BBW and WBW).
Answer: Probably each person can see the hats of the other 2 persons. Let A,B,C denote the 3 persons. A says he doesn't know so B,C don't both wear white hats otherwise he would know that he wears a black one. So B,C wear both black or one black and one white.
Same stands for B. So A,C wear both black or one black and one white. So we have the 6 cases of what each of the 3 can be wearing:
A: |x|x|x|B|B|W|
B: |B|B|W|B|W|B|
C: |B|W|B|x|x|x|

So C sees what A,B wear according to the above table (checking the right half of the table). For example if B wears white hat then C wears black hat.
So we obtain the following according to the above observations:
A: |  B   |B|W|
B: |  B   |W|B|
C: |B or W|B|B|

But in the first column C cannot wear white since then B by seeing that C wears white and that not both B,C wear white (because A doesn't know what he wears) then he would know that he wears black. So we exclude this possibility and we have:
A: |B|B|W|
B: |B|W|B|
C: |B|B|B|

So C wears a black hat.
Answer: If first person saw the two others wearing white hats, he would know that he must wear a black hat, and would have said "black". Since he said he doesn't know, at least one of the other two must wear a black hat.
The second person can look at the third. If the third is white, he knows that he himself is black (based on the first guy's answer), and must answer "black". Since he says he doesn't know, the third person must be wearing a black hat.


MYSQL Advanced Wild Card Search

Question: Say my mysql table has a field name with a value of
record 1: Steve ABCDEF data
record 2: Steve C data
record 3: Steve BCF data
record 4: Steve F C data
I want to search for results that contain something like "Steve %C% "
Which would bring up record 1 2 & 3
I don't however, want it to pull up record 4!
Because I only want the wild card to go to the space character. Once it hits space, I want it to stop searching.
So something like:
SELECT * FROM `test` WHERE `name` REGEXP 'Steve \*[C]\*'

This obviously doesn't work though, because it will bring up all the records (including record 4), and I only want it if it has the "C" before the space, ie. records 1, 2, & 3.
Is this even possible?
Answer: You can try this:
SELECT * FROM `test` WHERE `name` REGEXP 'Steve [^[:space:]]*C'

MYSQL Advanced Wild Card Search


Group delay of the FIR filter

Question: For an FIR filter, with symmetrical tap values $h[N-1-n]=h[n]$,

why is the group delay $\frac{N-1}{2} T$ (where $N$ is the number of taps of the FIR filter and $T$ is the sampling time)?
Why is linear phase so important for the filter response?
Comment: Have a look at the book Oppenheim Schafer, Digital Signal Processing, section 5.7. They have quite a good explanation about this. It's the bible of signal precessing and will give you real precise answers
Comment: Good overview at MathWorks: [Compensate for the Delay Introduced by an FIR Filter](https://www.mathworks.com/help/signal/ug/compensate-for-the-delay-introduced-by-an-fir-filter.html).
Answer: To be precise the group delay of a linear phase FIR filter is $(N-1)/2$ samples, where $N$ is the filter length (i.e. the number of taps). The group delay is constant for all frequencies, because the filter has a linear phase, i.e. its impulse response is symmetrical (or asymmetric). A linear phase means that all frequency components of the input signal experience the same delay, i.e. there are no phase distortions. So for a frequency selective filter (e.g., a low pass filter), if the input signal is in the passband of the filter, the output signal is approximately equal to the input signal delayed by the group delay of the filter. Note that in general FIR filters do not have a linear phase response. In this case, the group delay is a function of frequency.
EDIT:
Consider an odd length FIR filter with even symmetry ("type I filter"). In this case the group delay is an integer number of samples $K=(N-1)/2$. The filter has a linear phase response (because the group delay is the negative derivative of the phase) and the filter's frequency response can be written as
$$H(\omega)=A(\omega)e^{-jK\omega}$$
where $A(\omega)$ is the real-valued amplitude function, and $\phi(\omega)=-K\omega$ is the (linear) phase. If the input signal's Fourier transform is $X(\omega)$, then the Fourier transform of the output signal is given by
$$Y(\omega)=H(\omega)X(\omega)=A(\omega)X(\omega)e^{-jK\omega}\tag{1}$$
Now assume that the frequency content of the input signal is in the passband of the filter, i.e. in the frequency region where $A(\omega)\approx 1$ holds. Then from (1) the output signal's spectrum can be written as
$$Y(\omega)\approx X(\omega)e^{-jK\omega}\tag{2}$$
and, from the shift property of the Fourier transform, the output signal is (approximately) given by
$$y(n)\approx x(n-K)$$
i.e. $y(n)$ is a delayed version of the input signal, where the delay is given by the group delay $K$.
Comment: the highest weight is assigned to the middle coefficient. so the output of the filter will follow the input only after (N-1)/2 samples. Is this why the group delay is (N-1)/2?
Comment: @JayeshP: Not really, because the middle coefficient (assuming that $N$ is odd) is not necessarily the largest coefficient, even though in practice it often is. I'll try to add more explanation to my answer later.
Comment: If N is even, the group delay will be ((N/2)+(1/2))T?
Comment: @JayeshP: If $N$ is even, the equation that Matt gave in his answer still holds. In this case, you have a non-integer-sample group delay, which is sometimes undesirable.
Comment: @JayeshP: I've added some more information to my answer.
Comment: The group delay of odd, symmetrical FIR filters is intuitively (N-1)/2 But could anyone recommend a book that can be cited? I need this for a thesis.
Answer: Why is the group delay constant and close to half of the number of taps in this symmetric tap filter ($h[N−1−n]=h[n]$)? The answer lies in it being symmetric. Note that the $n^{th}$ tap (coefficient) of an FIR filter can be seen as delay of $n$ "sampling intervals" (or $n$ samples).
Thus, if you pick a pair of "symmetric" taps/coefficients of this filter (say at $n_1$ and $N-n_1-1$), and pass a sinusoidal signal, $\sin(\omega t)$, through this pair, you would see that the output of this passing is a sinusoidal signal of the same frequency $\omega$ but with a delay which is an average of the two tap delays, i.e., $(N-n_1-1+n_1)/2 = (N-1)/2$. It is simple math, i.e., try adding $\sin(\omega t-t_0-t_1)$ and $\sin(\omega t-t_0+t_1)$, the sum is $K*\sin(\omega t-t_0)$. Do this for all $N/2$ pairs and you will find all will have a time delay of $t_0 = (N-1)/2$.
Please excuse my extreme brevity and delay in replying. I hope I got the point across.
Answer: To answer your second question: why Linear phase so important for filter response.
Consider filter as a channel, when you pass your signal from a channel what you want is all frequency components to be delayed by equal number of samples, if different frequency components gets delayed by different value then there will be distortion in your signal which is a bit difficult to compensate while a constant delay can be compensated by some simple techniques at receiver. Linear phase or constant group delay indicates that all frequencies (for which filter response is linear) are delayed by an equal amount. Therefore your output signal is just a shifted version of your input signal.
Answer: FIR Equation is given as
$y(k) = \sum\limits_{i=1}^{N-1}w_n$$\cos\omega(k-n)$    - Eq(1)
where

$w_n$ are taps (coefficients or weights) of the filter

$\omega$ is the frequency of the signal

$N$ is the number of filter taps

Consider an example $N = 8$ (ie 8 Tap FIR filter ie filter having 8 coefficients/weights). The coefficients will be from $w_0$ to $w_7$
For symmetric FIR filter  - Eq(2)
$w_0$ = $w_7$
$w_1$ = $w_6$
$w_2$ = $w_5$
$w_3$ = $w_4$
Eq 1 can be expanded for N=8 case as  - Eq(3)
$y(k) = w_0\cos\omega(k-0) + w_1\cos\omega(k-1) + w_2\cos\omega(k-2) + w_3\cos\omega(k-3) + w_4\cos\omega(k-4) + w_5\cos\omega(k-5) + w_6\cos\omega(k-6) + w_7\cos\omega(k-7)$
Due to symmetry indicated in Eq(2), we can rewrite Eq(3) as        Eq(4)
$y(k) = w_0\cos\omega(k-0) + w_1\cos\omega(k-1) + w_2\cos\omega(k-2) + w_3\cos\omega(k-3) + w_3\cos\omega(k-4) + w_2\cos\omega(k-5) + w_1\cos\omega(k-6) + w_0\cos\omega(k-7)$
Eq(4) can be indicated in compact form as Eq(5)
y$(k) = \sum\limits_{i=1}^{3} w_n\cos\omega(k-n) + \sum\limits_{i=1}^{3} w_n\cos\omega(k-7+n)$
Using the identity
$\cos A + \cos B = 2\cos(A+B)/2  \cdot \cos(A-B)/2$
Eq(5) can be expressed as
$y(k) = 2\sum\limits_{i=1}^{3} \cos\ \omega(k-(7/2))w_n \cdot\cos\ \omega(n-(7/2))$
We can take $\cos\ \omega(k-(7/2))$ out of summation, as this equation does not depend on $n$ which is limit of summation
$y(k) = \cos\ \omega(k-(7/2))\sum\limits_{i=1}^{3} 2w_n\cos\ \omega(n-(7/2))$
We can see that, value inside the summation is a constant and value outside the summation is the signal sample shifted by 7/2  ie (N-1)/2  --- We have taken N as 8 (N is number or filter taps/coefficients/weights)
So the signal is delayed by (N-1)/2 in symmetric or antisymmetric FIR filter. In the answer, example is shown only for symmetric case. Similarly antisymmetric case also can be worked out.

Group delay of the FIR filter


Python How put relation data into mongodb+gridfs

Question: How save 1.000.000 web-pages with css,js,img-files into mongodb+gridfs? How to define a link between the page and html files?
Answer: See here for general sql -> mongodb:
http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart
And embedding and linking specifically:
http://www.mongodb.org/display/DOCS/Schema+Design#SchemaDesign-EmbeddingandLinking
You should be able to apply this to GridFS as well.
Answer: GridFS uses two collections to store data files contains the object metadata and chunks which contains the binary data.  You can extend that metadata in files in any way you wish as long as you don't interfere with the existing fields, so you can "tag" your objects to describe them in any manner you see fit and separate them any way you want - file type, content type, language etc.
This capability is even mentioned in the GridFS spec: http://www.mongodb.org/display/DOCS/GridFS+Specification
Alternatively, you can create an entirely separate collection yourself and refer to the the objects in that way (probably by storing the files _id).


Maximum size that can be allocated

Question: Can I allocate more memory than VmallocTotal given in /proc/meminfo ?
Answer: vmalloc() is an internal kernel function.  It is not available to user programs.  It has no effect on allocations of memory for user programs.  VmallocTotal limits the allocations of kernel code which calls vmalloc() (and VmallocTotal does not change, either automatically or manually).
Maximum size of memory that can be "allocated" by user programs depends on overcommit settings.  I write "allocated" in scare quotes, because "overcommit" somewhat contradicts the idea of "allocating memory".  One explanation is here, you can search on the keywords it uses for other explanations: https://serverfault.com/questions/606185/how-does-vm-overcommit-memory-work
As the kernel doc puts it, system calls like mmap() or the old sbrk() do not allocate memory by default.  They return "address space".  Real memory will be mapped on-demand if/when it is written to.  Memory is mapped in terms of pages (usually 4096 bytes).

Maximum size that can be allocated


which type of camera should be used for detecting road lanes for good processing in matlab

Question: What are the parameters which should be selected to choose camera for lane detection system.What parameters should be kept in mind (like picture quality,frame rate,cost e.t.c). Which camera will suit best to my application.
Answer: This depends on several things, mostly what your processing the images with, if you have a 1080p camera running at 60hz and your using a raspberry pie, that is clearly overkill. I would recommend you benchmark your platform of choice to come up with your ideal resolution to fps, and based on that select your resolution. The other factor will be focal length, witch  determines how wide an image your camra picks up (see the wikipedia article) having a lower focal length will allow you to pick up objects more to the left or right, but the only downside will be he bigger it is the less pixels your tracking target will pick up witch can become a problem as your resolution drops.


Always show mute button on items in REAPER

Question: I'm using REAPER 3.76 and am muting and unmuting various items for comping purposes. There is a convenient mute button that appears on muted items to allow you to unmute them, but I would like it to stay there so I can re-mute them with a single click. Is that option available? I'm sure I saw a screenshot of someone with the mute button (and a few more) on all their clips.
Answer: -Open the preferences pane.
-click on "Media" under the "Appearance" heading in the left hand menu.
-check both boxes for "muted" and "unmuted" in the middle of the panel.
-click "apply".
now you should see a mute button both when the item is muted and when it is unmuted.
be aware, the buttons will disappear when the the view is zoomed out very far anyway, but should be visible under most circumstances.
Comment: brilliant - I searched the preferences box for ages looking for that setting
Comment: to be honest the preferences box in Reaper is a pain. Items seem to be labeled in a strange way that doesn't really reveal what they actually do. If you're stuck looking for something you can type a word into the "Search" box in the lower left corner of the Preferences box, sometimes it gets you where you need to be, sometimes not.


ACPI tables information

Question: What information is present in the ACPI tables?
Answer: The ACPI tables are the central data structure of an ACPI-based system. They contain definition blocks that describe all the hardware that can be managed through ACPI. These definition blocks include both data and machine-independent byte-code that is used to perform hardware management operations.
courtesy = http://www.usenix.org/event/usenix02/tech/freenix/full_papers/watanabe/watanabe_html/node4.html
Answer: The ACPI tables are collection of tables like FADT,DSDT,MADT,XSDT and so on.
Each of these tables are arranged in the form of bit fields that can be read or they contain AML data(example the DSDT tables which contain AML stuff).
Each table gives some information,depending on what you are looking for. For exampple the MADT tables contain information about APIC ID's ,Local APIC processors.
I would highly recommend reading the ACPI Spec. It is the most authoritative and complete guide in this matter.
See http://www.acpi.info/spec50.htm for the spec
Additonally you can use the userland ACPI tool called acpidump.
Selecting the -d option enables displaying DSDT tables. See http://www.freebsd.org/cgi/man.cgi?query=acpidump&sektion=8 for acpidump

ACPI tables information


Can the latest glibc DNS vuln be tested on remote servers?

Question: I recently heard of the critical DNS vulnerability in glibc that can lead to arbitrary code execution. I hadn't found much about the cases when the faulty function is called and ways to remotely diagnose the vulnerability - what could be an example scenario that determines whether a given target isn't patched yet?
Answer: Since the attack needs the client to first make a DNS request you need some way to trigger this request. If this can be done remotely depends on the server setup and applications running. But if you have access to the server you can try the PoC from google.
Please not that failure of the PoC indicates only that the server is probably not affected but you cannot be fully sure. There might be binaries on the system which contain a statically linked libc and are thus not fixed by upgrading the system libc.


Alternate for Whey!

Question: I'm tring to get all the nutritions from natural food. But I cannot find a alternate for Whey. I'm using cottage cheese instead of Cesain supplements, which is a low digesting protein. Eggs as medium digesting protein. But I cannot find any fast digesting protein, easy availble food as an alterante to whey supplements. So which is best fast digesting protein rich natural food?
Comment: Whey protein powder *is* a natural food.
Comment: just because it is powdered does not mean it is bad, you also assume that anything "unnatural" is bad which is a fallacy to nature.
Answer: Well, as the name whey suggests, you could maybe go to your local farmer and get some fresh whey.
If this does not suit you, you could try to get some natural whey powder. I do not mean the unflavoured whey protein, but the really natural whey.
If you still do not want the powder, you could simply drink milk. It also has a decent amount of whey protein by nature....
There does not seem to be a real alternative besides that. I dug through some posts on  the internet now and some suggest egg whites, but I think the best would be a whey shake.
The benefit of a shake in general is the better and faster digestability, so maybe you should really consider it.
Answer: Nuts and soy products are a great source of fast non-dairy protein. (You can generally find a soy isolate protein powder in a nutrition store).
Personally I'm a big fan of peanut butter and almonds. Just watch your fat intake with adding nuts to your diet.
Answer: I would recommend quaker with milk,yogurt,banana (general fruits).I haven't take never whey. I can't say whey if it gains more but like those it can replace.I hope to help

Alternate for Whey!


Erorr: no operator ">>" matches these arguments

Question: int main()
{
char* NamePointer = new char;

std::cout << "Enter the file you want to edit (MUST BE IN THE PROJECT'S DIRECTORY): ";
std::cin >> &NamePointer;

const char* FileName = NamePointer;
delete &NamePointer;

return 0;
}

This returns me the error in the title:
std::cin >> &NamePointer;

Any ideas? This is probably something simple I'm missing, but when I looked it up I didn't get my answer.
JUST FIXED IT, SORRY FOR BOTHERING! I took out the "&" in "&NamePointer".
Yeah I just found out another way of doing this using c_str(). Sorry!
Comment: Just removing the `&` didn't fix it, It still is broken.Check my answer.
Answer: You should have:
std::cin >> NamePointer;

Also, you are just allocating an memory of one character, probably you meant:
char* NamePointer = new char[MAX_SIZE];

and dellocate it as:
delete []NamePointer;

Note that the, C++ way of doing this is to simply use std::string which takes care of the problem of buffer overflows you get with using char*:
std::string Name;
std::cin >> Name;

Answer: There's no need for the address of operator here. Simply:
std::cin >> NamePointer;

Some other things I've noticed:
char* NamePointer = new char;

You probably want more space than just one character. A simple start may be a large static allocation:
char NamePointer[1024];

In which case, you omit the delete statement at the end (which also doesn't use an address of operator, by the way).


Debugging a Web Application in Visual Studio 2008

Question: When my colleague debugs a web application in his visual studio instance his output window streams all of the assemblies that are being compiled, (at least I believe that is what it's doing) but mine does not. I do see the text "Ready" flashing down in the status bar intermittently which I believe is something similar to what is being dumped to my colleagues output window. Does anyone know what switch I need to flip to get this working on my instance? Both of our output windows are configured to "show output from:" Debug. The reason I'm asking all of this is because this particularly smelly application I've been asked to help on takes something like two or three minutes for it to "spin up" before I actually see an explorer instance for this site and I was thinking that this output information might be able to help me figure out why it's taking so long to "spin up".
Answer: You want to make sure to use the Verbose (or something else more than Minimal) setting for build output. Then simply make sure your output window is open, and set the dropdown to "Build".
Tools->Options->Projects and Solutions->Build and Run->MSBuild project build output verbosity dropdown
Comment: That isn't exactly what I was looking for but it show me something new. Thanks for the input.
Answer: Another thing I have noticed, when 'Building' a web site (as opposed to a web application), the build process takes a long time compared to the web application.  I think the slow build speed is just a byproduct of how a web site is compiled, not the code itself.
Also, usually those dlls you see flashing in the ready field is the debug assemblies/symbol files/etc being loaded into the debugger and everything being attached to processes...
Answer: I figured out that if I right click in console area of the Output window when Show out from: "Debug" is selected that their are 6 different outputs available to select, several of them were not selected on my machine but they were selected on my colleagues machines, now I am receiving the Output I was looking for. As for other problem, I am now looking into it, looks like a lot of HttpCompileExceptions and NullReferenceExceptions are being thrown when "spinning up"... interesting, not sure if this is normal behavior or not.


top navigation vs bottom navigation which is better?

Question: We are thinking of developing a site with navigation after the main image and not the top of the page is that ok?
 Is there a best practice on this? Is top nav important or better
Comment: Whichever is better for the user. There is some discussion on this topic already here: http://ux.stackexchange.com/questions/46529/when-is-a-bottom-fixed-main-navigation-appropriate
Comment: Have you queried your customers? If you're doing something that is not part of an expected norm what justification do you have for it?
Comment: Many e commerce websites use a navigation on top of the page, and also bottom navigation is a very popular trend now both in iOS and Android applications. It all depends on your usage and the way you wanna present it but using a bottom navigation in desktop view of websites may be a bad practice. After all it's not something users are used to.
Comment: For mobile or desktop?
Answer: Depends. The norm is to have it on top, and in general this is good advise, since it doesn't interfere with the experience yet it's located where the user expects it to be. However, there are some conditions and approaches for these conditions.
Case 1
Visible and notice-able navigation on top
In this case, you want the user to have the navigation present at all times, since navigation plays a big role to access certain areas of teh site.
Example: https://ux.stackexchange.com/

Case 2
Non intrusive static top navigation
This is common in pages where navigation is less important because the main parts of the site are the landing page itself. Usually blended with the background by use of transparency and used in long-page layouts or pages that want the user to concentrate on CTAs above the fold
Example: https://www.agencyascend.com/

Case 3
Non intrusive with "on scroll changing" top navigation
Same as above, but once the user scrolls down the fold, the navigation changes in more or less radical ways, going from converting transparencies in solid backgrounds, changing color of background, changing appearance, layout and many more. In general, these navigation bars are fixed to the top, and are used to provide the user with a clear path to navigate the site once the fold has been scrolled.
Example: http://tritraining.edu.au/

Case 4
Bottom fold navigation
In this case, you place the navigation on the bottom of the fold. This is usually used in full screen layouts and are clearly displayed since they are not in the expected position, yet they're important to the user's experience
Example: http://www.conjurecognac.com/conjure_cognac/conjure/

Case 5
Interstitial navigation
In this case, you want the user to concentrate on the top element and add a "cut" in the layout while making the navigation very noticeable by placing it in the middle of the screen. Basically, using the navigation bar both as an information element as well as a content separation element.
Example: http://mozlo.com/chopper/

Considerations:
These are NOT the only options you may have. And please keep in mind I'm not advocating for any of the mentioned options, nor the chosen examples to illustrate those options. Whatever path you choose to follow, it's highly recommended that you test it. Navigation bar placement is very easy to change with a couple lines of code, so it's not a big deal, thus there's no excuse not to test it! Just in case, and in order to provide you with some insight, please take a look below:
Additional Reading
In case you're wondering about the above the fold concept and navigation placements, you might be interested in this article, this one and this one
Answer: In general, people tend to expect navigation on the top. Or at least above the fold in a column left or right. Your eyes start searching there automatically.
It might be best not to confuse your visitors.
However, I would say it depends on how far down you are planning on displaying the navigation. Is it still right there at first sight, just lower then usual, or do I have to scroll down to it?
The question is why you want to do this, your answer lies in there.
Bottom navigation is used for instance for navigating through pictures, in that sence, it is very acceptable and common.
Answer: Considering mobiles the experience can be very different, with more devices with large screens a top nav could be very difficult to reach.
Regarding desktop I like to break standard rules and be more creative with disruptive new experiences.
Very good point regarding an user testing, A/B testing.
Answer: Test, don't guess
The question is: will your users find the navigation if it is not in a standard place? The only way to know for sure is to test. A/B testing (of two prototypes) would be ideal for this.
Consistency
Will you have a large image on the top of every single content page? If not, where will your navigation be on those pages?
Is the navbar location forcing you to always have a graphic up top?
Current research shows that users tend to ignore carousels at the top of websites. What if six months from now research finds problems with large images at the top of websites and you want to remove your image? Where will your navbar go then? Sites are often redesigned every two years, but that is expensive. If you only change one element (e.g. remove the image), how will your navigation look in the middle of the page? Will it still be as findable? You may be limiting design options by anchoring your navbar to an image.


Store Manager - Re-index during product import despite setting to false

Question: I am trying to use Store Manager to import changes for 1 attribute on 650 products. Even though the "Reindex product data" is un-checked, Store Manager is STILL trying to re-index after every product is updated.  Is there a global setting that can prevent this issue from occurring?  My Store Manager worked fine until today when my computer was reset to factory settings and all programs re-installed.
Answer: Re-install should not cause any settings changes and some kind of re-index, such as the one, responsible for the product reflection in the back-end will still be run, even if the "Reindex product data" option is unchecked. Also, this process depends on the attribute you are making changes to. If you work with Bridge type of connection, you can see the information about index-related fields in Pending data section.


How can you determine if the job position you are placed in now is really for you?

Question: I am working as a data analyst in a healthcare company.So far, it has been a little over a month since I have been working at this company. However, there are some parts of the position that are difficult. I know how to program and write queries, but sometimes I don't understand what analytics my co-workers are looking for, so I have to ask many questions to understand what they want me to find. So, there are some grey areas. I understand your job is going to be full of challenges, especially when you are starting off in your career at an entry level position. That being said, how do you determine whether or not if a job position you are currently working in is really a right fit for you?
Comment: When you ask your coworkers for more details on the analytics they need, do they feel that you ask the right questions on the right topics and they are happy to help you ? or do they think otherwise ?
Comment: They think I ask the right questions on the right topics. This is the first day I am working on queries. My co-worker wanted me to predict and see why there is a decrease in a trend that being remits. However, when I was not able to get all results, so my co-worker was not happy. So, I told him I would talk to the Data Analyst manager to see if we can work together on this issue. After I said that, still he is not happy either because of the issue we're having in our data, and he may be behind in his work in trying to help me get through, or he is not happy with me.
Comment: it depends if you can do your work in given time and also you feel happy after finishing that work than you can do this job and you are fit for this job. Because at the starting everyone feels the same give some time you will learn and get more experience in your area.
Comment: I am also a data analyst in healthcare! EMRs are so big, and there are so many different workflows to populate, say, an imaging order, that I always put the responsibility of accuracy on the requestor. One of the first things you should ask is, how will you ensure this data is accurate? This isn't quite an answer to your question, but I wanted to lend some encouragement and advice. Have someone validate and make sure there's a paper trail!
Answer: Vague and unclear instructions that need clarification are common in the workplace.
In a past job, I was asked to implement an audit logging system for a piece of software that I worked on. What exactly we were logging was not specified and was never specified because it was a regulatory requirement that the product owner did not really understand. So we just logged every database change and that was apparently fine as we never heard about it again. It is a very good week if I don't need to tell some non-technical that their request can describe somewhere between 2 hours and 2 years of work and it isn't uncommon to be told to just do it and see if what I come up with works.
This is not exclusive to technology either. I used to work in investment research and was asked for a report on "everything important" about a stock. My boss complained about me after two days as he had expected a one pager that day. I was writing 20 pages.
Needing for something to be clarified is usually not a deficiency on your part, especially if it is about what specifically they want rather than how to obtain it.
Comment: This is the classic "People don't know what they want." The pessimistic spin is "People don't know what they want and complain about what you gave them." It is also possible that what they want is actually mutually exclusive (Everything Important + One Page).
Answer: It is completely normal to have anxiety and doubt yourself when you are learning something new and / or starting out at a new job. Even more so when companies do not provide adequate training for the job, or (as Mathew Gaiser pointed out in his answer) proper instructions.
When you ask whether you are a right fit for the job, you are essentially trying to evaluate two things:

Do I have the necessary skill-sets to execute the tasks assigned to me?
Do I enjoy executing these tasks?

In your case, you are perhaps doubting yourself based on the first and wondering if you lack the qualifications or skills required, and whether you can acquire and become proficient in them. Moreover, you feel the added stress of seeking help from colleagues.
If you have received proper training and mentoring, and still feel you aren't proficient at executing your tasks after 6 months to 2 years, then perhaps the job isn't right for you. (I say 6 months to 2 years because not all jobs are the same and some jobs really do require more hands-on experience before you can be good at it - speak with experienced people in your industry to determine how much time it takes to be adequately proficient in your field).
Till then, you can focus on the second part - find out if you enjoy the job and if the future opportunities ahead in your field excite you? (Note also that your employer hired you because they saw potential in you and were satisfied with your qualification).

As for seeking help from colleagues, don't stress about it. It is normal for anyone to sometime feel a bit irked by the demand you may place on them when you ask for their help. Especially if it means they have to divert attention from their tasks. It is unproductive to over analyse their words or actions. Instead, if really necessary, learn to seek direct clarification non-confrontationally.
(Don't let a real or perceived bad experience stop you from asking for help though. If they can't or don't want to help they will tell you so and it doesn't really have to mean anything more - you have the right to ask someone for help and they have the right to say no, for whatever reason.)
Meanwhile, be grateful to those who offer their valuable time to you, and, more importantly, show your appreciation to them by doing something for them too (e.g. by helping them out with their tasks at work or buying them coffee or a meal or even giving them a gift for some occasion).
Comment: Thank you for all the advice! I really appreciate it. I know starting a new position in your field is always stressful, but all the advice that I have received is very helpful
Answer: I've been working in data for a decade plus. What you are dealing with is really common. Data folks are usually there to address business questions using technical tools. Similar to software engineering but structures are often more poorly defined.
There's two ways companies usually tackle this. The traditional company way would be to have detailed requirements for everything to avoid miscommunication. A more agile way would be to embed into a team and gain context on the business. Good data analysts can often go on to become product managers via this path (others become more like software engineers). They can often pre-empt the questions before they are even asked.
In your case, you shouldn't let challenges like this deter you. The core skills of a very junior analyst is just to execute given clear instructions. A more experienced one can do based on vague instructions and a lead is more an advisor to the business and will pre empt stuff. Also remember that as you become more senior a skill which is equally important is knowing how and when to push back on requests. Maybe in your case the original request was not really feasible and your actual mistake was saying yes to it.
Anyway thats the path to becoming more senior. You should seek help and mentoring to progressing down that path.
Answer: You seem more worried about whether the company is happy with you, rather than whether the job is making you happy. In which case the simple answer is to ask your boss "Am I doing OK? Do you have any feedback for me?".
You should have regular reviews, but if you haven't heard much it probably means you're achieving everything that is expected.
It normally takes a few months to become fully productive, so don't worry if you're still asking newbie questions after a month or two (just try not to ask the same questions repeatedly).
Don't worry about unclear requirements, that's at least half of the job, and something that school doesn't prepare you for. My advice is to sketch out two or three options quickly and discuss them. Looking for options means that you don't just go with your first idea, and 'sketches' mean anything that's easy to change so you're not invested in it (and it can't be mistaken for the finished product). You'll probably have suggested somethings they didn't think to ask for but really want.
As to whether the job is right for you, think about what you enjoy/don't enjoy and try to work out why. Take some time to really drill down into your motivations, then talk it over with family and friends.


How do we contain nuclear fusion?

Question: I understand that here on earth we create fusion at temperatures that are much hotter then our sun. What I want to know is how we contain those high temperatures safely. Also if any one can give an estimation on when we will have practical nuclear energy available to the everyday person that would be great.
Comment: For mathematical details of magnetic confinement, see: https://physics.stackexchange.com/questions/411283/magnetic-confinement-in-a-tokamak
Answer: This describes the international collaboration that is building a production level fusion machine, ITER, a prototype .

The tokamak is an experimental machine designed to harness the energy of fusion. Inside a tokamak, the energy produced through the fusion of atoms is absorbed as heat in the walls of the vessel. Just like a conventional power plant, a fusion power plant will use this heat to produce steam and then electricity by way of turbines and generators.
The heart of a tokamak is its doughnut-shaped vacuum chamber. Inside, under the influence of extreme heat and pressure, gaseous hydrogen fuel becomes a plasma—the very environment in which hydrogen atoms can be brought to fuse and yield energy. (You can read more on this particular state of matter here.) The charged particles of the plasma can be shaped and controlled by the massive magnetic coils placed around the vessel; physicists use this important property to confine the hot plasma away from the vessel walls. The term "tokamak" comes to us from a Russian acronym that stands for "toroidal chamber with magnetic coils."

So the plasma is controlled by magnetic fields , and the tokamak design is successful in this.
You ask:

Also if any one can give an estimation on when we will have practical nuclear energy available to the everyday person that would be great.

It is worth reading the link:

ITER's First Plasma is scheduled for December 2025.

Then one will experiment with demonstrating that it really produces the planned energy, 500MegaWatt over the energy needed to run the experiment.
After a successful demonstration the countries participating will start building the industrial machines as they will share the knowhow.
Another 10 years? The finish line moves over the years I have been following fusion's progress.
Answer: Plasmas in a fusion reactor at such temperatures cannot touch any material. No wall or floor or ceiling. It has to be kept suspended, levitating. This is done with magnetic forces by electromagnets that are continuously adjusted during operation. If you Google for pictures, you'll find the inside of such chamber covered in shiny metallic plates, which are there to protect the vacuum vessel and the magnetic coils. The adjustments are highly automatic and highly advanced to do.
According to a university professor some years ago, fusion energy will become available for real in 50 years or so... Maybe some breakthroughs will happen before that, who knows.

How do we contain nuclear fusion?


how to prove that the convolution between two discrete signals is the discrete signal of convolution between two continuous signals

Question: Like the title. We already know $x[n]$ and $h[n]$ are the discrete time signal of $x(t)$ and $h(t)$ respectively, which are continuous time signals. And also $x(t)*h(t)=y(t)$, $x[n]*h[n]=y[n]$. Prove that $y[n]$ is the discrete time signal of $y(t)$.
Comment: What have you tried so far and where are you stuck?  Have you considered working out the continuous convolution, sampling it and comparing it to the discrete case?
Comment: Let $x(t) = \delta(t - T_s / 2)$, where $T_s$ is the sampling interval.  Let $h(t) = u(t) a e^{-a t}$.  Then $y(t) = u(t - T_s / 2) a^{a T_s/2} e^{-a t}$.  Now observe that $x[n] = 0 \forall n$, and that if you convolve it with _anything_ the result will be zero.  Thus, $y[n] = 0$ and -- oh crap.  Did the prof put any _constraints_ on $x(t)$ and $h(t)$?
Comment: What is your reason for believing that the result that you are asked to prove is true? It might be easier to come up with a counterexample to the alleged result.
Comment: Then what should be the case if the above statement isn't true? Is it not true only under certain circumstances?
Comment: @jsnjztr didn't you read my comment?  I disprove the hypothesis that $y[n]$ is the discrete equivalent of $y(t)$ in every case, by _showing you a case_ where that is not true.
Answer: Say continuous signals $x(t)$, $h(t)$, $y(t)$, sampled continuous signals $x_s(t)$, $h_s(t)$ satisfy
$$
y(t) = \int_{-\infty}^{\infty} x(\tau)h(t-\tau)d\tau \tag{1}
$$
$$
\begin{aligned}
x_s(t) =
\begin{cases}
      x(t) & t=nT\\
      0 & \text{otherwise}
    \end{cases}
\end{aligned}\tag{2}
$$
$$
\begin{aligned}
h_s(t) =
\begin{cases}
      h(t) & t=nT\\
      0 & \text{otherwise}
    \end{cases}
\end{aligned}\tag{3}
$$
where $T$ is the sampling period. The continuous-time convolution of $x_s(t)$ and $h_s(t)$ is given by
$$
\hat{y}(t) = \int_{-\infty}^{\infty} x_s(\tau)h_s(t-\tau)d\tau \tag{4}
$$
Now we have discrete signals $x[n]$, $h[n]$ are the discrete version of sampled continuous signals $x_s(t)$ and $h_s(t)$. $y[n]$ is the discrete convolution of $x[n]$ and $h[n]$
$$
y[n] = \sum_{m=-\infty}^{\infty} x[m] h[n-m] \tag{5}
$$
If you are talking about continuous-time convolution between two sampled continuous signals, which is $\hat{y}(t)$, equals to the discrete-time convolution between two discrete signals, which is sampled $y[n]$, that's true because $x_s(t)$ and $h_s(t)$ are zero unless $t=nT$ and the integral in Eq. (4) is reduced to summation.
But $y(t)$ is a full integral whose discrete signal is not equal to $\hat{y}(t)$ nor $y[n]$. These two pictures are going to help you understand.
Eq. (1): $$y(t_0) = \int_{\tau=0}^5 x(\tau)h(t_0-\tau) d\tau$$

Eq. (4) and Eq. (5): $$y[n_0] = \sum_{m=0}^5 x[m]h[n_0-m]$$

I think this question is related.


Calculating Exponential Moving Average

Question: I looked up EMA on wikipedia, but I could not understand the explanation. Can anyone break it down with an example ?
Answer: EMA = (Price * Alpha) + (Previous EMA* (1 - Alpha))
Where Alpha = 2/(1+N)
AND N = Number of Trading sessions.
Suppose Reliance  is trading at Rs. 1000 a share and its previous days EMA is 950, then to calculate EMA for 10 days, It would be like:-
(1000* (2/(1+10)) + (950 * (1-(2/1+10))
=(1000 * (2/11)) + (950 * (1-(2/11))
=(2000/11) + (950 * (1-(2/11)
=181.81 + (950 *0.8181)
=181.81+777.27
= 959.08
If you need to calculate EMA for 15 days, then just substitute N with 15.
Cheers!
Comment: I disagree with your comment, for purposes of a moving average, the average itself becomes meaningful on the Nth day.
Comment: Lets say I will be calculating EMA for today, but I do not have a previous day EMA, so I go back to calculate the previous days' EMA, so on and so forth until I reach a day D0, which is the beginning of the trade for that stock, so How would I get the EMA on day D0. Or is there another easy way to calculate the previous days' EMA? I am going to calculate based on yahoo stock data.
Comment: EMA means exponential moving AVERAGE. So on d0, the average will be the price of the stock.
Comment: @JoeTaxpayer: Agreed; it isn't meaningful until the Nth day of data (if it's meaningful at all, which is open to debate). But for purposes of getting the calculation going, starting the calculation with PreviousEMA at the value on the earliest day you have records for and calculating forward from that is a reasonable approach.

Calculating Exponential Moving Average


Refunding received package [AUS laws]

Question: I recently bought something off the internet and it didn't come within the time they said which was 7 days, and neither did it come within 30 days so I placed a Paypal refund dispute and the money was refunded to me, two weeks after this at about the 54 day mark since it was shipped I got it. Am i required to return it? or is it covered under the "unsolicited goods" laws?
Answer: It isn't unsolicited, so it wouldn't be covered by that.
The item now doesn't belong to you, so not returning it would be dishonest.
Get in touch with the company and arrange them to pay for the return.
You could also arrange payment if you wanted to keep the item.
Comment: Or arrange with them to repay for the item if you still want it.
Comment: I've bolted that on to my response now.
Answer: I believe you would not immediately own the item but would not be obliged to pay to return it - ie if they want it back they would have to pay for shipping and handling - If they don't, after a reasonable period of time it would be considered abandoned and I guess you could claim it !   (Note this is a general law perspective from someone in NZ rather then AU - and I'm not a lawyer !)
Comment: Not exactly on-point, but related - https://www.accc.gov.au/consumers/consumer-rights-guarantees/repair-replace-refund talks about returning a product if there is a problem.

Refunding received package [AUS laws]


League of legends end of game stats

Question: Does Riot offer any way to keep track of the end of game stats via an XML file or something similar? They show a score grid that keeps track of almost everything; gold earned, damage dealt, largest critical strike, etc. I'd like to pull that data and make a graph out of it. I know how to do it if I can get access to that data so I'm wondering if anyone has heard either way.
Comment: Not a game development question;  more a question to be asked of the LoL developers.  Perhaps on their forums.
Comment: I can't answer my own question, but I found what I was looking for. [Curious?](http://www.lolbase.net/champions?period=v184.108.40.206&server=all&level_range=all↦=all)
Comment: @totbar you can answer your own answer just click answer button down there
Answer: Totbar, I saw you commented above with this link. As a LoL player myself, I used this site for a bit, until I learned that you had to do it almost every day or the logs would be outdated.
Also, if you didn't start doing it the moment you started playing LoL, the stats only reflect the logs you have uploaded.
I stopped paying attention to it because it was faulty.
Essentially, I'm sure your records overall are saved on the LoL servers somewhere (they have to be due to the takedowns calculation and stuff), but as of right now, and for whatever reason, this is not available to the players.
Frustrating, I know.
Edit: I just found a League of Legends statistics crawler! http://lolstatistics.com/
Thank me later. :)
Comment: Thats a very nice site, I used http://riotstats.com/ and was wondering about a better way!
Comment: lolstatistics.com and riotstats.com appear to no longer exist.
Comment: For anybody that is looking for the same kind of thing but that is still open and maintained in 2020, here: https://www.leagueofgraphs.com/

League of legends end of game stats


cannot draw on texture

Question: Im new and I am currently making the donut. For some reasons I can't paint on it, does anyone know how I can solve this problem?
Answer: From what I'm seeing, you need to add a texture paint slot, found under the tools tab at the very top. Just click the part that says "add texture paint slot" pick "base color" set the resolution and I ASSUME that will fix your problem.

cannot draw on texture


Why do they want to hire prostitutes for the space program?

Question: Why do they want to hire prostitutes for space program in Predestination?
Answer: It's actually from the novel:

The film adaptation follows the source material fairly closely, with a
  couple of exceptions. The view on women has been updated. In
  Heinlein's story women's role in space travel is limited to providing
  sex and company to male astronauts, basically as some kind of luxury
  prostitutes. In the movie they're more capable than that.

Drew McWeeny from HitFix discusses the subject with Ethan Hawke (around minute 5) and they agree that the movie tried to keep close to the source material, i.e. the idea of space prostitutes was a very Sixties idea.
Answer: It's a real life thing, sex slaves, I mean ""comfort women"" that are found in any large military/army camp to keep the men happy/in-line. In modern times, it's less heard of, but still common.
Japanese Comfort Women:

[...] were women and girls who were forced into sexual slavery by the Imperial Japanese Army in occupied territories before and during World War II.
The name "comfort women" is a translation of the Japanese ianfu (慰安婦), a euphemism for "prostitute(s)". Estimates vary as to how many women were involved, with numbers ranging from as low as 20,000 (by Japanese historian Ikuhiko Hata) to as high as 360,000 to 410,000 (by a Chinese scholar); the exact numbers are still being researched and debated. Many of the women were from occupied countries, including Korea, China, and the Philippines, although women from Burma, Thailand, Vietnam, Malaysia, Taiwan (then a Japanese dependency), Indonesia (then the Dutch East Indies), East Timor (then Portuguese Timor), and other Japanese-occupied territories were used for military "comfort stations".

South Korean government who made women available for stationed allied US Military:

A group of women in South Korea sued their own government in June, alleging that it trained them to serve as "patriots" or "civilian diplomats" in the 1960s and 1970s. Their real job: work as prostitutes near American military bases. The women were tested regularly to make sure they didn't have sexually-transmitted diseases, and were locked up until they were healthy again if they did, they said.
It's an uncomfortable part of the U.S. military's long history with prostitution. The world's oldest profession has long catered to U.S. troops, whether at home or abroad. But the issue is getting new scrutiny  in South Korea, where the top U.S. commander, Gen. Curtis M. Scaparrotti, recently forbid all military personnel under his command from paying an employee in an "establishment" for his or her time.

The Nazis too:

German military brothels were set up by the Third Reich during World War II throughout much of occupied Europe for the use of Wehrmacht and SS soldiers. These brothels were generally new creations but in the West they were sometimes set up using existing brothels as well as many other buildings. Until 1942, there were around 500 military brothels of this kind in Nazi occupied Europe. Often operating in confiscated hotels and guarded by the Wehrmacht, these facilities used to serve travelling soldiers and those withdrawn from the front.

And that's just the last 60 years? There is a long history of sexualized violence, which even "consensual" prostitution is considered. This is borne from the idea that women are things for men's enjoyment or comfort and not people, still very much prevalent at the time the novel was written, 1958.
Answer: It's a very common trope seen in a lot of science fiction, based on the idea that the people most likely to be willing to give up their current lives to explore the new frontier of space (which could require a commitment of years and years, possibly life, depending on the end point) would be young, adventurous single people, and back when a lot of these tropes arose it was just assumed they would mostly be men.  But what is the one thing many young, hardy men would never give up?  Sex.  So they add prostitutes (also usually single and thus often willing to attempt this new life if the price is right) to the equation to make sure men will sign up for the program.
Remember this isn't like say... exploring the West Indies in the Age of Discovery, where sailors could assume they would run into inhabited places eventually and there would be access to sex.  This is space.


Reproject global latlong into UTM slices

Question: I'm working with a global shapefile in R that is latlong projected. I'd like to reproject it into the appropriate UTM projection for individual zones. But, I'd like to chop it up into those zones before reprojection, instead of having multiple global reprojections into UTM most of which have meaningless coordinates. Also, computational efficiency. So, how would I split a latlong shapefile into areas corresponding to UTM zones before the reprojection (and a little overhang is fine)?
Comment: I am sure you have good reasons for this, but just in case, the world really doesn't need more data in UTM. Is there not a better choice of projection/s for your application?
Comment: I agree. I'm working with Landsat data to see if part of a scene falls along a coastline or not. I have a global coastline shapefile, in latlong, and all scenes are in UTM. Computationally, it's less expensive to reproject the coastline into UTM zones and then use that to use gIntersect or somesuch on rather than reproject each of the thousands of rasters I'm working with.
Comment: They are in UTM? Gosh. Is that standard delivery for Landsat or some sub project? I had no idea, keen to explore can you point to some sources? Usually sat data has some rawer form or is swath data or some projection masked by longlat arrays.
Comment: Yeah, that's the standard. Like you, i assumed otherwise - WGS84, and then...had some problems that made me take a second look. That's been...an experience.
Comment: So really you want a map source that will always plot this in context correctly? This slicing gores approach won't work all the time. Still personally seeking best ways to do this kind of thing for myself.
Comment: I just want something that I can hold a scene up to and ask, does it intersect a coastline?
Comment: I would decompose a coastline map to points, reproject them to the UTM of the image, plot the points that are finite over the top, optionally with bbox filtering before the plot. No need to worry about pointless topology problems though you could join the lines OK.
Comment: I've actually done this for a tiny slice of coast as a SpatialPolygonsDataFrame object, and using gIntersect after the reprojection works great, so, I'm not worried. It's the making of a big-big reprojection that was the hangup.
Answer: You can use crop from raster to crop to a defined extent, in this case your UTM zone approximate boundary.
So I have a world map shapefile:
> w
class       : SpatialPolygons
features    : 1
extent      : -179.9997, 180, -89.9999, 83.2479  (xmin, xmax, ymin, ymax)
coord. ref. : +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0

And some xy coordinates of a box to crop to:
> xy
$x
[1] -4.386177 28.181688

$y
[1]  78.54324 -86.03500

You might want to tweak the latitude limits depending on how near the poles your world shapefile goes. Set the longitude (x) to your UTM zone.
Then crop.
> library(raster)
> wc = crop(w, extent(SpatialPoints(data.frame(xy))))
> plot(w)
> plot(wc, add=TRUE,col="red",lwd=2)

Note you better not have any odd geometry problems in your world shapefile...
Comment: Right, but they aren't rectangular like that. Then again, widest points should be good enough.... which I guess means find a file with those points deliniated (or zone boundaries)
Comment: Oh, https://www.arcgis.com/home/item.html?id=715d4d6a36cc4b019bd84cb34ce37647 - ok, I think this should do.


Bluetooth connects, but does not play sound

Question: I've got a Toyota Sienna that has a bluetooth connection for phone audio.  I purchased the GTA Car Kit to connect to the stereo.  This works great with Android devices.  However, I've recently switched to an iPhone 6.  While it will show that it is connected to GTA Car Kit, it almost never actually plays audio over it.  How can I resolve this?  It does work fine for the phone audio, and any other bluetooth device I connect it to.
Comment: what do you mean by 'almost never actually plays'? How often does it play? What do you do in order to make it play for a bit? Make sure the sound is on the highest in both the phone and on the speaker.
Comment: The problem is that it typically would just not make any sound.  I tinkered with things, and I think I've got it working.  Not sure, but it might have been that the bluetooth volume was set too low.
Answer: I have the same problem.  I have a GTA Pure Bluetooth system in my 2007 Honda Civic. I have an iPhone 5S that connects automatically to play music about 5-10% of the time. To work around, I have to go into iPhone Settings, Bluetooth, select the ! symbol next to GTA Car Kit, Disconnect, back up one level and reselect GTA Car kit and it then connects 100% of the time. Kind of a pain.
It is almost like there are two levels of Bluetooth connectivity.  My phone connects perfectly 100% of the time but my music does not connect much at all.  In iPhones, look for the tiny headphone icon in the top-right corner of the screen when you have successfully connected to play music.


Is $s$ larger than the radius of circumscribed circle?

Question: In the figure, showing a square and an equilateral triangle, is $s$ larger or
smaller than the radius of the circumscribed circle?
Comment: You can convert the equilateral triangle+square into one big isosceles triangle using basic pythagorean theorem. The base would be the same as the square's base (s), while the diagonal can be calculated (Height is s+√3s/2, side is s/2, calculate the diagonal). Then i believe you can find the radius of a circle based on its inner triangle... I think. I'm too lazy to do the calculations though :P
Answer: The radius is S. Translate the top point down s units: the distance of this new point is s from all three vertices. Therefore the radius is s.
Comment: This is a great solution.
Comment: "The distance of this new point is s from all three vertices." How did you know that this new point will be exactly "s" distance away from the bottom two points ?
Answer: There's probably an elegant solution.  Meanwhile, here is a bash:

As Votbear says, we should analyze the isosceles triangle formed by the bottom of the square and the tip of the triangle.  The common side lengths will be $\sqrt{(s/2)^2+(\frac{2+\sqrt{3}}{2}s)^2}=s\sqrt{(2+\sqrt{3})}$.
Now let use use the formula $R=\frac{abc}{4K}$, where $R$ is the circumradius, $a,b,c$ are the sidelengths, and $K$ is the area.  We get $R=\frac{(2+\sqrt{3})s^3}{4(\frac{2+\sqrt{3}}{4})}=s$.  Wait what?

As for a possible elegant solution:

 Starting with the top vertex and working counterclockwise, name the vertices of the pentagon ABCDE.  Reflect B across AC to B'.  This creates parallelogram ABCB', so B'A=B'C=s.  Also note that B'A || BC || DE, so B'A || DE.  But B'A = DE = s, so B'AED is also a parallelogram.  So AE = B'D = s.  Now we know that B'A = B'C = B'D, so B' is the circumcenter of the triangle ACD, and thus s is the circumradius of the given circle.
Answer: Another approach:

Reflection of the right leg of the triangle and right edge of the square about the orange line results in their common vertex being reflected to the centre of the circle, therefore the radius is $s$.


What conditions would an A-type star need to have a blue color?

Question: So I'm working on a world that orbits a blue star that's not much bigger (or even smaller) than the sun. I was thinking that an A-type star would be a good choice for it, but it's still is closer to white than blue. Is there any way for the conditions of an A-type star to be just right to give it a bright blue glow?
Comment: I don't understand. An A-type star is, by definition, white. If it were blue, it would be O-type.
Comment: Did you describe the reason for the bounty correctly? I would have thought that you still wanted a usable story idea and none suitable were suggested. But "more detail?" It appears the answers are already quite detailed and specific on the reasons for star color.
Answer: Here are your color options:

If you can get your star past infinite temperature, then you can have it be a nice blue rather than blue-white. A more feasible option is to make the star appear blue due to the atmospheric composition. Or, if something else needs to budge, you'll need to make it the largest type A you can (about 2.6 solar masses) and it'll be just between blue-white and deep-blue-white
But, basically, a bluish-whitish is the most likely outcome. For a human observer, at least.
Answer: I see one serious problem - time scale.

Solution I - you use high concentration of handwavium to explain why it was possible to form planet and interesting enough life on such planet so fast. As an excuse I could imagine UV light splitting water, causing hydrged to escape and oxygen to accumulate, thus speeding up local great oxygenation even that allowed multicelluar life.
Solution II - blue dwarf - just wait
The only problem that the universe is clearly to young for them and they are just predicted late phase of small red dwarfs. If your story can wait so much... Then you may use it.
http://beyondearthlyskies.blogspot.be/2013/09/blue-dwarfs-stars-yet-to-be.html
Solution III - blue dwarf - lucky coincidence
After a series of nearby supernovas (? not 100% sure how to get such composition, it may also involve serious amount of handwavium) a tiny star was formed with ultra high helium concentration, hundred of billion of years before their time, looking more or less like a blue dwarf.
Comment: If there were precursors, they could have seeded and terraformed the planet.
Comment: That's kind of the tricky part, the story takes place within the near future, roughly a few decades from now. Plus the system is much younger than our own, so a blue dwarf is probably out of the question.
Answer: The light given off by a blackbody spectrum at high temperatures like those found in stars, once you get above the temperature of the Sun's photosphere, which is around 5700 K, is going to be practically indistinguishable from white.
The first thing I thought of when it comes to this is absorbing the light coming off from the star. But any amount of dust between the star and the planet would get blown away over the course of a few thousand years.
I'm thinking you want something like this though.

The rings around the stars are actually optical defects, so I'll ignore that. But the thing which makes the entire area blue is not anything to do with the stars. Rather, it has to do with the dust which reflecting the blue light coming off from the star itself.
This, due to radiation pressure from the star, cannot last for long, but like the Pleiades, the stars could be travelling through a particularly dusty region of the galaxy which provides the dust necessary to explain such scattering.
Secondarily, one should also note that this solution wouldn't make the star blue (it would still be blue-white). But rather, it would make, for a planet inside the cluster, the entire sky have a faint blue glow.
Comment: That's a false color image. [Here is another photo of the Pleiades in visible light](https://en.wikipedia.org/wiki/File:The_Pleiades_(M45).jpg). It demonstrates the actual blue-white color of the stars.
Comment: What if the star itself contains impurities with the right absorbtion spectrum?
Comment: Such impurities already exist. If we look at the spectra of large stars, the emission lines are generally overpowered by the sheer heat of the plasma's  continuous spectrum. Also, absorption spectra only exist when there is a hotter source behind some cooler gas. Such cooler gas would generally be removed from the system over a short timescale if it is close to the star.
Answer: If the sky were red rather than blue, might our sun look blue by physiological or neural colour-contrast effects? I'm not sure.
Anyway you can't get a red sky by scattering off dust because short wavelengths scatter more strongly than long. Hence blue sky. But suppose plants on this planet had evolved hydrogen bladders, and a different photosynthesis to Earth that worked on blue and green but not red? Then plant life would be red not green, and because of airborne plants the sky would also be reddish.
Answer: Your A-type star has a Dyson Swarm of unknown (or known) origin around it. Except the modules are not entirely opaque, but almost transparent, and of a nice shade of blue.


Color a surface according to its slope

Question: I want to color a terrain according to how steep the slope is at each point. I've read How do I colour a 3D terrain based on its height?. If I could generate a new surface that is the gradient of my terrain (such that height of the new surface corresponds to slope in the original), then I could create that height-based material and apply it to the the original terrain. Is this feasible? Is there a better way to create a slope-based material?
Answer: Yeah,, you can actually do it follow this video: https://youtu.be/qSafYNQrodk?t=1330
But here you have a simplified node setup to do it:

The color ramp is used to choose the steepnes you want to select, the white parts are what is selected, so maybe you'll need to inverse the color ramp colours.
The "Average Node" of the video is actually the "Vector Math" node with the average option choosed, I don't know why he used it, the simplified node setup that I shared works equally.
How this works? I really don't know, I only know that you use the perpendicular normal axis (in this case the Z) to get the stepness in said axis and the ramp to set the threshold.
With three points (black, white, black) in the color ramp and the ease mode you can customize more the selection.
Comment: The color ramp is a selector, like a mask on photoshop, you have to use it like a factor on a mix shader, try this: https://imgur.com/a/XMIw5Na . And don't forget to add a light.
Comment: I see this requires Cycles. I'm not as familiar with Cycles but my surface is solid black when rendered. I have the following nodes: Geometry.Normal -> Seperate XYZ.Z -> ColorRamp.Color -> Material Output.Surface.  Is there some other setup I'm missing? I watched the first part of that video and didn't see anything obvious.

Color a surface according to its slope