Freelancing and GPL?

Question: Is it possible for a freelance programmer to use Open Source products under GNU Public License and make money given that he cannot stop his customers from freely distributing his products?
Comment: Consulting and customizations go a long way.  It certainly depends on how the application is built and realizing what the intention of the GPL is.
Comment: Companies that produce GPL software usually make their money by providing customization and support services, not by selling the software.
Comment: I'd say it's compatible, but you should discuss it with the client first and make the implications very clear. Some could back off if you were to clearly tell them they wouldn't be able to resell or license the product.
Comment: @RobertHarvey I don't see that as the case much anymore. I see now that they release a GPL version to be used by other GPL products. And then sell a commercial version of the product to be used in closed-source products.
Comment: I don't quite understand the question. Are you trying to say that a freelancer maintains the rights to the code they write for another company? That is not typically the case.
Comment: @AndrewFinnell: They would have to keep the two code bases completely separate.
Answer: IANAL (I am not a lawyer):  Freelancing and GPL are very compatible -- if the client is a company that wants something done, rather than a product they can sell, the fact that it is GPL is actually a bonus.  It clearly establishes the copyright situation.
It can also be used effectively when what you are selling is a service.  Only when you are developing something that is going resold to others would the GPL be a possible obstacle.
Answer: When you are freelancing, copyright usually reverts to the company for which you are doing the work. Which means that you need to clear your use of GPL'd code with them, as they will have to comply with it when distributing their product.
If you retain all rights to your software, you would be selling a license to use your product to your customer(s) and that license needs to be compatible with the licenses of whatever libraries you used to create the product. Your customer needs to accept that license and make their customers accept it as well when the license you sold to them included re-distribution rights.
TL DR: when you use GPL'd code to create software for a customer, you need to make your customer aware of the consequences and they need to accept those consequences. If they are not willing to accept the consequences of GPL'd code, you should not use any GPL'd code in the solution you are building for them.
Answer: @jmoreno's answer is spot on.  And another good thing about GPL (or open source in general) is that it frees you from worrying about what the customer might do with your "proprietary" code after you have moved on to the next job.  If you've given it to them, you don't need to worry about them stealing it.
However, if you are concerned about them attempting to resell it (in some form), then you may need to keep an eye out for signs that this has happened.  Depending on how they did that, it could be a breach of the GPL (and your copyright) and potential grounds to sue them.
But if you simply don't care about that (and you are happy for them to try to make a buck from "your" code) then maybe something like the Bsd or Apache licenses would be more appropriate.

But note that you need to deal with these issues at the point where you sign the initial agreement with your client.  They need to sign off on you releasing the relevant part of your work for them under the GPL ... and on who will own the copyright.  You can only release something as GPL (or under some other open source license) if you actually own the copyright.  And the fact that you wrote it doesn't necessarily mean that you do.  (In some legal jurisdictions, the entity that is paying the bills for the work may own the copyright on work product ... by default.)
Answer: What the other answers have not touched upon: There is a huge difference between using a GPL library in your product or using a GPL tool in your toolchain to build the product.
If you just use a GPL editor or compiler (or other tool) to create your product, then this has no influence whatever on the licenses you can use for your product. It is perfectly well possible to use a GPL editor or other tool (such as GCC or Make) to create a closed-source application and you will not be violating any license terms in doing so.
If you use a GPL library in your product, or in some other way incorporate GPL code in the product, then you need to apply the GPL license to your code as well. Note that this situation can also occur if you use a tool that generates code for you.

As for making money from GPL software, the GPL does not forbid this so you are perfectly within your rights to charge a customer for the code you write for them or the maintenance you perform afterwards.
You can't forbid the customer from giving the source away, but then, why would they if they paid hard-earned cash for it themselves?

Freelancing and GPL?


Anyone ever actually tried 'rm -rf /*' in Linux?

Question: Anyone ever actually tried rm -rf /*, or something similar, in Linux? You always hear people joke about it, but I'm curious if it actually executes, and if so, what kind of damage it actually does (not in terms of deleting disk).
Comment: http://www.youtube.com/watch?v=SIIweirHwek - fantastische musik
Answer: Just for you, I tried it. I got a whole bunch of "rm: cannot remove ...", even with sudo. If you would like to try it out, I recommend VirtualBox and a copy of Ubuntu.
Answer: Yes, I did, but only in a VM that could be reverted, just to test and demonstrate (I used to teach OS).
In older distributions it will execute and wipe out your distribution, but in most newer distributions this will fail.
If you want to try, do it in a place you don't care about, or in a VM that you can revert like me.
Answer: Have I "tried" it? No. Have I done it? Yes, and it's bad.  However, if you're lucky:

You weren't logged in as root, so the damage will be minimal
You've installed safe-rm which will prevent stuff like this.
Answer: Wikipedia : rm -rf (variously, rm -rf /, rm -rf *, and others) is frequently used in jokes and anecdotes about Unix disasters[2] . The rm -rf variant of the command, if run by a superuser on the root directory, would cause the contents of nearly every writable mounted filesystem on the computer to be deleted, up to the point the system itself crashes from missing some crucial file, directory, or the like.
http://en.wikipedia.org/wiki/Rm_(Unix)
I think some distros added a protection.
EDIT : muffinista gave the link to the protection.
Comment: Even the official wiki of unix know this joke.


How a power assurance check works?

Question: In a Bell 407 the power assurance check takes into account torque, pressure altitude and MGT (measured gas temperature aka TOT). The flight manual states that if MGT when tested is less than or equal to the charted MGT, engine performance equals or exceeds minimum specifications. So my question is how does MGT factor into the health of an engine. Torque gauge meters off oil pressure, MGT is a result of compressor performance or bleed air systems. So an engine could be a plus engine with let's say bad compressor vanes, or a bad bleed air valve etc. So my initial question is what is the correlation between MGT and engine health.
Answer: Think of it this way.  When an engine is temperature limited (as opposed to being torque limited) it means that the power control can be advanced (thus making more power) until the max specified engine temperature  is reached.  if one engine produces a particular amount of power while at a lower temperature than a second engine when producing the same amount of power then that first engine has more "room" to further increase power than the second one does.  Thus, the first one performs better.   In other words, the cooler the engine is at a particular power output level the better the engine.
The manufacturer puts out engine performance tables that specify what the nominal engine performance should be. If the engine runs cooler than that then it is better than spec.
Comment: Thank you very much Jim I greatly appreciate your answer!
Comment: @Wes Showing appreciation is done by voting and accepting questions. :-)
Answer: The difference between the max ITT/TOT/EGT and the measured value is "ITT/TOT/EGT margin". The margin is highest when the engine is new, and declines as the engine wears out.  As compressor and turbine blades erode, efficiency declines and more fuel is burned to make the same torque or N1 or EPR, so temps go up.  When the margin gets to some value close to zero, that is, the measured temperature is close to or at the engines limit, the engine is worn out.  The power assurance run is mostly to monitor and track the margin over time.
Comment: Thank you John that makes perfect sense! Easy enough to comprehend I just couldn't put it together on my own! I appreciate you sharing your knowledge with me!

How a power assurance check works?


Add category as filter in all other categories in layered navigation?

Question: Is there any way to make a category appear in all other categories as the filter in layered navigation?
Comment: I assume you want a filter which, regardless of category listing, allows to filter by listed products which belong to one specific category?
Answer: In admin catalog->category management->your catagory->is anchor set to Yes then save. After doing this you will have your layered navigation with catalog_category_layered layout handle.


Why videos play in Ubuntu-provided LibreOffice, but not in LibreOffice from community-supplied installers?

Question: When I install LibreOffice from Ubuntu repository, import and playing of videos (flv, mp4...) works just fine. If I uninstall that version and install LibreOffice from the LO download page, the same videos neither insert correctly or play. Most recently this happened when I moved to LO4 on my 12.10 laptop. Can anyone tell me why this is happening?
Answer: I just installed from the ppa and get the same result: adding an mp4 using the insert - movie and sound gives me a speaker symbol, no video and very slow interaction, the standard install with 12.04 worked with all video formats.
Answer: I've installed LibreOffice 4.0 from the PPA and have no problem adding a video files (both a large .mkv and a large .avi) to an Impress presentation.
Not a feature I use, so I wouldn't know if it worked before (with LO installed from the downloaded packages).
However, this issue has been reported elsewhere (without solution so far).
It may be related to the fact that the LO packages have not been "tailored" specifically for Ubuntu. Try the PPA and let us know.


Will a microwave induce current in a transformer placed inside of it?

Question: If a transformer, say your typical 12v wall wart. were to be placed inside a microwave and then power the microwave, will the microwaves induce current in the transformer? What will happen to the transformer?  What would happen if the transformer was also powered as well as the microwave?
Answer:
If a transformer, say your typical 12v wall wart, were to be placed inside a   microwave and then powered on, will the microwaves induce current in the transformer?

This depends on many things, but any "wall-wart" variety may get hot, arc, and/or catch fire. So yes, the microwaves can induce curents in wires, but probably not how you think they will. And any wires from this leading out of the microwave, if the safety-interlock door could even be closed, could contain extremely dangerous voltages.

What would happen if the transformer was also powered as well as the microwave?

The afore-mentioned. Transformers use magnetic energy... microwaves are RF (wave) energy. Magnetism interfering with RF is a technical possibility, however the tiny amount of magnetism produced by a wall-wart (at 50 or 60Hz) wouldn't do much to 1000W of RF energy at 2.45GHz.
A microwave oven typically employs about 1000W of non-ionizing RF energy at 2.45GHz to heat food. This RF energy (wave radiation) is generated by a magnetron "tube" inside, which is powered by a large microwave oven transformer (MOT) which converts the household mains AC into about 2000V DC, 0.5A to drive the magnetron. 2000V * 0.5A = 1000W. MOTs and magnetrons are very dangerous devices.
(Contrary to popular belief, 2.45GHz is not the resonant frequency of water or fat or anything else; water's resonance point is actually around 22GHz. 2.45GHz was chosen due to economy of magnetron production and limited free RF frequencies.)
The more pointy any metal objects are inside a microwave oven, the more likely arcing will occur. A smooth metal object by itself like a spoon may do little, but a fork will induce arcing at the tines. Aluminum window screening and steel wool burst into flame. Since 1000W of energy is put into the system, sparks of thousands of volts are possible. So a transformer inside an oven may induce some current in the outermost windings, but the electrical plug is pointy so may arc, which could quickly turn it into a flaming mass.
If you wanted to couple into some of that RF energy, you would have to design and use an RF antenna, not a transformer. 2.45GHz frequency corresponds to 12.25cm wavelength, so any conductor longer than a tenth of this (1.225cm) will start to conduct RF energy. (This is why the holes in the oven door don't let out any microwaves - they are smaller than 1cm.)
So in summary, no, you cannot place a transformer into a microwave oven and get any useful power out of it. You might get a deadly shock and fire, however.
If a properly engineered 2.45GHz antenna were used instead, then some of the power could be coupled to that and used to do something. But then you would have 2.45GHz AC at very high voltages, and few to nil electronic components are fast enough or robust enough to downconvert that into anything usable. At this frequency, only low-power detector Schottky diodes work well, but they can't rectify much power, and are quite inefficient.
Comment: Would you say this is an interesting question or not? My son asked me the other day and I couldn't give him an answer, but gave him a stern warning about the consequences.
Comment: I'd say that the physics behind microwaves, magnetism, and electricty are very complex, but possibly very interesting to the right individual. :) I'd suggest steering clear of microwave ovens though, they are just too dangerous. Microwave communications though, are very popular today and used in almost every aspect of communications. (Routers, cellphones, bluetooth, WiFi, Ham radio, etc.)
Answer: Short answer, yes. What will happen? Likely it wil arc and the transformer may be burnt as well as much of the rest of the wall wart. If you're going to try it, I'd suggest doing it outside and stand away from the microwave.
Comment: Not that I am planning it, but how could this microwave radiation be harnessed by a transformer such that it doesn't self destruct and produce current?


Amplitude of electromagnetic waves

Question: We know that an electromagnetic wave is produced by periodically changing electric field (by an accelerating charged particle). We know that the electric field of a point charge varies inversely with square of distance from the charge. Therefore the amplitude of the electromagnetic wave such as light must go on decreasing and practically vanish on covering a finite distance. But , as we know, it doesn't happen and we see the light waves coming from stars very far away. Then what's happening there? Or am I wrong? Please  explain.
Comment: It's (much) easier to use photons, at least for me it is. In the same way, explaining diffraction or interference using photons will give you a headache. But my argument is possibly  wrong, if you take into account the fact that photons lose energy  emerging  from a large mass,  such a neutron star. I need to look that up, (or rather,  you do, sorry   :).  The model of an EM wave that the pictures show is not to be taken too far, it's the start of using math seriously, and forgetting about mental pictures, which are confusing. In other words, it's real physics...+1
Comment: In photon terms, sure for a single photon, maybe only a frog would see it, but obviously a star emits a large amount of photons.  If no interaction occurs along the way, the wave/photon will keep going. https://van.physics.illinois.edu/qa/listing.php?id=84900
Comment: But why the amplitude doesn't decrease with time?
Comment: Why should it? This is why we have the wave/photon duality, some things are easier to calculate or think about in momentum conservation terms. (Like a photon...tiny bullet), The energy density drops as the sphere expands, but the **total** flux remains constant. If the amplitude diminished, the total flux would also, but it doesn't.
Comment: So it can't be explained by wave nature?
Comment: https://physics.stackexchange.com/questions/362057/does-light-heat-transparent-mediums. If you read Emilio's answer, and relate amplitude to intensify, that might help explain your question in wave terms.
Answer: The reason we can see stars from far away is because those stars are unimaginably bright up close. Stars do vary in brightness depending on the star type and distance, and there are certainly stars whose light we cannot see. Read about apparent magnitude and absolute magnitude.
Answer:
We know that an electromagnetic wave is produced by periodically changing electric field (by an accelerating charged particle).

Photons are emitted by accelerated charges. The energy of the photons depends on the strength of the acceleration, e.g. small accelerations of electrons lead to infrared radiation and braking radiation Bremsstrahlung to X-rays or gamma radiation.
mostly
The electric field you mentioned is needed, for example, in an antenna rod for the forward and backward acceleration of electrons. As a result, the electrons emit polarized photons and one is able to identify a common oscillating electric and a common oscillating magnetic field from all these photons. Such radiation has the properties of an electromagnetic wave.
The light or electromagnetic radiation from the sun is mostly the result of the chaotic acceleration of charges and the flow of the emitted photons does not have the properties of a wave.

... the amplitude of the electromagnetic wave such as light must go on decreasing and practically vanish on covering a finite distance. But , as we know, it doesn't happen and we see the light waves coming from stars very far away.

The amplitude of EM radiation has to do with the intensity of the light. The intensity of a monochromatic radiation - all photons of the same wavelength - has to do with the number of photons through a given area in a given time.
The potential decrease of intensity is only correct if there is an indistinguishable number of photons. But there are stars so far away that their observation is only possible by collecting single photons. Thus the potential decrease is right only other a long time of observation and the energy packages which arrive the earth are discrete one.

Amplitude of electromagnetic waves


Biological basis of the science fiction story "The Dipteroid phenomenon"

Question: The science fiction novelette by Poul Anderson The Dipteroid Phenomenon describes a plot in which

 the protagonist Evalyth is one of the members of a space-faring civilisation which is rediscovering atavistic humans stranded on other planets following the fall of human civilisation from an interplanetary war in the past.

The husband of the protagonist is murdered and cannibalised by the savage guiding him through the jungle, and she finds and captures the savage's whole family in revenge, intending to execute the savage. While doing so, she discovers that all of the humans on the planet, including the civilised city-dwellers, have a tradition of cannibalising humans. The savages hunt each other for cannibalism, while the city-dwellers hunt down the savages, which they then keep as slaves for consumption.

In the end of the story, it is revealed that:

 all of the male humans on the planet are unable to sexually mature normally due to a genetic mutation in their Y-chromosome, which results in them having to consume male genitals in order to reach sexual maturity.

The novel then further states that the phenomenon of having to consume males in order to mature is also found in terrestrial Diptera flies.

'Hence a dipteroid phenomenon may have appeared in man on this planet. Such a thing is unknown
  among higher animals elsewhere, but it is conceivable. A modification of the Y chromosome would
  produce it. The test for that modification, and thus the test of the hypothesis, is easily made.'
  The voice stopped. Evalyth heard the blood slugging in her veins. 'What are you talking about?'
  "The phenomenon is found among lower animals on lower worlds,' the computer told her. 'It is
  uncommon and so is not widely known. The name derives from the Diptera, a type of dung fly on Old
  Earth.'

Is this "dipteroid phenomenon" a real biological phenomenon observed in Diptera dung flies on Earth? I was unable to find a scientific paper describing this rather interesting phenomenon.
Answer: After some research, it appears that the phenomenon being discussed was the consumption of Diptera flies by the dung fly, Scatophaga stercoraria. This paper describes their inability to sexually mature without consuming prey (for which Musca domestica flies were provided).

Male  Scatophaga  stercoraria must prey on other Diptera before they
  display sexual behavior, develop  the  accessory cells  of  their  ejaculatory ducts, and
  achieve  full elongation of  the testes. The corpus allatum also becomes enlarged
  after predation and is  necessary for  the onset of sexual behavior and development
  of reproductive organs. The complex diet consumed  during predation apparently
  cactivates the corpus allatum, and the hormone released acts  independently on
  organ growth and sexual behavior.


Is the sentence 'There's no such thing as ghosts.'' correct?

Question: As for the sentence, 'there's no such thing as ghosts.'  Is it grammatically correct to use the plural form of ghost? From what I have learned, the object 'thing' is in singular form, so ghost should be singular too. But I see a lot of native speakers use this sentence.
Comment: @P.E. Dant I have learned to conjugate the verb to be, but I saw native speaker use this sentence, so I just want to confirm whether it is correct. I think it should be 'there is no such thing as ghost.
Answer:
There are no such things as ghosts.

and

There is no such thing as a ghost.

are both grammatically correct.

There is no such thing as ghost.

is completely incorrect but a common mistake among Chinese English-speakers (i.e., Chinglish) because Chinese does not usually distinguish between countable and uncountable nouns the way English does. This sentence would mean "there's no such thing as the substance (物质) known as 'ghost'". Since that doesn't exist, the sentence has no meaning.

There is no such thing as ghosts.

on the other hand is perfectly fine as informal (不正式) English because—even though its grammar doesn't agree in the logical way prescribed by English grammarians—it's actually clearer phrasing. The phrasing of There are no such things as ghosts and its singular counterpart focuses the listeners' attention on the number in a strong way. The speaker, on the other hand, isn't concerned with the number of things that don't exist but with expressing the complete nonexistence of an entire category of things.
Comment: Anyone care to explain the downvotes for a correct answer? or you're just that annoyed at China's firewall keeping me from the research I already know would have helped it?
Comment: I'd better inform this up with an ngram of "no such thing as *" versus "no such things as *" but the PRC spiked all the country's VPNs at the first of the month. Anyone else want to do the honors and report back?

Is the sentence ‘There's no such thing as ghosts.'’ correct?


WDS boot taking a long time over site-to-site VPN connection

Question: We have three sites and a new server colocation facility that we are in the process of bringing online. We have several WDS servers at each site. We are moving servers from the smallest site to the colocation facility. The colocation facility connects to our network at our main location via site-to-site link with Cisco ASA firewalls at either end. All traffic is allowed, and routes correctly. The link between the sites is 400Mbps. I can do a file transfer via SMB or iperf and easily get over 200Mbps. Active Directory, Group Policy, and DFS Replication sync over the connection as fast as ever. Latency is 7-8ms. I have set up DHCP to point the PXE clients at the WDS server (Windows Server 2016) at the colocation facility. They are able to PXE boot and the entire process proceeds without failure, but the "Loading windows" screen with the progress bar above the IP address takes a really long time. When there is no other traffic to this server, I can check Task Manager and see it almost hard-limited to 5-6Mbps the entire time. This happens with our physical clients (several different models of HP EliteDesk desktops that work fine with local WDS servers) and Hyper-V virtual machines. Neither Cisco ASA firewall seems to be particularly overloaded during this process (RAM/CPU).
Answer: try to set/change the "Maximum Blocksize" (depended on your MTU?) and also "Variable Window Extension"
Comment: My TFTB tab looks just like that, with a 0 max size and the Variable Window Extension box checked. What should the size be?
Comment: As I sayd, I would check on those options. On the picture you find only the defaults. I think block size needs to be smaller than your MTU. Try also to remove Variable Window Extension.


Will using a higher speed rated tire do anything for the car?

Question: I heard that going down on the manufacturer's tire speed rating will affect the handling but will going up from an H to a V do anything such as increasing tread life.
Answer: tl dr - There is absolutely no worries about putting a higher rated tire on your vehicle. It just means you can drive your car faster if the car is capable (and the speed limits will allow). You will gain nothing in any other aspect of the tire, such as tire life, treadwear, or what have you. In fact, the higher speed rating doesn't have much to do with cornering ability, either. Just the speed factor of the tire itself.
There is no relationship between the speed rating and the longevity of the tire. Every manufacturer will have different combinations of factors. There is a whole wide range of tires available in many different sizes.
It is widely known how to tell if a tire will fit your car: you look at the size. The size reads something to the effect of: P255/75R-15. It breaks down as:

P equates to Passenger tire (LT = Light Truck)
255 is the width of the tire tread in millimeters
75 is the aspect or sidewall ratio as a percentage (in this case, the tire sidewall would be 75% of the width of the tread)
R is telling us the tire is a radial tire
15 is the rim diameter

This same indicator may also look like: P255/75ZR-15 92Y
The Z indicates the tire is speed rated above 149mph (or 240kph). When this speed was introduced, it was thought that there would never be a need to have a tire which would need to go faster. It was soon discovered that there was a need for greater speeds, so W and Y were introduced. You will see the actual speed rating at the end of the 92Y indicator.
<code>225/50ZR16  in excess of 149 mph, 240 km/h
205/45ZR17 88W  168 mph, 270 km/h
285/35ZR19 99Y  186 mph, 300 km/h
</code>
The 92 in my above example, indicates the load rating of the tire. The higher the number, the more the tire can individually haul.
<code>(NOTE: LI=Load Index)

LI   LBS    KG  |  LI   LBS     KG
71   761    345 |  91   1356    615
72   783    355 |  92   1389    630
73   805    365 |  93   1433    650
74   827    375 |  94   1477    670
75   853    387 |  95   1521    690
76   882    400 |  96   1565    710
77   908    412 |  97   1609    730
78   937    425 |  98   1653    750
79   963    437 |  99   1709    775
80   992    450 |  100  1764    800
81  1019    462 |  101  1819    825
82  1047    475 |  102  1874    850
83  1074    487 |  103  1929    875
84  1102    500 |  104  1984    900
85  1135    515 |  105  2039    925
86  1168    530 |  106  2094    950
87  1201    545 |  107  2149    975
88  1235    560 |  108  2205    1000
89  1279    580 |  109  2271    1030
90  1323    600 |  110  2337    1060
</code>
There are more indicators on the side of the tire which are also useful when trying to figure out anything about a tire and how it should behave when on your vehicle. Discount Tire has a great page on this info, but I want to point out one area since you mentioned it, that being tread life. On the side of the tire it will look something like the following:

There are three parts to this being: treadwear; traction; temperature.

Treadwear: Treadwear is a measurement of the tires durability. The higher the number, the longer the tire should last (under normal conditions). The thing to remember out the treadwear number is it is specific to the manufacturer not to other brands. If you are contemplating a Goodyear brand tire, only compare the number on other Goodyear tires.
Traction: This measures the tire's ability to stop in a straight line on wet surfaces in a controlled test environment. It doesn't measure the tire's ability to handle in the corner. There are several ratings: AA, A, B, & C. AA is the highest rating.
Temperature: This measures a tire's ability to withstand heat buildup in the tire. It has measurements of: A, B, & C. A is the highest rating.
Comment: @mrsc Yes, it makes the tire more expensive. Sometimes much more expensive. It does not mean the compounds and other materials used will last more time - it just means they can handle higher speeds, nothing more.
Comment: In the UK using an incorrect tyre speed rating can cause your insurance to be invalidated http://www.blackcircles.com/general/speedrating - its dependent on your insurance though.  Driving without a minimum of 3rd party insurance is illegal.
Comment: @Mauro - That is crazy, though the OP is talking about going to a faster tire, not a slower one. Thanks for,pointing it out.
Comment: But does going up a speed rating on the tire do anything at all??
Comment: Please see edit at the top.
Comment: @Paulster2 UK insurers are an odd bunch, some will invalidate your insurance if you put winter tyres on your car in winter without telling them.  You'd think that should help reduce premiums.
Answer: Treadwear can be negatively affected, lowering the speed rating substantially and all aspects of the tire's handling. As well, a T-rated tire is manufactured differently from an H-rated tire, so that is why they handle higher speeds differently. Weaves, ply and compound can change ride comfort, handling and wear. Essentially the only thing that is the same is the tread pattern.
Though these changes  may not be noticeable to a lay person, tread life may be significantly affected the further from the manufacturer specs you get, which sometimes can lead to cupping. I say this because at my job I have encountered these happenings. Specifically, 2 customers, 1 had V-rated tires and was having a cupping issue that caused a very noisy ride. He had his suspension checked and was found to have no issues, so without a mechanical issue and no apparent cause for cupping, then the only thing left is the fact he had a plu- zero upsized T-rated tire on his V-rated vehicle.
As far as tread wear, there was a 2004 Kia Sedona which came in and had bought S-rated tires on what I believe is an H- or V-rated vehicle and they changed about 3 pairs of these tire over a 2 year period. A 50,000 mile rated tire wears down to the wear bar within 20,000 miles because instead of spending $20 more per tire to get a closer match to their speed rating they throw out their warranty and buy under-rated tires.
Comment: Might be a great answer, but could you improve the formatting a bit, please?  Even some line breaks and a spell check would improve readability.
Answer: UK road regulations only specify a requirement of minimum speed ratings, that of the vehicle to be met, and insurers have no issue whatsoever with higher rated tyres. Many miss the load rating, however, not only for tyres, but wheels, too. Insurers will not cover you if either your tyre load rating, or your wheel load rating is insufficient (lower than specified by vehicle specs - check GCWR, the gross curb weight rating, find the load distribution of your vehicle, select heavier axle, calculate). E.g. 3000kg gross curb weight rated vehicle with 40% front 60% rear weight distribution: 3000kg * 0.6 = 1800kg on the rear axle, divide by 2 = 900kg. Both your wheels and your tyres MUST be load rated at least that. Beware of aftermarket wheel purchases, some sellers will try to tell you it's "fine" to buy a lower weight rated rims, it's not. It's dangerous, and it's an insurance voider.


Electron energy in a synchrotron storage ring vs. X-ray energy from the wiggler: why is the latter much lower?

Question: I know in large synchrotron facilities some beamlines produce very intense X-rays by injecting the accelerated electrons into "wigglers". I have read that the typical energy of the electrons in the storage ring is about a few GeV, but the energy spectrum of the X-rays generated in the wiggler is in the range of keV. One may expect that the X-ray spectrum had energies up to the incident electron energy (like in a conventional X-ray tube). Why is this not the case?
Answer: The X-ray radiation is Bremsstrahlung radiation created when the electrons are accelerated in the wiggler.
In an X-ray tube the electrons are accelerating (well, decelerating) from their initial energy to zero when they hit the target. So the energy of the Bremsstrahlung radiation is comparable to the initial electron energy. In the wiggler the acceleration is lateral to the beam direction and is tailored to a required value by adjusting the magnetic field strength. The acceleration, and therefore the wavelength of the Bremsstrahlung radiation, is not directly related to the beam energy.
Typically the wiggler is being used to generate a well characterised beam for research purposes, so the acceleration of the electrons will have been tuned to make the intensity peak at the required wavelength. For example there is little point in producing X-rays with an energy of several GeV to do X-ray diffraction because the wavelength would be far too short. For X-ray diffraction we typically want a wavelength of about 0.1nm, which is 10-15keV.
Comment: For some aplications it would be interesting to reach much higher energies, but anyway, that's not the point.
My undertanding is that the wiggler use magnetic fields to bend alternatively the trajectory of the electrons (right-left-right...), electrons follow a sinusoidal trajectory and emit radiation due to the centripetal acceleration, like in the main syncrotron (but with higher emitted output). Perhaps the question I should have made is more basic: what is the maximum energy in the spectrum of the syncrotron radiation?. I assumed it was close to the electron energy.
Answer: X-ray tubes are generally designed such that the electron beam knocks out inner shell electrons in the target (e.g. copper K shell), resulting in well-defined lines in the output spectrum. There is also a bremsstrahlung spectrum but depending on what you want to do, it may be less useful due to its broadband nature.
Wiggler/undulator radiation is purely due to acceleration. When dealing with synchrotron radiation, it's conventional to define the critical energy
$$E_c = \frac{3}{2}\frac{\hbar c \gamma^3}{\rho}.$$
Gamma is the relativistic gamma and rho is the bend radius.
Half the total energy is emitted above $E_c$ and half below, hence the name.
The spectrum is found to be
$$
\frac{d^2 N}{ds\,dx} = \frac{\sqrt{3}\,\alpha}{2 \pi} \frac{\gamma}{\rho} \int_x^\infty K_{5/3}(\xi)\,d\xi
$$
which is messy because of the modified Bessel function. See reference 2 and/or Jackson for details. The following plot gives the power spectrum in terms of the critical energy. (I made this plot using the method described in ref 2, which is actually implemented in GEANT4.)

Note that this spectrum neglects the spatial distribution.
1: http://hyperphysics.phy-astr.gsu.edu/hbase/quantum/xrayc.html
2: http://cds.cern.ch/record/1038899/


"Destiny" vs. "Fate"

Question: I'm aware a search will turn up many discussions on the differences or interchangeability of these terms, but it would be good to get some answers here with an emphasis on the etymology of the two words. Does the usage history of these words add connotations beyond their dictionary definitions?
Comment: Don't use either. Stick with *wyrd*.
Comment: _Fate_ is more fatalistic.  No one is ever left to his destiny.
Comment: I prefer *weird*
Comment: Destiny is pulling the sword out of the stone. Fate is tripping and falling on it.
Answer: Fate is from the Latin fatum, which means "that which has been spoken."
Destiny is from the Latin destinare, which means "to make firm" or "to establish."
I agree with Billare that fate has a more fatalistic feel (fatalistic also comes from fatum), as  it has a deeper implication of one's end being decided by a separate entity.
Reference: the NOAD.
Answer: From Wikipedia:

...fate relates to events of the past and is proven to be true and unalterable, whereas destiny relates to the probable to almost certain future. Note that it is only almost certain and not absolutely certain, allowing for change to occur. This can be seen in our common language usage, e.g. "His calling, his destiny is to be a doctor." Will he definitely be a doctor? Well, it remains to be seen.

I apologise in advance for the lack of original examples and more authoritative sources, but perhaps further research into the use of 'fate' and 'destiny' in both classic and modern literary texts will help.
Answer: As reported by the Online Etymology Dictionary, the etymology of the words is the following:

fate
Late 14th century, from Latin fata, neuter plural of fatum ("prophetic declaration, oracle, prediction," thus "that which is ordained, destiny, fate"), literary "thing spoken (by the gods)," from neuter past participle of fari ("to speak"), from PIE *bha- ("speak"). The Latin sense evolution is from "sentence of the Gods" (Greek theosphaton) to "lot, portion" (Greek moira, personified as a goddess in Homer), also "one of the three goddesses (Clotho, Lachesis, and Atropos) who determined the course of a human life." Related: Fated; fating. The native word was wyrd.
destiny
middle 14th century, from Old French destinée ("purpose, intent, fate, destiny; that which is destined,") feminine past participle of destiner, from Latin destinare ("make firm, establish"). The sense is of "that which has been firmly established," as by fate.
Comment: Like definitions I've seen elsewhere, he uses _fate_ to help define _destiny_, and vice versa. Interesting.
Comment: @Callithumpian What I think it is more interesting is the evolution of the Latin sense of _fate_.
Answer: To me, "fate" sounds more likely to be used in a negative context, while "destiny" is (generally) more positive. Headline examples:

Waiting for word on fate of kidnapped American
Super Bowl win was destiny for Saints
Answer: To supplement the etymology-centered answers that snumpy and kiamlaluno provide, I offer these discussions from three synonym dictionaries of quite different ages. First, from James Fernald, English Synonyms, Antonyms and Prepositions (1896):

Fate is heathen, an irresistible, irrational power  determining all events with no manifest connection with reason or righteousness; ...

This characterization is in contrast with the book's description of the words foreordination and predestination, which Fernald asserts "are Christian, denoting the rational and righteous order or decree of the supreme and all-wise God." Destiny, we may suppose, is intimately connected with predestination in this second category of words, although Fernald does not devote any space to it. Certainly there was a strong religious strain in the term manifest destiny, popularized in the 1840s in expansionist political discourse in the United States. For example, in "Speech of Hon. C. W. Cathcart, of Indiana, on the Oregon Question" (February 6, 1846):

We are asked how we expect to dispossess the Hudson Bay Company of her pallisade forts in Oregon? Is it possible that an American can doubt upon this point? Prepare yourself and demand their surrender, as Ethan Allen did the surrender of Ticonderoga, "in the name of the Great Jehova and the Continental Congress." And this reminds me of the sneers of some gentlemen in relation to what they call our "western doctrine of manifest destiny." Do gentlemen reflect where they place themselves by these sneers? Do they forget that the Savior of mankind has said that a "sparrow shall not fall to the ground without your Father?" And yet we are asked, where is the clause in Adam's will which gives us this territory? Apart from the "book title," which is "clear and unquestionable," we see it written in letters of living light in everything which surrounds us—in that merciful dispensation, full of charity and love, towards the fallen children of Adam—of a just and omniscient God, who has given to man that control of the elements, the effect of which is to bring the remotest parts of our vast country into practical propinquity. The iron horse, (the steam car,) with the wings of the wind, his nostrils distended with flame, salamander-like vomiting fire and smoke, trembling with power, but submissive to the steel curb imposed upon him by the hand of man, flies from one end of the continent to the other in less time than our ancestry required to visit a neighboring city; while by the magnetic telegraph the lightning of heaven is made subservient to the will of man in annihilating space.

Thus, the destiny of the United States to rule North America from ocean to ocean, by Providential decree, is manifested in part by God's granting mankind the railroad train and the telegraph.
A much later discussion of fate and destiny appears in S.I. Hayakawa, Choose the Right Word: A Modern Guide to Synonyms (1968):

destiny, fate, fortune, lot These words refer to a situation or outcome as though it were fixed or predetermined. Destiny is the most general and least specific of the these. It can suggest an occult prearrangement of the future: No man can escape his destiny. At the other extreme, it can refer simply to a result, without suggesting any forces at work beyond cause and effect: Congressmen meeting to decide the destiny of the abortion reform law. Fate, by contrast, is much stronger in implications of a deterministic pattern. Where destiny might point to a desired goal without rejecting the notion of free will, fate points to an outcome, good or bad, as though choice, chance, or cause and effect played no part in its working out: Oriental religions that advise man to accept his fate without bitterness. Even when weakened by use to refer merely to result, the word often suggests an unpleasant outcome: mountain-climbers who met a disastrous fate.

In Hayakawa's view, destiny can work hand-in-hand with effort and intentionality, but fate is a done deal: Oedipus (unwittingly) works toward his destiny, because he can't escape his fate.
A third treatment appears in Merriam-Webster's Dictionary of Synonyms (1984):

fate, destiny, lot, portion, doom are comparable words when they denote the state, condition, or end which is decreed for one by a higher power. Fate presupposes such a determining agent or agency as one of the ancient goddesses called Fates, the Supreme Being, or the law of necessity; the term usually suggests inevitability and, sometimes, immutability {he either fears his fate too much, or his deserts are small, that dares not put it to the touch to gain or lose it all—Montrose} {let us, then, be up and doing, with a heart for any fate—Longfellow} {he maintained that the fate of the Southern Negro depended on his right to protect himself by voting—C.L. Thompson} Destiny may imply an irrevocable determination or appointment (as by the the will of the gods or of God); even in this sense, however, it carries little or no suggestion of something to be feared; on the contrary, it may even imply a great or noble state or end {the conception of a lordly splendid destiny for the human race—Russell} {Lawrence was ... unescapably an artist .... There were moments when he wanted to escape from his destiny—Huxley} Destiny may also apply be applied to whatever one envisions as his end or goal, sometimes retaining a slight implication that it is, or has the inevitability of, the will of God. {the intoxication of victory swept Hitler's fears away; they were never voiced again, drowned with cries of defiant belief in his destiny—Times Lit. Sup.}

It appears that the distinction (proposed by Fernald) between heathen inevitability (fate) and Christian foreordination (destiny) is long gone, if it ever existed in popular usage. In my experience, an expression like "You can't change destiny" means essentially the same thing as the expression "You can't change fate." But as Merriam-Webster's commentary suggests, there is sometimes a kind of grandeur in destiny that seems more often lacking in fate, and this may reflect an older distinction along Fernald's lines.
Answer: Fate is passive with elements of acquiescence and peace. Purpose is active with elements of glory and distinction. Purpose and fate share the same axis, each on opposite sides of the axis.
Comment: Note that the poster asks about the difference between _fate_ and _destiny_, but your answer doesn't mention _destiny_ at all. Please consider editing your answer to make it more responsive to the poster's question.

"Destiny" vs. "Fate"


How do I deal with Inferi?

Question: When Dumbledore is trying to drink the potion and the Inferi keep coming up the hill and dragging you into the water, is there a way to keep the Inferi back and stop them from dragging you down the hill?
So far I am only able to grab a drink of the potion, then wait to be dragged into the water. This means it takes me a while to drink all five cups. Can I hold them back in any way so I can drink them faster?
Answer: I used Reducto (the orange spell) to constantly blast them back. That keeps them away long enough for Dumbledore to finish his drinking game.
Comment: Targeting with the spell doesn't work, but just casting it worked a treat.
Comment: I just hit the button repeatedly.
Answer: Another option is to hit them with Augmenti.  The spray of water blasts them into pieces and gives Dumbledore the time he needs to drink the glass of water.
Also, whenever you are grabbed by the Inferi, if you switch to Lumos Solem, they let go of you for a brief amount of time, which is long enough for you to jump and run far enough away from them that you can switch back to a different spell that will destroy them.
Answer: I used augmenti though my brother helped me I would kill them and he would gulp it down lol. So I recommend augmenti because you hold it down and it sprays its op.

How do I deal with Inferi?


How would a WebTorrent VueJS component could be build?

Question: Hy there. Given webtorrent.io I would like to build a VueJS component that shows loading magnet files, and status and also when downloads finishes triggers players.
Is the Vuex Store a good place to keep a list of active download queues and a stream o data?
All that is possible with webtorrent.
var WebTorrent = require('webtorrent')

var client = new WebTorrent()

var magnetURI = 'magnet: ...'

client.add(magnetURI, { path: '/path/to/folder' }, function (torrent) {
  torrent.on('done', function () {
    console.log('torrent download finished')
  })
})

How could I structure that architecture/pattern with VueJS? Any insights, apreciated
Thanks!
Answer: I will answer cause I found a solution. Then if the community wants this to be deleted, its all right.
Basically what I did is wait for a Component to be mounted.
Inside AComponent.Vue
<template>
  <keep-alive>

  </keep-alive>
</template>

Why this achieve what I was looking for ? :

keep alive keep that parts of the DOM alive, when i render another template and come back to this one (as if the download queue is in a widget, modal, or another view that needs to keep alive).
mounted, its part of the component lifecycle hooks (https://v2.vuejs.org/v2/guide/instance.html#Lifecycle-Diagram), and happens once the DOM has been maniuplated, window exists (needed by WebTorrent), and the component has been rendered.


How do processes communicate?

Question: What transports/pipes/interops are available that most or all languages support across OSs? Not necessarily, network, but interprocess. Or is interprocess communication OS specific? I mean, for instance, the COM interop is on windows. Is there an equivalent on Linux, for instance, that would work the same and a programming language could use interchangeably? I know most languages support network IO. Do we have to use that for interprocess communication or are there other options?
Comment: Although it's a broad topic, I don't think this question necessitates huge answers.
Comment: "Your questions should be reasonably scoped..." ([help/dont-ask]). http://meta.programmers.stackexchange.com/questions/6483/why-was-my-question-closed-or-down-voted/6490#6490
Comment: For a solution that works across most languages and operating systems, I guess nothing beats networking (using the loopback interface to avoid real network traffic).
Comment: If I understand it correctly, COM Interop is not inter process communication because the COM component is loaded into the same process as the host .NET process. This makes COM Interop a form of foreign function interface (FFI). As to how functions in different languages can call each other, it is because one of them implemented the calling convention of the other language. A calling convention defines how a function call is implemented in a language in the assembly/bytecode level, it describes how to identify and locate the right function, how to push the arguments, and how to return value.
Comment: @LieRyan Correct regarding calling conventions when using .dll in-process servers, but COM also has .exe out-of-process servers, which relies on Windows RPC to marshal requests across process boundries.
Answer: Inter-process communication is always mediated by the operating system. Generic options for communication include (but are not limited to) files (you'll have to lock them to avoid race conditions), using standard in and standard out, or network sockets. Which one works best depends on your application's needs. Of course, you'll need a way to structure the data, since all 3 mechanisms operate at the byte level. JSON, YAML, and XML are all common formats for structuring and passing around data as strings.

How do processes communicate?


Are penalized regression techniques greedy algorithms?

Question: In other words, is it feasible any of the various penalized regression techniques (such as ridge regression, lasso, and elasticnet) could completely miss the optimal solution for a regression model due to poorly chosen initial values for the model parameters?
Comment: For what it's worth, I'm not sure greedy algorithms are necessarily sensitive to initial conditions or always miss optimal solutions. My impression is that some min-spanning-tree algorithms and Huffman coding are both greedy and optimal. Still an interesting question though!
Answer: My understanding is that initial values (usually taken as zero for non-intercepts) are not that influential for these penalization techniques and models such as the logistic.  And 'optimal solution' is not very well defined.  You need to tell us more.  For these techniques what is usually the toughest decision is that of how much penalization to use.
Comment: Thank you Frank, by optimization I meant the choice of parameter values that minimizes the penalized residual sum of squares. Actually ridge regression has a solution which can be explicitly solved as with OLS. However, with lasso & elastic net, I'm confused how the solutions are found for each choice of penalty values. Is the entire parameter space explored or is a Newton-Raphson algorithm used that takes the shortest route from the initial parameter values to the closest local minimum (possibly ignoring a global minimum)?
Comment: @RobertF everyone and their grandmother has come up with a different way of conducting the optimization, and they are all iterative in nature (like Newton-Raphson, although that involves getting a Hessian and the $L_1$ penalty is not differentiable). For the LASSO, for example, the LARS algorithm can be used to get the trajectory of the parameter values as the penalization term is varied. These methods all go to a local minimum, but if everything is convex then there is only one local optimum, and it is the global optimum.
Answer: If the loss and penalty are convex functions of your parameters as in a linear regression or GLM then no, you won't get stuck in the wrong place (although it could take awhile to get where you want to go). On the other hand, if you are training (say) a multilayer neural net with quadratic loss using backprop and an L2 penalty then you can very easily get stuck because the loss is not convex as a function of the parameters. In these cases, people typically are just hoping to get a good local solution (which might generalize better anyways), not the best solution.
Comment: Ok thanks guy, this tells me I need to be careful which model (decision tree vs linear or GLM) I use.


How to explain calling a C function from an array of function pointers?

Question: This example https://godbolt.org/z/EKvvEKa6T calls MyFun() using this syntax
(*((int(**)(void))CallMyFun))();

Is there a C breakdown of that obfuscated syntax to explain how it works?
#include <stdio.h>

int MyFun(void)
{
    printf("Hello, World!");
    return 0;
}

void *funarray[] = { NULL,NULL,&MyFun,NULL,NULL };

int main(void)
{
    size_t CallMyFun = (size_t)&funarray + (2 * sizeof(funarray[0]));
    return (*((int(**)(void))CallMyFun))();
}

Comment: This code is ridiculous, but the idea of the line in question is first to cast the (numeric) address to a pointer to function, and then dereference this pointer to invoke this function.
Comment: @tromgy: That line casts the numeric address to a pointer to a pointer, then dereferences that to get the pointer, then uses that pointer to call the function.
Comment: @EricPostpischil, yes, you're correct!
Answer: The behavior of void *funarray[] = { NULL,NULL,&MyFun,NULL,NULL }; is not defined by the C standard because it converts a pointer to a function (MyFun) to a pointer to an object type (void *). Conversions to pointers are specified in C 2018 18.104.22.168, and none of them cover conversions between pointers to object types and pointers to function types except for null pointers.
The code size_t CallMyFun = (size_t)&funarray + (2 * sizeof(funarray[0])); sets CallMyFun to the address of element 2 of funarray, provided that conversion of pointers to the integer size_t type works "naturally," which is not required by the C standard but is intended.
In (*((int(**)(void))CallMyFun))();, we have (int(**)(void)) CallMyFun. This says to convert CallMyFun to a pointer to a pointer to a function taking no arguments and returning an int. When using a table of heterogenous function pointers in C, it is necessary to convert between types, because C provides no generic function pointer mechanism, so we cannot fault the author for that. However, this converts not merely to a pointer to a function type but to a pointer to a pointer to a function type, and that is an error.
The array contains pointers to void, not pointers to pointers to functions. The C standard does not require these to have the same size or representation.
Then the code applies *, intending to retrieve the pointer. This is another error. If if a pointer to void had the same size and representation has a pointer to a pointer to a function, accessing a void * (which is what was stored in the array) as a pointer to a function (which is what retrieving it using this expression does) violates the aliasing rules in C 2018 6.5 7.
However, if the C implementation does support this and all the prior conversions and issues, the result is a pointer to the function MyFun, and then applying () calls the function.
A proper way to write the code, assuming the array must support heterogenous function types, could be:
// Use array of pointers to functions (of a forced type).
void (*funarray[])(void) = { NULL, NULL, (void (*)(void)) MyFun, NULL, NULL };

…

// Get array element using ordinary subscript notation.
void (*CallMyFunc)(void) = funarray[2];

// Convert pointer to function's actual type, then call it.
return ((int (*)(void)) CallMyFunc)();

If the array can be homogenous, then the code should be written:
int (*funarray[])(void) = { NULL, NULL, MyFun, NULL, NULL };

…

return funarray[2]();

Answer: To understand what's going on here, we should look at each part of the code piece by piece (at least the odd pieces):
void *funarray[] = { NULL,NULL,&MyFun,NULL,NULL };

In the above, we are creating an array of pointers initialized to be most "empty" (ie, NULL) but at index 2 we have a pointer to MyFunc. It's helpful to track the types as we go, so at this point, we have &MyFunc of type int (*)(void) (function pointer syntax in C is a bit odd as the * and possible identifier goes in the middle rather than at the end), which is immediately turned into a void * in the array. Why the array is of type void * when it appears to be containing function pointers is a bit odd but let's assume there is a good reason...
size_t CallMyFun = (size_t)&funarray + (2 * sizeof(funarray[0]));

This code is a rather complex way of accessing the array and getting the second element by converting the head of the array to a size_t then adding the correct number of bytes to get the address of the second entry (a simpler way would be (size_t) &funarray[2]). Here again, we have lost the type information, going from originally a int (*[])(void) to void*[] to size_t.
return (*((int(**)(void))CallMyFun))();

Now that we know that CallMyFunc contains a pointer to a function pointer, ie the address of the MyFunc pointer in the array, if we want to call it we need to convert it back to the proper type and dereference it correctly. So, unwrapping the call, we direct have ((int(**)(void))CallMyFun) which casts the improperly typed CallMyFunc from size_t to a double function pointer, ie a pointer to a function pointer, which the syntax for is int (**)(void), just like any other double pointer which needs two * to denote. Next, as is isn't yet a function pointer, we need to dereference it to get the pointer of type int (*)(void), so (*((int(**)(void))CallMyFun)). Finally, we want to actually call the function pointer so the last set of parents.
As mentioned in the comments, this code is rather obfuscated by changing types and using unusual ways of accessing arrays; it's usually best to keep types consistent as it lets the compiler help you avoid mistakes and makes the code more readable for yourself and others.


Does IKEv1 support multiple combinations of a source IP range?

Question: I saw in several places online that the different between IKEv1 and IKEv2 is the use of multiple combinations of a source IP range as left and right subnets (locally and remote), a destination IP range, a source port range and a destination port range are allowed per Child SA.
I am using Strongswan 5.3.5 version on Ubuntu 16.4 LTE.
Answer: No, IKEv1 does not support negotiating multiple combinations of source IP ranges (or subnets) within a single SA.
The IKEv1 RFCs (specifically, 2407 and 2409) constrain the negotiated source IP to be either a single IP address, or an IP subnet (that is, an IP address and a mask; this is typically used to handle things such as 10.0.0.0/8; it can also handle "any" IP address) [1].  As for ports, you can ask for a specific port, or any port; nothing inbetween is allowed.  And, no, a single SA cannot have multiple; if you need to protect multiple subnets, you need to negotiate separate SAs.
It is possible that the Strongswan implementation of IKEv1 attempts to go beyond what the RFC permits (at least, when negotiating with other Strongswan implementations); however, I personally find that unlikely
[1]: Note: this is a subnet, not a range; it can't negotiate, say 10.0.0.1-10.0.0.6; the closest you can do is 10.0.0.0/29 (which also covers 10.0.0.0 and 10.0.0.7).  It could negotiate "discontiguous" subnets, such as 10.0.X.1 (for any X); I wouldn't be surprised if many IKEv1 implementations didn't support such an oddball thing...


rails - how to pass changes back to parent model

Question: I need to pass updated paramaters to back to a parent model when saving a series of its children.
For example if a save a bunch of employees to each task  through a project, I need to let the project know the title of some of its tasks have changed, then I need to collect all the titles that changed and process them in the ProjectObserver.  Is this possible?
I realize there might not be a way to make this work the way I'm trying.  If not I'm happy to hear suggestions about how I might be able to get around this.
Here is what I have tried without any success:
<code>class Employee < ActiveRecord::Base
  has_many :employee_tasks
  has_many :tasks, :through => :employee_tasks

  accepts_nested_attributes_For :employee_tasks
  accepts_nested_attributes_For :tasks
end

class Project < ActiveRecord::Base
  attr_accessor :changed_employees
  has_many :tasks
end

class Task < ActiveRecord::Base
  has_many :employee_tasks
  has_many :employees, :through => :employee_tasks
  belongs_to :project

  accepts_nested_attributes_For :employee_tasks
end

class EmployeeTask < ActiveRecord::Base
  #this is what I want to accomplish
  before_save do
    if self.employee_id_changed
      self.task.project.changed_employees ||= []
      self.task.project.changed_employees << self.employee_id_changed
    end
  end
  belongs_to :task
  belongs_to :employee
end

class ProjectObserver < ActiveRecord::Observer
  observe :project
  def after_save(project)
    puts project.changed_employees
    # should print out the changed attributes loaded from EmployeeTask
    #send a single email with all the updated titles (not one email for each change)
  end
end
</code>
Answer: Sounds like you need to use the after_save method described here http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html


White stuff on bromeliad

Question: So I didn't realize that some bromeliads have a natural white substance on them until after I had wiped it down and done some research. ♀The leaves look a little wonky (it's been 24 hours since the wipe down). Have I started the process of killing it unintentionally?
Answer: No, you have not killed it.  That waxy cutting, the cuticle, is a protective coating, protecting the plant from loosing too much water through transpiration on hot sunny days.   Depending on where you live the world this may never be a problem.  If you live in a very northerly climate it may never encounter a day too hot for it to handle.  If you live in a hot region of the world, like South Africa, India or even Arizona this maybe a problem.
To be on the safe side, if you live in the Northern Hemisphere, keep your plant in a south window for the winter.   Then move it to a east facing window in spring and summer.  This should not be too much sun.  Eventually your plant will grow new leaves replacing the ones that were damaged.
Answer: The cuticle also acts as a sun screen (in addition to limiting transpiration). Keep an eye on the plant for signs of excess sun exposure (bleaching or yellowing of the leaves).
Don't let the plant get too dry if you see signs of sunburn. As mentioned above, where you are on the globe will determine how much exposure risk you have.
The cuticle should come back for the most part over time.

White stuff on bromeliad


Reading an Oracle Lite ODB file without Oracle Lite

Question: Is there a way to extract the data from an Oracle Lite ODB file without installing Oracle Lite?  Is there a reader out there which will let me browse and copy the data?
Answer: You should be able to export the data using the OLLOAD utility, which is part of, but should not require the installation of, Oracle Lite.
OLLOAD Documentation
Answer: If you know the tables you need, you do need Oracle Lite completely. You have to however have the webtogo.jar on your classpath. Then you can simply write a small java program to connect via JDBC to the ODB and extract the data you need.


Kendo UI menu Action and Controller produce error on ISP provider like DiscountASP.NET. Must use URL

Question: I create a Kendo UI for MVC Web Application project and it runs find on localhost. When deploying this as a web application to a subdirectory of my domain on either DiscountASP.NET or WinHost, I receive an error:

The relative virtual path '~4/' is not allowed here.

<code>Line 21:            </div>
Line 22:
Line 23:            @(Html.Kendo().Menu()
Line 24:                    .Name("menu")
Line 25:                    .Items(menu => {
</code>
Somehow I was able to get the proper deployment done through an FTP deployment from Visual Studio 2012 at work. But from home it still does not work. I am using Visual Studio 2012 and Web Deploy  and have properly stated the addresses for the web application. I searched within IIS 8 for some kind of a setting but cannot find one.
These two internet host providers have "virtual" web sites I guess though I am not familiar with how that works. I think it might be related.
The solution to this above for now is to change from the default Telerik provided code:
<code>            @(Html.Kendo().Menu()
                .Name("menu")
                .Items(menu => {
                    menu.Add().Text("Home").Action("Index", "Home");
                    menu.Add().Text("About").Action("About", "Home");
                }))
</code>
To this:
<code>            @(Html.Kendo().Menu()
                .Name("menu")
                .Items(menu => {
                    menu.Add().Text("Home").Url("~/Home/Index");
                    menu.Add().Text("About").Url("~/Home/About");
                }))
</code>
If there is a way I can get back to the Controller and Action method of using Telerik's Kendo UI Menu in the MVC wrapper, I would appreciate knowing that. I have submitted a help ticket on the Host provider to see what I might do in the deployment stages but otherwise I am not sure what to do next.
Edit: The Internet Host Provider indicated that I need to contact the vendor (Telerik Kendo UI) to check why the wrapper is causing this behavior.
Answer: how about this:
<code> menu.Add().Url(Url.Action("About", "Home")).Text("About");
</code>


Conditional probability of sum of $n$ Poisson variables given sum of subset of $n$ variables $P(X_1+X_2+...+X_n=z|X_1+X_3=y)$

Question: I have $n$ Poisson random variables $X_i$ each sampled from an independent Poisson distribution parametrized by $\lambda_i$. I want to compute $P(X_1+X_2+...+X_n=z|X_1+X_3=y)$. The distribution of the unconditional sum would be a Poisson, but I am not sure how to condition it.
Comment: It is equivalent to computing $P(X+Y=z|Y=y)$ when $Y$ is Poisson with parameter $2\lambda_n$ and $X$ is Poisson with parameter $(n-2)\lambda_n$
Comment: One proof of the statement by @Xi'an begins by observing that $Y=X_1+X_3$ and $X=X_2+X_4+\cdots+X_n$ have Poisson distributions with parameters $\lambda_1+\lambda_3$ and $\lambda_2+\lambda_4+\cdots+\lambda_n,$ respectively, and are independent. You can go further and rewrite the question as asking for $\Pr(X=z-y\mid Y=y),$ which permits you to write the answer immediately.
Comment: I don't think so cause if the sum and one of the variables are known, the answer is easy to calculate and deterministic. If there were two free variables like $P(X+Y+Z=a|Y=y)$, then it would be similar to this https://llc.stat.purdue.edu/2014/41600/notes/prob1805.pdf, and the answer would be $\frac{e^{-\lambda}\lambda^{a-y}}{(a-y)!}$. However, when I have more free variables, the summations get complicated, and I am unsure about how to reduce them to a similar Poisson variable.
Answer: The sum of independent Poisson random variables is a Poisson random variable as shown here. So for $Z = X+Y$ where all are Poisson r.v., $P(Z=z)=\frac{\exp^{-\lambda}\lambda^z}{z!}$. Here, $\lambda=\lambda_x+\lambda_y$. If $P(Z)$ was conditioned with $X$, $P(Z|X)$ the solution would be deterministic as the sum of two variables is known and one of the variables is known. As per @whuber and @Xi'an suggested, $P(X_1+X_2+X_3+X_4+...+X_n=z|X_1+X_3=y)=P(X_2+X_4+X_5...+X_n=z-y)$.
So, the conditional can be reduced to an unconditional that is just a sum of r.v. which in turn is just an extension of the attached derivation. Thanks @Xi'an and @whuber, appreciate the help.
Comment: That's right: but take some care to specify that when $z\lt y,$ the chance is zero!


slot machine can display the numbers 1, 2 or 3.

Question: A slot machine can display the numbers 1, 2 or 3. 1 has probability
  0.1, 2 has probability 0.3, and 3 has probability 0.6.
  The machine is run 10 times, and the numbers that show are added. At
  the end you get as many dollars as the sum indicates. What are the
  expected winnings?
My thoughts were to find the expected value of winnings for one trial and then multiply it by 10. So $E(x)=1*0.1+2*0.3+3*0.6 = 2.5$ then since we ran it 10 times the expected winnings would be 25. Would this be correct or no?
Answer: If the draws are independent, this is correct.


Armature problem pose

Question: I know the correct position is when the avatar is in T pose but I have created this avatar in another pose and it why I have some problems.
I want to draw the shoes but the foot is not "flat". How can I make the change?
If you download the file the mesh and the armature have a different poses.
I appreciate also a tutorial on youtube!
Comment: You can change the rest pose with the menu entry *Pose > Apply > Apply Pose as Rest Pose* in *Pose* mode. To compensate for the heavy deformation of the foot and leg add a *Corrective Smooth* modifier on the body mesh after the *Armature* modifier.
Comment: You can duplicate the Armature modifier, disable the copy, change the pose and apply the Armature modifier?
Answer: You can use in the menu bar: Pose -> Apply -> Apply Pose as Rest Pose.
If it doesn't work you can copy the object.

Armature problem pose


Special characters in XHTML - Parse Error

Question: When there are special characters like & in the xhtml the DOM / SAX parser throws parse exception. The xhtml document is got as an input for my component. I want to ignore such special characters when i parse. How can i achieve it using DOM/SAX JAVA parser.
Comment: what programming language? What XML parsing kit?
Answer: & should be encoded as &. If it's not then your XHTML is encoded wrongly. Whatever is writing it should escape these (and other) characters properly according to the XML specification.
Answer: How do the "special" characters get into the XHTML? XHTML is meant to be XML. It should be created by tools that understand XML. If you're using string manipulation to create your XHTML, then you're setting yourself up for errors like this.
Answer: You can create and store XML's special characters in text fields in XPL - which is just like XML, but allows the special characters in text fields. It's Java based, but you can also run the free version outside of your application and it will create valid XML files for you. eXtensible Process Language


JMeter - cannot use recorder for internal site that has some resources that should use corporate proxy

Question: I have a site that sits within corporate firewall. When I start JMeter with corporate proxy address defined (ie parameters in command line) and start recording a scenario, page gets blocked by corporate proxy - address not recognised. When I start JMeter with no proxy defined though and record the website activity, I see the basic html page (just a border) but no content is loaded - basically because the main content is from external resources and blocked (because no corporate proxy details were supplied I believe- don't have error message immediately to hand). Is there any way to specify domains that should be excluded from using corporate proxy when recording? Why does this issue not occur other times? I'm assuming that plenty of our internal sites use external resources, eg .js packages? Am using FoxyProxy Chrome addin for ref. Am trying the Blazemeter AutoCorrelation tool for recording. Thanks
Answer:
Make sure to import JMeter's certificate into the browser. The file is called ApacheJMeterTemporaryRootCA.crt and it's generated in "bin" folder of your JMeter installation when you start HTTP(S) Test Script Recorder. See HTTPS recording and certificates chapter of JMeter Documentation for more details.
Clear your browsing history
There is no need to use any add-in, just configure Chrome to use JMeter as the proxy. Alternatively go for the browser which has independent proxy configuration like Firefox. Also set JMeter to use your corporate proxy. There is a way to specify host(s) for which proxy will not be used (the connection will be direct). However it means that these requests will not be intercepted
I don't think you should record and especially replay external resources for the internal application, you should exclude them from recording and replaying scope
Comment: Thanks you Dimitri - problem now resolved!
Points 1 and 2 were done (imported cert and always use Incognito). Point 4 - in the process of reviewing.
Point 3 was the issue - I had started JMeter from the command line with parameters as per section 1.4.3 in the manual but the parameter -N was incorrect. Once I added the domain for local addresses eg "-N *.my.local.domain.com" as an exclusion for the proxy, all was good. Thanks again


Asp.net mvc3 razor with multiple submit buttons

Question: I'm using MVC3 Razor. I have 2 submit buttons setup on my view but the problem I'm having is that both submit buttons cause the validation of the model. I want to hook up individual submit buttons with specific input controls for validation.
Answer: I know this is a few months old but the solutions here seemed needlessly complex and there's no accepted answer yet.  If you name your inputs the same but give them different values, you can get that value in your controller just by including a string with the name of the input as a variable.  This is how I solved this problem:
View:
 <input type="submit" id="EnterprisePush" name="btnSubmit" value="Push" />
 <input type="submit" id="EnterprisePull" name="btnSubmit" value="Pull" />

Controller:
[HttpPost]
public ActionResult EnterpriseAdmin(int id, string btnSubmit, FormCollection collection)
{
  switch (btnSubmit) {
    case "Push":
      /* Do Something here */
      break;
    case "Pull":
      /* Do Something else here */
      break;
  }

Comment: This should be marked as an answer. I also found that this solution works well with custom validation.
Comment: Just to add to you solution, this can be done with regular buttons as well: `@item[1]` and then use `RemoteControl(string Command)` for the method. I had a case where the "Command" was different from what I wanted displayed.
Comment: This doesn't answer the question the OP asked.  He asked how to have conditional validation, not how to have multiple submit buttons.  He already has multiple submit buttons working.
Answer: The browser is always going to submit the entire form regardless of which submit button you press.
The best solution would be to have two submit buttons with the same value for the name attribute and different values for the value attributes.
When you submit the form, the value of the button will be submitted as well.  In your action which handles that form submission, you check to see the value of the button and perform the correct validation based on that.
In your form you would have something like this:
<button type="submit" name="Command" value="command1">Do Command #1</button>
<button type="submit" name="Command" value="command2">Do Command #2</button>

Your Form Model would look like this:
public class MyFormModel() {
    public string Command {get;set;}
    public string SomeOtherVal {get;set;}
}

Your controller\action would look like this:
public ActionResult HandleFormSubmit(MyFormModel model) {
    if (model.Command == "command1") {
        // do something
    } else if (model.Command == "command2") {
        // do something else
    }
}

Comment: In your example the MyFormModel is a parameter for Action. In this case model validating is already done. You should use the FormCollection instead the MyFormModel to make this examlpe work
Comment: Not sure what you mean.  I think you mean model binding and yes you are right, it happens already, but it just binds any string value to `Command` property, irrespective of the value.  All we are doing inside the action is checking *which* value it is and acting based upon that.
Comment: I mean that if you check ModelState.IsValid in your code lines before if (model.Command == "command1") you can see that Command or SomeOtherVal appears invalid. I mean that in spite of we submit just one model the second can be invalid and user vill see that in ValidationSummary and this will look confusing
Comment: I suppose you could have a second parameter to the action method which contains the Command property rather than having it inside the form model.  This way the form model validation would be separate from the command.
Comment: While this is a neat solution, I think it's worth mentioning that IE6 and IE7 have some major issues with the button tag. See this http://stackoverflow.com/q/1903453 where it concludes "Button tag: not worth the trouble, just use input for now."
Comment: I suppose the same thing could be achieved with an `input` element of type `submit`
Comment: You could also get the value from the `Request.Form` instead of changing the model. This way you would avoid mixing UI behavior with you data representation.
Answer: Firstly, you can disable client validation on your cancel button simply by adding the CSS class 'cancel' to it. See: Disable client-side validation in MVC 3 "cancel" submit button
Secondly, as well testing the submit element's form name as described above, you can use a custom action selector. Here's mine, which I originally took from the blog post shown in the comment:
///
/// Used to vary an action method based on which button in a form was pressed. This
/// is useful but is an anti-pattern because it couples the controller to names
/// used in the form elements.
///
/// <remarks>
/// See the example at http://weblogs.asp.net/dfindley/archive/2009/05/31/asp-net-mvc-multiple-buttons-in-the-same-form.aspx
/// </remarks>
public class AcceptButtonAttribute : ActionMethodSelectorAttribute
{
    public string ButtonName { get; set; }

    public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo)
    {
        var req = controllerContext.RequestContext.HttpContext.Request;
        return !string.IsNullOrEmpty(req.Form[this.ButtonName]);
    }
}

In your controller:
    [HttpPost]
    [ActionName("Edit")]
    [AcceptButton(ButtonName = "Cancel")]
    public ActionResult Edit_Cancel(MyModel model)
    {
        return RedirectToAction("Index");
    }

    [HttpPost]
    [AcceptButton(ButtonName = "Save")]
    public ActionResult Edit(MyModel model)
    {
        // do real work here
    }

Note that you need the [ActionName("Edit")] attribute to tell MVC that although using a different method name, it is for the Edit action.
And in your View:
    <input type="submit" name="Save" value="Save" />
    <input type="submit" name="Cancel" value="Cancel" class="cancel" />

Comment: Wow, this is really clean. Not only should this be marked as the answer, this should be included in the MVC framework. You should consider submitting a pull request for MVC4. I don't care if this is an anti-pattern or not, it is incredibly useful!!!
Comment: I Agree with @DanVanWinkle. This is useful in certain cases. +1
Comment: This is worth being the answer!
Answer: My solution was to do two things. Say we have a Save button and another Add Something button. When user clicks on Save we want client validation and server validation to be performed. For later button we don't want any validation to take place.

Temporarily disable client validation for second button (on click):

<input type="submit" name="submit-button" value="Save" />
<input type="submit" name="submit-button" value="Add Something" onclick="document.forms[0].noValidate = true; document.forms[0].submit();" />

Good thing about it is when JavaScript is disabled the client validation would never have taken place anyway.

Take care of server side

Similar to what Bryan is saying when you click any submit button within a form, the entire form and the clicked submit button value is posted. You can differentiate which button was clicked by the name posted. In example above when user clicks on Save button and we read Request.Form["submit-button"] in controller post action we get "Save". If user clicked on Add Something we would get "Add Something". This is the way HTML is supposed to work.
Now to get around having magic strings all over the place I usually have a public static class within the controller, like so:
public class HomeController
{
    public static class Buttons
    {
        public const string Save = "Save";
        public const string AddSomething = "Add something";
    }
    // Action methods
}

So you can use these for rendering form:
<input type="submit" name="submit-button" value="@HomeController.Buttons.Save" />

And you can easily read the button clicked in controller:
[HttpPost]
public ActionResult Index(Model viewModel)
{
    var buttonClicked = Request.Form["submit-button"];
    switch (buttonClicked) {
        case HomeController.Buttons.Save:
            return Save(viewModel);
        case HomeController.Buttons.AddSomething:
            return AddSOmething(viewModel);
    }
    return View();
}

In Save method you first ask if ModelState.IsValid and return view model if not but in AddSomething method we will clear any errors:
public ActionResult AddSomething(Model viewModel)
{
    ModelState.Clear();
    // your code to add something to model
    return View(viewModel);
}

This was you keep everything clean, tidy and testable. And you can introduce a constant for submit-button html name attribute. It might be possible to do all the constants with T4MVC too. A similar solution applies to when you need a "auto postback" combo box, except you need a hidden field that is set via onchange event of the select element.
Hope this helps.
Answer: Just use this code as a template:
@{
    var nextButtonVal = "Next >>";
    var backButtonVal = "<< Back";
    if (IsPost) {
      if(Request["navigate"].Equals(backButtonVal)){Response.Redirect("~/pageFoo");}
      if(Request["navigate"].Equals(nextButtonVal)){Response.Redirect("~/pagebar");}
    }
}

<input type="submit" value="@backButtonVal" title="Back" name="navigate"/>
<input type="submit" value="@nextButtonVal" title="Next" name="navigate"/>

Answer: One final thing I would do is instead of using intelligent strings, use an enum to determine the value for each input tag.  Using razor syntax:
@Enum.GetName(typeof(YourEnumType), yourEnum.WhateverValue)

then in your controller:
public ActionResult DoSomethingBasedOnEnumValue(string enumValue)
{
    YourEnumType localVar = (YourEnumType)Enum.Parse(typeof(YourEnumType), enumValue);

    switch(localVar)
    {
        case YourEnumType.Action1:
            //do something
            break;

        case YourEnumType.Action2:
            //do something else
            break;
    }
    return View();
}

Answer: If you want to have separate action for delete, try this.
add a delete action in the controller and mark it as HttpDelete,
[HttpDelete]
public ActionResult Edit(int id, string foo) {
   ...
}

And in the view,
button name should be X-HTTP-Method-Override and value should be DELETE
<button name="X-HTTP-Method-Override" value="DELETE" formnovalidate="formnovalidate" class="cancel">Delete</button>

note: all most all the browsers don't allow for other HTTP methods, like HEAD, PUT, or DELETE. but by add a header to the HTTP request, X-HTTP-Method-Override, that is supposed to be interpreted by the service and acted upon regardless of the actual HTTP method used. So above code will add a header to the request like X-HTTP-Method-Override: DELETE. and .net framework will do the rest of the things and direct you to delete action.
Answer: Submit button name don't come to server side if in all from this situation you are will be use [Remote] attribute for validation model property.


How to open a phpBB forum in the same website as sub-page

Question: I have a separate phpBB forum and I want it to open below the navbar, on the same website, so that it will look like as part of the website, something like that (Image edited with Microsoft Paint):
Answer: If you want the phpBB page to have the same look/feel of your site, there are two ways to do it.
1) Build a phpBB 'skin' with the elements you want.
2) Build a custom page template, and put the call to phpBB inside the page area of the template.
Either way is probably a lot of work; phpBB and WP have totally different ways of 'skinning' a page. You might consider a somewhat easier third way:
3) Add your WP theme header image (and maybe some WP site menu links) to the header of the phpBB install with a custom phpBB 'skin'.
I'd also ensure that the phpBB installation is in a totally different folder from any WP folder.
And, you'll need to find a way to integrate a WP login with the phpBB login, passing credentials between both as needed.
A big project (although #3 is easiest, perhaps, if you don't need login credential sharing between phpBB and WP).


recording conversations without consent and playing the recordings to others

Question: I live in Arizona a retirement community and was on my porch recently having a conversation with a friend. During the conversation, I said some negative comments about the manager and the maintenance man. My neighbor recorded our conversation without my knowledge or permission; he then played it to the manager and the maintenance man and several other residents. Now my friend and I are being ostracized by several residents. My question is do I have a case against my neighbor for illegally recording my private conversation and, if yes, what type of attorney do I contact? Thank you
Comment: Was the neighbour a party to the conversation or an eavesdropper?
Answer: This is legal in Arizona, which is a "one-party consent" state. That means that as long as one of the parties to a communication (the guy doing the recording) consents, the recording is legal. What that precludes is the government planting a bug and recording the conversation (but they can send in an agent wearing a wire who is a participant).
Comment: Surely the neighbour was an eavesdropper, not a party to the conversation. Doesn't that change things?
Comment: I don't see that that conclusion is supported by the postulated description of the event. Let's see if more details come out regarding what that person was doing.


Is fear rational?

Question: Let's suppose a big ugly monster thingy wants to eat you. While you're running away from it, you're feeling fear. Can this situation be considered one where fear would be rational?
Comment: As a related topic you may want to read up about the evolution of emotions and arguments for their adaptive functions: http://en.wikipedia.org/wiki/Evolution_of_emotion
Comment: As mentioned in my answer below, I believe that this is not a question about cognitive sciences at all and have flagged it.
Comment: I closed the question as "Not A Real Question" instead of suggested by @what as Off Topic. It might be on topic but it's way too vague, and you leave it up to the answerer to guess what you are referring too. Additionally there is no background research whatsoever. You can still update your question to address these issues.
Comment: I do see you are new to Stack Exchange, so don't feel offended by this. I advise you to read through the [faq](http://cogsci.stackexchange.com/faq) properly to better understand what is expected of you when asking a question here.
Comment: Please don't further downvote this question, people, it has been closed. There's no need to be unnecessarily harsh on a new user.
Answer: The answer depends on your definitions of "fear" and "rational".
If you simplify the complex English semantics, rational might mean either (1) "sensible; not foolish" or (2) "using the faculty of reasoning".
If you understand rational to mean "sensible", then fear can be rational or not, depending on the situation. Fear of mice is probably not very sensible, while fear of heights most probably is.
If you understand rational to refer to cognition (as opposed to affect), then the answer depends on your understanding of fear.
If you define fear as an emotion, then fear can, by definition, not be a cognition. An emotion can be caused by a cognition, it can be thought upon and suppressed by the faculty for rational thought, but it is not a cognition. In this sense fear would not be rational.
How could you define fear to make it meaningful to think of it as not an emotion?
If you define fear as, e.g., an attitude (the attitude of judging something to be dangerous or harmful), then fear would very likely have affective and cognitive components. I am not sure if any speaker of English would accept this definition (even the OED says that fear is an emotion), but you could certainly define fear in such a way -- which would lead to a lot of interesting but unnecessary confusion with your readers.

Psychologists would avoid the word "rational" here, because it is not a scientific term. It is a philosophical term. From this perspective, the opening question is not a question relating to cognitive sciences at all, but to everyday wisdom, and should be closed.
Answer: Yes! Of course fear can be rational, especially when there is in fact a big scary monster and you are in danger.
There is an unfortunate meme in society that emotions and rationality are incompatible, but that's not the case. Emotions can only be irrational if you are mistaken to feel those emotions in that context.
Cases where fear is irrational include:

Fear of cotton balls
Fear of a non-existent monster
Not fearing being chased by an actual monster/cheetah/grizzly bear

Now, it's largely up to you to decide what emotions are reasonable for each context, because otherwise the examples become a bit normative. For example, is it irrational to feel a lot of anxiety in social situations? That depends on the social situation, but I'll guess not.
The folks over at Less Wrong have given this sort of thing a lot of consideration. Here's their wiki link to the subject.
Comment: I'm not sure I agree that the emotion itself is rational.  The action of running away from danger is rational,  but the emotion is supplementary.
Answer: Why are you running away?
1) Are you running because of fear?
2) Are you running because the monster might harm you?
3) Are you running because you've had an encounter with a monster before and even though this one doesn't look like that one and that one had claws and this one doesn't but this one is still coming towards you, kinda fast?
Fear is a marker, like pain.  Fear can be automatically activated by occurrences in one's environment in order to activate a response before the conscious mind could possibly have time to react.
LOOK OUT, DUCK! ---  Yell this at someone sometime and watch them flinch, down and back.  Almost every time.
The problem comes when we aren't paying full attention to our environment, and instead using cognitive shortcuts, such as stereotypes.  In these cases, we're using past experiences to inform future expectations - when past experiences are traumatic, we will sometimes (unconsciously) assume negative future expectations, which is the fundamental basis of anxiety.
Is fear rational?
Let me turn that around:
Is a dishwasher rational?
Fear is a tool, baked into the human brain.  A dishwasher is a tool.  Both can malfunction, both can run improperly (long, short, etc).  We can even, over time, reduce our exposure to both (meditation / washing the dishes by hand).
If we run a dishwasher once for each dish we have to wash, that would be irrational.  If we feel fear at every occurrence, that would be irrational.  If we run the dishwasher without soap, that would be irrational.  Unless we have need for it.
It's all about context.

Is fear rational?


What do vector size and direction really mean in vectors that are not position vectors?

Question: I know that vectors are objects that have both magnitude and direction. Let's say we have a vector r that represents a house as an example, and it is r = [a, b, c] (a=number of rooms, b=number of floors, c=price). For this vector the idea of finding its magnitude does not make any sense to me, what would it mean? Also what would the direction or the angle between two house vectors mean?
Answer: Not all vector spaces have a sensible dot product, and thus not all vector spaces have a sensible notion of length and direction (other than two vectors being or not being parallel, and one vector being longer or shorter than another, parallel vector).
Your vector space is a case of this, where the non-existence of a sensible dot product is a result of the application, rather than a mathematical inability to impose any dot product on the space. (A vector space where we mathematically cannot impose a dot product implies the negation of the axiom of choice. So that's not an easy thing.)
Comment: @MustafaShujaie No, it is the basis vectors that have units. The coefficients are unitless. So as far as pure arithmetic goes, there is no issue with $a^2+b^2+c^2$. You have $5$ oranges and $3$ apples, and the Pythagorean formula is like telling you to calculate $5+3$. Makes no practical sense, but entirely doable.
Comment: (Or rather $5^2+3^3$.)
Comment: Okay! So, for the same vector in my question, we can perform dot prodcts and calculate its magnitude mathematically even if it is not sensible. Another thing that I am wondering about is that each element of the vector is representing different quantities like price and number of rooms. Is it mathematically correct to use pythagorean theorem to calculate the magnitude because they are different like oranges and bananas?
Comment: @user88731 Any dot product you impose will imply some form of the Pythagorean theorem on your space (although it might not be that the coordinate axes are orthogonal with the given dot product, so it's not necessarily as simple as $a^2+b^2+c^2$). So if you have a dot product, you have Pythagoras.
Comment: What I mean is that a^2 + b^2 + c^2 have 3 different values each representing 3 different things. As I said it is kind of like adding bananas and oranges together.
Comment: Thanks! I think I get it now.
Answer: There doesn't need to be a physical interpretation for your examples. Vectors, in full generality, don't need to have a magnitude and direction. In your case, the vector's magnitude and direction are just the magnitude and direction you get when you draw it in 3D space---no physical meaning.