Why was it formerly illegal to use the Swiss coat of arms in the United States?

Question: 18 U.S.C. § 708 formerly made the unauthorised commercial usage of the Swiss coat of arms (the white cross on a red field) a criminal offense in the United States.  It was repealed this year, but why was it ever law in the first place, making it the only country or entity in the US ever to have protection for its heraldic devices?
Comment: Note that the other design protections repealing in your link from the same section of USC include: the 4-H club emblem, "Smokey Bear" character or name, and "Woodsy Owl" character, name, or slogan; as for the Swiss Coat of Arms specifically, I would suppose it was originally enacted as part of protection for the Red Cross (the inverse of the Swiss arms, by design).
Comment: FWIW it also a crime to impersonate a girl scout. And, the U.S. as noted in an an answer below, is not the only country in the world to protect this particular image.
Comment: But the logo of the Victorinox Swiss Army Knife wasn't a violation?
Comment: @NateEldredge Probably grandfathered. See my answer re the text of the previous statute.
Answer: I don't know any specific on the US law, but a special protection of the Swiss coat of arms is very widespread. This comes from a provision in Art. 53 § 2 of the First Geneva Convention 1949:

By reason of the tribute paid to Switzerland by the adoption of the reversed Federal colours, and of the confusion which may arise between the arms of Switzerland and the distinctive emblem of the Convention, the use by private individuals, societies or firms, of the arms of the Swiss Confederation, or of marks constituting an imitation thereof, whether as trademarks or commercial marks, or as parts of such marks, or for a purpose contrary to commercial honesty, or in circumstances capable of wounding Swiss national sentiment, shall be prohibited at all times.

Because of the connection of the Red Cross and the Swiss coat of arms the US is obliged by international public law to prohibit the commercial use of that arms.
I'm surprised to hear that law was repealed. Maybe it was transferred to some other place in the code? Often it is regulated next to the prohibition of the misuse of the Red Cross.
Comment: https://www.law.cornell.edu/uscode/text/18/706a seems to cover the relevant Geneva Convention territory.
Comment: There were complaints about the law being misused to ban the red cross display on video game medkits. It became politically expedient to repeal it.
Comment: @Joshua Isn't the section on the Red Cross the problem for this cases?
Answer: This is one of a zillion laws (re)-passed as public law 722 in 1948, which created title 18. It is part of a larger set of laws, 18 USC Ch 33, pertaining to emblems, names and insignias, specifically prohibiting "misappropriation" of government symbols, and other kinds of deceptive behavior. It would be surprising if there were any committee reports on why such a law was found to be desirable, from whenever the first version was passed. This discussion sheds no historical light, except to say that there is no evidence that it was ever enforced.
Comment: Your last link says: "since the purpose of the law was to protect the American Red Cross"
Comment: The problem is (1) he doesn't support his claim and (2) that is accomplished by a different law (§706) so §708 isn't explained.
Answer: Prior to its repeal, the statute was as follows (incidentally, the statute section number was changed after its original enactment; 18 U.S.C. § 708 was formerly the section of the federal criminal code applicable to mail theft):

Whoever, whether a corporation, partnership, unincorporated company,
association, or person within the United States, willfully uses as a
trade mark, commercial label, or portion thereof, or as an
advertisement or insignia for any business or organization or for any
trade or commercial purpose, the coat of arms of the Swiss
Confederation, consisting of an upright white cross with equal arms
and lines on a red ground, or any simulation thereof, shall be fined
under this title or imprisoned not more than six months, or both.
This section shall not make unlawful the use of any such design or
insignia which was lawful on August 31, 1948.

The exception probably protected the Victorinox Swiss Army Knife trademark which was in use already at the time that the statute was enacted, and didn't undermine the statute's primary purpose.
The prohibition is probably to prevent this symbol from being used in a way that causes it to be confused with the Red Cross, an international symbol for peaceful humanitarian activity and medical care, which has relevance under the Geneva Conventions and customary international law of war crimes that compel refraining from harming people who are sincerely using it in most circumstances, because it uses the same colors in the opposite places of same form. As noted below, one of just two reported appellate cases discussing the statute suggests this reading of the statute.
It could also have been to prevent its misleading use to convey the message of the Swiss emblem itself, which is a symbol of political neutrality, in a way that could mislead and disadvantage the U.S. military if utilized by enemy forces, because usually, U.S. military forces are not supposed to open fire on neutral nations. Almost no other country has such a long standing and universally recognized policy of political neutrality, so there are no other national symbols that would convey a similar message.
Another answer, also aptly suggests that this may have been a treaty obligation of the U.S. to enact under Art. 53 § 2 of the First Geneva Convention 1949, which is a mix of both reasons.
The most recent case to discuss the provision (found in a dissenting opinion of esteemed U.S. Court of Appeals Judge Posner, interpreting another statute) was very critical of it, noting that:

The federal criminal code contains thousands of separate prohibitions,
many ridiculously obscure, such as the one against using the coat of
arms of Switzerland in advertising, 18 U.S.C. § 708, or using "Johnny
Horizon" as a trade name without the authorization of the Department
of the Interior. 18 U.S.C. § 714.

U.S. v. Wilson, 159 F.3d 280, 294 (7th Cir. 1998) (dissenting opinion).
The opinion of esteemed U.S. Court of Appeals Judge Easterbrook in the same year also illuminates a possible purpose for the statute, in dicta, and favors my first explanation:

The Red Cross has exclusive rights to "Red Cross", see 18 U.S.C. §
706, and to fortify this exclusivity Congress prohibited newcomers
from using the Swiss Confederation coat of arms, 18 U.S.C. § 708.

Am. Legion v. Matthew, 144 F.3d 498, 499 (7th Cir. 1998).
Incidentally, my use of the word "esteemed" to describe these judges is not just a general courtesy. These are two of perhaps a dozen superstar appellate judges in the entire United States in the history of U.S. jurisprudence who didn't serve on the U.S. Supreme Court, and are household names among lawyers and legal scholars in the U.S. Posner is a leading moderately conservative jurists known especially for his law and economics jurisprudence. Easterbrook is a well regarded and well spoken moderate justice.


How do you tell Wordpress to ignore a folder, in favor of a permalink?

Question: I have a client who had a non-WordPress site, with a WordPress blog located in a subfolder /blog/. We launched them a new WordPress site in the root. Unfortunately, all the images in their blog posts are still pointing at /blog/wp-content/uploads/. I want to just add all these images to a subfolder on the file tree at /blog/wp-content/uploads, so it will just automagically fix all those broken images without extra work from me.
The problem is that their new blog page is located at /blog/. I can't change this for SEO reasons. If I move the images, then navigating to /blog/ doesn't show the WordPress page, it shows a folder on the file tree.
I want it to show the WordPress page instead. Is there a way to tell WordPress to ignore that folder, and show the WordPress page when /blog/ is called instead?
Comment: I assume sub pages do work OK, it's just the WP home page that does not?
Answer: The WordPress front controller only routes the request when you don't request a physical file or directory on the file system. The problem here is that when you create a physical directory called /blog then WP will no longer route the request and you see the directory.
Aside: You shouldn't really be seeing the directory contents, ideally you should get a 403 Forbidden. Add Options -Indexes to the top of your .htaccess file.
The default WP .htaccess contains the following lines that excludes physical files and directories from being routed (ie. so that static resources can be accessed).
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

You can make an exception for the /blog subdirectory by changing this to:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_URI} ^/blog/?$


Change the startup directory to something other than HOME

Question: By default, when I open the fish shell, my working directory is the home directory. Is there a way to change the default working directory on startup, without having to edit the HOME variable?
Comment: perhaps add `cd /wanted/startup/directory` to the end of your `~/.config/fish/config.fish`
Answer: Fish does not change your CWD to $HOME when it starts. When you launch a shell from a terminal, the terminal will normally have set CWD to your home directory. Your terminal may provide a way to set a different CWD when launching the shell. If it doesn't, then add something like this to your ~/.config/fish/config.fish:
<code>if status is-login
    cd /my/preferred/starting/directory
end
</code>
Comment: So the CWD on startup is a concern for the terminal, not the shell? In that case it's good that Fish provides some way of setting the CWD even though it isn't Fish' concern. Thanks for the pragmatic solution, Glenn and Kurtis :)
Comment: @jallersma, Yes, more or less. The CWD that fish (or any other shell) inherits is whatever the parent program decides it should be. Your question is also applicable to other shells such as bash, zsh, ksh, elvish, etc.


Do pilots of piston/prop aircraft have discretion to determine how much runway is required for an intersection departure?

Question: For piston/prop aircraft requesting intersection departure, is it pilot discretion for the minimum amount of runway length required? Is there a takeoff calculator in conjunction with calculations?
Comment: Before you get in the aircraft, you should have calculated your take-off distance and added an "oops factor" or "inexperience factor". Once you know that you can ask the tower the TODA if you don't have it handy. Typically when I was going to ask for an intersection, I would know ahead of time which one would be my "bare minimum" as part of preflight planning.
Comment: I don't really understand the question. A determination is not "discretion." The pilot is **required** to look up the minimum amount of runway and make a decision to accept or refuse an intersection departure accordingly, as the other answers point out. There is no "calculator," only the question of whether the downfield runway remaining is sufficient or insufficient...
Comment: Yes, the pilot has discretion.  But it can have fatal consequences.
Answer: For the first part of your question, yes.  It is always the pilot's discretion to either request, or to refuse/accept an intersection departure if offered by the tower.
To the second part, yes as well, but "takeoff calculator' is a little unclear.  All piston prop aircraft, (really all certified aircraft) have performance charts in the Pilot's Operating Handbook, (POH).  Pilots are trained to use these to determine ground roll distance, obstacle clearance, and other takeoff related performance numbers based on weight of the aircraft, density altitude, and other parameters.  (more sophisticated aircraft have automated tools available to help with performance calculations.)
So, the decision in the first part of the question should be based on the knowledge derived from preflight planning described in the second half of my answer.
Answer: All general aviation pilots are required to know the takeoff and landing distances needed during the operation of a flight and the runway length available, per §91.103.  So to comply with safety and legal requirements, a pilot had better well know how much runway is available in an intersection departure prior to attempting it. This not only includes the distance required for a ground roll, but that needed to clear obstacles at the departure end of the runway, and offer the required accelerate-stop distance, if operating a multi-engine airplane.
The decision to accept an intersection departure is ultimately at the discretion of the pilot and the pilot is fully in the right to refuse an intersection departure and request a full length departure if they don't feel comfortable with doing so.
Answer: Because people do have their right to privacy, few comments other than these are offered.  Nevertheless, let's think about this for a moment. An expedient action can have unintended fatal consequences. The first and last paragraphs of the introductory summary of the NTSB accident report read as follows -

The pilot and passenger departed on a local flight in the amateur-built experimental airplane using an intersection departure from the runway. Several frames of a surveillance video that captured the airplane during the initial climb from the runway showed a thin white trail of vapor/smoke behind the airplane. GPS data recovered from the airplane indicated that the airplane climbed to about 100 ft above ground level, leveled off, turned left at the end of the runway, and entered a descent. Shortly thereafter, the airplane collided with parked vehicles about 0.25 miles from the departure end of runway. Examination of the accident site indicated that the airplane impacted in a near-vertical attitude, consistent with an aerodynamic stall.

The circumstances of the accident are consistent with the pilot failing to maintain sufficient airspeed following a loss of engine power during takeoff, resulting in the airplane's wing exceeding its critical angle-of-attack and a subsequent aerodynamic stall. Instead of using the full runway length of 6,179 ft, the pilot elected an intersection takeoff with about 2,570 ft of available runway. Calculations showed that, had the pilot used the entire runway for takeoff, sufficient runway for a landing following the loss of engine power would likely have been available.


An effective beginning and end of a literary essay

Question: I always struggle with making introductions and conclusions.

How can I write a good hook that attracts my readers?
How can I conclude effectively at the end of a literary essay?
Answer: There are more good ways to begin an essay than there are good writers. (That is fortunate; otherwise, each good writer would be stuck with only one good opening.)
An effective introduction depends on a number of factors that may include your audience, subject matter, and goals for the piece. For example, open an essay on the death imagery in Poe's works with a light-hearted joke, and your audience might think you crass, or worse yet, might not take you seriously. The same joke, however, might work well in an essay on the fool archetype in Shakespeare's comedies.
An effective closing will bring the reader "full circle" by succinctly restating the premise of the essay without seeming repetitive. You, the writer, may do this by finding a fresh way to restate your main point(s) or by elaborating on the original premise based on the evidence (information) provided in the body of your essay.
Best wishes on your writing efforts.
Answer: Good question.  One answer is practice, and with practice comes confidence and that confidence can then show itself in the gentle persuasion of your body.
Caveat: If you have a specific question to answer for an assignment then deal with it head-on and try not to forget it.
I would start with a blunt statement or something to make the reader sit up.  How on Earth did Edna St. Vincent Millay win the 1923 Pulitzer prize for poetry?   Make the reader read more to argue or learn.  Be sure to leave room for push and shove.  That start wasn't saying Millay was a rubbish poet or the jury were idiots.  A ghost sentence hovers next: Let's take a closer look.
The body depends on your personal style. (And possibly what straightjackets others might apply.) Now you've got the reader by the hand, take then for a walk and keep referring to the theme.  You might use some metaphor or symbolism of your subject to do this.
I've referred to the body because the end is just a wrap-up of the body.  Instead of section headings you gave section conclusions.  Now comes the logical ending, the buffer-stops for your train of thought.
There's a special thing you can do with the end if you feel like it.  After addressing the opening, you might add a two or five words 'and that's that!' or 'Justice at last'.  Again this shows you're confident about your opinions.  To follow from the above example: So that's my guess as to how Millay won.  Lucky to be the different candidate.  Not her best work but hey!  $1000 can't be bad.  This flourish at the end is rampant unsubstantiated opinion.  The reason for this is that surely only somebody who really knew their stuff would go out on a limb so provocatively. It's psychology.  'I know things so best agree with me.'
PS.  Obviously this works best when you actually do know what you're writing about.  Sometimes you might find that your first plan is undermined by your research...  Hooray!  You have hooked yourself into discovery.  Changing your draft is nothing compared with the satisfaction of making a better case for plan-B.


How does electrical energy gets converted to sound energy?

Question: I have seen that inside headphones there is a magnet with a coil of thin wire around it. There must be longitudinal waves coming out of it that is why we can listen to audio. There must be pressure waves created as sound is nothing but pressure wave. So, my question is how is the pressure actually created there in the first place and how are the variations in pressure created? There is the electric current that flows through the wires and the electric and magnetic fields due to the current and the magnet. So, how do they "exert" pressure on air?
Comment: The membrane (usually made from some plastic or some form of paper or cardboard) driven by the linear motor realized by the coil and the magnet.
Comment: @SebastianRiese but who puts pressure on the membrane to make it vibrate? Could you write a detailed answer with diagrams?
Comment: I beg to protest a bit. :-) It is right, but just for the electrodynamic case. Beside that we have piezoelectric etc. Please rephrase the question, if you just care for an electrodynamic loudspeaker.
Answer: A permanent magnet has a fixed north/south polarity - in this example, lets say north is facing up and south is facing down. This magnet has a membrane of some kind attached to its north face.
An electromagnet beneath the permanent magnet can switch the direction of its north/south polarities by changing the direction of the electric current running through it.
When the electromagnet's south is pointing up, it pushes away the permanent magnet's south pole and therefore the membrane, creating an area of pressure in the air.
When the electromagnet's north is pointing up, it attracts the permanent magnet's south pole and therefore the membrane, allowing for the next pressure wave to be made.


How are the outcomes that generated from different predictive models combined to get more accurate predictions?

Question: The simple average is commonly used to combine the predictions of different predictive models. Apart form the simple average, what are the other methods that can be used for combining the predictive models to get more accurate predictions?
Answer: There are a few different ways. Here are examples:

Voting

If it's a classification problem, the models can vote on the outcome, establishing the class most models have selected. The voting procedure can be a straight one vote per model, or weighted, for example by confidence.

Super learner

The outputs of previously generated features are used as features in a new model - the Super Learner - which finds the best combination of those models. The recent R package SuperLearner is an implementation of this approach.

Averaging variations

Although you have mentioned averaging already, note that there are a number of different ways to weight the predictions in the averaging process. For example, you can assess the accuracy of the model, and then give more weight to the better performers. Or alternatively you can weight the prediction by confidence.
Comment: Super learner *does* apply different weights to the individual base models. your third example is repeating the second example. please expand on alternative weighting schemes besides super learning


One Disk on two SATA ports for full performance

Question: I want to connect my 860 evo SSD with 550MB/s to my PC and actually utilize all the performance. My Motherboard only has SATA II ports (300MB/s). Is there a way to use two SATA ports for one SSD to unlock the full 550MB/s?
Answer: No.
You may be able to get a PCI SATA card to give you higher speed. That said, are you sure the SATA ports are 300 megabyte? I would have thought a motherboard that is that old would not be a good candidate for eeking speed out if an SSD.  That said, even at 300 megabyte its a worthwhile upgrade - 3 times the sequential speed but a huge latency reduction for random access and wait times.
Comment: BTW, there are [port multipliers](https://en.wikipedia.org/wiki/Port_multiplier) for SATA (even though SATA it is "serial"), so I was wondering if there's some kind of "port aggregator" that takes different ports at lower speeds and passes them on at a higher speed... Probably not, as not many people would buy one, but it should be possible in theory. (Though I agree that a PCIe SATA card is probably the practical solution).
Comment: @dirkt ta. TIL....
Comment: thanks. Yes, I'm sure, the motherboard only has SATA II as per manufacturer specification. I'm upgrading either way, for the reasons you mentioned, and also when eventually I upgrade the whole PC I'm able to utilize the full performance of SATA III (almost..)
Answer: You may partially succeed if you buy two half-capacity 860 EVO SSDs (that should be about two times cheaper), connect then to your ports and setup a RAID-0 one or another way.
I understand the advice is not helpful if you need to use exactly the single SSD you have in your hands but would work if you are only bound to our motherboard and budget for buying a SSD 860 EVO (these come in capacities from 250 Gb to 4 Tb).
It may be more hardware limitations on your board that would limit the total throughput to less than 300+300.
Comment: neat idea, but I think the mobo's built in raid won't be faster than SATA II (I might very well be wrong here, it's just my intuition. could be that the RAID controller has more throughput.) so I would have to buy a raid extension card that would be able to handle the throughput but at that point I can just buy a SATA III extension card. Also I already have the SSD so getting two with half the capacity each is no option either.

I've come to accept that I'll just have to use SATA II on my board until I get a new one that probably has SATA III anyway.
Comment: No, RAID 0 configuration provides close to double throughput and the capacity is the sum of capacities of both drives. Under Linux you could use the same two ports without additional hardware. But if one drive fails in RAID 0, you lose data in both.
Comment: I know RAID 0 but I'm not sure how the RAID controller on the mobo is connected, and whether it would actually result in a higher throughput


How do the areas of the emitter, base and collector affect their respective currents?

Question: I want to know what will be the effect on current if we change(increase or decrease) the area of the emitter, base, and collector. For example, if we double the emitter area what will be the effect on emitter current, base current, and collector current?
Answer: A standard method to manipulate the behaviour of bipolar is to include INTEGER scale factors on the schematic used by the simulator and in defining the silicon layout.
Doubling the emitter-area, such as laying down TWO devices adjacent (for thermal tracking), while operating at the same total current, reduces the current density and thus reduces the emitter-base voltage by 18 milliVolts. Also, the allowed peak current will have doubled, should you expect heating issues or beta-collapse at higher currents.
Bandgap voltage references often use 2x or 4x or even 100x. I've reverse-engineered some older ICs that used 100:1 collection of diodes, where the 100:1 allows
log2(100) * 18 milliVolts
as the working delta_Voltage for the bias-generator design.
Answer: If you see the internal structure of a transistor, you can see that the area of emitter base and collector are different. See the simplified schematic below. The actual structure is little more complex than this.

The region directly below the emitter region is called the internal transistor. The remaining region is the external transistor. Most of the carrier transport happens in the internal transistor and hence the current will be directly proportional to the emitter area.
The external part of the transistor mostly contributes to the parasitic (resistance and capacitance). So increasing the area of base and collector won't change the current much.


Can we use jQuery functions as web part properties?

Question: I want to build a wrapper web part which will have properties. These properties must be consumed by jQuery functions and support its consumer webpart. Can we do this?
Answer: jQuery runs entirely client side, so it can consume anything which ends up in the markup of the page. It doesn't matter what you add to properties on the development side if those properties aren't available in the page client side.
Keep in mind that you can also use jQuery's AJAX function to query SharePoint's Web Services or read any URL-accessible file, though I don't think that helps you here.
Comment: thanks buddy, In fact i don't want to use webservice for now. can we do this then? say i have created wrapper webpart which having the properties. in each property i added a inline jquery functions as per our requirement. and i register jquery on client side using ClientResgistredScript object. so would that works ? I want something like this http://jquerywebparts.codeplex.com/
Comment: It sounds like what you're describing would work. I'd give it a go.
Comment: Thanks again, but i gone through few url's where author suggested to add the reference of jquery file in the master page. but in this (which i given in my last comment)...the reference of .js files added in the Assembly.config file using attribute. i could not get the difference between both. is i need to do any one out of these both ways?
Comment: I'm not sure I understand your last question, but I almost always simply put the jQuery reference in my master page using a plain old


How to know the relative frequency of equal or almost equal phrases in casual speech?

Question: For example:

Once in a while
Now and then

Dictionaries don't provide labeling for every phrase in terms of whether it's formal, informal, slang, etc.
Answer: If you look up the word occasionally in Longman Dictionary of Contemporary English, it has "S2" next to it, and if you hover over that, it explains that this means it is one of the top 2,000 most common words in spoken English.
Although Longman also defines the phrases "now and then" and "once in a while", it unfortunately doesn't attempt to indicate their frequency.
The best known way to find how much a word or phrase is used is to search for the phrase on Google NGrams.  However, this only searches written English, and includes formal texts.
There are searchable corpora of spoken English as well as written, and Longman use these to calculate their statistics.  The British National Corpus and the Corpus of Contemporary American English each contain large amounts of spoken material (transcribed and searchable).  At https://www.english-corpora.org/coca/ (login required, but free), you can select 'Search' and 'Chart' to see the frequency by "section".  For example, in the SPOK (spoken word) section of COCA, "now and then" has a frequency of 6.18 per mil, while "once in a while" is 7.52 per mil - not a great deal higher, to my mind.  But for most learners, doing corpus searches is unlikely to be worth while (and it would be easy to make mistakes doing so, for example where a phrase has multiple meanings); plus, most of the sites dedicated to this are liable to prompt you periodically to upgrade to a paid account.
You mentioned that:

Dictionaries don't provide labeling for every phrase in terms of whether it's formal, informal, slang, etc.

But generally speaking, if a word or phrase isn't labelled, then you can assume it is in general use and is neither particularly formal nor particularly informal.  Of course, there are exceptions to this.  The main one is Merriam-Webster: even when it comes to words (let alone phrases), M-W is extraordinarily sparse with its usage indicators.  For instance, it doesn't note that "pinch" (in the sense of "steal") is informal, nor that the phrase "muck around" is informal, nor that "summer" (in the sense of "year") is literary.  Lexico, Cambridge, and Macmillan are much better in this respect, as is M-W's Learner's Dictionary, interestingly.
Still, even the better dictionaries don't tell you everything.  Hence "it's" isn't marked as informal in Lexico, and yet most people would probably argue for its complete exclusion from formal essays.
Answer: Once in while refers to something you do occasionally, but not regularly.
Example
Once in a while I go hiking.
Now and then refers to something you do occasionally, but periodically.
Example
We go to the movies now and then, but not as often as we used to.
Hope this helps.
Comment: @rose : online dictionaries do mention whether a phrases is formal or informal ( Macmillan , the free dictionary ,ect.)


Vertex count number display

Question: Is there any way to show the number of selected vertices in Edit Mode?
Answer: In 2.9 version of Blender, you can also have the stats in the 3D viewport, using an option in the overlays:
Answer: Here's a 2.8+ answer with some visual reference and additional info.
1. First, make sure Window > Show Status Bar is enabled

2. Next, to see the stats for selected geometry (Verts|Faces|Tris|Objects), Right Click on the Status Bar itself and enable Scene Statistics

These settings can also be accessed through Preferences > Interface > Editors > Status Bar (and here a contextual Video Memory option is listed as well).
Comment: This should be an accepted answer.
Answer: Switch to edit mode, and the selected vertices will be shown as below:

As shown there are 4 selected vertices out of 8 vertices in the mesh
Comment: Is there a way to show the vertex number of the selected vertex? For example the rightest vertex is the i-th vertex.

Vertex count number display


Estimating Sun luminosity from first principles

Question: In a lecture, it was claimed that luminosity can be estimated by dividing how much energy there is in the Sun with the typical time it takes for a photon to get out from the centre of the Sun to its surface. I don't see how that argument holds. Why would that give me luminosity?
Comment: What lecture? Who was giving it?
Answer: The thermal energy of the Sun is something like
$$E \sim  \left(\frac{3k_BT}{2}\right)(N_i + N_e)\ , $$
where $N_i$ is the number of ions and $N_e$ is the number of electrons and the interior temperature $T \sim 10^7$ K.
To first order we can consider the Sun to be made of hydrogen, so $N_e = N_i \sim M/m_p$, where $m_p$ is the mass of a proton.
Putting in the numbers gives $E \sim 5\times 10^{41}$ J.
The typical mean free path of a photon in the solar interior is $l\sim 10^{-3}$ m. The solar radius is $R\sim 7\times 10^{8}$ m. Since the photons get out by a "random-walk" diffusion process, then it takes about $(R/l)^2$ steps, each of which takes a time $l/c$.
Thus the diffusion timescale
$$ \tau \sim \left(\frac{R}{l}\right)^2 \left(\frac{l}{c}\right) = \frac{R^2}{lc} = 1.6\times 10^{12}\ {\rm s}$$.
The ratio of these two numbers gives $3\times 10^{29}\ {\rm W}$, so about 3 orders of magnitude larger than the solar luminosity.
This ratio does not give the solar luminosity.


How to limit outgoing traffic per IP Address using Linux TC

Question: I want to limit outgoing traffic per IP address. For example I have a network interface eth0, having 1Gbps of bandwidth.
I want to limit the whole network interface to 1Mbps each destination IP Address.
For example 1Mbps for 192.168.1.1 and 1Mbps for 192.168.1.2
Currently I am using wondershaper using this command:
<code>wondershaper eth0 1024[outbound traffic] 1024000[inbound traffic]
</code>
But this is limiting the whole network interface and there won't be seperated traffic for each IP address.
Answer: You might need iptables' CLASSIFY. See
http://www.fyzix.net/index.php?title=Traffic_shaping_with_tc_and_iptables


Nested modelbuilder: parameters from submodel not showing up as inputs in main model

Question: I have a submodel that takes 3 numeric parameters and one raster as inputs. I want to nest this in a second model that iterates through a folder of rasters. However, when I drag the submodel into the main model, only the raster input shows up as an input parameter (even though I've also marked the numeric inputs as parameters). How do I get the three numeric parameters to show up as inputs to the submodel in the main model? See screenshopts of the submodel (first) and main model (second) below.
Answer: Figured it out... Turns out parameters will not show up as input "bubbles" to the nested tool but rather simply as inputs in the tool interface when you double click on it (see photo).
Answer: It's worth pointing out to others that your 3 numeric "parameters" are variables which are Preconditions to the calculate tools, so they are not classic inputs to a tool.
You can expose those variables in the sub-model in your master model. Once you have dragged your sub-model into your master model, right click on the sub-model (yellow box) and choose Make variable > from parameter > your variable.


Organize software distributives

Question: I use a lot of software: some big programs, a lot of small ones, plugins and extensions… Some of them are installed and I use them every day, some of them I use once a year. I store all distributives in one directory, for some software I even save multiple versions. Can anyone give advice on how to organize all those files, so it will be easy searching through them? I use Mac OS X Snow Leopard.
Comment: You probably should mention your OS/Version.  I see you tagged it as Mac, are you on Snow Leopard?
Comment: Yes I do use Snow Leopard (added this to question).
Answer: Whenever I download software, patches, plugins, etc, that I plan to keep for possible future use, I rename the files to something meaningful.  Downloads often have weird names, and software installers in particular can have generic names.  I don't replace the original filename, but I add text to its beginning: the application name, along with any important variant information like version.
Although I primarily use Windows, this should work with any O/S.
So the installer for an application called "Fnord" version 1.2, downloaded as "setup_fv12.exe", becomes "FNORD_V1.2_setup_fv12.exe".
I formed this habit a while ago and it has paid off on numerous occasions.

Organize software distributives


Is there a way to make a worn laminate floor shine again?

Question: Is there a way to make a worn laminate floor shine again?  There are a couple of areas in my house where lots of traffic seem to have dulled the shine on our laminate (pergo) floor, as well as where I foolishly have used a rolling chair at my desk with no mat.   Is there anyway to get something close to the original shine back?
Comment: check into a warranty claim some are supposed to be good for 25 years
Answer: According to their web site at http://na.pergo.com/HowTo_FAQ.aspx they state:

Pergo floors must never be waxed, polished, sanded or refinished and never use a wet or jet mop when cleaning.

Given that Pergo's surface is just a printed substrate, odds are the printing, itself, has faded. Probably time to replace.
An easy 'fix' might be to get some runners (narrow rugs) to cover the heavily trafficked areas.
That said, given that it's a printed surface, one option--if you don't want to pull it out and replace completely--might be to repaint it. Talk to a paint professional to see if there are any primers that would work on the Pergo. You could then roll on a new painted finish.
Comment: Because laminates are usually just a "picture" of wood on a thin backer, they are almost impossible to restore. This is the main reason I will not sell or install them for my customers. Heaven forbid they have a heavy dog!!!!!!
Comment: Thanks for the feedback.  Was hoping for a cheaper answer, but wasn't too hopeful.
Comment: Having three dogs ranging from 25 to 60 pounds, even moderately cheap laminate flooring is pretty claw proof.  Actually better than hardwood.
Answer: You can make the following test:
Damp mop the floor (A microfiber dust mop sprayed with 1/4 strength vinegar works for this)
Take a look at the floor while wet.  This is the best you can hope for.
If the wear has gone through the aluminum oxide protective coat, and taken out the paper "wood coat" all you will get is a darker version of the blah base layer.  If the problem is scratches in the oxide coat then you may be able to make some recovery.
Everything I've read says, "don't varnish laminate"  If you are faced with "varnish it or replace it", it may be worth a try.
I HAVE NOT DONE THIS.  Beware!!
Aluminum oxide is a very inert surface.  Getting an actual bond between varnish and it will be difficult.  You may be successful if you have a clean freshly sanded surface.  Experiment in a corner, or on scraps of material from when you put it in.
I would suggest:

Sand lightly with 600 grit paper.  Note:  If you are through the oxide coat even light sanding will destroy the image.  STOP.
Wash with 2 tsp tri-sodium-phosphate in a quart of water.  Put it in a spray bottle.  Wet a microfiber mop, and spray the floor or the mop as needed.  This will remove foot oils, dog drool, stick bits from spilled food.
Clean the mop, and do it again.  Repeat this until the mop is clean when you finish.  This may take several passes.
Clean the mop, and do it one more time, this time with plain water.  This removes any TSP residue.
Clean the mop.  Leave it damp.
Put some water soluble floor varnish in a squeeze bottle, or narrow neck bottle like a beer bottle.  Pour a 2" diameter puddle near one corner, and wet the mop in it. move the mop back and forth to get it uniformly wet.  Do your floor.
As needed pour a thin stripe of varnish in a pattern that the whole mop will pick up.

This puts a VERY thin layer of varnish on the floor. This layer will be dry in about half an hour.  Take a picture of the shine.  Put on another coat. Let dry Take another picture.  Is this coat shinier?  (Put your mop in a plastic bag while the floor is drying.)

Repeat until the floor is as shiny as you want it, or until it stops getting better looking.

The idea here is that the varnish is filling in the scratches in the oxide coat.  As long as it's filling it in, it will get shinier.  Once you have a complete layer over the top of the ridges, it stops. Overall you are putting more varnish in the cracks than on the ridges.
Risks:

The varnish is NOT as hard as the oxide coat.  You will likely need to do this every year or two.  Likely you can repeat in the trafficked areas only sometimes.  Or you may find that the edges of the room take only one coat while the centre takes 2 or 3.
If the varnish fails to get a grip on the oxide coat, it will peel.  You can end up with a mix of peeling parts and well stuck parts.  This will NOT make an image for Better Homes and Gardens, but may earn you karma posting it here on diy.SE.  However if the option is replacing the floor, you don't have a lot to lose.  Everything I've read says it won't stick.  But that is said of polyethylene and paint too, and paint sticks just fine to PE pots.  So far I can't find anything that says why it won't work, and what happens when you ignore the results and try it.


cordova/phonegap does not make android directory

Question: ant, java, node.js, phonegap, and my adobe account are all setup properly. The getting started guide says I should be able to type:
cordova create hello com.example.hello "HelloWorld"

to create a phonegap project. This does not work but following these instructions and doing:
phonegap build android

does eventually get me a .apk file. But the getting started guide tells me to open eclipse and navigate to the directory of my project and then set the subdirectory as /android. but /android does not get created when you do phonegap build android so I have nothing to work with.
How do I get phonegap to create the android directory? I am trying to finish the getting started guide instead of taking shortcuts.
Answer: It does seem like you are using PhoneGap 3.0 and for this version, eclipse is not required (only if you want to use it for coding - compared to PhoneGap 1.0-2.x where eclipse was used to compiled the app, for the latest version it is no longer a requirement).

To begin, you should use the phonegap command instead of the cordova command: phonegap create hello com.example.hello "HelloWorld"
Then navigate to /HelloWorld/ folder
You should see atleast these two key folders /www and /platforms. Inside /www is where you place your HTML files and codes, and /platforms/android gets generated when you compile the app with the following command: phonegap build android.

Note: Avoid making any direct changes to files inside /platforms except for config and manifest files. The other files are dynamically generated when you run the build command. All coding should take place within /www.
One more thing, use the 3.0.0 Getting Started guide.
---- February 2014 Update ----
With the release of Cordova 3.3.0, it seems the PhoneGap team is trying to address the naming confusion. The documentations have been updated to recommend people using the cordova command instead. Do not use the phonegap command anymore.
Here is a fresh installation guide for a guaranteed trouble free set up:

Install Cordova (forget the name PhoneGap from now on).
For PC: C:> npm install -g cordova
From command prompt, navigate to the folder you want to create your project using: cordova create hello com.example.hello HelloWorld
cd HelloWorld
Define the OS you want to suppport, we'll go with Android for this example: cordova platform add android
Install plugins (If needed). For example we want the following:
cordova plugin add org.apache.cordova.device
cordova plugin add org.apache.cordova.camera
cordova plugin add org.apache.cordova.media-capture
cordova plugin add org.apache.cordova.media

Finally, generate the app using: cordova build android
or to directly install the app to your connected device: cordova run android

Here is a link to the PhoneGapCordova 3.3.0 Documentation
http://docs.phonegap.com/en/3.3.0/guide_cli_index.md.html#The%20Command-Line%20Interface
Comment: There's a lot of confusion about cordova and/or phonegap commands. Now their docs tell us to use cordova but it seems more like an error. I was trying to find out more in blogs or updates but nobody is mentioning the switch. Cheers.
Comment: phonegap 3.3 uses `cordova platform add android`.  One can check using `cordova help`
Comment: Hello @quik_silv thanks for your input, the post has been updated accordingly.
Answer: First of all, you should be using phonegap instead of cordova to create the project folder structure.
phonegap create hello com.example.hello "HelloWorld"

And secondly, please note that build command uses two way to build for any specific platform. One using the phonegap build API (online) using the below command
phonegap build android

and second one locally using below command,
phonegap local build android

So you should try to use the second command for creating the android specific folder and use it with eclipse. You can look for more details over here http://docs.phonegap.com/en/3.0.0/guide_cli_index.md.html#The%20Command-line%20Interface
When you run the build local command, android folder is created inside the platforms folder, and you should always modify the code(html, js, css) on the www folder present outside the platforms folder.
The changes will get reflected once you again run the build command. This helps you maintain single code base for multiple platform ( which is the basis aim of using Phonegap)

Note: you need to have latest android sdk tools (vs18) to run on Android SDK.
Answer: I have found this
Multi-Device Hybrid Apps for Visual Studio Documentation for CTP1.1 Last updated: May 29, 2014 .
Some of the content from the documentation as follows.
This release supports building apps for the following device targets:
Android 4+ (4.4 providing the optimal developer experience)
iOS 6 & 7
Windows 8.0 (Store)
Windows Phone 8.0
Requirements:
Windows 8.1
Visual Studio 2013 Update 2 - Professional, Ultimate, or Premium with the following optional features installed:
Tools for Maintaining Store apps for Windows 8
Windows Phone 8.0 SDK
Additional system requirements vary by device platform:
The Android emulator works best with PCs capable of installing the Intel HAXM driver
Windows Phone 8 requires a Hyper-V capable PC to run the emulator
Building for iOS and using the iOS Simulator requires a Mac capable of running Xcode 5.1
Third Party Dependencies :
Joyent Node.js – Enables Visual Studio to integrate with the Apache Cordova Command Line Interface (CLI) and Apache Ripple™ Emulator
Git CLI – Required only if you need to manually add git URIs for plugins
Google Chrome – Required to run the Apache Ripple emulator for iOS and Android
Apache Ant 1.8.0+ – Required as a dependency for the Android build process
Oracle Java JDK 7 – Required as a dependency for the Android build process
Android SDK – Required as a dependency for the Android build process and Ripple
SQLLite for Windows Runtime – required to add SQL connectivity to Windows apps (for the WebSQL Polyfill plugin)
Apple iTunes – Required for deploying an app to an iOS device connected to your Windows PC


Is it possible to set code behind a resource dictionary in WPF for event handling?

Question: Is it possible to set code behind a resource dictionary in WPF. For example in a usercontrol for a button you declare it in XAML. The event handling code for the button click is done in the code file behind the control. If I was to create a data template with a button how can I write the event handler code for it's button click within the resource dictionary.
Comment: The correct way to do this is to use a command, it also gives you the ability to enable and disable the button, while you can do it the way some answers have suggested it smells to me of a hack.
Answer: I think what you're asking is you want a code-behind file for a ResourceDictionary. You can totally do this! In fact, you do it the same way as for a Window:
Say you have a ResourceDictionary called MyResourceDictionary. In your MyResourceDictionary.xaml file, put the x:Class attribute in the root element, like so:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    x:Class="MyCompany.MyProject.MyResourceDictionary"
                    x:ClassModifier="public">

Then, create a code behind file called MyResourceDictionary.xaml.cs with the following declaration:
namespace MyCompany.MyProject
{
    partial class MyResourceDictionary : ResourceDictionary
    {
       public MyResourceDictionary()
       {
          InitializeComponent();
       }
       ... // event handlers ahead..
    }
}

And you're done. You can put whatever you wish in the code behind: methods, properties and event handlers.
== Update for Windows 10 apps ==
And just in case you are playing with UWP there is one more thing to be aware of:
<Application x:Class="SampleProject.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:rd="using:MyCompany.MyProject">

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>

                <rd:MyResourceDictionary />

            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

</Application>

Comment: Make sure you provide a default constructor in the partial class codebehind, and make sure it calls InitializeComponent().  (In my case I was using MEF to Export the resource dictionary.)
Comment: You'll also have to set the Build Action on the ResourceDictionary's XAML file to "Page", otherwise the InitializeComponent() call won't compile. (ResourceDictionary XAML files are usually set to "Resource" by default.)
Comment: As an addendum to ageektrapped's answer: Make sure that you put the fully qualified name of your codebehind class in the x:Class attribute. `x:Class="MyCompany.MyProject.MySubFolder1.MyResourceDictionary"` Otherwise, if you merely put x:Class="MyResourceDictionary", the xaml parser won't find your class.
Comment: Updated code snippet for upvoted comment. I felt it was needed to complete the answer ; a common mistake. I did it just now :) Revert if you dont like it. Thanks for the answer.
Comment: Note that (at least in wp8.1) this is no longer valid and you'd have to create a custom usercontrol that your resourcedictionary references
Comment: Interestingly enough, I've tested this without a default constructor and without inheriting `ResourceDictionary` and code-behind still works. Not sure why this is, but I imagine it's best to avoid anyway.
Comment: MS Docs are here: https://learn.microsoft.com/en-us/windows/uwp/data-binding/data-binding-in-depth#resource-dictionaries-with-xbind
Answer: I disagree with "ageektrapped"... using the method of a partial class is not a good practice. What would be the purpose of separating the Dictionary from the page then?
From a code-behind, you can access a x:Name element by using:
Button myButton = this.GetTemplateChild("ButtonName") as Button;
if(myButton != null){
   ...
}

You can do this in the OnApplyTemplate method if you want to hookup to controls when your custom control loads. OnApplyTemplate needs to be overridden to do this. This is a common practice and allows your style to stay disconnected from the control. (The style should not depend on the control, but the control should depend on having a style).
Comment: Phobis I think the purpose of separating the Dictionary from the page is about reusability and readability of the Main page xaml. The above solution worked for me too.
Answer: Gishu - whilst this might seem to be a "generally not to be encouraged practice" Here is one reason you might want to do it:
The standard behaviour for text boxes when they get focus is for the caret to be placed at the same position that it was when the control lost focus.  If you would prefer throughout your application that when the user tabs to any textbox that the whole content of the textbox was highlighted then adding a simple handler in the resource dictionary would do the trick.
Any other reason where you want the default user interaction behaviour to be different from the out of the box behaviour seems like good candidates for a code behind in a resource dictionary.
Totally agree that anything which is application functionality specific ought not be in a code behind of a resource dictionary.
Answer: Adding on....these days, with the advent of {x:Bind ...}, if you want to put your DataTemplate into a shared ResourceDictionary file, you are required to give that file a code behind.
Answer: XAML is for constructing object graphs not containing code.
A Data template is used to indicate how a custom user-object is to be rendered on screen... (e.g. if it is a listbox item) behavior is not part of a data template's area of expertise. Redraw the solution...
Comment: I wouldn't - to me it doesnt feel right. A dictionary should return values for specific keys. In the OP's case, bundling code with the data template.. I'd rather try a different approach.. use the Command model for instance. I need more details on the OP's problem to recommend a diff soln.
Comment: Completely disagree. With MVVM, there is one scenario where having code behind is extremely useful: developing attached properties. Get it working with code behind, then port it to an attached property. This is much faster than simply developing the attached property from scratch, unless you have a brain the size of Manhattan.
Comment: conclusion:
Would u recommend on using resource dic with code behind or not??
I have never used it, I am doubting.


Rates of convergence of empirical measures in Wasserstein distance

Question: Let $X_1, X_2, \ldots$ be iid random variables in $\mathbb {R}^d$ with common distribution $\mu$, and
$\mu_N = \frac 1N \sum_{k=1}^N \delta_{X_k}$, $N \geq 1$, the associated empirical
measures. If $\mu$ is uniform on $[0,1]^d$,
the optimal (in $d$ and $p$) rates of convergence of $E(W_p^p(\mu_N, \mu))$ as
$N \to \infty$, where $W_p$, $p \geq 1$,
is the Wasserstein distance, are known from the Ajtai-Komlos-Tusnady theorem
https://mathscinet.ams.org/mathscinet-getitem?mr=779885
What kind of rates, if possible sharp,
are known under some strong (for example exponential) moment of the law $\mu$ of the $X_k$'s, specifically when $d \geq 2$? For example, what about $\mu$ the standard normal (in
$\mathbb {R}^d$)?
Comment: Not sure if that is your question, but of course under sufficient moments ($q$-th moments for $q > 2p$) you have the same behavior as for the uniform distribution, which is shown in the paper by Fournier and Guillin "On the rate of convergence in Wasserstein distance of the empirical measure."
Answer: There are some result for Gaussian samples on a series of paper by Michel Ledoux and coauthors: On Optimal matching of Gaussian samples, On optimal matching of Gaussian samples II and on Optimal matching of Gaussian samples III. They also know sharp rates, of course there is dependency on both the power of the cost and the dimension of the problem.
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).


What is pseudo-synchronisation when a planet is orbiting a host star?

Question: I understand the term synchronous rotation - when the plant spin frequency is the same as the orbital frequency. However, I've seen the term pseudo-synchronization coming up in a few places and I'm not sure I understand what is the physical meaning behind it. Does it relate to eccentric orbits? Where the angular velocity changes across different phases of the orbit?
Comment: My guess would be a spin-orbit resonance (like Mercury's 3:2)
Answer: According to Hut [1981], for eccentric orbits, pseudo-synchronous states are states of

near synchronization of revolution and rotation at periastron

Kepler's 2nd law says that a planet sweeps out equal area in equal time from the star.  Periastron is where the planet is closest to the star and thus moving the fastest, with the fastest angular speed around the star.  That means that other than at periastron, the orbital angular speed is less than the rotation rate of the planet.
The planet Mercury is in such a state.  Also from Hut [1981]:

We can contrast this with the Moon, which is in synchronous rotation with the Earth.  Hence its rotation is less than revolution at perigee, but greater at apogee.
Pseudo-synchronization does not have to be at resonant frequencies.  See Greg Laughlin's explanation here, with an equation that calculates the spin period of a pseudo-synchronous orbit as a function of the orbital period and eccentricity:
$$P_\text{SPIN}=\frac{(1+3e^2+\frac{3}{8}e^4)(1-e^2)^{3/2}}{1+\frac{15}{2}e^2+\frac{45}{8}e^4+\frac{5}{16}e^6} P_\text{ORBIT}$$
Note:

Our Moon presumably passed through a pseudo-synchronous rotation state on its way to tidal lock with the Earth, demonstrating that not all pseudo-synchronous rotation states are stable.
Comment: This happens in binary star systems as well, for eccentric orbits.  The reason the rotation rates end up matched at periastron is that that is where the tidal forces are the strongest.
Comment: Dear Connor Garcia, thank you for this detailed explanation. I think, you made a slip of the pen in the closing line. You probably wanted to say not "pseudo-synchronous orbits" but "pseudosynchronous rotation states."
Answer: Connor Garcia has provided a wonderful answer to this question. I would like to dwell on the final point in his post, that not all pseudo-synchronous rotation states are stable.
When a rapidly rotating secondary is undergoing tidal deceleration, it may experience either one or two torques from its primary.

If the secondary is a fluid body (say, a Juipter, or a stellar companion, or hot and molten terrestrial planet), it experiences only the tidal torque -- which produces a tidal bulge running over the secondary's circumference.

As Valeri V. Makarov demonstrated in his wonderful work, the tidal torque will make the fluid secondary end up in the pseudosynchronous state, provided the mean viscosity of this body is lower than some critical value.

If the secondary posesses a rigid crust and can sustain a permanent triaxiality, it is experiencing an additional torque from the star. A proper name for it would be "the permanent-triaxiality-generated torque", but for brevity we call it simply the "triaxial torque." It is then the interplay of the tidal and triaxial torques that defines the rotational dynamics of the secondary and its end state.

When the body is away from spin-orbit resonances, the triaxial torque averages out and plays no role. Things become interesting when the rotator has to transcend a spin-orbit resonance (or to get trapped in it). There the triaxial torque comes into play, and the passing of -- or capture in -- a higher spin-orbit state becomes in many situations probabilistic, i.e. dependent on the phase difference between the two torues. It can be demonstrated that the outcome depends on the orientation of the rotator in the pericentre at the moment of crossing of the resonance. (Why exactly in the pericentre -- that is explained in Eric Jensen's comment to Connor Garcia's post: because in the pericentre the tidal forces are the strongest.) For more on this, see another paper by Valeri V. Makarov.
Now, suppose that a triaxial body has successfully crossed all the higher spin-orbit resonances, and is approaching pseudosynchronism. Will it stay there, or will it cross it, to end up in the exact synchronism? Were the tidal torque dominant, pseudosynchronism would be the end state. In real life, however, the elevation due to the permanent figure will normally be higher than the tidal bulge. Consequently, the triaxial torque will be larger. So the body will be captured in the exact synchronism, with its figure tilted very slightly relative to the direction to the perturber (so that the emerging triaxial torque could compensate for the tidal torque). This is what happened to our Moon when it crossed the pseudosynchronous state without stopping there, and went on to despin towards synchronism. See this work for details.


Orbeon upload component active in read mode?

Question: SOLVED - I have an upload component in section of an Orbeon form (in Liferay portal). Users have to upload a document here in the first stage of the workflow.
Later in the workflow, when this section of the form is in read-only mode, the upload button can still be used to upload something. Afterward uploading there is no evidence in the form of any upload (no file name), either of the original upload or the one later committed in read-only mode.
On clicking "Download" the original upload is downloaded, not the file that seemed to be uploaded when in read-only mode.
Is this a known bug, is there anything we can do about this?
Thanks in advance.
Answer: Yes, this is a known issue, and it is fixed in Orbeon Forms 4.5.


Multiple test mock runtimes with slightly different configs based off common base?

Question: We have some custom pallet unit tests that use multiple mock runtimes that are configured slightly differently.  The problem is that when we have to make changes to the runtime, we have to apply those changes to all of them. Furthermore, we'd like to have a set of common functions that all of the unit tests can use.  If Rust had inheritance, the solution would be an abstract base runtime and subclasses for each runtime but Rust doesn't have it.  The solution likely involves creative use of modules and macros but what's the recommended approach?
I'd like to avoid making changes to the Cargo.toml.  I'd like to have some sort of macro level attribute that I could set in each runtime:  "runtime1" and "runtime2" and then conditionally compile which value is used based on that attribute.
In our case, we have two runtimes that differ only by the constant values for two of the associated types.
e.g.
type MaxMessagesStored = ConstU32<25>;  // runtime1

and
type MaxMessagesStored = ConstU32<1000>;  // runtime2

So, I'd like something like this.  This code is for example and does NOT work:
#![cfg_attr(RUNTIME, define = "runtime1")]

    #[cfg(RUNTIME = "runtime1")]
    type MaxMessagesStored = ConstU32<25>;
    #[cfg(RUNTIME = "runtime2")]
    type MaxMessagesStored = ConstU32<1000>;

In C, this would be:
    #define RUNTIME "runtime1"

    #if defined(RUNTIME) && (RUNTIME == "runtime1")
    // code
    #else
    // code
    #endif

Alternatively, is there a way to change the value at runtime?  I assume not because it's a constant but have to ask.
Answer: I think the best practice is using macro.
Sometimes, we need to speed up the session time for the development runtimes.
So, we have a fast-runtime macro.
Check how fast-runtime works: https://github.com/paritytech/polkadot/blob/a8e6828115f852dc08a90c9fc0698f59a589b977/runtime/common/src/lib.rs#L247-L275
You can simply replace the fast-runtime with something like multi-runtimes and make accepting more args.


What is the meaning of quantum spin axes and directions?

Question: I just completed watching all 24 lectures of the Quantum Mechanics course on "The Great Courses". The course was excellent overall, but I am a bit confused about a few things. For example, they use the terms "spin-up" and "spin-down", as well as spin axes x, y, and z. What does the "up" in "spin-up" mean? Does it mean "up" in the normal sense of the local gravitational field? If not, what? If two quantum particles are far apart and are both "spin-up", does that mean their spin axes are both in the same direction in inertial space? Nothing was mentioned in the course about this that I recall. Also, how are the x, y, and z axes defined? Are they common for all particles? In what sense?
Comment: We give quantum spins names in order to understand them better , a quantum spin is just a property of a quantum particle
Answer: The directions are arbitrary, and depends entirely on the direction you define as "up" (or down, left, right etc.). If for example you chose the positive y-axis as being the "up" direction, then if you were to measure spin and find it to be pointing in the same direction as the positive y-axis, then the particle has a spin "up". If you measure it to be spinning in the direction of the negative y-axis, then you have measured it as having a spin "down".
These directions depend completely upon your choice of what direction is "up", i.e., on your choice of axes. It has nothing to do with the direction of gravity, but there is a natural inclination to chose "up" as pointing in the positive y-direction of the standard Cartesian axes. It's intuitive and you will always find your lecturers doing the same.
If you were to pass electrons through a magnetic field so that they emerge with their spins pointing along a particular direction, you may define this direction as being "up" (or left, right etc.) and then detect particles who's spins point in different directions. Again, you define which directions are up or down, left and right etc.
Comment: yes - so in practice spins are measured indirectly such as an NMR scanner measuring the resonance of a spin precession around a strong magnetic bipole - it's anyone's guess if the precession direction is clockwise and the nuclear spin anti-clockwise or vice versa - you just need a terminology to describe the act of flipping from one state to another
Comment: Yes, this is true.
Comment: OK, thanks. I get that the orientation of the axis is completely arbitrary. So I guess that means that an entangled "total-spin-zero" pair that are far apart must be measured based on the same set of axes. Also, I don't understand why the Wikipedia equations are slightly different for the z axis than for x and y if they are completely arbitrary.
Comment: I second the OPs question about distant pair of entangled particles; what does it mean to identify two orientations at the two laboratories as being the same for the purposes of the experiment (say. both represent "up")? Is it just that the relative orientation between the quantum system and the measuring equipment has to be maintained (even if the "absolute" orientation of the two labs differs - if "absolute" orientation can even be meaningfully defined in light of GR)?


Getting albums on home screen

Question: Now to go to albums I need to open camera, then click the last saved image, then click the photos icon, then click the albums icon. Can I just have the icon on my home scrern to go to albums instead? Also how about going to a specific album or even a specific photo (like a subway map or my family picture)?
Answer: Yes, you can. The "albums app" is usually called "Gallery" or "Photos", so just place an icon of it on your home screen.
Depending on launcher it may also be possible to add a shortcut to a particular image to your home screen. Also, as far as I know, ES File Explorer can do that too.
Comment: And don't forget about the specific widgets existing (e.g. "photo frame"), so one could even place a particular album (or image) directly on the home screen. No external app needed for that.

Getting albums on home screen


What happens if we know that for an RSA key pair, the equation $d^e \equiv c \pmod{n}$ holds?

Question: If we possess the knowledge that the expression $d^e \equiv c \pmod{n}$ holds for an RSA key pair, what would be the implication or consequence of this? Here, $e$, $n$, and $d$ represent the public exponent, modulus, and private exponent, respectively.
Comment: Remark: we must set some upper limit to $d$, like $d<n$. That's because if we selected a random $d$ in some largish interval like $[0,n^3)$ among those $d$ such that $e\,d\equiv1\pmod{\lambda(n)}$ (alternatively: $e\,d\equiv1\pmod{\varphi(n)}$ ), then $c$ would be undistinguishable from a uniformly distributed integer on $[0,n)$ and would thus disclose no information.
Answer: Reformulating: it's asked if disclosing the integer $c=d^e\bmod n$ compromises the security of an otherwise secure RSA public key $(n,e)$ with private exponent $d$. I'll assume $0<d<n$, as customary in most RSA key generation standards, which variably set the upper limit for $d$ to $\lambda(n)$, $\varphi(n)$, or $n$.
The disclosure of $c$ has at least one notable security consequence: with a query to an hypothetical textbook RSA decryption (or signature) oracle, we can obtain $d$ and factor $n$. Whereas there is no known way to factor $n$ or otherwise obtain a permanent textbook RSA oracle from temporary access to one.
The simplest is to submit $c$ to the oracle, which outputs $d$, and now we can decipher. And since $e\,d-1$ is a multiple of $\lambda(n)$, we can factor $n$ (see this answer).
Using the multiplicative property of textbook RSA, we can extend the attack to an oracle that imposes a little formatting to it's input: we pick an arbitrary $u$ and compute $v=u^ec\bmod n$ until that fits the format required by the oracle. Then we submit $v$, get $w$, and compute $d=u^{-1}w\bmod n$.

So far I found no attack that works with common oracles (e.g. computing RSASSA-PKCS1-v1_5 signature of a given message), much less an attack that works without oracle.
Answer: As a complement to fgrieu's answer, here is an idea of the sort of issues that can occur.
Let's say that $d$ is taken as the inverse of $e$ mod $\varphi(n)$ (it would work pretty much the same with $\lambda(n)$). We have $ed-1 = k\varphi(n)$ for some $k$ which we can assume is known, since $k<e$ and $e$ is usually small, so exhaustive search is feasible. Then the known leakage value $c$ satisfies:
$$e^e \cdot c \equiv (ed)^e \equiv \big(1+k(n-p-q+1)\big)^e \equiv \big(1+k-k(p+q)\big)^e \pmod n.$$
This means that $p+q$ is a solution of a known degree $e$ equation modulo $n$, of size $\approx n^{1/2}$. If we had $e=2$, this would be sufficient to recover $p+q$ using Coppersmith's theorem and hence factor $n$. Since $e$ is odd and at least $3$, this doesn't give an actual attack, but it does suggest that funny business may occur (for example, if we also had an additional leakage of a third of the bits of $p+q$, we would be able to factor when $e=3$).


Different alignment for elements of two groupBox in a form

Question: I'm trying to design a settings form for a Desktop Application. There is two groupBoxes in the form. Each groupBox may contains some elements(TextBox, ComboBox , ...). Is it force for good design to align this elements with single alignment ? Or if i don't do that may it break up the rules?
Here is the screenshot with alignment:
Comment: There are common patterns, and a general rule, they say that you should align elements, but if you want a better answer, you should provide a screenshot or mockup of the design you are working on.
Comment: I second that. You can read more about form alignment here: http://www.lukew.com/ff/entry.asp?1502, however, regarding encapsulating some form fields it may depend on some specific case regarding your project. In general I would say it's better to have the same alignment, but sometimes it may lead to non-optimal results.
Answer: You should be mindful of gestalt principals when grouping or aligning controls.
Gestalt principal of perception states that when looking at a complex visual image, our minds see coherent, whole forms, rather than individually perceiving all of the smaller elements in the image.
For grouping controls, alignment will of course make a form more pleasing to the eye, but take care that you get the spacing right or the user will see "groups" of controls that you did not intend.

The above image illustrates what I mean in relation to your question. In the first example the alignment combined with inadequate spacing forces the user to see the controls from 2 different groups as being a single entity. In the second example all the controls are still aligned, but now the spacing aids the user in seeing them as 2 seperate groups.


What are some important aspects to be considered when creating microcopy for a web app that has a global audience?

Question: We are creating an enterprise web app for a global audience. I am responsible for creating microcopy - the content you see all over the web interface, such as button text, error messages, guiding text, etc. So, what are some important aspects that I should consider or research when my audience are from all over the world?
Comment: Are you talking about many languages or just English users globally?
Answer: Disclaimer : A few of the I am posting are from a blog post I wrote recently,so if this is considered as a attempt at self promotion, please let me know I'll remove my answer.
Here is a brief list of the things I would call out before while writing content for international audiences

Research your audience and find out the local language in thier region : There are a number of countries which have multiple languages and what might be considered acceptable in one of the languages might not be the case there. So while creating content, be mindful of the language of the area you are targeting. To quote the W3C internationalization page :

The script may also change by legislation or with changes in
  government policy. For example, to reach the Azeri-speaking population
  in Iran, you would use Arabic script. From the late 1930s, Cyrillic
  was the script of choice in Azerbaijan itself and became policy in
  1940. Due to the fall of the Soviet Union, beginning in 1991 a gradual switch to Latin occurred, becoming mandatory for official uses in
  2001. However, for your target audience and unofficial uses, you might want to use Cyrillic for older audiences and Latin for younger
  audiences, and most likely both to reach the general Azerbaijani
  population. If you want to reach all Azeri speakers, you would use all
  3 scripts. (Note that there might be terminology and other differences
  among Azeri speakers in different countries, just as there are
  differences between English or French speakers in different
  countries.)
You also should be aware that your choice of script may have
  political, religious, demographic or cultural overtones. In countries
  where the language of higher learning was Russian, Cyrillic will be
  used by educated people. Latin is associated with Pan-Turkic
  movements, and more generally can indicate Western-tending movements.
  Arabic script has associations with Islamist movements.

Get a professional translator : The web is replete with stories of poorly translated tag lines or messages which were a failure in the target countries due to incorrect translations or automated translation. To quote an example from my blog post :

Pepsi's 'Come alive with the Pepsi Generation' slogan reportedly
  turned into 'Pepsi brings your ancestors back from the grave' when
  translated into Chinese.
Germany was not entirely receptive of Irish Mist whiskey liqueur,
  Clairol's mist stick curling iron or the Rolls Royce Silver Mist
  model. This isn't surprising when you consider that 'mist' is German
  for 'manure'.

Be Mindful of small details: While writing text for international audiences or audiences from a specific country, ensure that you are mindful of small details which might influence the way your users perceive your app. Some details are :

Dates: Be mindful of date formats used (DD/MM/YYYY vs. MM/DD/YYYY)
Time: 12-hour vs. 24-hour time.
Currency: Pay attention to conversions and formats.
Phone Numbers: Formats are different around the world.
National Holidays: Holidays are country and region specific.
Metric Units : Be mindful of the metric units being used in that country
Website Language Codes: ISO codes are important to know.

Understand how users access your site (the platforms they use) : You need to do some research about the kind of platforms your users might use to access your site. Though your site might be a web app, chances are a lot of users might access it through a mobile browser. A good example is that of that of how facebook customizes its tag line and leading text depending upon its audience :

The English page says, "Facebook helps you connect and share with the
  people in your life." The Japanese page says, "Using Facebook, you can
  connect with friends, colleagues and classmates to deepen your
  connections. Also access Facebook from cell phones and smartphones."
The thing to notice is that the Japanese page mentions users can
  access the site with phones, but the English page doesn't. This is
  perhaps because this study 95% of the Japanese population is mobile
  subscribers.

I also recommend looking at this article for additional inputs. To quote the article :

Ensure you follow the spelling of the area you are targeting: For example,if your user base is mostly american, they you need to
  ensure your spelling follows american english  guidelines but if your
  user base uses mostly British english, then change the spellings
  accordingly
Avoid idioms or metaphors unless you are sure your users will understand them
Avoid specific cultural references
Keep sentences short and light Jargon, multiple sub clauses, obtuse syntax – it's just going to give everyone a headache
Comment: @Senthil Can you mark this as the answer if it was helpful ?


Execute code on model creation in Django

Question: I want to execute some code in a Django model when it is first created. After that whenever it is saved I want to execute some other code. The second task can be easily done by overriding the save() method.
How can I do the first task?
Answer: Extending sdolan's answer by using receiver decorator:
from django.db import models
from django.dispatch import receiver

class MyModel(models.Model):
    pass

@receiver(models.signals.post_save, sender=MyModel)
def execute_after_save(sender, instance, created, *args, **kwargs):
    if created:
        # code

Comment: This is what works now with django 1.10, rather than the accepted answer which was presumably correct for earlier versions.
Answer: You can use django signals' post_save:
# models.py

from django.db.models import signals

class MyModel(models.Model):
    pass

def my_model_post_save(sender, instance, created, *args, **kwargs):
    """Argument explanation:

       sender - The model class. (MyModel)
       instance - The actual instance being saved.
       created - Boolean; True if a new record was created.

       *args, **kwargs - Capture the unneeded `raw` and `using`(1.3) arguments.
    """
    if created:
        # your code goes here

# django 1.3+
from django.dispatch import dispatcher
dispatcher.connect(my_model_post_save, signal=signals.post_save, sender=MyModel)

# django <1.3
from django.db.models.signals import post_save
post_save.connect(my_model_post_save, sender=MyModel)

Comment: Yeah, setting up the signals through the dispatcher module was added in 1.3.  You need to connect using the `signals.post_save.connect` shown at the bottom.
Comment: @RohitAgarwal: I glanced at the old docs and updated the bottom of my example of what should work for 1.1.1.
Comment: `AttributeError: 'module' object has no attribute 'connect'`. Then I tried using the receiver decorator(https://docs.djangoproject.com/en/dev/topics/signals/#connecting-to-specific-signals) but I got `ImportError: cannot import name receiver`
Comment: I tried this but was getting an error. Turned out I am using Django version (1, 1, 1, 'final', 0) and this works only for Django 1.3 and above. I will try to upgrade but do you know any other method? Thanks!
Comment: @Rohit: What was the error in 1.1.1?  These signals existed in 1.1.1, the setup just may be a little different, or I have a typo.
Answer: field.default
The default value for the field. This can be a value or a callable object. If callable it will be called every time a new object is created.
So, we can use any field callable to do what we want on creation, huh? ;-)


iOS UIBarButtonItems for navigation and sharing

Question: I am creating app and I need in detail page for item add some bar image buttons to rightBarButtonItems of navigation bar. I know that there are several predefined styles but I am not sure which images to use for share button and for button which runs navigation. How they should look like that user immediately knows purpose. For which use there is action style in predefined styles? Thanks
Answer: The Share icon is:

As defined here:
https://developer.apple.com/library/ios/documentation/userexperience/conceptual/mobilehig/Bars.html#//apple_ref/doc/uid/TP40006556-CH12-SW33
Answer: There are icons that have been so widely adopted now that they have become useful for situations like this because everyone knows what they mean; though you could just say "Share" in the titlebar and that would to the trick.
Default Android share button icon:
Default iOS 7 share button icon:
As for your other question about navigation you would want a chevron arrow pointing to the left on the left side of your titlebar like this:
Comment: Thanks, I am familiar with Android icon and I was almost sure that it wouldn't be right one for iOS. But as navigation icon I mean icon that after tap would run 3rd party applications (or Apple app) which navigate user to exact place.
Answer: If by "running the navigation" you mean showing other sections of the app/site vs going backwards or forwards (the chevron left or right), then you can use what many applications tend to use which is the three horizontal stacked lines or what some refer to as the "hamburger" button.  The "hamburger" button has become synonymous with showing/hiding the navigation options/sections of the app or page.  When the user clicks it, a dropdown appears or the screen slides out to reveal different options.

Hope this helps.
Comment: I give you +1 because your answer is describing but as I wrote in another comment. By navigation I mean icon which after clicked run app which user navigates to the place. I am sorry if it's another word in english. Do you know icon like that?