Is using dvcs making harder to use continuous integration in corporate environments?

Question: There are unarguably lots of advantages in using dvcs and it can be used like centralized vcs, but is having local commits and being able to very easily fork the project for some smaller group making it harder to support continuous integration? It helps in development that everybody has access to the most recent changes, which are tested by the CI server so possibility of incompatible changes can be minimized.
Answer: You can centralize a DVCS.  The difference between DVCS and centralized ones is that with a DVCS, you don't have to centralize it.
You could have a central repository where everyone can push changes, and everyone can pull the latest code from.  You can write a commit hook on the server so that every time someone pushes code, it runs a test to make sure it passes the tests.  It's just like centralized version control, only better, because I can create a local branch and make several local commits before I'm ready to push to the central server.
Have you ever been making a big change that breaks a lot of things, and wanted to make several commits, but not share them until you're done and everything is fixed again?  That's what DVCS makes easy.
Answer: It does make it harder to perform CI as the source control system is encouraging you NOT to integrate continuously. However, there is absolutely nothing that prevents you from doing that regular integration into the central repository. The team just needs to remain disciplined about that.
Where smaller teams fork the project and do their own thing for a while, you should do continuous integration builds against that fork as well and potentially set up a regular integration between the two forks.
This would be similar to the stream based multi-stage continuous integration strategies that Accurev pushes:
http://www.accurev.com/multistage-continuous-integration.html


Who can create a MAC? Who can verify a MAC?

Question: I have read many answers but I cannot get the basic explanation. There's no need for full details. I just need some basic information about who can create a mac and verify it.
Answer: Anyone who holds the key can create a MAC. For any secure MAC it should be computationally infeasible to create a MAC without knowledge of the key.
By the correctness of a MAC, anyone who holds the key can verify it. In pretty much any practical MAC, the key is also needed to verify, but this is not something that's actually implied by the functionality or security definitions.
Answer: Given that a secret key was exchanged among some parties any of them can authenticate/verify a message using some MAC implementation in conjunction with the shared key. Typically you would share a key between 2 parties because otherwise you cannot tell who was the sender. However, this is not to be confused with the property of non-repudiation that you get from using a digital signature algorithm because in the case of a MAC, for a given message you cannot tell who generated the MAC (because both parties use the same shared key for the generation).


FreeBSD and Windows show different times

Question: In a dual-boot system, I usually use FreeBSD 9 but when I boot to Windows 7 my system time in both OS automatically change and show incorrect time. What's the problem and How can I solve it?
Answer: A typical BIOS PC has a clock which stores the time without a timezone indication. Different operating systems have different conventions: some require the clock to store UTC, others require the clock to store the local time. Dual boot between systems that require different conventions is a problem.
Older versions of Windows had no notion of a display time that is separate from the local time. Hence you need to set the hardware clock to the time you want displayed in Windows. I don't know if this has been fixed in Windows 7.
Unix systems have a per-user setting for the time zone, and use UTC internally. Most unix variants like to use UTC the clock, but unices designed for PCs often provide a way to cohabit with Windows. On FreeBSD, run tzsetup then adjkerntz to update this setting. You can tell whether the hardware clock is using UTC or local time: if /etc/wall_cmos_clock exists, then the hardware clock is assumed to use local time.
Note that if you live in a time zone with daylight savings time, and your hardware clock uses local time, your multiple operating systems may compete to reset the clock when DST starts or ends. This is one reason why setting the hardware clock to UTC is preferable: you should set the hardware clock to local time only if you use an operating system that absolutely requires it.
Comment: Windows is able to handle hardware clock in UTC: from XP to W7, it was accomplished by setting `RealTimeIsUniversal` registry parameter; W8 is reported to ignore that. However, XP's implementation was not complete, and the system clock dropped to the default "local time" behavior every hour or two, — probably each time sysclock was synched to hwclock.
Answer: From my experience, your problem sounds like one OS is seeing your hardware clock as using UTC and one is thinking it's local.
Check to see if your BSD and Windows installations are configured for your local timezone


is not allowing mistake of law as a defence in criminal trials unjust?

Question: the burden of proof when it comes to providing defences is up to the defendant when they make a claim. since that burden of proof exists and assuming a defendant can prove that they didn't know the applicable law , would it be unjust to not allow this defence ? also is it even possible to prove this kind of defence ?
Comment: Despite the [*ignorantia juris non excusat*](https://en.wikipedia.org/wiki/Ignorantia_juris_non_excusat) principle,  ignorance, when it can be substantiated, is often taken into consideration, especially at sentencing. There are even legal exceptions when pleading ignorance is allowed as a defense, e.g. for new laws (Canadian hunters were acquitted when a law was changed while they were in the wilderness) or for ["knowing violations"](https://www.mncrimdefense.com/ignorance-of-the-law), where "specific intent" is an element of the crime.
Comment: how does specific intent relate to mistake of law ?
Comment: Some crimes require *scienter*, a culpable state of mind, or intent to bring about specific harmful result. Those unaware that their conduct is unlawful may lack such state or intent, see [criminal intent](https://courses.lumenlearning.com/suny-criminallaw/chapter/4-2-criminal-intent/).
Comment: Which legal system? Different systems will have very different answers to this question.
Answer: I'm going to restate the problem here for clarity as I discuss the analysis.
The Case: We have a person, say Adam, who has committed some crime X. When brought to court, Adam says he did not know that X was a crime when he was doing X. This is the Ignorance Defence.
Is The Ignorance Defence legal?
No, generally this falls under a legal principle that states that ignorance of the law is not an excuse for breaking it.
(There are specific cases, however, where this defence would work, where the law states things like "willingly")
Is it unjust to not allow the Ignorance Defence?
There's no clear consensus here. However, there are a number of philosophical arguments why the Ignorance Defence should not be allowed.
The core of your question is probably based around the idea of Epistemic Vice.
Epistemic Vice is the idea that you might be responsible for action X and responsible for not knowing that action X was wrong. The claim is that there are certain facts that agents are obligated to know. (Usually with the caveat that the agent must have had the reasonable capacity to know these facts).
So the argument against the Ignorance Defence would go:

Adam had an obligation to know that X was illegal.
If X is illegal, then X is wrong.
Adam did X.
If Adam had an obligation to know that X was wrong, and Adam did X, then Adam is guilty of doing X.

C: Therefore, Adam is guilty of doing X.
Obviously the two caveats here are Premise 1 and Premise 4.
General justifications for Premise 1 are:

Normative justifications: We live in a society where knowing the laws is a social norm. By extension, knowing the laws is your duty as a citizen governed by these laws and thus you have failed your duty by not knowing them, thus justifying Premise 1.
Presumption: We could also claim that Adam can be presumed to know
the law based on his broader knowledge. We assume that Adam knows
that he lives in a society with laws. We also assume Adam knows that
these laws govern all behaviour, including his own, and that they
carry penalties for violating them. Thus, we can reasonably assume
that Adam has strong incentives for knowing the law if he wants to avoid the
penalties. Thus, we can reasonably assume that Adam knew the law. (If Adam doesn't, then it is probably because he was bad at reasoning, or because he was lazy, etc. In these cases, he has committed an epistemic vice. Either that, or that he did not want to avoid the penalties, in which case I suppose punishing him is justified because he accepts the penalties for his actions willingly.)

(Note: Obviously if Adam does not know that laws exist in the first place, then he probably falls outside these arguments, but that will be beyond the scope of this answer.)
Premise 4 feeds into the broader philosophical debate of whether Epistemic Vice even exists and you can read about Revisionism (that opposes Premise 4) and the responses to it here.
There are also historical arguments, both in the flavour of epistemic vice and outside it. I've summarised some key ones here:

Christian Theistic Argument: Leviticus 5:17 makes it clear that you are guilty of a crime before the Lord even if you did not know it was a crime. (Though it's unclear if this makes the crime less severe). This seems to be an a priori argument, it is this way because the Bible says it is.
Natural Law Argument: Some ancient Greek and Roman thinkers, like Cicero, would probably argue that legal systems are bound to and derived from cultural and natural laws. This leads to a presumption of knowledge, where just by living in society you are inevitably exposed to these laws and ideas.
Duty to Participate: A lot of thinkers, from Socrates, to Social Contract Theorists, are committed to some idea of political obligation that could reasonably answer this by saying that knowledge of the law is part of this obligation. Social Contract Theorists could justify opposition to the Ignorance Defence by saying that the people, as a whole, have consented to the laws and so they are enforceable. (i.e. someone else agreed to the law for you).
Utilitarian Argument: Obviously there's the Utilitarian argument that allowing the Ignorance Defence means allowing a defence that is difficult to prove or refute, and in addition incentivises people to not seek out the legality of their actions.

At its core, the answer I find most compelling is a combination of (1) the intuitive force of Epistemic Vice (if you did something that really hurt someone, it seems reasonable to say that not knowing it would hurt them doesn't absolve you of responsibility), (2) the idea that presumption of legal knowledge seems reasonable, and (3) the argument that one's social contract with the government includes a duty to educate oneself about the legal system at the very least.
For opposing arguments that support the Ignorance Defence, I'd recommend looking at Revisionism (linked above) and maybe checking out Matthews' arguments around the legal status of the ignorance defence.
Answer: In principle, it is unjust to demand that average people learn every intricacy of the legal system. Indeed, it is impossible, since no one can predict in what way a judge or jury would rule in a particular case. It is impossible for a person to simply "know every law" and act accordingly.
In practice, laws are not arbitrarily written by aliens from Mars. They often codify things that are already commonly accepted in society. For example, few people would sincerely claim that it's news to them that theft or murder is illegal. You would assume that it would be even without reading a single page of criminal code.
Often, as you get into more commercial areas, unjust laws become more common. For example, hidden fees, counterintuitive "gotchas" about parties surprisingly receiving ownership, and so forth. I would consider these outside the scope of the question's "ethics" tag, because these typically arise from the corrupting influence of moneyed interests on government, or the government itself becoming corrupt in the name of increasing its revenue. However, even so, the authorities enforcing such laws rarely use them as pure "gotchas". They will usually attempt to contact you, and inform you that you have not done something required by some law, and give you opportunities to comply and avoid punishment or receive a smaller one.
The courts are normally a last resort, after you have actively refused multiple opportunities to comply. Even with simple criminal acts, if the police see you trying to engage in illegal activity, they will attempt to discourage you (where practical) rather than watch you do the bigger crime and bring you in. So people ignorant of the law may often be reminded about the law by the authorities, when they are about to break it. So while many people do not know the law, not all of those would remain ignorant by the time they end up in court for breaking a law - they would have been informed at some point. This is obviously not a perfect system, many people end up in court out of the blue due to infractions they knew nothing about, but it's an important caveat.
As for allowing ignorance as a defense, the practical problem is that it's a defense that is almost always applicable. Everyone would plead it. And it's very difficult to prove that someone does know something. If such a defense would allow, it would get even worse, as prospective criminals would actively avoid speaking about laws or appearing to learn about them. It would also encourage honest people to not learn the laws, which is also a negative. Realistically, you would have to periodically require that people sign a statement to the effect of "I know these laws and promise to follow them", which you can then use in court to pre-empt the ignorance defense. Yet this is already the case for many non-obvious laws. For example, when receiving a driver license, you are required to attest that you've learned all the complexities of traffic law - in fact you are tested on it.
Moreover, rather than requiring endless statements, many laws already have a builtin standard of "what a reasonable person would do". In this case ignorance of the law by itself is not meaningful, since it could be claimed that even if ignorant of the law, you could have still acted "reasonably". Of course the definition of what is reasonable is yet another can of worms, but for what it's worth, it's there.
So I think that, while in principle it seems fair to not punish people for breaking rules they didn't know, in practice there are already multiple safeguards against such "unfair" punishments, and moreover there are many practical problems caused by allowing ignorance as a defense. For this reason I think the injustice of not allowing it is actually quite small, compared to how it would seem per se.
If anything, I would say the solution here is that it should be part of the government's mandate to ensure that the public is sufficiently educated in what the law expects of them, through effective channels such as primary school, public broadcast and government-sponsored free legal advice. Meanwhile, the legislature should be discouraged from making laws that are complex and confusing, thereby also reducing how much work the fore-mentioned "education" will be. Unfortunately, this does not appear to be a common trend as of yet.


How do I convert a R12 to R134A for my AC system?

Question: I have an older vehicle that has AC, but it needs a recharge.  It uses the older R12 refrigerant and it is very expensive and can be difficult to locate as it is not made in the US anymore.  How do I convert it over to cheaper newer R134a?  Can this be done without replacing the AC compressor?
Comment: I haven't done this, but a little surfing finds: http://www.ehow.com/how_6616048_convert-r12-r134a-system.html
Comment: It might depend on the vehicle. Can you be more specific? For instance, my mechanic told me that my 1992 Volvo 940 would need a new evaporator and condensor in order to use R134a.
Answer: Checkout the Auto AC board at AC Source
There are some good people on there.
Don's right. You do need to flush the old oil out of the system because they don't mix. Also it's difficult to flush the compressor so odds are it will not last if you don't replace it. The best thing to do is change the compressor out if its older at the same time, replacing all the o-rings too. R134 operates at higher pressures and it won't be as efficient, so you have to be careful not to overcharge. Older condensors designed for R12 might not cut it.
Answer: I have done it before. I just replaced all the seals and o-rings, cleaned out all of the old oil and then refilled with r-134a. That's about it. I did it on an '86 Volvo 740 and it worked really well.
Answer: Probably a decade ago, I had a mechanic I trust do a conversion from R12 to R134 on a 1977 Cadillac I own. The conversion was necessary since the compressor locked up. He replaced the compressor, dryer, orifice tube, flushed the system. I queried him why he didn't replace the lines and o-rings. He replied it was not necessary. He said using the replacement old style compressor and condenser, it would not get as cold as it originally would, but it would be fine. Ten years later this seems to be the case. I haven't had a day in Georgia or Ohio where I felt like the A/C was insufficient.
On Grassroots Motorsports, I like this short list of things to do:
https://grassrootsmotorsports.com/forum/grm/duracool-or-r134a/23302/page1/

Borrow w/deposit vacuum pump from your FLAPS
Buy adjustable orifice tube ~30
Buy new dryer/accumulator
Buy oil and R134a from FLAPS
Drain old oil from compressor
Replace the accumulator/orifice tube
Vacuum down for an hour
Let it sit and make sure there are no further leaks
Charge up with R134a.

I have an RV that I plan to do this conversion on. It was down a bit, I have recharged it and tested it with R12a (propane). I have found the leak on the receiver. I plan on replacing the compressor just so I know all the R12 oil is gone. I believe I can successfully flush the rest of the system.


What's the actual or official definition of activation energy?

Question: In some sources I have seen that activation energy is the minimum energy required to cause a reaction. This implies that activation energy doesn't change with temperature (not considering very high changes).
In other sources it is the difference between the energy required to cause the reaction & the energy of the reactants. This implies that activation energy is temperature dependent since the energy of the reactants change with temperature. So which is correct?
Also another source (khan academy's guardian chemist) says that "The official definition of activation energy is a bit complicated and involves some calculus."
Answer: Activation Energy is the minimum amount of energy needed extra than the average potential energy of the reactants to cause a reaction.And it does not change with the change of temperature, and for clarification the energy of the reactant molecules don't also change with the reaction. It is just the rate which changes with the reaction according to the arrhenius equation k=Ae^{-\frac{Ea}{RT}}So,the fraction of molecules having energy higher than activation energy changes with change in temperature. I think the easier definition can be stated like this
Comment: The free energy of activation depends on temperature. Free energy has enthalpy and entropy components, and the entropy component is multiplied by the temperature.
Comment: The FREE ENERGY  ($\Delta$ G) and ACTIVATION ENERGY both are different.The FREE ENERGY  change is of total reaction but ACTIVATION ENERGY is only regarding min energy which is independent of temperature.  Don't combine them without any logic.. Think twice before adding comments and downvoting.
Comment: Actually both exist: there is the free energy of reaction ($\Delta G$) and also the free energy of activation ($\Delta G ^{\ddagger}$).
Comment: Free Energy (e.g. Gibbs) is different from Energy. The Arrhenius equation considers Energy and not Free Energy. In that regard, what you wrote is correct, Energy does not depend on temperature. However, free energy depends on temperature.


Does the thickness of insulation on the cooling pipe of an air contioner make a difference to preventing mould and condensation

Question: We have an apartment in Port Hedland WA.( Extreme humidity and heat)   It's  relatively new( 3 years old)  but there was mold all over the ceiling and along the walls following the air con pipes to the  out door unit.
 When we got it repaired   the repairman  said it was insulated with the wrong material.. He changed it to a thicker material. The builder said it was because the air con was a bit dirty and needs cleaning more frequently in hotter conditions. .
 I have pictures of before and after and can send so you can see what was before and what is now...  but would really like some input as to what caused the mold. any ideas..  ? Thanks
 liz
 Hope you can help  Liz
Comment: Hello, and welcome to Stack Exchange. Those pictures would be helpful; if you can include the actual pictures, edit in links to the pictures and someone will be along to edit the actual pictures into your question.
Answer: Yes, if it wasn't insulating nor tight to the pipe & therefore trapping & holding the condensation water. You basically had a very thick & long wet sock in the room that never dried.
Now that the correct insulation material & method has been employed. Completely spray & let soak for a few minutes & then sponge wash the moldy areas with a solution of 1-part Bleach to 3-parts water. Re-painting may be needed if the walls are on the darker side.
Answer: Please be aware Bleach does not kill mold.
https://www.normi.org/articles/bleach-mold.php
Moreover, pictures would greatly improve our chances to help you.  Things I would suggest you to look for is condensation in the ducts.  This can occur when there is a leak of cold air in the duct work.  This creates a heat exchange between the hot air outside in the duct work and the cold air inside the duct work.  This condensation can start dripping and generating moisture.  I would use a FLIR camera to detect moisture or heat around the duct work.  If you do have a leak you can apply foil tape and mastic to seal the leak.
Hope this helps.


Are cosmological distances additive?

Question: If we observe two galaxies that are diametrically opposed from the Earth, and each $1000\,{\rm ly}$ away from the Earth, is the separation distance between the galaxies $2000\,{\rm ly}$? Really the question is: if the galaxies were separated from Earth by $10\,{\rm Gly}$ each, then would their separation be $20\,{\rm Gly}$?
Answer: For nearby distances, yes, you can just add them up in the usual way. (Of course, if two galaxies are just a few thousand light-years apart, then they're right on top of each other -- galaxies are much bigger than 1000 light-years!)
For large distances (i.e., distances comparable to the Hubble length, as in your last example), you have to be careful. The best answer is that there is no unique, well-defined notion of distance over such large distances. On cosmological distances, spacetime is curved, and what that means is that there are no inertial reference frames covering these large distances. Different people may choose different (non-inertial) reference frames, and as a result they'll disagree about the distance, but no one is necessarily "right."
When people talk about the distance to a faraway galaxy, they most often mean distance as measured in a particular coordinate system, namely comoving coordinates, with distances evaluated at the present (cosmic) time. With that specific definition, the answer to your question is yes: two galaxies that are 10 Gly from earth in opposite directions are 20 Gly from each other.
Comment: Btw. @jormansandoval You might consider accepting Ted Bunns answer if you liked it, so he can get proper rep for it.
Comment: true. I put "1000ly" just do the question. but in reality the question is: if the above situation is true, someone who is in the galaxy "A", could see the galaxy, "B"?
Comment: The answer to that is that it depends! It depends on the distances you're talking about, and on when the observer is trying to look. In general, the maximum distance an observer can see at any given time depends not just on the age of the Universe at that time, but also on what the expansion rate was like as a function of time in the past. You can see further than you might naively expect (i.e., if the Universe is 14 Gyr old today, you can see further than 14 Gly), simply because, at the time the light left on its way to you, the distances were smaller.
Comment: (continuing ...) But it's certainly true that there are some objects so far away that we can't see them now. And it's possible to find a pair of galaxies, in opposite directions on the sky, that are visible from Earth but which are too far from each other to be visible to each other at the present time. To explore the relation between ages and distances, you might want to play around with Ned Wright's cosmology calculator, http://www.astro.ucla.edu/%7Ewright/CosmoCalc.html . To get the maximum distance you can see, plug in very large values of z (the maximum distance is really $z=\infty$).
Comment: In your last sentence, don't you mean that two galaxies  that each are 10 Glyr away from us in opposite directions are *20* Glye apart, not *10* Glyr apart...?

Are cosmological distances additive?


Partial sum square root of reciprocal of primes

Question: I would like to know if the following reasoning makes sense. I want to bound/estimate the following sum
$$
\sum_{p\leq x}\frac{1}{\sqrt{p}}
$$
Using integration by parts we have
\begin{align}
\sum_{p\leq x}\frac{1}{\sqrt{p}}&=\int_2^x \frac{1}{\sqrt{t}}\,d(\pi(t))\\
&=\left[\frac{\pi(t)}{\sqrt{t}}\right]_2^x+\frac{1}{2}\int_2^x\frac{\pi(t)}{t^{3/2}}\,dt\\
&=\frac{\pi(x)}{\sqrt{x}}+\frac{1}{2}\int_2^x\frac{\pi(t)}{t^{3/2}}\,dt
\end{align}
Now, using that by the PNT we have $\pi(x)\sim \dfrac{x}{\ln x}$, we get
$$
\sum_{p\leq x}\frac{1}{\sqrt{x}}\sim\frac{\sqrt{x}}{\ln x}+\frac{1}{2}\int_2^x\frac{1}{\sqrt{t}\ln t}\,dt
$$
On the other hand we have
$$
\int_2^x \frac{1}{\sqrt{t}\ln t}\,dt=\operatorname{Ei}\left(\frac{\ln x}{2}\right)-\operatorname{Ei}\left(\frac{\ln 2}{2}\right)\sim\operatorname{Ei}\left(\frac{\ln x}{2}\right)\sim\frac{2\sqrt{x}}{\ln x}
$$
which I got using wolframalpha. Hence I obtain
$$
\sum_{p\leq x}\frac{1}{\sqrt{p}}\sim \frac{2\sqrt{x}}{\ln x}
$$
Does it make sense? How could I prove the asymptotic for $\int_2^x\frac{1}{\sqrt{t}\ln t}\,dt$ without the need to refer to wolframalpha? Thank you!
Comment: One direction: you can lower bound the integral by replacing log t by log x and you get 2sqrt(x)/log(x). Now you can similarly fiddle around to get a good upper bound
Answer: If $\pi(x)$ is the number of primes not greater than $x$, then $\pi(x)$ is continuous from the right and the Riemann-Stieltjes integral over $[2, 2 + \epsilon]$ will tend to zero. The first equation should be
$$\sum_{p \leq x} \frac 1 {\sqrt p} =
\frac 1 {\sqrt 2} + \int_2^x \frac {d \pi(t)} {\sqrt t} =
\frac {\pi(x)} {\sqrt x} + \frac 1 2 \int_2^x \frac {\pi(t)} {t^{3/2}} dt.$$
To prove the asymptotic equivalence of the integrals, show that l'Hopital's rule applies. Then
$$\lim_{x \to \infty} \frac
 {\int_2^x t^{-3/2} \, \pi(t) \, dt} {\int_2^x t^{-1/2} \ln^{-1} t \, dt} =
\lim_{x \to \infty} \frac {x^{-3/2} \, \pi(x)} {x^{-1/2} \ln^{-1} x} = 1.$$
To estimate the integral in the denominator, apply integration by parts and l'Hopital's rule again:
$$\frac 1 2 \int_2^x \frac {dt} {\sqrt t \ln t} =
\frac {\sqrt t} {\ln t} \bigg\rvert_{t = 2}^x +
\int_2^x \frac {dt} {\sqrt t \ln^2 t} =
\frac {\sqrt x} {\ln x} + o {\left( \frac {\sqrt x} {\ln x} \right)}.$$
Therefore your final result is correct.
Comment: thank you! I have to go check what are the requirements to apply l'Hopital's rule :)


Shockwave flash for Ubuntu 16.04

Question: I had shockwave flash installed on Ubuntu 15.10 with Firefox.
Now I have updated to 16.04, it appears to no longer be available. Or at least I can't find it in the usual ways. I understand it is no longer updated, but where can I get the last version available?
Where is it to be found? Or should I re-install Ubuntu 15.10?
Comment: @DavidFoerster: Those are different topics. _Shockwave flash_ refers to the plugin, and an updated overview of Flash on Ubuntu is available on [this page](https://help.ubuntu.com/stable/ubuntu-help/net-install-flash.html).
Comment: Have you tried downloading it from the Adobe website? They have an APT package for Ubuntu.
Answer: Info

Q: The difference between the Adobe Shockwave and Flash Players?
A: Shockwave Player displays content created with Adobe Director 11.5
  software such as high-performance multiuser games, interactive 3D
  product simulations, online entertainment, and training applications.
  By using extensions, developers can extend the capabilities of
  Shockwave Player to play back custom-built applications.
Flash Player displays content created with Flash Professional CS5.
  This content includes web applications, website user interfaces,
  interactive online advertising, and rich Internet applications (RIAs)
  created using Flex.

Do you really need Shockwave or only Flash plugin?
the flash plugins is available for 16.04 Install Flash Player for Watching Video in Ubuntu 16.04 Xenial Xerus (LTS)
<code>sudo apt-get install ubuntu-restricted-extras
sudo apt-get install flashplugin-installer
</code>
Adobe Shockwave Player is not available anymore for Linux. It's obsolete. It doesn't work with modern browsers and operating systems.

The even list PowerPC based Macs. In 2006 Apple switched to Intel.
Comment: Thanks, it works now. I don' t know what I actually needed. The only message I got was "you need a plug-in to view this site".  No indication whatsoever as to which plugin is needed. I don't care whether it's fashionable or not, I just need to be able to view the site. Then comparing with a firefox that works on another computer, the only additional plugin i could see was shockwave flash.
Answer: Start by doing:   sudo apt purge --remove adobe-flashplugin flashplugin-installer pepperflashplugin-nonfree (to remove older versions of flashplugin and pepperflashplugin.
Then do:  sudo apt install browser-plugin-freshplayer-pepperflash .
If you get any message of a missing file or any error message, go to http://www.ubuntuupdates.org/adobe-flashplugin , select "adobe-flashplugin" 32 or 64-bit deb package and select to open it with "software install(default)". Softaware center will open on adobe-flashplugin page. Press install, then restart your browser and you are done.  I hope it helps !

Shockwave flash for Ubuntu 16.04


Bandwidth Aggregation with multiple 3G cards?

Question: I have multiple 3G data Cards as well as a wired connection to the Internet. I can connect each of them separately and access the internet. Is there any way i can aggregate the bandwidth of these cards to enjoy the combined speed? What i mean is simultaneously plugging in all the cards and getting the sum total of the bandwidth.
Answer: You could do this. Network Manager can do one connection per device just fine. But even with network-manager connected to multiple things, outbound traffic will only chose one gateway. You need to bridge these gateways into a virtual tunnel and use that as the gateway.
The problem is all the machinery is there (iptables, ipchains, iproute2, etc) is somewhat lower-level than network manager. You can try and follow a guide showing example configuration to split traffic over multiple gateways but network-manager might end up getting in the way.
It might not. It might work out just fine. You won't know until you've poked it ;)
Comment: imho network-manager will only get in the way when the network interfaces bounce if he uses the load balancing method from your link.  my understanding of nm breaking things is the route table mangling it does when links bounce.  if it doesn't remove the multiroute component when an interface goes down, you'll just get proportional packet loss.  one additional note: he might want to change the weight values to map to available bandwidth more correctly.  if he switched to wicd postup and postdown scripts could be added to fix the multiroute.
Comment: +1 - this is the right solution. it just requires some tweaking
Answer: No, you can't aggregate multiple data cards out-of-the-box.
You need to buy a device that does link aggregation(802.3ad protocol).
Comment: Link aggregation is not the right subject for this problem. LA is binding two cables going both going from A to B in order to handle more bandwidth. *This* problem is binding A's separate links to B and C together.
Answer: In my opinion you cant.Because you can not make your network manager connect to multiple lines at the same time..
Comment: I have two wireless and a wired adapter plugged in now. I can connect to three different networks just fine in network-manager.
Comment: ohh is it..You should get 3 ips in that case isnt it ??
Comment: Yeah you would.
Comment: If my understanding of the subject is correct, i will get three separate IP's on the three interfaces ( provided i have 2 wireless and 1 wired ) but only one outbound gateway will be chosen and hence there will be no bandwidth aggregation. Am i right? so is there a consensus that i need to bridge that into a tunnel and use that as gateway.
Answer: You need to "bridge" multiple connections into one. While I've never done it on Ubuntu myself, the following guides seem to have directions for it:

https://help.ubuntu.com/community/BridgingNetworkInterfaces
https://help.ubuntu.com/community/NetworkConnectionBridge
Answer: You can configure Linux routing to use more than one gateway easily.
The more problematic part is that if one of the gateways is down, you want your machine to stop using it and start again once it's up.
I have once written a script that does it (only for wireless connections).
You can see torrent working and utilizing 3 different wifi internet connections here:

If you want to get the script to understand what commands I used or try running it see:
https://sourceforge.net/projects/powernet/
The first versions have just the configuration commands, the later versions stop using a connection if the gateway of that connection cannot be reached and retry after some time.
Expect newbie coding quality., I was just studying bash at that time.
Edit(link change and more explanation): As I see people get confused over "binding" connections and "load balancing" connections. When you are connected to more than one network and each has it's own "gateway" your system by default uses only one of them (usually the last one you connected to).
Powernet configures the routing table to "round-robin" over the available gateways so for example, each connection will go over different gateway/link.
Single connection will only be as fast as the gateway it uses but multiple connections will be as fast total speed of all the gateways combined.
Side effect: You can enter website from one IP and after sometime your IP will change (as you now use different gateway) and it may drive some sites crazy.
This is not "bonding" and this technique does not require special ISP support. It can work if you just have more than one Internet connection available.
Comment: Link fixed to sourceforge. The original website is no longer maintained.
Comment: powernet link is broken


What is this mobile bottom sheet UI element called?

Question: I want to communicate the implementation of this kind of bottom sheet to developers, specifically how it's a tall bottom sheet, but you can still see the background minimized underneath. What is this called?
Answer: Sheet, bottom sheet, bottom drawer, bottom modal sheet. Depending on who is more familiar with what system/nomenclature it may vary. I would recommend making very simple prototype that you can show off if you aim for a specific behaviour.
Personally, if the sheet is covering so much that you no longer can tell what is behind it then should be a full screen page. You can get over with a lot of content showing only part of it initially (if it makes sense for particular situation), and then allowing to expand the sheet to the full screen.
Here is an example from material design.
https://material.io/components/sheets-bottom#behavior
Answer: This is according to iOS, a Sheet

A sheet helps people perform a distinct task that's related to the parent view without taking them away from their current context.

A sheet appears as a card that partially covers the underlying content. The card's top corners are rounded to visually distinguish it from the parent view.

Similar to your example, the parent view is still visible in the background.
Comment: Thank you! I would use it also in Android but in the HIG i didn't find any size for the UI. I would like to replicate it in Figma.


Three-phase circuit breaker trip current

Question: If a three-phase circuit breaker is specified as, for example, a 32 A breaker, does this mean the breaker will trip when the current in a single phase exceeds 32 A, or when the total current of all three phases combined exceed 32 A?
Answer: If you are talking about general purpose 3 Phase breakers, they are 3 individual breakers mechanically coupled to ensure an overcurrent on any one phase will trip all 3.
If you have a 32A breaker, then the instantaneous trip current is far above 32A. The standards typically classify the trip point at 0.1 seconds. For current at the rating the trip time may never occur, or may occur in hundreds of hours (usually temperature sensitive).
This article will talk you through the trip characteristics.
Typical residential applications use Class B or C breakers.
Class B breaks instantaneously (<0.1s) at 3-5 times rated current.
Class C breaks instantaneously (<0.1s) at 5-10 times rated current.
Answer: A 32 amp three-phase breaker should effectively be three 32 amp breakers in one box. All three phases should operate together.
It should open all phases if the current in any phase exceeds 32 amps.


Manager-Employee Relationship?

Question: I am an employee at a retail store, and my manager and I have been flirting for a while now, and we're definitely attracted to each other. He isn't the store manager, he's just over customer service. There is nothing in our company policy preventing it, but I don't want things to be weird between us if its not allowed. Would it be inappropriate for me to ask him on a date? I don't know if the whole manager thing would cause a problem.
Comment: SUggest you read this http://workplace.stackexchange.com/questions/8701/why-are-romantic-relationships-with-someone-who-works-under-you-discouraged/8702#8702
Comment: I don't think we can give you an answer as it is more opinion based. Although if there is nothing in your company policy that is keeping you from dating him, just go for it
Comment: Related, but the fact that he is your manager makes it not a duplicate: [How to have a relationship with someone at the office?](https://workplace.stackexchange.com/questions/50238/how-to-have-a-relationship-with-someone-at-the-office)
Comment: @DavidK ermagerd! Someone who actually reads the duplicates!  I though you were like unicorns!  :)
Comment: @ChristopherEstep Depends on my mood - I've certainly been guilty of "Yeah, title's the same. Duplicate."
Answer: It's rare that romantic relationships work out when the workplace is involved, in my personal experience. The first thing you have to consider is "what happens if the relationship ends horribly?" and that's usually why they don't work.
Having said that, it's not uncommon for people to date from the workplace. It's one of those "caveat emptor" situations. Just be aware that if things go horribly, you may need to find work, voluntarily or involuntarily.
And if it does go long-term, you probably would want to find other work anyway (at least in another store) so you don't have to worry about personal issues bleeding over into the workplace.
Do what you feel as long as you're aware that it could all end horribly.  No risk, no gain.
Comment: Right, I'm not suggesting a conflict so much as an awareness of the potential complications if things end. It could be anywhere from friendly to awkward to completely horrible, affecting day-to-day work.
Comment: There's no conflict of interests here, so I'd say go for it (and good luck!).  Just make sure he's single though - guys can be jerks at work sometimes.
Answer: I'd be careful about something like this. You say your company has no policy against it, but many do precisely because it can cause all sorts of problems.
Namely, (a) Even if you try to keep the relationship secret, sooner or later co-workers will figure it out. And then there will be accusations of favoritism, whether they are justified or not.
And (b) If the relationship goes sour, you may find yourself working for someone who has hard feelings toward you.
On the other hand, if you think this has the potential to be the love of your life, do you want to miss the opportunity because of the risks of problems at work? That's not a rhetorical question: you could give a serious answer either way.
Personally, if I was interested in a girl I worked with, and it was of the, "She's kinda pretty and seems nice, maybe I should ask her out", I probably wouldn't do it. Not worth it. But if it was, "Wow, this is the girl of my dreams, I want to spend my life with her forever", I probably would and accept the risks. I think it all comes down to, If you had to give up your job to pursue this relationship, would you think it was worth it? If your answer is yes, I'd say go for it. If your answer is no, then probably best let it pass. Of course if you haven't even gone on one date yet, you probably don't know if it will turn out to be worth it.
Answer: This answer expands on that given by @Christopher Estep, specifically:

And if it does go long-term, you probably would want to find other work anyway.

Another reason why a long term couple should not work together is to protect their joint finances. If the company goes bust then the pair of you have lost your income. Whereas if you 2 work for 2 different employers, then there is still a source of income for the pair of you.

Manager-Employee Relationship?


Why does paper become uneven when soaked and dried?

Question: Pouring water on a small part of sheet of paper and then drying it makes it uneven, it gets a wave like appearance and seems to have become larger in size.   Why?
Answer: Paper is made of many, many tiny fibers. When you wet a piece of paper, those fibers absorb water and swell up. As they dry, the relaxed fibers don't go back to exactly where they started. Some will have shifted or "untangled", moving out of the plane of the original paper. So yes, the paper actually does become slightly bigger because the fibers have stretched.
Comment: i learnt that paper consist of CHO- bonds and when water is poured on it due to its high dielectric constant it weakens CHO- bonds. when dried bonds are formed but are not orderly. they cant regain their shape due to presence of starch. how far is this true?


Create EC2 instance without starting

Question: I would like to create some EC2 instance, but before it starts do some stuff using instance ID generated for this instance. Is there any option in aws ec2 run-instances or another aws ec2 command for creating an AWS EC2 instance without starting it? A workaround would be generating UUID to tag this instance and associate this UUID instead of instance ID, or stopping just after run instance, but I would prefer some smarter solution.
Comment: What do you mean by by "do some stuff"? The right way to act on the instance before it is fully operational is to give the instance some [userdata](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html). If you really want your instance to remain shutdown and start with the right datas, you can prepare an `EBS` volume on another instance and attach it to the one booting but I would not recommend that, userdatas is the way to go.
Comment: @iMil by "do some stuff" I mean create some resources which will be used by the instance. I can set them up if they do not exist in `/etc/rc.local`, but I this makes more conditional code. I know how user data works, but I can't see how it could help me with doing some action on instance starts existing event but before it starts working. I want to be able to reset an instance and don't create the resources again.
Comment: Actually what you're trying to do is exactly what userdatas are for, they are executed way before `rc.local` and in fact before your Linux system enters the multi-user stage. Another option would be to create an AMI (for example using [packer](https://www.packer.io/)) that would setup what you need to at the instance creation. And btw, packer do start an instance in order to build the AMI :)
Comment: @iMil: I just paid attention to the part of user-data docs telling about running with instance launch, tried your suggestion and it solved my actual issue. why didn't you post it as an answer?
Comment: Great! will do :)
Answer: There is no option under EC2 to create an instance without starting it. Once you create an instance it will automatically will move from pending to running state
Docs -
http://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html
Answer: So as I was telling to @pt12lol in the comments, this is exactly what userdata is for.
From Amazon's documentation:
When you launch an instance in Amazon EC2, you have the option of passing user data to the instance that can be used to perform common automated configuration tasks and even run scripts after the instance starts. You can pass two types of user data to Amazon EC2: shell scripts and cloud-init directives. You can also pass this data into the launch wizard as plain text, as a file (this is useful for launching instances via the command line tools), or as base64-encoded text (for API calls).
User-datas can be passed to the instance at creation time, for instance using the --user-data flag in the aws cli or the Userdata text box in AWS console.
Comment: This is most applicable solution for the question.
_

Create EC2 instance without starting


The direction of net force in circular motion

Question:
The small ball attached by a thin string is in uniform circular motion as shown in the picture (vertical plane). There are two forces acting on the ball, Gravitational force $F_g$ and Tension force from the string $F_T$, and the direction of these two forces are as shown. I've learned that the direction of acceleration is pointed to the center of the circle, so does the net force. But The net force F$_{net}$ I got is shown in the picture, What did I miss?
Comment: The force points to the center when the speed around the circle is *constant*. That is not the case for vertical circular motion - it is slower on top and faster on the bottom.
Comment: So it will never be uniform vertical circular motion?  @MariusLadegårdMeyer
Answer: For uniform circular motion, acceleration and force are directed toward the center.
Here you have another component. The ball will slow as it rises on the circular trajectory. On the other side, it will speed up.
As the speed varies, the component of force and acceleration toward the center will vary. $a_{r}$ must be $v^2/r$ for the path to be circular. As long as the ball rotates fast enough to keep tension in the string, the string will exert enough force to keep the path circular. That is, the tension in the string will adjust itself so that $F_r = mv^2/r$.
In short, there is always a radial component of force in circular motion. The total force may or may not be directed toward the center.
Comment: Is there a special case where "always" fails when at the top of the circle, the tension is zero and mg supplies the radial force (for zero time…)?
Comment: @jeb, I don't see how that fails.   The statement says there is a net force with at least some component that is radial.   In your statement, $mg$ supplies that force.
Comment: @BowlOfRed yes.
Answer:
I've learned that the direction of acceleration is pointed to the
center of the circle, so does the net force. But The net force
F$_{net}$ I got is shown in the picture, What did I miss?

The net force doesn't point to the center of the circle. The centripetal force responsible for the centripetal acceleration does. Only in the case of uniform (constant speed) circular motion does the net force point to the center.
For non uniform circular motion  (which this is) the centripetal force is one of the components of the net force. But there is also a tangential force responsible for the change in speed (tangential acceleration) of the ball. That is the  other component of the net force. Both components of the net force are changing in time.
For a complete analysis of how to determine the speed at various positions, and thus the centripetal force, see: http://hyperphysics.phy-astr.gsu.edu/hbase/Mechanics/cirvert.html
Hope this helps.


Load a different theme for IE less than 9

Question: I want to load a different theme for those users who still use IE 6 - 7 - and 8
any plugin or code?
Comment: Don't forget to set `Cache-Control: private` because you have to break every other cache to make browser sniffing work. It would better tough just to learn CSS. ;)
Answer: Drop this inside a plugin:
add_filter('template', function($template){

  // could be IE
  if(preg_match('/MSIE [1-9]/i', $_SERVER['HTTP_USER_AGENT']))
    return 'your_ie_theme_name';

  // other
  return $template;

});

Just so you know, browser detection trough PHP is not really that accurate. There's a get_browser() function available PHP, not sure if it's any better though.


TextBoxFor model incrementing dynamically in a loop

Question: I am building a web application for working out. When a work out day loads, it displays a FORM that has a series of text boxes for each exercise to record the amount of repetitions and the weight done for each set. Each exercise requires a different amount of sets.
I created a class that holds two object types, a list of exercises from an ExerciseReference entity class/database table, and an entity class for recording the data that the user enters into the form and submits.
My model looks like this:
public class ExerciseListModel
{
    public List<ExerciseRef> exercises { get; set; }
    public ExerciseREC recordedExercises { get; set; }
}

When building the Reps and Weights text boxes for each exercise, my Razor HTML looks similar to this:
 @foreach(ExerciseRef item in Model.exercises)
        {

@item.Name.ToString()

@item.Description.ToString()

                for (int i = 0; i < item.NumberOfSets; i++)
                {
                   <text>Set #: </text> @(i + 1)

                   <text>REPS: </text> @Html.TextBoxFor(m => m.recordedExercises.Set1Reps)

                   <text>WEIGHT: </text> @Html.TextBoxFor(m => m.recordedExercises.Set1Weight)

                }

        }

So essentially, this is a for loop within a foreach loop. The foreach loop builds the HTML list of all of the exercises, while the for loop builds the text boxes for reps and weights.
I need the number in Set1Reps in the following line:
 @Html.TextBoxFor(m => m.recordedExercises.Set1Reps)

To be dynamic and increment with the loop. I need it to have Set1Reps for Set 1, and change to Set2Reps for Set 2, and so on and so forth.
Any idea how I could go about doing that?
Answer: I would change your data model to contain sets and reps as collections on the recordedExcercises property.  Then, you can iterate over them like you are iterating over the entire collection of exercises.


How do I get paid for my photography?

Question: I am an amateur photographer who doesn't even own a DSLR. But, I do have a good collection of mobile photgraphy (mainly nature photography) and would like to sell them. Are there any magazines (or anything else) that would be willing to pay me for my work (if they think it's good enough)?
Comment: I suggest reading [How can I make extra money with photography?](https://photo.stackexchange.com/questions/11417/how-can-i-make-extra-money-with-photography) - if you still have questions after reading that, please edit your question to be specific about exactly what you want to know. But the tl;dr is "nobody's going to pay you more than a pittance".
Comment: @PhilipKendall I'd also add that with the rise of AI generated art, the bottom is going to fall out of the stock photography market.  IMHO The only way forward is event photography such as weddings, or high end art (as long as you can prove that it wasn't AI generated)
Comment: Just because in your own opinion you have great snapshots does not mean you can compete with experts in a crowded market place. Your shots must be very good when compared with the competition, in both composition and technical quality.
Comment: Does this answer your question? [How can I make extra money with photography?](https://photo.stackexchange.com/questions/11417/how-can-i-make-extra-money-with-photography)
Answer: To put into perspective the challenge
I spent 4 years apprenticed to a master photographer before I went into business. I didn't realize it at the time, but it would take me a further 6 years to progress enough that I can look back on my work at the time as reliably and consistently delivering value to my clients.
At that time, there were no cell phones and no digital cameras, so the barrier to entry to photography in general was much higher. Today, practically anybody can take a "good" picture by sheer luck (you can take thousands of pictures for the cost of a single frame of film). As a result, the supply has greatly increased. To stand out in this market you need to be even better and now you have to compete with AI generated art as well.
You may also find that many (most?) publications will have technical specifications for submission that you cannot meet with a phone.
All that being said
As a self-professed amateur, your best bet is probably to not worry about getting paid yet and just focus on developing your own skills. Push you cell phone as far as it can go, then invest in some better equipment once you can't progress any further without it. (You can learn a tremendous amount without a DSLR or mirrorless, but there is still a fairly low ceiling compared to what you can learn with one.)
If you do have anything that is really good, your best outlet is most likely submitting it to an online source for fine art on demand or a higher cost options is to print and place it for sale directly (many coffee shops and similar venues will sell artwork on commission). But don't get your hopes up too high in either situation.
It is also possible to sell work if you submit it to some competitions, with the added benefit of getting feedback on your work.
Finally
You also need to consider that the Dunning-Kruger Effect may be (probably is) at play. Every photographer goes through a period where they have progressed enough to recognize their own improvement, but not yet learned enough to realize just how much they have yet to learn. During this period the self-assessment of their work is wildly skewed. To overcome this, seek out experts in photography who can give you an honest (even brutal) assessment of your work. Your peers are ill-equipped to provide meaningful feedback.
Don't let any of this discourage you. My mentor gave me the same talk when I first came to him for advice on selling my amateur work and—though I didn't like hearing it—it made it possible for me to truly start to grow as a photographer to the point where I could make it my full time living for nearly 25 years.
Comment: An additional venue to sell things is to get a stall at your local art market
Comment: @PeterM, very true, but I didn't mention it because that is likely a much bigger initial investment for OP. It's very difficult to sell prints for later delivery at an art market, so in addition to the stall rental, a variety of artwork in various sizes would likely be required. Even ready to frame (print and matte only) rather than framed could easily run into the $1000's.
Answer: The most important thing about selling photography is that you have to want to sell photography more than almost anything in the world.
Give up on the idea of selling fine art prints. If you want to be paid for photography you have to provide the photography people will pay for.
Anyone can take perfectly good photos with a phone or camera. You have to zealously market yourself, spend 99% of your time trying to sell. You have to withstand rejection from most people you approach.
What needs to be photographed? Obviously weddings and other life-events. Unfortunately you need a lot of equipment and skill to do it. Call every wedding photographer in your town and ask to be hired as an assistant.
Real Estate. Every house and apartment that is sold needs photos of every room. This is much simpler than weddings as all you need is a camera and a flash. Call every real estate agent in town and offer your services. If they say they have someone, call them and ask to be hired as an assistant.
You get the picture.
And, back to selling your photos: Contact every photography gallery, arts group, exhibition promoter, contest promoter in the entire country and find out how to enter photos. Make sure you follow format rules and enter all of them. You might win a prize.
Comment: In a nutshell: "_If you want to be paid for photography you have to provide the photography people will pay for._"

How do I get paid for my photography?


Should methods be inside classes? in Ruby

Question: I have coded more in Python but I am learning Ruby now. So I am trying to write a solution to create a family_tree and add and get relationships. The code below is of the file that contains the main function which is called from the command line. The below code works and solves the problem but I have written methods without classes. In python it is acceptable. Is is acceptable in ruby? Even though the code works is this how it is written in Ruby? Or does this need refactoring? If yes then please tell how?
#main_file.rb
require_relative 'family'
require_relative 'family_tree'
include FamilyTree
require_relative 'constants'
require_relative 'errors'

def is_valid_input(command)
  #User input Validation
  commands = command.split(' ')
  return false unless (commands && INPUT_FUNCTION_MAPPER.key?(commands[0]))
  return false if (commands[0] == "ADD_CHILD" && commands.length != 4)
  return true
end

def create_family_tree(family_tree)
  #Initializing the family
  family_name = family_tree[:name]
  members = family_tree[:members]

  family = Family.new(family_name)
  members.each do |name, gender, mother_name|
    family.add_member(name, gender, mother_name)
  end
  family
end

def execute_command(command, family)
  result = nil
  unless is_valid_input(command)
    raise InvalidParametersError, "Command is not valid"
  end
  command = command.split(" ")
  if command[0] == "ADD_CHILD"
    mother, name, gender = command[1..]
    result = family.add_member(name, gender, mother)
  end
  result
end

def main_method
  if ARGV.length != 1
    raise InvalidParametersError, "Please provide an input file"
  end
  input_file = ARGV[0]
  unless File.file?(input_file)
    raise InvalidParametersError, "Input file does not exist"
  end

  family = create_family_tree(FAMILYTREE)
  File.readlines(input_file).each do |line|
    line = line.strip
    puts execute_command(line, family)
  end
end

main_method()

This is executed as below:
ruby main_file.rb input.txt

Comment: A small thing caught my eye: the last three lines of the body of `is_valid_input?` would normally be written `commands && INPUT_FUNCTION_MAPPER.key?(commands[0])) && (commands[0] != "ADD_CHILD" || commands.length == 4)` (or the logical equivalent).
Answer: This "global function" style works for small scripts but isn't reusable.
A more practical problem with it is if you want to have state that is shared between functions, you don't have anywhere to store it (well, you could use global variables ($var), but that's prone to conflicts).
For a more encapsulated design, create a class that does the work and move the methods into the class. See for example definition and usage.


How do I start tmux with N equally-sized, vertically-split panes given an arbitrary list of startup directories?

Question: I want a shell script that will launch tmux with N equally-sized, vertically-split panes, each with its own starting directory, where N is determined by the number of starting directories specified. For example,
tmux-launch SESSION-NAME DIR1 DIR2 DIR3 ...

It would be very useful to be able to provide an intial command(s) corresponding to each starting directory. For example,
tmux-launch SESSION-NAME DIR1:"CMD1" DIR2:"CMD2" DIR3:"CMD3" ...

Answer: Here is a script I wrote to do this. Save it as tmux-launch.sh (chmod +x tmux-launch.sh):
#!/bin/bash

if [[ -z $2 ]]; then
    current=$(tmux display -p "#S")
    cat<<EOF

USAGE: $(basename $0) SESSION DIR [DIR] ...

        [DIR]   one or more startup directories; at least one is required

EOF
    if [[ -n $current ]]; then
        echo "current session: $current"
    fi
    exit 1
else
    session="$1"
    shift
fi

# start tmux
tmux new-session -s $session -d

args=( "$@" )

i=1
for e; do

    # capture directory and optional command from $e
    d=$(echo $e | cut -d: -f1)
    c=$(echo $e | cut -d: -f2)

    if [ ! -d $d ]; then
        echo WARNING: directory does not exist, $d >&2
        continue
    fi

    # Select pane $i, set dir to $d, run pwd
    if [ $i -gt 1 ]; then
        tmux split-window
    fi
    tmux select-pane -t $i
    tmux send-keys "cd $d" C-m
    if [ -n "$c" ]; then
        # execute optional command
        tmux send-keys "$c" C-m
    fi

    # equally-spaces
    tmux select-layout even-vertical

    i=$(expr $i + 1)

done

# Finished setup, attach to the tmux session!
tmux attach-session -t $session

For example, the following usage will launch a tmux session named "work" with five panes, each starting in a unique directory, and execute the pwd command in each pane  and echo tada command in the first (of course this exmple assumes that the ~/scratch* directories exist):
tmux-launch.sh work ~/scratch1:"pwd;echo tada" \
                    missing-directory:"echo do nothing" \
                    ~/scratch2:pwd ~/scratch3:pwd ~/scratch4:pwd ~/scratch5:pwd

This tool will skip any non-existent directory, and print a warning to stderr.
I've testing this on Red Hat Enterprise Linux and SUSE Linux Enterprise Server distros using tmux versions 2.7, 3.1c, 3.2a and 3.3.
EDIT 2024-03-02: A more complicated edition of the script described above is found here. This extended script provides some additional options, including horizontal split and tiled layouts.
EDIT 2024-03-04: This script assumes that your tmux configuration begins with pane number 1 instead of the default 0. For example, in my ~/.tmux.conf:
# Set the base-index to 1 rather than 0
set -g base-index 1
set-window-option -g pane-base-index 1


How do I find a right flash not to get red eyes?

Question: How do I find a right flash not to get red eyes?
I did try all options.
Comment: What exactly have you tried? Red-eye is caused by having the flash coming from close to the camera - if you move the flash off-camera or bounce it off something, you shouldn't get red-eye.
Answer: Red eye is caused by the flash being to close to the optical axis of the photo.  The way to remove red eye is to move the flash away from the lens.  This can either be done by bouncing the flash off a wall/ceiling or by physically moving the flash using a cable or a wireless remote trigger device.
I've not seen this with an external flash unit however and there's not really a lot you can do to the pop-up with out killing what little power it has.  Maybe try a bit of card to bounce it off a wall?


Proof for $\sin(x) > x - \frac{x^3}{3!}$

Question: They are asking me to prove $$\sin(x) > x - \frac{x^3}{3!},\; \text{for} \, x \, \in \, \mathbb{R}_{+}^{*}.$$ I didn't understand how to approach this kind of problem so here is how I tried:
$\sin(x) + x -\frac{x^3}{6} > 0 \\$
then I computed the derivative of that function to determine the critical points. So:
$\left(\sin(x) + x -\frac{x^3}{6}\right)' = \cos(x) -1 + \frac{x^2}{2} \\ $
The critical points:
$\cos(x) -1 + \frac{x^2}{2} =  0 \\ $
It seems that x = 0 is a critical point.
Since $\left(\cos(x) -1 + \frac{x^2}{2}\right)' =  -\sin(x) + x \\ $
and $-\sin(0) + 0 = 0 \\$
The function has no local minima and maxima. Since the derivative of the function is positive, the function is strictly increasing so the lowest value is f(0).
Since f(0) = 0 and 0 > 0 I proved that $ \sin(x) + x -\frac{x^3}{6} > 0$. I'm not sure if this solution is right. And, in general, how do you tackle this kind of problems?
Comment: There's one tiny little mistake in your approach, namely that $0>0$ isn't exactly true (but is $0\in\mathbb{R}^+$ true?). What immediately comes to mind is the [Taylor series expansion of $\sin(x)$](http://en.wikipedia.org/wiki/Sine#Series_definition) in this situation.
Comment: sorry, forgot to specify that `x` should belog to $ R_{+}^{*}$
Comment: Possible duplicate of [Prove that $x - \frac{x^3}{3!} < \sin x < x$ for all $x>0$](https://math.stackexchange.com/questions/390899/prove-that-x-fracx33-sin-x-x-for-all-x0)
Comment: Of possible historical interest are the references in [this answer](https://math.stackexchange.com/a/2780697/13130).
Answer: A standard approach is to let $f(x)=\sin x-\left(x-\frac{x^3}{3!}\right)$, and to show that $f(x)\gt 0$ if $x\gt 0$.
Note that $f(0)=0$. We will be finished if we can show that $f(x)$ is increasing in the interval $(0,\infty)$.
Note that $f'(x)=\cos x-1+\frac{x^2}{2!}$. We will be finished if we can show that $f'(x)\gt 0$ in the interval $(0,\infty)$.
Note that $f'(0)=0$. We will be finished if we can show that $f'(x)$ is increasing in $(0,\infty)$.
So we will be finished if we can prove that $f''(x)\gt 0$ in the interval $(0,\infty)$.
We have $f''(x)=-\sin x+x$. Since $f''(0)=0$, we will be finished if we can show that $f'''(x)\ge 0$ on $(0,\infty)$, with equality only at isolated points. This is true.
Or else for the last step  we can use the geometrically evident fact that $\frac{\sin x}{x}\lt 1$ if $x\gt 0$.
Remark: It is more attractive to integrate than to differentiate, but we used the above approach because differentiation comes before integration in most calculus courses.
For the integration approach, let $x$ be positive. Since $\sin t\lt t$ on $(0,x)$, we have $\int_0^x (t-\sin t)\,dt\gt 0$. Integrate. We get $\cos x+\frac{x^2}{2}-1\gt 0$ (Mean Value Theorem for integrals), so $\cos t+\frac{t^2}{2}-1\gt 0$ if $t\gt 0$.
Integrate from $0$ to $x$. We get $\sin x+\frac{x^3}{3!}-x\gt 0$, or equivalently $\sin x\gt x-\frac{x^3}{3!}$. Nicer, by a lot.
Answer: Take a decreasing sequence of positive real numbers $a_n$ such that $a_n\to 0$.
Now, consider the sequence $b_k=\sum_{n=1}^k (-1)^{n-1}a_n$. The alternating series criterion guarantee us that it converges to some $b$.
Note that $b_1=a_1$, $b_2=b_1-a_2\in(0,b_1)$, $b_3=b_2+a_3\in(b_2,b_1)$, etc. So the limit $b$ is lesser that the terms $b_{2k+1}$ and greater than $b_{2k}$.
Then, if $x<\sqrt 6$,
$$\sin x=\sum_{n=1}^\infty(-1)^{n-1} \frac{x^{2n-1}}{(2n-1)!}>\sum_{n=1}^2(-1)^{n-1} \frac{x^{2n-1}}{(2n-1)!}=x-\frac{x^3}{3!}$$
If $x\geq\sqrt 6$, the function $f(x)=x-x^3/6$ is decreasing and $f(\sqrt 6)=0$, so $f(x)<0$ for $x>\sqrt 6$. Since $\sin x>0$ for $0<x<\pi$, we have that $\sin x>f(x)$ for $0<x<\pi$. (Note that $\sqrt 6<\pi$).
Last, for $x\geq \pi$, $\sin x\geq -1$ and $f(x)<f(\pi)<f(3)=3-4.5<-1$.
Comment: There is a caveat which this answer does not address. The sequence $$a_n=\frac{x^{2n-1}}{(2n-1)!}$$ needs not be decreasing. For example, for $x=100$ one has $$a_n=\left(100, \frac{10^6}{6}, \frac{10^{10}}{120},\ldots\right).$$The sequence becomes decreasing *eventually*, but it is not obvious that you can apply your reasoning.
Comment: @Giuseppe Thanks. I hope this fixes the caveat.
Comment: Sorry I had forgot to come back here. I see your edit now. It is perfectly fine to me (Minus an extremely small detail: you should turn the line "Then, for $x<\sqrt{6}$..." into "Then, for $0<x<\sqrt{6}$...". For $x=0$ strict inequality does not hold. Good solution, BTW.
Answer: You just have to prove your inequality when $x\in(0,\pi)$, since otherwise the RHS is below $-1$. Consider that for any $x\in(0,\pi/2)$,
$$ \sin^2 x < x^2 \tag{1}$$
by the concavity of the sine function. By setting $x=y/2$, $(1)$ gives:
$$ \forall y\in(0,\pi),\qquad \frac{1-\cos y}{2}<\frac{y^2}{4}\tag{2}, $$
so:
$$ \cos y > 1-\frac{y^2}{2} \tag{3} $$
for any $y\in(0,\pi)$. By integrating $(3)$ with respect to $y$ over $(0,x)$ we get our inequality.
Answer: Observe that:
$\\ \\ \displaystyle \sin(3\gamma)=\sin(2\gamma)\cos(\gamma)+\sin(\gamma)\cos(2\gamma)=2\sin(\gamma)\cos^2(\gamma)+\sin(\gamma)(1-2\sin^2(\gamma))=2\sin(\gamma)(1-\sin^2\gamma)+\sin(\gamma)(1-2\sin^2(\gamma))=3\sin(\gamma)-4\sin^3(\gamma)\Rightarrow \sin^3(\gamma)=\frac{1}{4}\left(3\sin(\gamma)-\sin(3\gamma)\right)$
\begin{equation}
    \sin^3(\gamma)=\frac{1}{4}\left(3\sin(\gamma)-\sin(3\gamma)\right)
\end{equation}
Do it $\displaystyle \gamma=\frac{\phi}{3^k}$:
\begin{equation}
    \sin^3\left(\frac{\phi}{3^k}\right)=\frac{1}{4}\left(3\sin\left(\frac{\phi}{3^k}\right)-\sin\left(\frac{\phi}{3^{k-1}}\right)\right)
\end{equation}
Multiplying by $\displaystyle 3^{k-1}$:
\begin{equation}
    3^{k-1}\sin^3\left(\frac{\phi}{3^k}\right)=\frac{1}{4}\left(3^{k}\sin\left(\frac{\phi}{3^k}\right)-3^{k-1}\sin\left(\frac{\phi}{3^{k-1}}\right)\right)
\end{equation}
Applying summation on both sides of equality, we will have:
$\\ \\ \displaystyle \sum_{k=1}^{n}3^{k-1}\sin^3\left(\frac{\phi}{3^k}\right)=\sum_{k=1}^{n}\frac{1}{4}\left(3^{k}\sin\left(\frac{\phi}{3^k}\right)-3^{k-1}\sin\left(\frac{\phi}{3^{k-1}}\right)\right) =\frac{1}{4}\left(3^{n}\sin\left(\frac{\phi}{3^n}\right)-\sin(\phi)\right)\Rightarrow \sum_{k=1}^{n}3^{k-1}\sin^3\left(\frac{\phi}{3^k}\right)=\frac{1}{4}\left(3^{n}\sin\left(\frac{\phi}{3^n}\right)-\sin(\phi)\right)\\ \\$
Take the limit:
\begin{equation*}
        \lim_{n\rightarrow \infty}\sum_{k=1}^{n}3^{k-1}\sin^{3}\left(\frac{\phi}{3^{k}}\right)=\frac{1}{4}\left(\phi-\sin(\phi)\right)
\end{equation*}
On the other hand, using the inequality $ \displaystyle \sin x \leq x $ and  using the infinite  geometric progression formula, it follows that:
$\\ \displaystyle \sin\left(\frac{\phi}{3^{k}}\right) \leq \frac{\phi}{3^{k}}\Rightarrow \sin^{3}\left(\frac{\phi}{3^{k}}\right) \leq \frac{\phi^3}{3^{3k}} \Rightarrow 3^{k-1}\sin^{3}\left(\frac{\phi}{3^{k}}\right) \leq \frac{\phi^3}{3^{2k+1}}\Rightarrow  \sum_{k=1}^{\infty}3^{k-1}\sin^{3}\left(\frac{\phi}{3^{k}}\right) \leq \sum_{k=1}^{\infty} \frac{\phi^3}{3^{2k+1}}=\frac{\phi^3}{3}\sum_{k=1}^{\infty} \frac{1}{3^{2k}}=\frac{\phi^3}{3\times 8}\Rightarrow \sum_{k=1}^{\infty}3^{k-1}\sin^{3}\left(\frac{\phi}{3^{k}}\right) \leq \frac{\phi^3}{3\times 8} \Rightarrow \frac{1}{4}\left(\phi-\sin(\phi)\right) \leq \frac{\phi^3}{3\times 8} \Rightarrow \phi-\frac{\phi^3}{6}\leq \sin(\phi) $
Comment: A nice approach
Comment: thank s for your comment @Yuri
Answer: (This started as a comment, but it is too big so I made it into an answer).
That method is quite general, indeed. It will work if you do computations with enough care.
Somebody is suggesting the use of a Taylor polynomial. I think that with an approach like that, the only thing that you can prove easily is weaker than the one you are seeking. For example, to quickly prove that there exists a $\delta >0$ such that
$$\tag{1}\sin x \ge \frac{1}{2}\left(x-\frac{x^3}{3!}\right), \qquad \forall x\in [0, \delta),$$
you can note that
$$\frac{\sin x}{x-\frac{x^3}{3!}} = 1 +O(x^4), $$
so there exists a constant $C>0$ such that in a neighborhood of $x=0$ one has
$$\frac{\sin x}{x-\frac{x^3}{3!}}\ge 1 - Cx^4$$
and the right hand side is bigger than $\frac{1}{2}$ for $x\le \delta=\left( \frac{1}{2C}\right)^{\frac{1}{4}}$.
Note that this value of $\delta$ is completely devoid of significance, it is just a small number that can in principle be very small. Also, in formula (1) you have a multiplicative factor of $\frac{1}{2}$ in the right hand side. All of that make this result way weaker than the one you are trying to prove; however, this proof is very quick and sometimes you do not really need the full-powered inequality.
Answer: Check that
$$\int_0^x (x-t)^2 \sin^2\frac{t}{2} d\,t= \sin x - (x - \frac{x^3}{6})$$
WA link
Answer: Your solution is right. There is no problem or fault in your solution.
If you know something about trigonometric functions convergent series
Sin(x) can be written as x-x^3/6+x^5/5!.... which is >x-x^3/6.
For a beginner the method of yours is first to strike and it will always lead you to your result but if we know trigonometric functions convergent series we can conclude also
Comment: Sorry I did not see the dots before. But I agree with BCLC: this answer tricks the reader into thinking that the result is obvious, which is not true. The only thing that is actually obvious is a local result in a neighborhood of $x=0$, as I said in my answer. For that, I am not removing my downvote for now. I will remove it if you edit again and show precisely how to prove the sought inequality.
Comment: @DSinghvi
0
down vote
I would try this?

sin(x)=x−x36+x5120−x75040+...−
easy to prove now.

shareeditflag
answered 27 mins ago

bobbym
964211
1 upvote
Could the down voter please elaborate? –  bobbym 21 mins ago
1

I'm not the downvoter but using this approach you would need to show that x5/5!−x7/7!+x9/9!⋯>0 for x>0 is which seems non trivial. –  Dan 15 mins ago http://math.stackexchange.com/questions/803127/proof-for-sinx-x-fracx33#comment1660156_803132
Comment: I have already edited my post and the dots are for continuation. Well these functions are trancedental functions not polynomial functions. they can be expressed in the infinite series following some pattern which will be a convergent series
Comment: It can be shown by theory of alternating series.
Comment: P.S.: See my comment to ajotatxe's answer. I am still convinced that the method of Taylor series does not lead to the solution that easily.
Comment: I haven't rejected his method . I am just giving an alternative . See my answer.
Answer: A trick is to get rid of the transcendental function.
As the sine is monotonic in $(0,\pi/2)$,
$$x>\arcsin\left(x-\frac{x^3}3\right),$$ and, as the two members coincide for $x=0$, by differentiation
$$1>\frac{1-x^2}{\sqrt{1-\left(x-\dfrac{x^3}3\right)^2}}.$$
Then it suffices that for $x<1$,
$$1-\left(x-\dfrac{x^3}3\right)^2>(1-x^2)^2,$$
$$-\frac{x^6}9-\frac{x^4}3+x^2>0,$$ which is true.
Answer: Recursive integration We know that $$0\le\cos a\le 1\implies \sin t = \int_0^t\cos s ds < t$$ for $0\lt t\lt z\lt x$. Integrating over $\color{blue}{(0,z)}$ we get
$$1-\cos z=\int_0^z\sin tdt < \int_0^ztdt= \frac{z^2}{2}$$
that is for all $0<z<x$ we have,
$$\color{blue}{1-\frac{z^2}{2}< \cos z\le 1}$$
integrating again over $\color{blue}{(0,x)}$ we get
$$\color{red}{x-\frac{x^3}{6} = \int_0^x 1-\frac{z^2}{2} dz< \int_0^x\cos z dz=\sin x}$$
that is
$$\color{blue}{x-\frac{x^3}{6} <\sin x< x}$$

continuing with this process you get,
$$\color{blue}{1-\frac{x^2}{2}< \cos x< 1-\frac{x^2}{2}+\frac{x^4}{24} }$$
$$\color{blue}{x-\frac{x^3}{6} <\sin x< x-\frac{x^3}{6} +\frac{x^5}{5!}}$$

More generally for  $n\geq1$, by induction we get
$$\color{blue}{\sum_{k=0}^{2n-1}(-1)^k\frac{x^{2k}}{(2k)!}<\cos x<\sum_{k=0}^{2n-1}(-1)^k\frac{x^{2k}}{(2k)!}+\frac{x^{4n}}{(4n)!} }$$
$$\color{blue}{\sum_{k=0}^{2n-1}(-1)^k\frac{x^{2k+1}}{(2k+1)!} <\sin x<\sum_{k=0}^{2n-1}(-1)^k\frac{x^{2k+1}}{(2k+1)!}+\frac{x^{4n+1}}{(4n+1)!}}$$


How do I create a Popup Dialog box in Silverlight?

Question: I'd like to create a popup dialog box in silverlight  in which i can manipulate controls, enter data, and return a value. I want it to be modal, so that when it is open, the page "Below" is inaccessible. I havent found an easy way to do this yet. Any suggestions?
Answer: I know the question asked for a Silverlight 2 solution but in Silverlight 3 (Beta now, RTW in July 2009) there is a built-in ChildWindow that can do everything you're looking for.
Comment: Here's a guide to child windows: http://www.wintellect.com/CS/blogs/jprosise/archive/2009/04/29/silverlight-3-s-new-child-windows.aspx
Comment: ChildWindows are available now that Silverlight 3 shipped.  They are easy to use, have a good usage pattern and look stunning!
Answer: I haven't found a perfect solution either. The closest I have seen is this:
Using Popup to create a Dialog class
If it is ok to be non-modal, you can try this tip using HtmlPage.PopupWindow().
How to Popup a Browser Window
Answer: I'm new to the Sliverlight framework and am just starting to figure it out, but I have a similar need for a popup modal dialog box.  I just tried an idea that looks promising:

I created a Rectangle (named "Shield") that covers my entire application area. It exists on top of everything in the main app.  I set the fill-brush to White, and the opacity-brush to 81% so that the main app contents show through, but lightly (as in disabled).  Then make sure the "Shield" is hit-testable.  Now, when the "Shield" is visible, it will also, in effect, block all input to the controls below (at least from the mouse, haven't tried keyboard yet).  When the app initializes, set the "Shield" visibility to Collapsed.  In that state it won't block input to the main app.
The dialog box is then constructed on another canvas element that exists in the z-order on top of the shield.  Normally the dialog box will be invisible, but when I need it, I just set the "Shield" to visible, and the dialog to visible. Since the dialog is on top of the "Shield" I get a very modal-like behavior.  When the dialog box is closed, make both the dialog canvas and "Shield" canvas invisible again and the main app is again active.

I'm sure this the most brute-force way of doing it and that I will eventually zero in on a more elegant construct, but it works for now.
Answer: A more elegant solution is here:
http://community.devexpress.com/blogs/theonewith/archive/2008/08/06/custom-silverlight-controls-creating-a-reusable-messagebox-dialog-part-i.aspx
Answer: I had the same requirement and ScottGu's Building a Basic Modal Dialog Using a User Control was the best solution that fit my requirement.
Answer: Here's a free library that provides one: http://www.vectorlight.net/demos/popup_dialogs.aspx


How to test field value for an object that should be in a list mixed with other objects of different classes?

Question: I am using pytest and trying to check if an object has the right content in one of its fields. The issue I face is that the object comes in a list where it could be in any position and mixed with objects from different classes where that field won't even exist.
Below you have an example that tests what I need. The example works as it should but I think this is not a great solution because it is testing 2 conditions in a test (instance in list and correct content if it finds the instance) and also because having to break the test function does not seem very clean.
Does anyone have advice on a more elegant and correct way to test this?
import pytest

class Foo:
    def __init__(self,name):
        self.name = name

class Bar:
    pass

def test_instance_in_list():

    l = [Bar(), Foo('foo'), Bar()]                      # Will pass the test
#    l = [Bar(), Bar(), Bar()]                     # Will NOT pass the test - "No instance"
#    l = [Bar(), Foo('other name'), Bar()]     # Will NOT pass the test - "Assertion fail"

    for item in l:
        if isinstance(item,Foo):
            assert item.name == 'foo'
            return
    pytest.fail("There wasn't a Foo instance in the list")

The expected outputs of running the test for the three conditions are:
Results of running with l = [Bar(), Foo('foo'), Bar()]
test_is_instance.py .                                                           [100%]

================================== 1 passed in 0.01s ==================================

Results of running with l = [Bar(), Bar(), Bar()]
>       pytest.fail("There wasn't a Foo instance in the list")
E       Failed: There wasn't a Foo instance in the list

test_is_instance.py:21: Failed
================================== 1 failed in 0.03s ==================================

Results of running with  l = [Bar(), Foo('other name'), Bar()]
>               assert item.name == 'foo'
E               AssertionError: assert 'something else' == 'foo'
E                 - something else
E                 + foo

test_is_instance.py:18: AssertionError
================================== 1 failed in 0.03s ==================================

Thanks for your advice and help to find a better way of getting the same results :-) !!
Comment: The inelegance is a consequence of your data, your list holds heterogenous types, so there really is no way around this.
Answer: This could one of the other approaches if you don't want to check availability of instance in the same test.
def get_params():
    l = [Foo('hello'), Bar(), Bar()]
    obj_count =0
    for item in l:
        if isinstance(item,Foo):
            yield item.name
            obj_count +=1

    if obj_count ==0:
        yield None

@pytest.mark.parametrize('obj_val', [val if val !=None else pytest.param(val, marks=pytest.mark.xfail(reason="There was not a Foo instance in the list")) for val in get_params() ])
def test_instance_in_list(obj_val):
    assert obj_val == 'foo', "Object content not matched"

The test will return xfail if the instance is not found in the list, else assert condition will check the object content


What is the need of randomizing memory addresses for loading libraries?

Question: ldd displays the memory addresses where the shared libraries are linked at runtime
$ cat one.c
#include<stdio.h>

int main() {
    printf ("%d", 45);
}
$ gcc one.c -o one -O3
$ ldd one
    linux-gate.so.1 =>  (0x00331000)
    libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00bc2000)
    /lib/ld-linux.so.2 (0x006dc000)
$

From this answer to another question,

... The addresses are basically random numbers. Before secure implementations were devised, ldd would consistently indicate the memory addresses where the program sections were loaded. Since about five years ago, many flavors of Linux now intentionally randomize load addresses to frustrate would-be virus writers, etc.

I do not fully understand how these memory addresses can be used for exploitations.
Is the problem something like "If the addresses are fixed, one can put some undesirable code at that address which would be linked as if it was a library" or is it something more than this?
Answer:
"If the addresses are fixed, one can put some undesirable code at that address which would be linked as if it was a library"

Yes.
Also.  Buffer overflow exploits require a consistent memory model so that the bytes that overflow the buffer do known things to known parts of the code.
http://www.corewars.org/ A great illustration of the principle.
Answer: Some vulnerabilities allow overwriting some address (stack overflows allow overwriting return addresses, exploit for heap overflows typically overwrite SEH pointers on Win32 and addresses (GOT entries) of dynamically called functions on Linux, ...). So the attacker needs to make the overwritten address point to something interesting. To make this more difficult, several counter-measures have been adopted:

Non-executable stacks prevents exploits from just jumping to some code the attacker has put on the stack.
W^X segments (segments which can never be writable and executable at the same time) prevents the same for other memory areas.
Randomized load addresses for libraries and position independent executables decrease the probabilities of succesful exploitation via return-into-libc and return-oriented-programming techniques, ...
Randomized load addresses also prevent attackers from knowing in advance where to find some interesting function (e.g: imagine an attacker that can overwrite the GOT entry and part of the message for the next logging call, knowing the address of system would be "interesting").

So, you have to view load address randomization as another counter-measure among many (several layers of defense and all that).
Also note that exploits aren't restricted to arbitrary code execution. Getting a program to print some sensitive information instead of (or in addition to, think of string truncation bugs) some non-sensitive information also counts as an exploit; it would not be difficult to write some proof-of-concept program with this kind of vulnerability where knowing absolute addresses would make reliable exploits possible.
You should definitely take a look at return-into-libc and return-oriented-programming. These techniques make heavy use of knowledge of addresses in the executable and libraries.
And finally, I'll note there are two ways to randomize library load addresses:

Do it on every load: this makes (some) exploits less reliable even if an attacker can obtain info about addresses on one run and try to use that info on another run.
Do it once per system: this is what prelink -R does. It avoids attackers using generic information for e.g: all Redhat 7.2 boxes. Obviously, its advantage is that it doesn't interfere with prelink :).
Answer: A simple example:
If on a popular operating system the standard C library was always loaded at address 0x00100000 and a recent version of the standard C library had the system function at offset 0x00000100 then if someone were able to exploit a flaw in a program running on a computer with this operating system (such as a web server) causing it to write some data to the stack (via a buffer overrun) they would know that it was very likely that if they wrote 0x00100100 to the place on the stack where the current function expected its return address to be then they could make it so that upon returning from the current function the system function would be called.  While they still haven't done everything needed to cause system to execute something that they want it to, they are close, and there are some tricks writing more stuff to the stack aver the address mentioned above that have a high likelihood of resulting in a valid string pointer and a command (or series of commands) being run by this forced call to system.
By randomizing the addresses at which libraries are loaded the attacker is more likely to just crash the web server than gain control of the system.
Answer: The typical method is by a buffer overrun, where you put a particular address on the stack, and then return to it. You typically pick an address in the kernel where it assumes the parameters you've passed it on the stack have already been checked, so it just uses them without any further checking, allowing you to do things that normally wouldn't be allowed.


Applying for job posted on both linkedin and company website

Question: First, I came across a job posting on linkedin that was only available to "apply with linkedin" and I did apply. However, now on the company website this exact same position is posted. Is it wise to apply again on the company website as well, or be patient with the application from linkedin?
Answer: Be patient with the LinkedIn application. It's going to the same place/person -- no need to apply twice. How long ago did you submit your first application, and how much do you want this job? If it's been awhile, you can follow up with the recruiter and emphasize how interested you are in the position, etc. That's a better option than applying twice.
Comment: Its only been about a week since I applied through linkedin


Zend Session webshop some items are just not stored

Question: I have a weird problem where I want to store products from my shop in a session. This works well, except for some products. The shop is part of a cms where all products are rendered the same way. When someone adds a product to the shop this will be serialized and send with ajax to a script.
Almost all items are stored, but for some reason some items don't get stored. I can't find a connection or anything and I don't get any errors returned.
So this is the code that stores the product in a session:
<code>$storeItemNumber = (string)$post['itemcode'];
                $storeItem = array($storeItemNumber => array(
                        'title' => $post['title'],
                        'price' => $post['price'],
                        'quantity' => $post['quantity']
                    )
                );
                $shopSession->$storeItemNumber = $storeItem;
</code>
This is an example of a product that gets stored:
<code> array('010101000' => array(
  'title' => 'Product title - 15',
 'price' => '28.95',
 'quantity' => '1',
));
</code>
This is an example of a product that doesn't get stored:
<code> array('400002001' => array(
  'title' => 'Product title - Pink',
 'price' => '5.50',
 'quantity' => '1',
));
</code>
I already checked if the data gets through alright and it does right until the saving of it in a session.
What could possibly be a reason?
Answer: Had a look with a friend of mine and we both concluded it had something to do with the numbers. So I changed the function to the following and Now I'm able to add all the products without a problem.
I'll leave this question open for the time being, because I'm really curious why some numbers are stored and others not and what is a better/cleaner solution then mine.


Would Abram have thought Sarai's womb was dead in Genesis 12?

Question: In Genesis 12, Abram is 75. Sarai a bit younger. In our current age such a woman would have a dead womb. And God promised to Abram: "I will make you into a great nation, and I will bless you" (12:2) and ""To your offspring I will give this land."" (12:7). The first step of these is for Abram to have offspring. Could Sarai have given Abram natural children at the time of Genesis 12?
Comment: It's your comment that lacks research ;-) Rom 4 refers to a later chapter. In chapter 12  she was still "very beautiful" and so desirable sexually that Abram fear the Egyptians would kill him in order to take her.
Comment: Paul tells us, specifically, that Abraham did not _consider_ that fact. _And being not weak in faith, he considered not his own body now dead, when he was about an hundred years old, **neither yet the deadness of Sarah's womb**:_ Romans 4:19. Yes, it was dead. Yes, Abraham was _aware of the fact_. But no, he did not _consider_ it and was strong in faith and believed the promise of God. The question lacks the research of having looked at the Romans text, in my view.
Comment: @DanFefferman Sarai was _barren_. Thus her womb was (effectively) dead, the reason for her giving her servant to Abram that the promise God had made might be fulfilled (by natural means). Mature feminine beauty is desirable, yes. But that does nothing for their procreative ability, sir. Her womb was dead through barenness, then dead through age and because 'it had ceased with her after the manner of women'. And then - yes _then_ - by a supernatural miracle, she conceived.
Comment: @NigelJ He also isn't about an hundred years old in Genesis 12. Romans 4 is talking about a different encounter.
Answer: No, Abram would not have thought Sarai infertile yet. Consider Gen. 12:11-12 where Abram says to Sarai:

"See now, I know that you are a beautiful woman; and when the
Egyptians see you, they will say, 'This is his wife'; and they will
kill me, but they will let you live.

This is followed by the story of Sarai being taken into Pharaoh's harem. So Sarai looked a lot younger than her reported age and was very desirable sexually. This is an indication of her continued fertility. Sarai herself did not give up trying to conceive until several chapters later, when she gave Hagar to Abram because "perhaps I will obtain children through her." (16:3)
Also, for those whose hermeneutics allows for a source-critical analysis of Genesis, there is the possibility that the report of Abram's age of 75 is not part of the original account. The Interpreter's Bible and others, say that the line about Abram's age is from "P," a narrative woven into the text at various places, while the the main body of this section is from "J."
Finally, we may consider the idea that "with God all things are possible." God promised Abram a son, and Abram responded in faith. Just as Sarah gave birth to Isaac later on and just as Elizabeth gave birth to John the Baptist when she was past her child-bearing years, Abram believed that Sarai could have given him children at the time of Gen. 12.
Conclusion: there are three ways to account for Abram's belief in Sarai's fertility in Gen. 12.

She looked much younger than she was, and this was in indication that she was still fertile.
Her apparent age is misreported because of an addition to the J text from the P source.
Abram believed God's promise regardless of his wife's age.

Thus, there are a variety of reasons why Abram would not think Sarai's womb was "dead" at this point.
Answer: First, Gen 12 never mentions anything about Sarai not having children or being barren.  That statement is found in Gen 11:30 -

But Sarai was barren; she had no children.

The statement about a "dead womb" is not found in the OT but in Rom 4:19.
The difference in age between Abraham and Sarah was 10 years as shown in Gen 17:17.  This means that when Abraham and Sarah moved to Canaan and Abraham was 75, Sarah was 65 years old.  However, the statement in Gen 11:30 (above) has nothing to do with age; Sarah was simply infertile and could not have children.
Thus, the miracle of the birth of Isaac was remarkable for two reasons:

Sarah was barren and could not have children
Sarah was old and had already reached menopause Gen 18:11, Rom 4:19, etc.

Now, the fact that Sarah, in Gen 12, was barren had nothing to do with her being desirable as an addition to a harem as expressed by Pharaoh.  Women were added to harems for various reasons:

sexual pleasure of the harem owner
to produce children
to create the trappings of wealth, ie, unrelated to either of the above two reasons.  A large harem suggested great wealth!
to surround the king with great beauty for its own sake, again unrelated to the above reasons
some harem members were there for ordinary companionship and counselling of the king

Thus, the fact that Sarah had no children and could not have children was not entirely germane to Pharaoh's request.  Sarah was very beautiful, wise, experienced and well-travelled and thus could satisfy all but one of the list above.


Code coverage deployment

Question: If there are four classes in the sandbox and first three classes have 100% code coverage and fourth class 0% code Coverage. Will the deployment will be success or fail
Answer: Deployment to a Sandbox does not require code coverage; the deployment would succeed. For Production, though, it depends on the parameter testLevel. If testLevel is set to RunLocalTests, deployment would succeed. If testLevel is set to RunSpecifiedTests, then the deployment will fail. This is true for both IDE deployments and Change Set deployments.
Answer: As @sfdcfox stated this depends where you are deploying your classes to. Deployment will succeed if you have 75% overall code coverage.
To further answer your question, this depends on the amount of lines in class 1,2,3 and 4.
Consider the following example:

You have a new Salesforce org with no custom code in production.
You are deploying your 4 classes to production in the same package / changeset
Class 1,2 and 3 have a combined total of 100 lines of code
Class 4 has 200 lines of code.

Your overall code coverage is 100 / 300 ~ 33%. This will fail deployment.
Consider another example where

Class 4 now only contains 20 lines of code.

Your overall code coverage is now 100 / 120 ~ 83%. This exceeds the 75% threshold so deployment to production will succeed.
** you should note that this is bad practice. You should not deploy classes with no code coverage for obvious reasons.
Not to mention that at some point in time you will probably piss off the developer that succeeds you when he realizes he has to re-write unit tests for the classes that you developed.
Please refer to Code Coverage Best Practices for more information.

Code coverage deployment