Generating a distinct k-partition of n from a finite set

Question: There is a number $n(\gt 1)$ and a finite set $S=\{1,2,...,r\}$. Here $n\ge r$. How do I form $n$ as the sum of exactly $k$ distinct elements of $S$ where $k \ge 1$, or know that it's impossible to do so?
Answer: This problem is reminiscent of Kakuro, the logic puzzle where distinct digits (i.e. $r=9$) have to be filled into entries of a fixed length $k$ such that they have a given sum $n$.
For a given $r$ and $k\le r$:

The smallest $n$ possible is $T_k=\frac{k(k+1)}2$, and is the result of choosing the $k$ smallest elements of $S$.
The largest $n$ possible is $k(r+1)-T_k$, arising from choosing the $k$ largest elements of $S$.
All numbers between these two bounds are achievable.

Taking $r=9$ and $k=4$ as an example, the smallest $n$ that can be formed is $T_4=10$, corresponding to a Kakuro line with 1234 in it. The largest $n$ is $4×10-T_4=30$, corresponding to a line with 6789. If $n=20$, I could achieve it in many ways like 2567 and 1379.
Comment: Nice! :) Assume n is between those two bounds. Any idea on how I can possibly generate such a set of numbers with sum equal to n?
Answer: Okay I figured out an algorithm to do this! Don't know how useful it might be if used to generate this decomposition by hand. But it's a nice method nonetheless and will work well in a computer program. Let $p$ be such that $1\leq p\le r-k+1$. Now we select the $p$ such that the sum of the $k$ consecutive elements starting from $p$ is as close to $n$ as possible(call this value of $p$ as $p_0$ and the respective sum $S$ as $S_0$). That is, we select the maximum $p$ such that
$$S=\frac{(p+k)(p+k-1)}{2}-\frac{p(p-1)}{2}\le n$$
In a computer program, $p_0$ can be found using Binary search in logarithmic time. Now we will distribute the remaining $d=n-S_0$ among the numbers $A=\{p_0,p_0+1,p_0+2,...,p_0+k-1\}$ with the following algorithm.
Denote the $i$ th element of $A$ as $A_i$. Starting from $A_k$ and considering each element until you reach $A_1$, increase each $A_i$ until it reaches its upperbound or the sum of all the increments so far reaches $d$. The upperbound of $A_k$ is $r$ and of all the other $A_i$ where $1 \le i \le k-1$ is $A_{i+1}$. The algorithm terminates when the cumulative sum of all increments reaches $d$.
Now, the elements remaining in $A$ will give you the desired decomposition of $n$. Of course, as Parcly Taxel has mentioned in his answer, we have to check whether
$$\frac{k(k+1)}{2} \le n \le k(r+1)-\frac{k(k+1)}{2} $$
before proceeding with the above approach. If not, there is no valid decomposition under the given constraints.
Answer: There's no known easy way (for a technical meaning of "easy") and there's a million dollar prize for finding one.
This is a variant on the subset sum problem, which is NP complete. If you don't know any complexity theory then this space is too small to give a proper explanation of what that means, but the intuition is that the amount of work required is probably exponential in the size of the problem (and if it turns out to be polynomial in the size of the problem then thousands of other well-known problems are suddenly easier than was previously believed).
The standard subset sum problem doesn't fix $k$, but if this variant could be solved with polynomial effort then running one instance of it for each $1 \le k \le n$ would give a polynomial algorithm for the standard variant.
Note that this doesn't mean that the heuristic in your answer doesn't work well in practice, but it does mean that there are going to be some problem instances on which it works badly.


1970s short story: military artificial-intelligence starship with smart-aleck personality from alternate timeline visits Earth

Question: This story was published in the mid-1970s, probably in F&SF, I remember it in a magazine, not in a book.  It is told from the perspective of a U.S. military unmanned, artificial-intelligence starship with a smart-aleck personality, launched as part of an international armada (he complains about Russian ships and their Cyrillic alphabet) to fight a malevolent alien force for which he has a dismissive nickname, like "spacelees" or something. He is orbiting 1970s Earth (supposed to be ours).  He has difficulty making contact as the U.S. space program has been shut down and its facilities are now museums. Just by luck museum staff were monitoring the radio.  He then realizes not only is he in the past, but in an alternate timeline -- he refers to the U.S. founding fathers, "Washington, Jefferson, Madison, and our first president, Schwartz," (or something like that) and is surprised when the USA he is talking to has a different history (ours). He then realizes that this non-spacefaring Earth will be a sitting duck for the aliens and must decide what to do.
Comment: Please accept the answer, assuming it works. I just downloaded the Galaxy issue and read it last night, and it fits your description perfectly, include President Schwartz. This helps other people who are reading this question.
Comment: Thank you I just accepted it.  I saw the issue online but went ahead and ordered the "Best of Galaxy Volume IV" one of the many anthologies in which it appeared.  The cover art is a great painting of two starships by Patrick Woodroffe, which was reproduced over a page and a half in Steven Eisler's 1979 coffee-table art book "Space Wars, Worlds and Weapons" -- having that on a book cover was just too tempting.  Thanks again everyone.
Answer: I believe the story in question is "Helbent 4" by Steven Robinet  "I was programmed by the NASA contingent.  They speak English, I speak English.  Never did get along with those Ruskie-speaking ships."
Here are the covers: https://www.isfdb.org/cgi-bin/titlecovers.cgi?51699
Comment: Yes, that's the line!  Now I can track it down.  Thank you very much.  Forty year mystery solved in 21 minutes.
Comment: I remembered the story and I remembered reading it in a book with a spaceship on the cover.  But that doesn't exactly narrow it down in this genre.  But you said you'd read it in a magazine so I pulled out "Best of" anthologies for all the mags and there it was.  Glad I could help.


Use of recursive functions

Question: I am reading Kleene's "Introduction to Metamathematics" and I got to the chapter "Recursive functions". I am learning logic in order to understand set theory in order to understand topology. Do I gain something from recursive functions? Is there application of recursive functions in other mathematics areas or is it purely necessary for proofs about formal systems. What is the use of recursive functions in logic? Why is it interesting to learn more about them?
Answer: Headline response. If what you want to get to know about is set theory, then you don't need to know about recursive function theory.
Slightly longer response. Yes, if you want to understand the general idea of a formalized theory (like formalized set theory), you need to grasp e.g. the (informal!) idea of its being effectively decidable what's an axiom, what counts as a proof, etc. But to grasp that, all you need is something like the idea of its being decidable-by-a-suitably-programmed-computer what's an axiom, etc. (or something like that). For these purposes, you don't need a theory of computable functions or the idea that the computable functions are just the recursive ones. So you don't need to know about  recursive function theory.
One more (important!) remark. Kleene's book -- over 65 years old -- is a marvel. It is still worth reading if you already know an amount of logic. But it certainly isn't the place for you to start now, with decades of later logic books orientated to beginners to choose from. But how to choose? Here is an annotated Teach Yourself reading guide through some of the logical literature linked here, including suggestions of introductory books on set theory (and if you take a look at them, you'll see how little logic you actually need to get started on set theory).
Answer: This is suppose to be a comment. But what I understand these days is that:
first order logic is kind of hard to define "infinity", or what you may write in the proof as "...". Notice "..." is sort of illegal in set theory, so recursive is a methods to deal with it.
Also, It was used to define the theroems, which comes handy when dealing with define operations like multiplication and addition.

Use of recursive functions


How reliable are bubble balancers?

Question: I'm starting down the DIY-automotive path and was reading about how some people use bubble balancers to balance their own tires at home.  Can anyone speak to the accuracy of these balancers?  Does anyone use them, and if so, how you found them to be precise enough for everyday use?
Comment: I bought a bubble balancer and have not yet used it. Your insight is extremely valuable. My dad was a mechanic in the 50's and 60's. All they had were bubble balancers. No complaints were heard. By the sounds of the reading I just did n the blog, bigger,better, faster isn't always better or faster. Thanks all, for your insight. You pretty much set my concerns to rest.
Comment: Steve. The guy who said use chalk and add half weights on inner and outer rim is exactly how we did it in the early 70s. Very good description on how to use a static or bubble balance
Answer: A bubble balancer is only able to balance the tire in one plane, as if it were a flat disc.  A dynamic balancer is able to detect and correct for balance in both that plane as well as the axial dimension.  You'll notice that wheels balanced on a dynamic machine often wind up with weights added on both the inside and outside of the rim.
Answer: Long before the spin balancer was invented all tires were balanced by a bubble balancer.  If done properly, the 4 point static balance is as good and accurate as any other method.
The most effective bubble balance is accomplished on both inner and outer portions of the tire rim.  This is called a 4 point balance, and can be accomplished as fast as any dynamic balance.
To statically balance a tire using a bubble, the outer edge locations are determined by centering the bubble with 2 weights at the outer side of the rim.  Once the weight is determined these 2 locations are marked on both inner and outer sides then the weight used is divided by 2 and the inner side has half of the weight of the outer side.
As an example 2 one ounce weights placed on the outer edge of the tire center the bubble.  These 2 locations are marked with chalk, and the bottom of the tire is also marked so when it is turned over the mark will show where to place the weights on the inside of the rim.  This creates 4 half ounce weights hammered into position, 2 on the inner rim and 2 on the outer rim.
Answer: The race team that I buy my tires through (they do periodic group buys), will do free mounting and balancing with a bubble balancer.  I've taken advantage of that before and have no complaints.  Couldn't tell any bit of difference between a set of tires dynamically balanced and those bubble balanced.  The only apparent downside was that it took longer to do the balancing process with the bubble balancer vs. a dynamic balancer.
Answer: I grew up in the days of a bubble balancer at most tire shops. The spin balancer was gaining popularity but many older shops still utilized their old balancers. Back then a tire change was about 5 dollars. The method worked well.
Today I am in my 40's and have noticed the skill and experience of those days are gone.  Go to an auto parts store and the lack of knowledge is very evident also. I have recently set my garage up to do all off my own general maintainence so I bought an older tire machine and bubble balancer. I have done my own tires now for over a year and I drive 500 miles per week on those tires. Bubble balancers are still quite accurate.
It is always nice to do for yourself. I have been able to do things on my time frame without paying expensive rates.
Answer: I have worked at a shop for over 30 years. And one of the things that people forget about Static balancing is that it gives you the opportunity to rotate the tire on the rim a lot easier than the dynamic machine before filling with air. Rotate the tire on the rim and get the balance as close as possible then fill with air !  Now recheck the balance and finish up with less weight than you would if you did not follow this procedure. This is what I learned thru out the years at various shops gas stations etc...
   This does take more effort and time but the results could be better. The major reason for dynamic balancing. Saves time ! And is easier to use. Almost fool proof.
  Nothing wrong with static balancing if you know what to do.
Answer: Quite some time ago I was in Dale Earnhardt's pit prior to the start of the Daytona 500.  A member of his crew was balancing his tires with a bubble balancer.  I asked him why he wasn't using a computerized balancer and he said because they weren't worth crap compared to a bubble balancer.
Not much more to say about the subject.
Answer: To echo many of the other statements our shop used a bubble balancer from 1967 to  1995,never had a complaint. We did go to spin balance,it was a nice selling point to have one. Perhaps we used fewer weights with this unit. I still have my own bubble balancer,it works great!
Answer: For the average car or truck a bubble balancer works just fine. You won't notice a difference in tire wear or ride.
Answer: To any one pursuing a comparison.   A Dynamic relies on cheap computerized chips that may be failing to read accurately after SO many balance tires.  A properly set bubble balancer will always give you a true natural balance that only water can give you. – Just don't have any beer before using it, otherwise it is on you. :-)
Comment: This is simply not true.  A static balance will read fine with two 20 pound weights added to the tire 180 degrees apart.  Now drive it and understand why dynamic balancing is always better.  The best dynamic balancers apply a "road force" to the tread for a true simulation of the tire in actual use.
Comment: @SteveRacer Certainly that'd be awful. But look at the Dec 29, 2013, Answer (above) from Steve, who suggests a bubble balance with the minimum required weight, then division of that weight between the outer and inner rim edges. I don't know the value of adding "road force" for actual-use simulation, but what Steve describes should work pretty well. Me...I'm letting the tire shop guys do this.

How reliable are bubble balancers?


Difference between "I will ____" and "I'm going to ____"?

Question: My ESL friend and I were talking, and he was ready to go to sleep, so he said "I'll go to sleep!", and I corrected him to "I'm going to sleep", but I couldn't explain why.  Does anyone know?
Answer: It depends when your friend said it.
I will go to sleep means that eventually you plan on sleeping.
I am going to sleep means you are currently in the process of "going to sleep".
Therefore, if your friend said "I'll go to sleep" and was not in the process of doing so, then he was correct.
However, if your friend was on his way to bed, or was on the couch attempting to fall asleep, then you were correct.

I'd also like to add that in casual conversation, people who say "I'm going to sleep" imply that they want to go to sleep (not that they're currently on their way to do so).


Ba'al-Pe'or outside of Jewish sources

Question: In the Tanach, Ba'al-Pe'or was a Moabite deity used by the Moabites and Midianites to cause the People of Israel to sin with idolatry and immorality (Numbers 25). Ba'al Pe'or is further mentioned in some other Jewish sources, such as the Talmud and later works.
I was wondering if any non-Jewish sources mention Ba'al-Pe'or, in particular ancient texts?
Comment: https://en.m.wikipedia.org/wiki/Baal
Answer: The only ancient sources I have been able to find are from the works of Roman and Greek Christians from the early stages of the Christianisation of the Roman Empire. These typically are acquainted with the god's name via the Ancient Greek translation of the Tanakh (commonly known as the Septuagint), in which he is called something like Beelphegor.
Moreover their main concern with the topic of his name is the performance of some interpretatio romana and interpretatio graeca, i.e. their attempts at identifying a foreign deity with a Roman or Greek one with whom, in their own homelands, they would be more familiar.
In Ch. 2 of his Commentary on Isaiah (writing in the late 300s & early 400s AD), Eusebius Sophronius Hieronymus, better known in English as St Jerome, says that "the idol Beelphegor" is to be interpreted as Priapus. According to Theoi.com, the Greco-Roman divinity Priapus

was the god of vegetable gardens. He was also a protector of beehives,
flocks and vineyards.
[He] was depicted as a dwarfish man with a
huge member, symbolising garden fertility, a peaked Phrygian cap,
indicating his origin as a Mysian god, and a basket weighed down with
fruit.

In Against Jovinianus 1.22, Hieronymus highlights further the logic behind this identification by appealing to an apparent similarity between the Greek/Latin word Priapus and the "Hebrew" Phogor, i.e. Pe'or.
According to p. 74 of A Dictionary of Angels, Including the Fallen Angels, by Gustav Davidson (The Free Press, A Division of Simon & Schuster Inc., 1967, New York, NY), Rufinus, a contemporary of Hieronymus, also identified Beelphegor (or Belphegor) with Priapus.
According to p. 97 of the Rev. John Thein's Ecclesiastical Dictionary, Containing in Concise Form, Information Upon Ecclesiastical, Biblical, Archæological, and Historical Subjects (Benziger Brothers, 1900, New York, Cincinnati, Chicago), Origen of Alexandria, who lived a couple of centuries earlier, made the same identification.
In his Commentary on Psalm 106, Theodoret of Cyrrhus, yet another contemporary of Hieronymus and Rufinus, says that "Baal Peor is an idol" while "Peor is the name of the place of the idol", and also that the idol Baal is "called Kronos [Cronus] in the Greek language."
The 10th century AD encyclopaedia called the Souda [Suda] seems to be referencing Theodoret when it uses almost these exact words of his for its definition of this god's name under the encyclopedia's "Beelphegor" and "Phegor" entries.
Thein's Ecclesiastical Dictionary says that Apollinaris and St John Chrysostom also identified Baal-Peor with Saturnus, in which case the Roman name for the Titan Kronos is being here employed.

Ba'al-Pe'or outside of Jewish sources


Reconstruct images from PCA reduced dimensions with NN

Question: I was reading this Medium post and I had the idea to reconstruct the original images with a convolutional neural network instead of applying the inverse transform method. The problem is that I don't know how to define the input of the CNN. From what I know, PCA reconstructs the original images as a linear combination of the eigenvectors, so I guess the features should be the k eigenvectors for each original image, but having the same features for different labels doesn't make sense. Is it possible to recontruct the images from the reduced dimensions? If possible, what approach is the one you think would work?
Answer: I'm not sure I understand your question. You want to create a neural network able to reconstruct an image thanks to its PCA ? This could be some sort of autoencoder that uses PCA for its latent representation. The encoder of the AE would simply be the PCA (AE isn't actually relevant here, nothing trainable in the "encoder", but I like the parallel since we're talking about generative machine learning/up-scaling 2D representations).

If possible, what approach is the one you think would work?

Since an image will have 2D eigenvectors of already good shape, you could simply concatenate them, flatten, use a mean, use a concatenation of different 2D statistics/transformations, combine the results of several sub-networks starting from different 2D statistics of the eigenvectors (or the eigenvectors themselves), etc. as an intermediate representation. This is the tricky choice, following which you'll have to deal with typical AE decoder architecture design.
An illustration of the sub-networks idea (replace 1D inputs and 1D output with 2D data in your case):

Is it possible to recontruct the images from the reduced dimensions?

If you're starting from reduced dimensions, it's not a problem: you can use either the so-called "deconvolution" (transposed convolution is the actual name) for direct 2D upscaling (see here for Keras implementation, and here for the equivalent PyTorch function), or simply if working with a flattened input/intermediate representation, re-shape a 1D large enough neural network layer, to go back to the original image shape.
Finally, note that if you use a neural network as it is commonly defined, your transformations will involve non-linearities.
That being said, not sure it's going to give you a great result, worth a try ! IMO you should try feeding each (or the n-largest) eigenvector into their own very simple sub-network, before combining their respective intermediate representations in a common final network that will output the right shape. Use simple architectures since you probably want to compare with linear combinations of eigenvectors.


Can users ask to have comments removed?

Question: Recently, while browsing stackoverflow, I came upon this question. As precedent dictates, we usually ask to see what the asker has tried.  In response, the asker asked me to remove the comment. Should users ask to have comments removed?
Answer: They can ask, but I'd just ignore that request.
If the OP has a problem with a comment he or she can flag your comment for mod attention. In this specific case, the mod would decline the flag though, there is nothing wrong with your request for more details.
You can do the same with that comment; I can understand it if someone were to flag it as non-constructive, for example. Either a moderator can then remove the comment, or, if enough people flag it too, it'll be auto-deleted.
Comment: More than that, I would mark the OP comment as off topic/not constructive and with enough such flags (5 I think) his comment will be auto deleted.

Can users ask to have comments removed?


jquery jrowl size

Question: How to set the jgrowl size to be as auto.Because if the the contents are more i thinks it wraps up the content.
can we set this something like

Thanks.
Answer: There does not appear to be any public methods for setting the width of the growl itself. Your best option may be to go into the css file itself, and change it from ~235px to something larger. Note that this isn't really solving a problem. In reality, causing long text to wrap is (generally speaking) the ideal behavior.
You may also be able to add some logic to the beforeOpen() method that estimates the width of an unwrapped child, and adjusts the width of that particular growl.
Answer: I have done this using the beforeOpen callback as follows:
$.jGrowl( "your message here", {
      life: 3000,
      easing: "swing",
      position: 'bottom-left',
      beforeOpen: function(e,m,o){
          $(e).width( "550px" ).height("108px");
      }
 });

Note that e refers to the container element that encloses your message. Therefore the above code does not set the size of the popup window itself but the content of the popup window. The popup window resizes appropriately to accommodate its content.

jquery jrowl size


Proving that sum of two continuous real valued functions in a metric space is continuous

Question: Let $(X,d)$ be a metric space and let $f:X \to \mathbb{R}$ and $g:X \to \mathbb{R}$ be two continuous real valued functions on X , I wish to prove that $(f+g)$ is also continuous on $X$.
My problem is that why we are choosing $\delta$ to be minimum of $\delta_1$ and $\delta_2$ why not maximum of $\delta_1$ and $\delta_2$?
Comment: Instead of posting a picture, learn some Mathjax and type the question.
Answer: Think about what could happen if $\delta_1\neq \delta_2$. Take $\delta_1>\delta_2$, then if we set $\delta =\text{max}(\delta_1,\delta_2)$ then $\delta=\delta_1$. Thus, we know that $d(x,y)<\delta$ implies $|f(x)-f(y)|<\epsilon/2$, but since $d(x,y)<\delta=\delta_1$ and $\delta_1>\delta_2$, we might not have $\delta<\delta_2$, and therefore the second condition might not hold. Therefore, we need to take the minimum of $\delta_1$ and $\delta_2$ to ensure that $d(x,y)<\delta_1$ and $d(x,y)<\delta_2$ so that the two implications in the proof hold.
Answer: By choosing $\delta$ to be the minimum, we have $d(x,y) < \delta$ implies both $d(x,y) < \delta_1$ and $d(x,y) < \delta_2$ so we may use the earlier two continuity statements regarding $f$ and $g$. If you choose the maximum, you may not be able to use one of the earlier statements.


Integrating Open ID and also leveraging Microsoft HealthVault

Question: I've seen several articles/questions regarding Open ID integration but I'm curious if I integrate this into my site and then try to integrate with Microsoft HealthVault which accepts live id or open id, how smooth that is or if there is a potential of multiple login actions (obviously undesired).
Ideally I would love to do something like, register for my site, if you would like to use Microsoft health vault to store health information, tether an account and subsequently you wouldn't have to do anything assuming you logged into your account within my site.  Anyone have any idea if that is possible?
Answer: I've been working extensively with HealthVault over the past few months.  I haven't been using OpenID at all, but I would think that it wouldn't make a difference to your application whether the user chooses to use OpenID or LiveID.
To integrate your application with HealthVault, you would provide a link to the "Auth" Shell Target that the user clicks on to logon to their HealthVault account.  It looks something like this (see this page for more info):
https://account.healthvault-ppe.com/redirect.aspx?target=AUTH&targetqs=%3Fappid%3Dcd77270a-365a-4018-81c2-48f1d950d66d%26forceappauth%3Dtrue%26redirect%3Dhttps%253A%252F%252Ffoo.bar.net%252Fhealthvault
After logging on, HealthVault will redirect the user back to your application, returning a "wctoken" parameter with it.  Your application uses this token to access the user's HealthVault record.
Answer: I'm not sure what kind of integration you have in mind, but if you want users to be able to post and/or view information from their HealthVault account while they are visiting your site, and assuming HealthVault supports such a scenario, then they (should) support some kind of delegating authorization protocol such as OAuth or (more likely) Windows Live's proprietary version of OAuth.  Anyway the fact that your site and/or HealthVault takes OpenID or Live ID shouldn't be any cause for a problem in that flow.  Authorization should be independent of authentication.


How to delete videos from iMovie on iPhone?

Question: I'm having an issue where I cannot delete anything from the iMovie app on my iPhone 7. How do I delete videos from the iMovie app?
Answer: On iOS - not all videos are stored in the camera roll. iMovie would also show videos which are not in the Photos app. They cannot be deleted the usual way.
There are probably several ways to get rid of them, but this one here deletes all:

Delete the entire iMovie app from you phone.
Install the app again from iTunes or from the App Store.
Answer: Videos in iMovie are from your camera roll. Delete them using the Photos app.


Overlapping Line Fits

Question: I have a large set of data, which when interpolated as a full data set makes for a complicated line shape. The overall line is made of 3 or 4 overlapping different lines for example: There is an x^2 curve, an arctan(x), a ln(x), and  x^-3 curve all hidden amongst the data.
How would I go about writing the code in Mathematica, to find an x^2 curve roughly around a certain point in the data, and fit it, and output details such as the line equation and R^2. Then subtract the x^2 from the fitting, so the other curves can be fitted in other places on the graph.
The end result being that adding all the superposed fitted lines together makes an overall fitted line, and with mathematica outputting the line equation and R^2 for each of those lines.
Thanks in advance!
Answer: <code>FitModel[myData, {1, x, x^2, x^3, Cos[x], ArcTan[x]}, x]
</code>

Overlapping Line Fits


Survival fiction-Plane crash logistics

Question: In my book, five middle-school students are stranded in a desert when their small plane crashes. The pilot dies saving one of them, and there is no civilization within hundreds of miles. How long should it take them to realize that there's no way out, and become determined to survive?
Comment: I would suggest asking this question on the Worldbuilding Stack Exchange. Your question has more to do with the (rather subjective) plausibility of character motives, which is something that's much better-suited for the Worldbuilding site.
Comment: Honestly, this will probably get closed on Worldbuilding as well. And the more pertinent question is how long until they die - no water, no food, no civilization and no survival skills. Perhaps even worse for a bunch of young teens - no internet.
Comment: I'm voting to close this question as off-topic because this question belongs to WorldBuilding SE more than here.
Answer: Five students, five different characters. Probably five different lengths of time to become aware of the seriousness of the situation. Some of them might never get there.
There might be a time when they all reach a collective interpretation, but the interesting writing (and reading) is going to be the conflict in views leading up to this.
Comment: Good point. What do you think should be the average? A few days? A month?
Comment: No idea, I'm afraid, and I'm not sure I'd be able to guess even if I knew your characters. I'm not convinced an average would be meaningful in terms of plot or dialogue - you could always have a "Twelve Angry Men" style reversal.

Survival fiction-Plane crash logistics


Can I win a science victory after I win a cultural victory?

Question: I wanted to win a science victory right after winning a cultural victory. To win a science victory, I have to build a bunch of spaceship parts and move them to my capital, where they are assembled. Thing is, I can't stack units, so either the spaceship parts can't move to the capital if there is another part there, or they just switch spots. Is this normal, or it is a bug?
Answer: To construct the spaceship, whenever you move a spaceship module to the capital, you need to choose the option to "add" it to the spaceship. The module will disappear and your spaceship will receive it (if it's the first module you add, a 3D model of a spaceship will also appear near the city). This option should be listed at the command bar on the left, just like other unit options.
However, you cannot add modules to the spaceship if one of these applies:

Another civilization has already completed a spaceship
You have manually disabled the "science victory" option when you set up the game
You have already won the game in some other way

As you can see, the 3rd case above applies to you. I'm afraid you cannot conquer the stars in this game... you have no choice but to start another :) enjoy your all-nighter!
Comment: Upvoting this gives mixed feelings. It's a good answer, but I really dislike that the science victory is the only one disabled after you already win. I wish they would change it. I was going for science victory but accidentally won by the diplomatic victory way before I was even able to build the space parts (it was in 1946, and I now have all parts in 1983 - having won culturally as well, in between). I was so excited to see the science victory for myself. Now I guess I'll have to sell them for the 4 aluminium: http://i.imgur.com/AMZN4By.jpg
Answer: the only way i can think of would be to launch the starship first, then win the culture victory while the ship is in transit, thus winning by both means. I have personally done this, btw.
Comment: Victory in Civ V occurs when the spaceship is launched.  Not on arrival.  You're thinking of a previous Civ game.
Comment: @BenCraig So you can't win with a science victory first, and then others later? That seems odd. I wonder why the science victory is different.
Comment: This answer is incorrect. Im not sure how you could have personally done this.


Passing date/time to cron job command

Question: Is there any possibility to pass current date/time to command in my cron job?
E.g. I want to make sql dump every night and name the dump file like 'dump-yyyy-mm-dd.sql'.
Answer: Sgaduuw's answer does work (and I've upvoted it), but I usually encourage people to write scripts and call those from cron, rather than try and do too much in the cron command directly.  Firstly, it allows you to easily test / enhance your script without having to mess with cron configuration, and secondly it allows you to be in better control of the environment in which your commands execute.
Answer: That would be something along the lines of:
mysqldump database > database-$(date +%F).sql

The $() will embed the output of date +%F, which is YYYY-MM-DD into the command line.
Comment: You should be careful to escape %s with backslashes in your format string if you're using a POSIX compliant cron, otherwise everything after the first % will be treated as standard input for the command.  Check `man 5 crontab` for details on this surprising yet fun feature.

Passing date/time to cron job command


Counting number of bluetooth 4.0 (BLE) devices near me?

Question: Does bluetooth allow you to discover devices around you that are simply on but aren't in any discovery state? I am not trying to pair with all these devices but merely count the number around me and maybe get signal strength information for very basic distance estimation. Essentially lets say I am in a room full of strangers who have their BLE turned on their phones, can I sense that they are on using my phone without them having to do anything? Essentially just notice them and count them?
Answer: What you are trying to do is not generally possible.
To achieve this the BLE device needs to be sending packets that you can detect. A BLE device will only be sending packets in some special cases. Those are when it is advertising (sending advertising packets), active scanning (and therefore sending scan request packets), or it is in an active connection.
Contrary to the previous answer though, advertising packets would allow you to get the Bluetooth address without having to make a connection and pair (although I don't think from your question you were interested in addresses).
It is correct though that you could use something like Ubertooth to sniff the any of the packets mentioned above. That would allow you to at least detect that there were some devices near you (even without having to decrypt the packets if the device was part of an encrypted connection).
Answer: I don't think that is possible. You can only look at the devices that are not hidden. You need to know the MAC ID of the devices to detect if the devices are there. Once you pair with them you can know the MAC ID. So, you can detect those devices if you somehow know their MAC IDs. You can get the MAC ID from devices you access to and use it in the future to detect the device. But for random strangers' devices, no, I don't think so.
However have a look at Ubertooth. http://hakshop.myshopify.com/products/ubertooth-one
It allows you to directly sniff all 2.4 GHz radio waves. It is also used for messing with Bluetooth.
Comment: This answer is incorrect with regards to bluetooth low energy.


Does my validation curve indicate over fitting from train and test?

Question: I carried out a grid search on my xgboost and varied the parameters below. I noticed in my grid search results that the train score is very high, e.g. 0.99999 and my test scores are more modest around 0.72. Since there is such a big difference between my train and test score does this indicate over fitting?
Answer: I assume your score is a metric like accuracy, f1-score etc. If that is the case, yes, it quite certainly indicates overfitting. 28% accuracy difference between train and test/validation is very high, and it means the model didn't generalise as well for the test set as the training set.
Comment: what if i am also doing a grid search on say brier score, how can i tell over fitting?
Comment: It still is large. It's also interesting to see that your scores don't change wrt hyperparameter changes


Does SharePoint in any way support Wiki markup languages?

Question: I tend to think the answer is no.  There is so much noise with these search terms that I am having problems coming up with a definitive answer.
Answer: SharePoint Wiki out of the box does not support 'full' standard wiki markup languages. (Most commonly the "[[page]]" markup is the only utilized wiki markup in SharePoint wikis). This is one of the foremost complaints with the SharePoint wiki.
Comment: Have you looked at the codeplex link?  Some interesting stuff.
Comment: For the enhanced wiki, yes. We use an alternative one from KwizCom. Not bad. Though the PM for the vNext SharePoint wiki is on twitter and REALLY listening to everyone's feedback.
Answer: If you prefer to edit your shared documents using markdown there is a workaround.
You can use the excellent opensource Atom editor and save your documents as html:

Edit your document
Open the markdown preview (Ctrl + SHIFT + M)
Right click in the preview pane, select Save As .html (you must save as file, not copy as .html)
Open the file, copy the contents

Then, on the sharepoint site, you paste the doc as HTML:

Select 'Edit this page'
Click edit source
Paste the html text
Click OK

The only shortcoming is that if others are editing the same page you won't be able to convert the page from html back to markdown; it's a one-way process only.
Comment: You can use standard [Pandoc](https://en.wikipedia.org/wiki/Pandoc) for Markdown to html conversion.


How can I delete just 1 or 2 message

Question: How can I delete just 1 or 2 sent or received text messages without deleting the whole text conversation?
Comment: Which version of iOs ?
Answer:
Click on the person's name from the Message screen. This will take you to a record of all the messages you have exchanged with that number.
Click on the edit button at the top right of the screen.
Choose the message or messages you would like to delete. If you change your mind and decide not to delete any, simply go to the "Done" button at the top right of the page.
Once you've finished selecting all of the messages you would like to delete, just tap the "Delete" button at the bottom of the page!
Comment: every since I did an update on my phone that edit button is not there instead it says contact.
Comment: @Jul which update?
Comment: not sure husband does that stuff
Comment: @Jul then see [this](http://support.apple.com/kb/ht2188)
Answer: Just hold down with the finger for 2. sec. on the message you want to delete, and then select "More..." - now you can select more message and when you have chosen all the message you want to delete, you click on the trash icon, and the message(s) are gone.

How can I delete just 1 or 2 message


Can I travel to the UK as a dependent, after a 10-year ban?

Question: I want to know if I can be granted a visa as a dependent after my 10-year ban has elapsed.
Comment: What do you mean "as a dependent". Do you mean to say you were given a 10 year ban when you were under 8 years of age? Or do you really mean "as a spouse"?
Comment: Being a "dependant" means that somebody else is supporting you. For example if you are a child supported by your parents or a wife supported by your husband.
Comment: Has the circumstances that led to the ban been resolved? You can apply, but whether you'll get one is not up to anyone here so we can't answer that, but if the reasons you got banned are still present, chances are higher that an application will attract another ban than be successful. (And why is this tagged "schengen-visas" when it's about the UK? They are not a part of Shengen)
Comment: @DJClayworth If that comment was to me, I do know that. However, whether the OP was an adult spouse who willing overstayed (assuming that as the reason for the ban) will be treated differently by the deciding officials, than if the OP was a young child who overstayed because their parents did.
Comment: No, that comment was for the OP.
Answer: You ask "can you" be granted a visa. You've served your time, a 10-year ban, from entry into the UK. There is no longer any reason the UK government, specifically the border agents, for you not be granted the right to enter the UK via a visa.
However, the real question you are probably asking, is will you be granted such?
There is absolutely no way for us to know your personal circumstances and your ties to your home country. If you are wealthy enough to be able to afford to travel to and stay in the UK as a tourist, for as long as you are intending, then that check box is handled. The real problem will come when you are attempting to convince the UK agents that you will leave the country at the end of your stay. They will be hard to convince. It also depends on why you were given the ban in the first place.
If your ban was for overstaying, then you've already proven your pre-diposition to ignore the length of visa. If you were banned, as a dependent because your parent or parents overstayed, then by all rights, they should not treat your case as harshly, but you'll need to give even more reasons you have to be willing to return to your home country after. Because you have history that you are attempting to overcome.
In this SE we have had many, very many, people who write questions asking why they were denied a visa with the reason of lack of proof of intention to leave and they didn't have the additional issue you do, which is having already served a ban.


3d object overlay - augmented reality irrlicht + opencv

Question: I am trying to develop an augmented reality program that overlays a 3d object on top of a marker. The model does not move along(proportionately) with the marker. Here are the list of things that I did
1) Using opencv: a) I used the solvepnp method to find rvecs and tvecs. b) I also used the rodrigues method to find the rotation matrix and appended the tvecs vector to get the projection matrix. c) Just for testing I made some points and lines and projected them to make a cube. This works perfectly fine and I am getting a good output.
2) Using irrlicht: a) I tried to place a 3d model(at position(0,0,0) and rotation(0,0,0)) with the camera feed running in the background. b) Using the rotation matrix found using rodrigues in opencv I calculated the pitch, yaw and roll values from this post("http://planning.cs.uiuc.edu/node103.html") and passed the value onto the rotation field. In the position field I passed the tvecs values. The tvecs values are tvecs[0], -tvecs[1], tvecs[2].
The model is moving in the correct directions but it is not moving proportionately. Meaning, if I move the marker 100 pixels in the x direction, the model only moves 20 pixels(the values 100 and 20 are not measured, I just took arbitrary values illustrate the example). Similarly for y axis and z axis. I do know I have to introduce another transformation matrix that maps the opencv camera coordinates to irrlicht camera coordinates and its a 4x4 matrix. But I do not know how to find it. Also the opencv's projections matrix [R|t] is a 3x4 matrix and it yields a 2d point that is to be projected. The 4x4 matrix mapping between opencv and irrlicht requires a 3d point(made homogeneous) to be fed into a 4x4 matrix. How do I achieve that?
Answer: The 4x4 matrix You are writing about seems to be M=[ R|t; 0 1]. t is 3x1 translation vector. To get the transformed coordinates v' of 4x1 ([x y z 1]^T) point v just do v'=Mt.
Your problem with scaling may be also caused by difference in units used for camera calibration in OpenCV and those used by the other library.


Can I give a single non-sudo user access to run a single command without sudo?

Question: Is it possible to give a single user without sudo access, the ability to run a sudo protected command like chmod?
Comment: This doesn't answer your question, but I think it's worth pointing out that allowing a user to run `chmod` as root in one way or another, without filtering what they can do with `chmod`, is effectively equivalent to granting them full root access.
Comment: yeah, is it `chmod`, or something else? Because as Stephen Kitt says, you can't give someone access to `chmod` without effectively allowing them to become root. There's other things that might be safe. Might be worth talking about the problem you're solving, more than about what you consider a good solution at this point!
Comment: What does it mean, "sudo protected"? I can run this command with my credentials.
Comment: why not limit sudo for a specific user to a single command (or even a group of commands) you want him to be able to run ?
Comment: @golder3 That is basically what I want, but how to limit sudo for a specific user?
Answer: sudo configuration files are stored in /etc/sudoers file and /etc/sudoers.d directory. It is preferable to add a file, with the same name as the user you want to set the sudo for, to /etc/sudoers.d although you can also edit /etc/sudoers.
The basic syntax is who where = (as_whom) what
For example:
root ALL = (ALL:ALL) ALL

menas allow user root to run on any host (ALL = ) as any user:group (ALL:ALL) any command (ALL)
In your case, you need to do something like:
echo "ltd_user ALL=NOPASSWD:/bin/cat, PASSWD:/bin/chmod" > /etc/sudoers.d/ltd_user

This gives user ltd_user rights to run cat without typing password and chmod after typing password, on any host, as any user
After making a file under /etc/sudoers.d you should set permission to 440
chmod 440 /etc/sudoers.d/ltd_user

Also note that I gave a very basic example (and hence used echo and redirection) but it would be good practice to use visudo command to edit sudo configuration files, which ensures that only one person is editing the file at a time, has the proper permissions, and refuses to write out the file and exit if there are syntax errors in the changes made.
visudo -f /etc/sudoers.d/ltd_user

see man sudoers for more details and advanced examples


prevent autocomplete in chrome address bar

Question: IS there a way to prevent automatic autocomplete in the Chrome address bar? If I start typing an address and an autocomplete suggestion appears it overrides my original typing.  Is there an option to make the user hit Tab or another key to actually select it? I would still like autocomplete to appear, but not select it by default.
Answer: I don't think there's a way to totally prevent autocomplete in the omnibar. You might already be aware, but you can just press backspace or delete to remove the suggested text. And pressing enter will accept the suggestion. This is probably the best way and is simple enough for most.
Answer: To do that.

Go to settings. (hamburge menu on top right corner)
Then navigate to advanced settings.
In the privacy section uncheck the box of Use a prediction service to help complete searches and URLs typed in the address bar. And you are done.

Also the autocomletion depends on your search history. So making it clear will also help you.
Comment: No, this does not resolve the issue.  Previously navigated addresses are the issue, not predicted searches.
Comment: Have you tried Clearing history of chrome? Ctrl+shift+delete.


linear vs non-linear kernel SVM

Question: The dataSet contains 213 examples of 7 classes . Each example are 25000 features. I want to learn model with SVM (test scenario used are 10-fold cross validation). I am a beginner in machine learning, i want to know what type of kernel i should use in the case of my data: linear or no-linear (as RBF kernel). Also, I want some tips to choose the value of parameter C. Thanks!
Comment: Cross-validate. That said, 7 classes from 213 elements is a bit of a tall order...
Answer: By elements you mean samples/examples right?
If your dataset consists of 213 samples of 25000 features each you have a much more serious problem to solve than the selection of your SVM hyper-parameters.
In short 213 samples provide are very few for the dimensionality of your problem. In high dimensional spaces you typically need lots of data have a sufficient representation of the space (and this is just one of the problems associated with high-dimensional data). The main issue you have to deal with is feature selection, in order to reduce the number of features.
Now to answer your question:
If I were to choose, I'd take a linear kernel in such a problem. The last thing you need is to project the data to an even higher dimensional space.

linear vs non-linear kernel SVM


What's the difference between incremental and throw-away prototyping?

Question: As far as I know, throw-away prototyping involves creation of prototypes in iterations where each prototype is discarded after one iteration. For incremental prototyping, the resources I referred to don't state a dissimilar explanation... What exactly is the difference between the two?
Answer: Such terms are alway a little bit problematic, since they mean not more or less than what the person who wrote them down had in mind with them. For a canonical answer, one had to ask them, not some strangers from the internet.
Said that, I usually would associate a throw-away prototype with something which is probably not even build with the technology which will be used for the final product. For example, when you are going to prototype a user interface, and use a drawing program, a spreadsheet with graphical capabilities, a mock-up tool or simply pencil and paper. So it is pretty obvious that you cannot incrementally build any real software directly from this kind of prototype. Or when you are using a scripting language for implementing a "proof-of-concept" for prototyping certain algorithm, but then switch to some compiled programming language to implement a full-fledged product.
Incremental prototyping however, is something I would expect to use the same technologies as the intended product, so one can start with a small-and-simple program and incrementally add feature by feature until it becomes the end product.
Answer: The difference is in the names: "throw-away" versus "incremental."
Throw-away infers a one time prototype. This likely happens early in the product development cycle as a means to "separate the wheat from the chaffe," so to speak — a quick and cheap implementation of a final product so stakeholders can judge whether it is even worth proceeding further. The operative words being "quick" and "cheap."
An incremental prototype infers a bigger commitment. When something is incremental, it is not a one time thing. You build something, get feedback, make changes, and get more feedback until you have an acceptable product. Basically "agile development" is fancy-talk for an incremental prototype that is deployed for end users, where at some point people go, "yeah, this is good enough." And then work stops.

What’s the difference between incremental and throw-away prototyping?


Is it harmful that my rabbit eats bugs?

Question: My rabbit is now eating bugs such as crickets and those things. She hasn't shown any signs of health problems while she ate them, but I'm not sure if they're healthy at all for her. The crickets are just in our normal backyard, and every time she runs around the yard, she eats bugs - especially crickets. She apparently wants to eat with her normal feeding. They do live in my backyard and she has eaten some of them inside her burrow to "defend" her burrow. Would bugs harm her in any way?
Comment: The crickets, per se, are harmless and may be a decent additional source of nutrition. My concerns would be whether they've picked up insecticides from your neighbor's garden, and whether there are any parasites which the crickets might be a vector for.
Comment: @keshlam not that i know of but she hasn't shown anything for 8 months.
Answer: No, she's safe to eat bugs if she wishes. The only concern would be if the bugs have insecticides on them but as you commented above chances seem slim.
Insects are not a common vector to transmit intestinal parasites to rabbits.

Is it harmful that my rabbit eats bugs?


Origin of term "Microbe"

Question: What's the origin of the term microbe? According to related definitions and topics, I think it may be micro + be. If it is, what does "be" stand for?
Answer: It comes from Greek, via French.

microbe, etymology - late 19th century: from French, from Greek mikros 'small' + bios 'life.'
popular name for a bacterium, 1878, from French microbe, "badly coined ... by Sédillot" [Weekley] in 1878 from Greek mikros "small" (see mica) + bios "life" (see bio-). It is an incorrect use of bios; in Greek the word would mean literally "short-lived." Online Etymology Dictionary

Therefore, literally it means "small life" and "microscopic life" scientifically speaking.
Comment: I got the impression that "microbe" is often used to refer to all "microscopic life," as you say, which would include an archæon, protozoön or fungal spore as well as the bacterium mentioned in that dictionary entry. It appears to be a synonym of "micro-organism." I guess viruses would technically be excluded by that definition. But interestingly, I found a site that lists them as a possible category of "microbes" nonetheless: http://www.microbeworld.org/what-is-a-microbe
Comment: What about micro organization?
Comment: @sumelic  In medicine we consider "microbe" any  living creature not visible to the naked eye. The word used in the scientific world  is micro-organisms, and this includes all bacteria, viruses, protozoa and fungi.  Prions, as far as I know, are still unclassified.
Comment: @Centaurus: well, there seems to be a bit of controversy about whether the definition of "living creature" should include viruses. I wrote a question about it that you'll see linked to the right of this one.

Origin of term "Microbe"


Where should I install a Kolerflo 120W water pressure booster pump?

Question: I have a tankless water heater and the water pressure is not enough to turn the tank on demand causing the water in the shower to be just barely warm. I purchase a Kolerflo 120W to boost the pressure, should I install it before enters a tankless water heater or after?
Answer: Welcome! I would install it before the tankless water heater for several reasons. Putting it on the outlet would tend to lower the pressure in the tank. Also if it is on the output it will need to operate with the hot water internally causing it to get hotter. To do this it must be rated for that temperature. Putting it if front of the heater will raise the pressure in the tankless water heater hopefully accomplishing what you need. Be sure the pump can run a short while with its outlet blocked as that will happen when shutting the shower off.


Mathematics behind factor loading in Confirmatory factor analysis/ Structural Equation Modeling

Question: I'm curious about how are the loading in a simple confirmatory factor analysis determined mathematically.
Also, the intuition is also hazy to me as to how are the factor loads determined when a variable which is not observed is present in the system and still its impact is being estimated on the observed variables (The factor loading)
Answer: The basic concept is as follows:

Determine what the covariance matrix should be, as a function of the factor model and the unknown loadings.
Calculate the observed variance/covariance matrix from the data.
Estimate the parameters. Different software uses different algorithms. A conceptually simple choice is a least squares fit. Choose the parameters to make the theoretical matrix close to the observed matrix.

For a simple, one factor model, the covariance of $X_i, X_j$ is $\lambda_i \times \lambda_j$ and the variance of $X_i$ is $\lambda_i^2 + \sigma_i^2$
If I have $p$ variables loading on the factor, that gives me $2p$ parameters from the model and $p(p+1)/2$ observed entries in the covariance matrix. Note that I am fixing the variance of the latent factor to 1. Alternatively, I can fix one of the loadings to 1 and estimate the latent factor variance.
Note that if $p=2$ I have too many parameters and if $p=3$, the model is saturated and I can choose parameters to give a perfect fit. You want at least 4 observed variables to make this interesting.
Comment: It's surprisingly straightforward to code up a simple confirmatory factor analysis in Excel, this can help you to understand what is happening.  There's a paper here: http://link.springer.com/content/pdf/10.3758/BF03192739.pdf
Comment: The factor loading is determined from the fact that there is covariance between indicators of a latent variable and thus by analysis of the variances of these indicator variables (the values of which is known to us) we try to find out the impact that a factor/latent variable has on a specific indicator (relative to one indicator for which we fix the loading to 1).
Is this the correct way to think about it ?
@placidia
Comment: you almost have it. the covariance between indicators comes from the loadings from the indicators to their common factor.


Are all of Cicero's writings considered models?

Question: When translating into Latin or writing in Latin, is there a hierarchy between Cicero's writings?
For example, if one construction is used in one of his letters and another in one of his speeches, can I arbitrarily choose one or the other as the best Latin?
Answer: When stylists claim to use Cicero as a model, they are chiefly talking about his orations, and his orations are what he is originally known for. Long before he penned philosophy, he was lauded as an excellent orator, to whom only Caesar could compare. (So how unlucky are we that Caesar's orations are lost!)
This reputation stayed with Cicero throughout his life and long afterward. When Antony had Cicero murdered, his wife Fulvia, so Cassius Dio reports, placed a pin in his tongue as revenge for the damage his orations (thinking probably of the Philippics) did to them. Later, when Quintilian is lauding the greatest stylists of Latin and Greek, he compares Cicero and Demosthenes. Demosthenes, of course, is also famous chiefly for his orations (and interestingly his most famous work is probably his Philippics, which, more appropriately named, was written against Philip II, father of Alexander the Great).
Cicero's philosophy probably comes second. Since they're written in dialogue form, Cicero does use some rhetorical devices in them, but they are generally not as well-regarded stylistically as the orations. Not necessarily for the lack of language, per se, but the orations are where Cicero fully recognized his talents and (with some probably polishing after the fact) was able to show those talents off to a wider audience. Meanwhile, the philosophy was largely introspective work, so while it is seen as "good Latin", it's just not what people usually are referring to when they talk about his rhetorical and stylistic prowess. Certainly of course you can find excellent examples therein and many grammars will freely quote from them, so don't neglect them if you want to model your own Latin off him.
The letters are generally not seen as excellent examples of Cicero's style. For one, they were not consciously written for publication. We only have them because they were posthumously publishes, and their importance is more in documenting his life and interactions and the decline of the Roman republic. They most certainly were read by later authors, though, and influenced them. Pliny perhaps had Cicero's letters in mind when he deliberately published his own. But for incongruities between Cicero's speeches and letters, the former are preferred as what Cicero himself saw (and was tested in courts and in publications) as good style.
Finally, avoid his poetry. It was a joke even in antiquity. Some scholars have tried to find positive merits in them, and certainly it can be done, but no one really sees them as excellent exempla to emulate.
Comment: Cicero's letters were extremely influential in the Renaissance, precisely because they modeled an alternative to his grand rhetoric. Petrarch imitated them in his own Ad Familiares, and from there it became a matter of course for influential humanists to curate collections of correspondence.
Comment: @Kingshorsey No doubt they were influential, and I hinted at their importance when I mentioned Pliny above, who copied Cicero (though less in style than in purpose) over a millennium before Petrarch. Their style is usually not what is meant though by rhetoricians and stylists when they exalt (or denigrate!) Cicero's Latinity (thus my phrasing: "not seen as...Cicero's style"). But yours is a point well made.
Answer: Some of Cicero's writings are great examples of Latin prose, but not all are. There are no strict rules about which of Cicero's works are the best to use as examples. It depends on what you're writing and what style you want. If you're writing something personal or casual, Cicero's letters might be more helpful, but if you want to write something more formal or persuasive, his speeches would be a better choice.
You also need to pick the right grammatical construction for the style and context of your writing. You can't just pick a construction from one of Cicero's works and use it without considering if it fits your writing.


Play QuickTime Video in WPF

Question: Is it possible to play a QuickTime Video in WPF? If yes, can anyone provide me the resources.
Answer: Quicktime is a tricky thing on Windows.  The APIs pretty much don't exist for any language except C++.  Here's some documentation from the Apple developer website; Quicktime Development For Windows.  But I doubt this will be useful for your WPF development.
Another option is to use the Quicktime ActiveX control/COM object.  Its essentially a built in player with minimal control.

Play QuickTime Video in WPF


Is "die Treuhand" used the same as "das Vertrauen"?

Question: I know that both mean "the trust" but I have never heard yet "treuhand" in a conversation or in books
Comment: If you have difficulties finding the appropriate German term for an English expression consider to consult another dictionary. Look at the [entry e.g. in dict.cc](https://www.dict.cc/?s=trust): using *Treuhand* as a translation for *trust* is reserved for its use as a technical law term - so it is of little surprise you don't hear it in everyday conversations.
Answer: While "Vertrauen" means "trust" in the sense of "I put my trust in you",
"Treuhand" is a rather specific term for certain judicial and/or financial constructs. You might want to look it up in Wikipedia:
Treuhand
Trust
After the German reunification, an agency named "Treuhandanstalt", often abbreviated as "Treuhand", was set up to manage the state property of the former German Democratic Republic. If someone talks about "die Treuhand" without further explanations, they most probably refer to the
Treuhandanstalt
Comment: And it is a politically loaded topic. Many germans, from both former parts, think the Treuhandanstalt did a wasteful, disrespectful, and/or corrupt job. So using that word for anything has a big risk of drawing you into an political discussion.
Comment: Even if it is a judicial construct its function and meaning is derived from "trauen". Maybe you can refine your answer a bit.
Answer: Vertrauen means "trust" in the sense of the feeling thereof.
"Treuhand" refers to a financial arrangement involving an intermediary, such as a bank, as a "trustee." The arrangement itself, is a "trust."


Raspberry Pi Menu missing on Raspberry Pi OS

Question: How do I get the Raspberry Pi Menu item back after upgrading to Raspberry Pi OS?
After the upgrade I had a "blank" Menu button which merged into the Panel.
Comment: same problem here.
Answer: There is a rather confusing answer at https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=275473&p=1669223#p1669223
I wrote the following to restore the menu
#!/bin/bash
cp /usr/share/icons/HighContrast/16x16/places/start-here.png /usr/share/icons/hicolor/16x16/apps/start-here.png
cp /usr/share/icons/HighContrast/22x22/places/start-here.png /usr/share/icons/hicolor/22x22/apps/start-here.png
cp /usr/share/icons/HighContrast/24x24/places/start-here.png /usr/share/icons/hicolor/24x24/apps/start-here.png
cp /usr/share/icons/HighContrast/32x32/places/start-here.png /usr/share/icons/hicolor/32x32/apps/start-here.png
cp /usr/share/icons/HighContrast/48x48/places/start-here.png /usr/share/icons/hicolor/48x48/apps/start-here.png
cd /usr/share/icons/hicolor
sudo gtk-update-icon-cache

Then right-click on the blank icon, select "Menu Settings" and enter "start-here" into the icon box.
NOTE this may be a user induced problem. During upgrade you would have seen the following prompt:-

The desktop has been updated.
  To apply the updates, please reboot your Pi, and then select one of the options on the Defaults page in Appearance Settings.

I you don't touch the Appearance Settings/Defaults you may not have a problem, although the upgrade changes a number of customised Appearance Settings, requiring corrections.
Answer: Thanks for posting!
I have had a similar problem:
Working on Raspberry Pi OS (32bit) on small Bluetooth keyboard.
Clearly I have hit some wrong keys, as a blank panel appears!
Reading the link in your post gave me the solution to this problem!
Here are my instructions:
[] Right-click on the blank panel, for a menu.
[] On the menu that appears, select Add / Remove Panel Items.
[] On the Panel Preferences window that appears  select the Panel Applets tab.
[] On that same Panel Preferences window select Add (on the right-side).
[] From the menu that appears choose Menu.
[] The word Menu should now appear in the list of added plugins.
[] Select Menu (so it is highlighted).
[] On that same Panel Preferences window select Preferences (on the right-side).
(A menu appears - which is also shown in your linked instructions).
[] Delete the text in the Icon field (box on right of Icon word).
[] Type in that same box (field) the letters rpi.
[] Type the number 4 in the Padding field (box).
[] Click [OK].
Hope it works for you!


"Aperture size is much smaller than focal length of the lens"

Question: My theory is limited in this regard so I had a little doubt. I often see it mentioned in the problems that "assume aperture size of lens much smaller than its focal length" what does this signify? What would happens if they were comparable?
Comment: it means that you assume that the paraxial approximation is valid but if the diameter were roughly the order of the focal length then you would have rays with large angle subtended from the axis
Answer: It is often told to take the aperture of mirrors very small , as elementary physics deals with paraxial rays (i.e rays which passes very close to principal axis). Well if aperture is large then rays can fall far away from the principal axis which will not remain a paraxial ray any more and it will be complex to deal with such rays.
For example only paraxial rays pass through focus when ray is parallel to principal axis where as non-paraxial rays misses the focus resulting complex calculations.


How to save Toast notifications to local database in windows phone 7?

Question: I am new to Windows phone 7 Push Notifications. I am able to send and receieve tile, toast notifications in my phone. However, my problem is, I want to save all these notifications to a local database in windows phone7.
When the application is running and if a toast message arrives, I can capture that event and we can save the data to local db, its fine.
But if the application is not running, and if I get a toast message, I need to save this message to the local database. I am unable to find a way for this problem. Please help me.
Comment: sorry i cont get u. do  u understand the problem
Answer: The bad news is that you can't do this at the moment (not in 7.0 or 7.5 Mango)
You can run background tasks on a WP7 device running Mango (7.5) while your app isn't running as detailed here: Windows Phone 7.5 Periodic Tasks
But there are limitations: The task will only fire once every 15 minutes or so, it won't be able to monitor for toasts while the app is off.
If you control the server that is sending the Toast messages then the best bet is for your periodic task to connect to the server every 15 mins and, if there are new toast messages, for it to collect them and then store them in the local DB.


History behind reproducible research tools and literate programming

Question: Reproducibility was talked about by Robert Boyle in 17th century. Literate Programming was invented in 1984 by Donald Knuth. Reproducible Research tools like R markdown were invented recently. My query is : After the invention of Literate Programming, how did the trend of making reproducible reports start? How did tools from R Markdown evolve AFTER the invention of tools like WEB and noweb.
Answer: [This answer was written for the original question, which has since been substantially edited.]
The question is backwards: if anything, it's literate programming which would have been inspired by reproducible research.
The concept of reproducibility is closely related to the criterion of falsifiability. This concept and its significance in science obviously predates literate programming (and anything related to computer science). More generally, the scientific method has been a pillar of scientific research for a long time. In particular the importance of reproducibility in research is definitely not limited to computer science.
It happens that literate programming can be useful to address the specific problems of reproducibility in modern computer science research, especially in experiments involving machine learning and massive amounts of data (related example). But as far as I know it was not designed in this specific goal, even if it shares some of the principles of the scientific method (transparency, interpretability).
Comment: Perhaps I was not clear. Reproducibility was talked about by Robert Boyle in 17th century. Literate Programming was invented in 1984 by Donald Knuth. Reproducible Research tools like R markdown were invented recently. My query is : After the invention of Literate Programming, how did the trend of making reproducible reports start. ?
Comment: You seem to think of this as a discrete process made of inventions which change the way people work, but the reality is much smoother. People were writing papers  describing reproducible research long before tools such as R markdown. It's true that these tools are useful in the perspective of reproducible experimental research, but  github or before that CSV and SVN were useful tools too. The "trend" of making reproducible reports is just the continuation of this process.
Comment: Is an R Markdown file an example of BOTH Literate Programming and Reproducible Reseach? [ https://en.wikipedia.org/wiki/Literate_programming says : Similar to Jupyter Notebooks, R Notebooks are a method of literate programming that allows for direct interaction with R (support for Python, SQL, and Bash are also explicitly named) while producing a reproducible document with publication-quality output. ] I think there is a difference between LP and RR. We may have one without the other. LP = document your code beautifully for a person to read while RR = share code and data.
Comment: @user2338823 of course there is a difference between LP and RR! you insist on putting these two concepts on the same level to compare them: it's true that they overlap, but they are very different concepts in scope and in depth. Sure some R markdown documents (not all) can be considered as examples of reproducible research, but so can thousands of papers published every year as well, and not only in CS. In CS many github repositories are examples of RR as well. You are essentially comparing what is mostly a technology (R markdown or Python Jupyter) against a scientific principle (RR).
Comment: I was reading the history behind these 2 (LP and RR) recently. It's not documented as to whether R Markdown is implementing LP or RR. There are references to BOTH in R Markdown literature. It was not clear to me whether R Markdown is an implentation of LP or RR while reading the docs. Hence my query. Seems like R Markdown implements both LP and RR.
Comment: LP is a a programming paradigm, so it can be implemented (and R markdown certainly implements a good part of it, if not all). But RR is a scientific principle, so there's no such thing as "implementing" RR in general. You are using a definition of RR restricted to programming, i.e. losing 99% of what RR covers.
Comment: Now that you put it in those words, I think I understand it better. Thank you.
Comment: RR ( = Reproducible Research ) I think can be fully done by R Markdown. The Replicable Research paradigm is not implementable by R Markdown/ or any other programming language because it is not related to programming. Do I understand correctly?
Comment: Yes that's what I mean. RR is much more general than programming, it's used in any kind of experimental research, e.g. medicine.


Where is it written in the Zohar that the Yishmaelites must have Eretz Israel until Mashiah comes?

Question: I remember reading a paper where it was written that the Yishmaelites should have Eretz Israel until the coming of Mashiah according to the Zohar. Is it true ? If it is the case, where is it written in the Zohar ?
Comment: it is not in the zohar, it is in Pirkei d'Rebbi Eliezer. Chapter 33 or 34 if memory serves.
Comment: I am pretty sure he told me it was in the Zohar but thanks
Comment: see also baal haturim on beginning of chumash parsha toldos
Comment: I didn't look up the sources inside, but look at the quotes on this page from 2 places in the Zohar and R' Chaim Vital: http://www.yesod-hatorah.org/torah.php?id=102&action=show_article&page=7&article_type=1
Comment: I still remember the story of the angel of Yishmael who negociate with Hashem the occupancy of Eretz Israel before the coming of Moshiach
Answer: "In the future, the sons of Yishmael will return to the Holy Land when it was vacant from inhabitants for much time, and they will prevent Yisrael from returning to their land until that merit of the sons of Yishmael expires. At a certain time, the sons of Yishmael will be roused to wage brazen battles in the world. The sons of Edom will gather together and stage a war against them; one on the sea, one by land, and one close to Yerushalayim. At that time a nation will come from the end of the world onto Rome and make a battle with them for three months, and they will fall in their hands, until all the sons of Edom will gather from all corners of the world." -Zohar Devarim 32a
"There is no exile more difficult for Yisrael than the Galus Yishmael" – Zohar Shemos 17a
Although it is not clear in the Zohar that the Galut Yishmael will end with the coming of Mashiach, the Baal HaTurim (23:18) wrote : "Next to this [verse it is written] 'And These are the descendants of Yitzchak son of Avraham', to tell us that when Yishmael falls in the end of days, then the son of David [Moshiach] will sprout forth, for he is the descendant of Yitzchak."
Source: http://www.yesod-hatorah.org/torah.php?id=102&action=show_article&page=7&article_type=1


How can I scale LiDAR intensity values to 8-bit, in order to apply the Wing2015 snag algorithm using segment_snags in lidR?

Question: I'm trying to identify snags using LiDAR stored in las format. The Wing 2015 algorithm used in segment_snags requires the values be in the range from 0 to 255. Is it possible to edit and scale intensity values (not by adding a new attribute)? Alternatively, is it possible to edit the segment_snags tool in lidR?
Answer: If your intensities are recorded on 16 bits you can use the data.table syntax
las@data[, Intensity := as.integer(Intensity/(2^16-1)*255L)]

If your intensities are somehow arbitrary recorded
las@data[, Intensity := as.integer(Intensity/max(Intensity)*255L)]

With a more regular R syntax
las$Intensity = as.integer(las$Intensity/max(las$Intensity)*255L)

I don't remember how Wing's algo work but first read the original paper to ensure that rescaling like that has a meaning for the method.

Alternatively, is it possible to edit the segment_snags tool in lidR?

This might be the object of a feature request.
Comment: After testing, rescaling does indeed work. However, some snags that fall within the right intensity range do not end up being classified as snags. My guess is that the BBPR thresholds have to be manipulated but this would be a result of the nature of the lidar itself and not the algorithm or its implementation.
Comment: It should be noted that arbitrary scaled intensities are non-conformant to the las specification and anyone that supplies such data should be kicked.
Incidentally don't expect much from intensity. practically it is a very poor metric. The author only claimed 56% detection rate.


Apply vs. Ok buttons

Question: Often when configuring settings, applications have both an "Apply" and an "Ok" button. Should the "Ok" button always perform the "Apply" before closing the window out? Are there pros and cons to doing this?
Comment: This might be a better fit for [ux.se]
Comment: @Daenyth - I think this has already been covered on UX - but if not a repost might be OK (ha!). However, I think the issue needs to be restated (not sure how though).
Answer: Yes, the OK button should always "Apply". I don't see any cons, as there usually is a "abort/close window" button to revert the previous settings, in case you mis-configured something.
The optional "Apply" button should set the changes made in the current dialog without closing it. IMHO it is a convenience button, which is really useful in complex dialogs with many settings (e.g. Eclipse Preference Dialog).
Answer: At this point, Ok, apply, and cancel are the equivalent of household names. So many other applications have adopted the standard that apply means just apply, ok means apply and close, and cancel means cancel and close that making an attempt to change this or "be witty" in your application is more likely to just confuse, frustrate, or cause your users to make mistakes. The psychological impact of mistakes makes your users feel bad, and they associate this bad feeling with your application, not their lack of knowledge on how it works.
As an example of this concept, one of OpenOffice's successes with Calc came about because they lowered the barriers to entry for Excel users. When I first started using Calc, I was surprised that many of the same shortcut keys worked the same in Calc, and this made it easier for me as a user to commit to using Calc.
Had OpenOffice decided to completely redo their idea of how the shortcut keys worked, OpenOffice may never have gained a successful following.
If you apply this same concept to your application, you would really want to ask yourself what you have to gain by changing something that is not only tried and tested, but that also eliminates a potential and unnecessary learning curve in your application.
Answer: I personally do not like "OK" buttons.
I have seen too many "The application has messed up and all your input will be lost" messages followed by an "OK" button when it is clearly not OK.
The "OK" button is used/misused in so many different ways in so many applications that it is effectively meaningless. "Apply" and "Cancel" generally mean what they say.
Comment: A co-worker once showed me one of those "you are losing all your work" dialogs he had coded.  I pointed out that there is nothing "OK" about losing all my work.  The next time he showed it to me, the dialog said "Oh well."
Comment: The question isn't about "OK" on error dialogs but about "OK" and "Apply" on settings/property dialogs.
Comment: @ChrisF -- the point is overuse and misuse of the "OK" button has rendered it meaningless. "Apply"/"Cancel" is much better.
Comment: @JamesAnderson - Apply and Cancel have no meaning for error dialogs which you appear to be talking about here.
Comment: The problem is one of standardization. No one familiar with computer applications takes the meaning of an "OK" button literally.
Comment: @Cody Gray, precisely the point "OK" is meaningless, you may as well display a blank button.
Comment: Except that users recognize "OK" and tie it to a known meaning. The word has lost its inherent meaning, but it has a clear contextual one. Much like the floppy disk icon, meaning save.

Apply vs. Ok buttons


Lightning Community Custom Theme/Component/Content Language change (text/button label)

Question: Any one has idea on how to change language based on profile language for text and button labels for a custom component in lightning communities? I tried to add language to the community page but it is only translating the standard components and only the component label is changing not the content. Attached is a screenshot of a standard object where only the label is translating into different language and not the content.
Answer: You should be using Custom Labels for that.
After creating custom label, you can use in cmp by using {!$Label.c.labelName} OR you can use $A.get("$Label.namespace.labelName") in Javascript of component.
Then you should translate the labels in translation workbench or Directly
After these steps you should see the labels in chosen language.


How do I find Ubuntu 20.04 icons for documentation

Question: I am working on a handbook about scanning with simple-scan in Ubuntu 20.04.
I need to transfere some pictures from the screen to the manual written in Google docs. Some are fine .svg icons with rounded corners.
They need to be converted with CloudConvert on Google, but that shouldn't be a problem.
But I have a problem with finding this file: org.gnome.SimpleScan. I have it in the favorites menu, but where is it on the disk?
See what it looks like here:
Answer: You can use the search bar or the terminal to find files.
In the terminal you can use the commands find, locate, or grep.
To learn how to use these commands, you can review the manpages by adding man before each command.
For example:
man grep

Comment: I have tried the ways you name and I have found the file simple-scan.desktop with 13 lines of text. One line says: Icon=org.gnome.SimpleScan. Thats why I am searching for such a file. But maybe the search is wrong. I wish there were a way to send you a picture to show you what it looks like?
Answer: You have to check the list of installed files from simple-scan package locally by command like:
dpkg -L simple-scan | grep -E ".png$|.svg$"

It has a lot SVGs and PNGs.
Answer: Do you mean this one enter image description here. I found it on google. enter image description here. Oh, it is another one. Since you have a screenshot you can use a graphical program e.g. 'Gwenview', 'Kolourpaint' or 'GIMP' to cut it out and save it as an .ico or .png or another format .


Finding side length from two scalene triangles with common angle and side and ratio between sides. Trigonometry

Question: I have two scalene triangles with a common angle and side. I would like to find the length of $x_2$.
I have all variables in green: the angles $\angle$ B,$\angle$ C,$\angle$ D,$\angle$ E and side "length". I also have the ratio $\frac{x_2}{x_1}$.
Stumped on this trigonometry question. I have tried using Sine rule and solving simultaneously but always end up canceling out all my terms. In my head there are enough equations to solve for the variables but can't seem to figure out how I would do it.
Any help greatly appreciated.
Comment: It's not clear to me exactly which data are known.  Are $a_1$ and $a_2$ known?  Are $\angle A$ and $\angle F$ known?
Comment: No only the green values are known. a1, a2, ∠  and ∠  are not known.
Comment: Welcome to MSE.  Please use [MathJax](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference) to format math on this site.
Answer: There are three triangles. Two compose the largest one. I'll call the leftmost part $L,$ its counterpart on the right $R,$ and their composite $K.$
Looking at $R,$ we can write down an equation for our goal $x_2$ as follows: $$x_2^2=a_1^2+a_2^2-2a_1a_2\cos E.$$ Thus we only need find $a_1$ and $a_2,$ and we'd be done.
To find $a_1,$ look at $L,$ the we have that $$\frac{\sin B}{\text{Length}}=\frac{\sin A}{a_1}.$$ Similarly, by looking at $K,$ we find that $$\frac{\sin D}{\text{Length}}=\frac{\sin A}{a_2}.$$ This helps us to find $a_2.$
From the last two equations we eliminate $A$ to find an equation in $a_1,\,a_2.$
Now look at the triangle $R,$ from which we may write down $$\frac{\sin E}{x_2}=\frac{\sin D}{a_1}.$$
Together with the first equation, we find a $3×3$ system in $a_1,\,a_2\,x_2,$ which we can now solve for $x_2.$
OK, let's do this together. From the two middle equations we find that $$\sin A=\frac{a_1\sin B}{\text{Length}}=\frac{a_2\sin D}{\text{Length}},$$ so that $$a_1=\frac{\sin D}{\sin B}a_2.$$ From the last equation we also have $$a_1=\frac{\sin D}{\sin E}x_2,$$ so that we have that $$a_2=\frac{\sin D}{\sin E}\frac{\sin B}{\sin D}x_2=\frac{\sin B}{\sin D}x_2.$$
Substituting now into the first equation and solving for $x_2$ is straightforward, and gives $$x_2^2\left(\frac{\sin B+\sin D}{\sin E}+1\right)=\frac{2\sin B\sin D\cot E}{\sin E},$$ amd finally recall that $x_2>0.$
Comment: @jimbo94 No, there's no typo. Go through it again on paper. I may not have included every step in great detail, especially how I deduced the last equation. But if you substitute the values of $a_1$ and $a_2$ into the first equation in my answer above, you get three terns in $x_2^2$ -- one on the left and two on the right. Subtract off the two on the right from both sides of the equation. Then all three terms on the left are now in $x_2^2.$ Simplify to get the given equation above. I believe you now know how to proceed from here.
Comment: Thank you for your help, I'm not sure I completely follow. Up until the last step makes sense to me, apart from what I assume is a typo in $\frac{SinB}{SinD}x_2$ that should read $\frac{SinB}{SinE}x_2$, however the last step is unclear, what happens to $x_2$ on the right side of the equation. When I try and substitute and simplify all the $x_2$ terms cancel out.
Answer: From the cosine and sine rules,
$$L^2 = x_1^2+ a_1^2 -2x_1a_1\cos B\tag{1}$$
$$a_1=\frac{\sin D}{\sin E}x_2\tag{2}$$
Plug the known ratio $r=\frac{x_1}{x_2}$ and (2) into (1),
$$L^2 = r^2x_2^2+ \frac{\sin^2 D}{\sin^2 E}x_2^2 -2r\cos B \frac{\sin D}{\sin E}x_2^2\tag{1}$$
Solve for $x_2$,
$$x_2= L \left(r^2+ \frac{\sin^2 D}{\sin^2 E} -2r\cos B \frac{\sin D}{\sin E}\right)^{-1/2}$$


When trying to redirect using HTACESS, a string "/redirect:/" gets embedded with the url

Question: I have setup two domains to point to the same hosting server. For eg: the domains be :

example1.com
example2.com

I have created a directory called 'home' in my root, and whenever the 2nd domain is accessed, it should get redirected to the home directory.
For eg: example2.com/post.php should get redirected to example2.com/home/post.php
I have done this by creating an htaccess file in my root directory with the following contents:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} example2.com$ [NC]
RewriteCond %{REQUEST_URI} !home
RewriteRule ^(.*)$ ./home/$1

This is working perfectly. Now, i have a second requirement where i need to redirect users to a php file  (post.php) inside home directory whenever the user accesses the url example2.com/gallery/somestring.
So, i created a second htaccess file in my home directory and entered the following code:

Options +FollowSymLinks

RewriteEngine On
RewriteRule ^gallery/([^/]+)$ post.php?post=$1

But, whenever i try to access the url example2.com/gallery/somestring, it shows a strange 404 Not Found error :

The requested URL /home/redirect:/home/gallery.html/somestring/somestring was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Here. "redirect:" string is getting concatenated to the redirected URL somehow.
Can any one please give me some idea as to why its happening ??
Answer: I solved this problem. I am sharing this if any one gets into this same problem and finds this post. The problem was that there was a file gallery.html in my root folder. This was causing this error. Just delete this file or rename the file to some thing else. Thats it :)


Why do scary situations make our skin crawl? Why do we have goosebumps in such situations?

Question: I do not see why should scary situations make our skin "crawl". In scary situations, we supply less blood to our skin (which makes it paler), so shouldn't its activities reduce? Goosebumps should take up some energy to raise the hairs. Shouldn't that energy be conserved?
Answer: Goose bumps are based on a pilomotor reflex where tiny muscles at the base of hair follicles contract, which leads to the "bumps" and also raises the hair in the follicle.
It's often explained as a vestigal reflex, dating back when our ancestors had more hair than the modern human. The "puffing up" of fur has two effects, which today still both can be observed:

Raised hair traps air in the fur, thus minimizing heat loss in the cold.
Raised hair (often combined with certain postures) makes an animal appear larger, thus intimidating an opponent or predator. This is the scenario you mention in your question.
Comment: Cats are champs at the raised hair / look large trick.


DD4T2.0 Java MVC - Not able to render the components in a Page JSP using view name defined as meta field in CT

Question: Not able to render the components in a Page JSP using view name defined as meta field in CT.  I am using the tag  in the page JSP but when I hit the page url its looking for component jsp created exactly with CT name instead of view name.
Comment: After some investigation - I believe this may be a bug in dd4t-2.0. Can you tell me what the key name is of your metadata field to denote the view?
Comment: It's a confirmed issue. See https://github.com/dd4t/dd4t-2-java/issues/34. I will release a build shortly.
Comment: Can you share with us some details like the relevant code, screenshots, url you're hitting, routes configuration, logs?  In general, try this more efficient approach: http://tridion.stackexchange.com/help/how-to-ask
Comment: How did you define the @ViewModel property? How did you define the usebean tag in your view?
Comment: Hi; I am using below in viewModel Class
@ViewModel(viewModelNames = {"header"}, setComponentObject = true, setRawData = false)
and below tag used in page JSP to make a call to render component view

In the CT i have one metafield fieldname=view value=header
Answer: There was a bug in dd4t 2.0.1-beta and 2.0.2, which caused rendering component presentations to by default look at the metadata key viewName instead of view.
This has been fixed in dd4t-java version 2.0.3 and that build is now in Maven Central, so please update the version in your build to make this work properly.
To reconfirm how the JSP view-finding logic works:
DD4T renders views for CPs by first determining the view name from either the Component Template name or by looking at the "view" metadata key if it is set on the Component Template.
If no view metadata key is present in the Component Presentation, DD4T will take the title of the Component Template. In all cases, the following rules apply:

Both the value of the view metadata field and the title of the component template will be lower cased;
Spaces in the value will be dashed ('-').

If for example your view name is: 'generic Content', the JSP view name should be: generic-content.jsp. The determined view name should then be present in the web application as a JSP file. If it is, then a sub Servlet request is fired which outputs the rendered JSP into the parent - usually Page - JSP.


text box giving problems on ASP.Net page

Question: I am designing a page to Add/Edit users - I used a repeater control and a table to display users. In users view the individual columns of the table row have labels to display a record values and when users click on edit button, the labels are hidden and text boxes are displayed for users to edit values - The problem is - as soon as the text boxes are visible, the table size increases - the row height and cells size becomes large. Is there a way to display the text boxes so that they take the same size as the labels
Answer: Dealing with tables, the question is: can your labels span on multiple text rows (ie: can you have long texts)? If yes, you may encounter layout problems any way. If no, a simple approach can be creating a CSS Class:

.CellContent { display:block; width: ...; height: ...; }

with your preferred cell width/height. Just stay a bit "large" with your height.
Assign the class to both your label and textbox, and you should not get width/height changes when switching control (thanks to the display:block property).
Again, if you have long texts, you will still encounter issues, and may want to use multilines. In that case, I would suggest ignoring height problems: just set the width to be consistent, and always show a 3-4 lines textbox for editing. Users will not be bothered to see a row height change, if they are ready to type long texts.
Answer: I'd use JS+CSS... You'll have to get your hands dirty for this one though. Visual Studio isn't going to help you much.
Here's how I'd do it:

Get the  clientWidth and clientHeight.
Set the 's width and height to those px values (so they're no longer relative)
Swap the text for the input
In your CSS, make sure the input has no padding/margin/border and set width:100%, line-height:1em, and height:1em

When you switch back, make sure you un-set the  width and height so they return to automatic values.
You'll need to tweak this all slightly. I'm sure you'll have to play around with the padding on the  and perhaps set overflow:hidden but you should be able to do what you want.


What is the best way to create Primary Key on a large table in Postgresql 9.5?

Question: I have to create a primary key on a large table (~100Million records) in Postgtres database. What is the best and fastest way to create pkey? This column is a sequence column and i don't want to lock the table because this is highly transactional database.
Answer: You can create a unique index with the option concurrently which will allow read and write access to the table while the index is created. However, building an index concurrently will take much longer then adding the index without that option.
create unique index concurrently unique_id on the_big_table (id);

Once the index is created, you can use that as a primary key:
alter table the_big_table
   add primary key using index unique_id;

That will only lock the the table for a very short time.
Comment: is is the answer to accept @rkt
Comment: "That will only lock the the table for a very short time.": No, as the primary key is a clustered index that define how the table is physically organized, even this will need to rebuild the whole table.
Comment: @Kedare: Postgres does not have a "clustered index". Neither creating the index nor creating the PK constraint will "physically reorganize" the table
Answer: You will have to lock the table if you want to add a Primary Key.
However (and this will require some storage space) ...

Create a new table with the same schema (and indexes, foreign keys, check constraints, etc.), and add the new Primary Key as well.
Create a view that selects (with UNION ALL) from both tables, and in a quiet period (or a maintenance window), rename the old table to something else, give the view the same name as the old table, and then your users and applications shouldn't know the difference (selecting from the view instead of the table).
Create a batch process that deletes x number of rows out of the old table at a time, and inserts these into the new table.
In another maintenance window, drop the view, rename the new table so that it gets the original table name (and it already has all the indexes, foreign keys, check constraints and so on), and then drop the old table, which should now be empty.

It will take some time to run this, depending how many rows you move in each batch, but it keeps your table (which is now part of the view) online. You will generate a lot of logs, and it will require a fair amount of disk space, but that's how I'd do it.
Comment: Planning to do this.. ALTER TABLE table1 ADD COLUMN "id" INTEGER;
CREATE SEQUENCE "table1_id_seq";
UPDATE foo SET id = nextval('"table1_id_seq"');

ALTER TABLE table1 ALTER COLUMN "id" SET DEFAULT nextval('"table1_id_seq"');
ALTER TABLE table1 ALTER COLUMN "id" SET NOT NULL;

CREATE UNIQUE INDEX CONCURRENTLY my_pkey_idx ON table1 (id_column);
ALTER TABLE table1 ADD CONSTRAINT my_pkey PRIMARY KEY USING INDEX my_pkey_idx;

Please let me know if that is the right solution or not.
Comment: Every time you ALTER TABLE, it will need to take a lock. If that's not what you want, then this is not going to work, and you should look at my proposed solution.


How does virtualization software work?

Question: I wonder how virtualization software such as VirtualBox or VMWare Workstation works? How can they create a virtual environment that is taken as a separate computer by operating systems? I'm almost sure the answer to this question is very deep, but I'd be well satisfied with basic theory.
Answer: In the simplest sense, a virtualised environment is to a native environment, what an interpreted language, like PHP, Javascript or Basic, is to a compiled language like C, C++ or assembler.
When a compiled binary executes, the binary machine code, is passed straight to the CPU.  However when an interpreted language runs, the language application reads in the code, then it decides what that meant and execute binary procedures to reflect that.
So virtualisation software like Qemu, while compiled to run on, say an x86 processor, will read the binary file, intended for say a Mac, and it will interpret the binary it receives, switch it from big, to little endian, and then know that op code X on mac corresponds to op code Y on x86, and that op code A on mac, doesn't have an equivalent on x86, so will need to call function B on x86 and so on.
The really clever bit, is the hardware interpretation, where someone has to write a driver, that will run on Qemu, on x86, but will present an interface to the Mac face of Qemu, to make Mac applications think they're talking to Mac hardware.
Answer: In the most basic sense, virtualization software puts a computer within another computer... kind of. (Here's a link that's very, very basic: http://blog.capterra.com/virtualization-software)
In a more complex sense, virtualization software (also called a hypervisor) abstracts the characteristics of a server. This allows several OSs to run on a single physical server.

How does virtualization software work?