Holding like the majority opinion for a d'oraita?

Question: In cases where there is a discussion among the Rishonim/Acharonim as to whether something is forbidden from the Torah (d'oraita), is it acceptable to go in accordance with those that deem it permissible (suppose they are in the majority if it makes a difference), or must one always take the stringent view, due to being stringent on cases of doubt with regards to biblically enacted commandments (safek d'oraita l'chumra)?
Comment: Related (maybe duplicate?): http://judaism.stackexchange.com/q/45349
Comment: with regards to Aveilus the halacha goes even with the minority, I beileve even in a doraisa case
Comment: Are you not aware of any case when people follow a minority opinion??
Comment: Eruvin also halacha kedaat hamekel
Answer: The OP seems to be asking about a case where one opinion says something is an issur D'Oraisa and the other opinion says it is permitted in the first place with no restriction. (There is no opinion that it is an issur D'rabbanan?)
I have seen Halachic cases like this. Although they are rare compared to D'Oraisa/D'Rabbanan arguments.
Even so, (and sometimes even if the heter is a minority opinion) sometimes, some still pasken like the lenient opinion or at least rely on them in a difficult situation.
This is because when we rely on a Rishon/Acharon as a Poseik/Rav, we are saying that the man (and his adherents, and traditions) certainly knew what he was talking about, he is correct, and we are relying on him; even if others argue. Therefore, there is no doubt involved. It is about relying.
It is true that today, Rabbis do gravitate towards paskening to the stricter view if that view holds its a D'Oraisa. This is because the Rabbi is assuming that he himself, really is not an expert to decide with his own mind when two great authorities from the past have already weighed in. He also doesn't have a reason to pick one Rishon over the other. So, he will treat it like a safek D'Oraisa L'Chumra situation and rule in accordance with the strict opinion (or at least caution that one should try to hold by it unless its a very difficult situation). Sometimes, a community has a tradition that they always held like the lenient authority in history past, and they have a right to rely on the leniency.
This should not be confused with the real use of the term "Safek D'Oraisa L'Chumra". That is applied to a situation. If a substance might have fallen into a mixture... if it was suspected to be the pork, then we are more concerned than if it may have been chicken soaked in milk.
For instance, a woman is either obligated in Birkat HaMazon D'Oraisa or D'Rabbanan. She can pick who she wishes to hold like. If she picks D'Oraisa, then if she has a doubt about having recited bentching, she may need to repeat it. If she had chosen D'Rabbanan, then she would not. (The benefit of her choosing to say she is obligated D'Oraisa, is that now she can recite it for a man and he has fulfilled his obligation.)
Picking the Halachic opinion is up to her. That is a choice, not a "safek". A situation of "safek" is then resolved based on the choice.
Hope this helps. :)
Comment: Related: http://judaism.stackexchange.com/questions/11625/se-challenge-halachot-in-which-rulings-range-from-permissible-to-torah-violation
Comment: @Scimonster, nice link, thanks for thinking of it.
Answer: See e.g. Hilkhoth Mamrim 1:5:

שני חכמים או שני בתי דינין שנחלקו שלא בזמן הסנהדרין או עד שלא היה הדבר ברור להן, בין בזמן אחד בין בזה אחר זה, אחד מטהר ואחד מטמא אחד אוסר ואחד מתיר אם אינך יודע להיכן הדין נוטה. בשל תורה הלך אחר המחמיר בשל סופרים הלך אחר המיקל:
Two sages or two courts that argue (about a halachic ruling) either in a time without the Sanhedrin or while they (the Sanhedrin) are not sure of the thing (i.e. the correct ruling), whether (the disputed positions are presented) at the same time or one later than the other, one declares tahor (ritually clean) and one tameh (ritually unclean), (or) one allows and one prohibits, if you do not know which way the law leans, in a biblical (issue) follow the stringent view (and) in a Rabbinic issue, follow the lenient view.

In general, the rule "safek d'oraytha l'chumra" (uncertainties in Biblical law are toward stringency), is applied in cases of "safek hashakul" (halachically equiprobable uncertainties).  If there is a halachically valid reason (e.g. rov - majority, chazaka - induction) to assume the lenient position is more plausible, that is the halacha.  This is why Maimonides uses the language: "אינך יודע להיכן הדין נוטה" - "if you do not know which way the law leans" - "you" are the one with the equiprobable uncertainty, as opposed to the debating authorities who have legally valid opinions; and if "you" (assuming "you" are a halachically recognized authority as well) also had a reason to assume "the law leans" toward one position, then that is the law for you as well.
See, however, the Kesef Mishna.  See aso the Lechem Mishna who cites a Responum of the Rashba (253):

כיצד שורת הדין אם שנים הפוסקים כאחד זה אוסר וזה מתיר אם נודע האחד גדול בחכמה ובמנין ויצא שמו כן הולכין אחריו וכו' היו שניהם שוין ולא נודע מי גדול משניהם בשל תורה הולכין אחר המחמיר וכו'

See also the source text at the basis of the dispute (Avoda Zara 7b):

היו שנים אחד מטמא ואחד מטהר אחד אוסר ואחד מתיר אם היה אחד מהם גדול מחבירו בחכמה ובמנין הלך אחריו ואם לאו הלך אחר המחמיר ר' יהושע בן קרחה אומר בשל תורה הלך אחר המחמיר בשל סופרים הלך אחר המיקל א"ר יוסף הלכתא כרבי יהושע בן קרחה


Electron in rotating frame

Question: Suppose there is a stationary electron in an inertial frame $S$. Then there is only a static Coulomb field relative to $S$. However, according to a rotating frame $S'$, whose angular velocity relative to $S$ is $\Omega$, the electron is rotating, and hence there is an acceleration of the electron. But an accelerating electron will emits radiation and loses energy. Since the $S'$ is always rotating with the same $\Omega$, the electron will emits the radiation indefinitely. The frame $S'$ observes there is radiation while frame $S$ sees none. How does the non-inertial observer account for the energy loss of the electron? If there is radiation observed, how to calculate the radiation exactly? Any help is appreciated.
Comment: This sounds like a variant on the [paradox of radiation of charged particles in a gravitational field](https://en.wikipedia.org/wiki/Paradox_of_radiation_of_charged_particles_in_a_gravitational_field).
Comment: Related: https://physics.stackexchange.com/q/286457 and links therein
Answer: In physics,accerlation is not the content of reletivity. Any observer can do any of the simple experiment to know what actually happens.In your hypothetical situation s'frame will feel accerlation(A) and if it seen the electron in that same accerlation it can understand that the electron is not actually accerlated (it seen just because of the s'frame is doing accerlation in reletive to s frame)  and that's why accerlation is not the content of reletive, rather it is a real effect which can be observed by both frames of the references. And because it can be experimentaly showed that the s'frame is not in accerlation so the electron will also not radiate the energy.

Electron in rotating frame


How to load WordPress on non WP page?

Question: I want to use the get_option() function of wordpress in one of my theme's files, which is not related to WP, it is just located in the same directory of the other theme files. I need this file because of some extra IPN paypal related actions, but I need some values from the options table that exists in WP to be called in this page in order for it to work. I know I can't just use get_option() as this file is overlooked by wordpress. Is there any approach by including some parts of wordpress in my theme to make this functionality only work?
Comment: I retagged your question. Hint: Just take a look inside [tag:wp-load.php].
Comment: Have you thought about getting these values out of the database using a custom mysql query? Loading the entire WordPress system for a couple of option values might be overkill. For maintainability I recommend Abdussamads [answer](https://wordpress.stackexchange.com/a/69186) (build it into a plugin)
Answer: The shortest way is to load wp-load.php and abort the loading of the template engine (Note: You couldn't do that, if you'd be loading the header file, like you see it on many sites in the interweb).
# No need for the template engine
define( 'WP_USE_THEMES', false );
# Load WordPress Core
// Assuming we're in a subdir: "~/wp-content/plugins/current_dir"
require_once( '../../../wp-load.php' );

Comment: Is there more docs on `WP_USE_THEMES` than https://codex.wordpress.org/The_Loop ? :)
Comment: @jave.web Sure: [The source code cross file search](https://github.com/WordPress/WordPress/search?utf8=%E2%9C%93&q=WP_USE_THEMES).
Answer: The simplest way is include wp-load.php file. This file will loads all WP core, so you can use WP functions such as get_option in your PHP file:
include 'path/to/wp-load.php';

echo get_option( 'option_name' );

Comment: One line (including `wp-load.php`) vs. multiple lines (plugin comments in the beginning), that's the simplest, lol.
Comment: +1 But by above answer, you can delete "the simplest" ;)
Answer: Turn your external file into a WordPress plugin. That way you'll have full access to WP core functions.
Comment: This would make your life much easier in the long run.
Answer: This should work on any WordPress installation:
<?php
function load_wp_load() {
  $wp_did_header = true;
  require_once($_SERVER['DOCUMENT_ROOT'] . '/index.php');
  $matches = preg_grep('/wp-blog-header.php/', get_included_files());
  if (!empty($matches)) {
    $abspath = dirname(reset($matches)) . '/';
    define('ABSPATH', $abspath);
    require_once(ABSPATH . 'wp-load.php');
  }
}
?>

How to load WordPress on non WP page?


How do podcast apps maintain the list of podcasts and podcast episodes?

Question: I use a third party podcast app called Overcast and I was curious how it gets the list of podcasts and episodes available, as my understanding is that it is difficult to get from iTunes. Is there a service that provides this information? I am assuming they would not maintain it themselves manually.
Answer: Overcast likely does not reference iTunes at all.  When they learn about a new podcast, they can add the RSS feed to their database of podcasts.  That RSS feed tells any subscribers (who are using iTunes, Overcast, and any other podcast apps) what episodes are available to download.


Should I skip a tax filing for a year I don't have all the information for, and file it later when I can?

Question: I'm waiting for some information before I file tax for the person for the calendar year 2010. He filed for an extension for the calendar 2010 and then 2011 too. The information is still not available to him, and we were wondering, if we should skip 2010 for now and go ahead and file income tax for calendar 2011 (deadline is soon approaching!)? Is there a way to notify IRS that "We aren't just skipping a year! We will come back to it ASAP"?
Comment: @mhoran_psprep I'm not tax professional - just doing it for family.
Comment: Are you a tax professional, or are you helping a family member?
Comment: And if you're a professional, you're going to be hit with the OPR penalties, in addition to the taxpayer's penalties.
Answer: Of course not. Moreover, you're going to be hit with 5% penalty per month for failure to file (with the minimum penalty of $135 or 100% of tax due, the lesser, maximum 25% of the tax due, if more than minimum).
What you should have done, and should do ASAP, is to file the returns based on the information you have (and estimates, if no precise data is available), disclose your problems in a statement attached to the return, and amend, if needed, when the finalized data is available.
Comment: Exactly. Extension (till mid October) then file with what you have.
Comment: I highly doubt he would owe any taxes for the year being skipped (2010), BUT he still needs to file it because of the amount of transactions that took place! He still shouldn't skip the year?
Comment: @TPR Of course. He's not in compliance with the tax law, it has various consequences, some may be totally unexpected. Why go there? What for?
Comment: @littleadv Actually, that's what I suggested him last year in October 2011 that file with estimates and you can always amend it later if need be. However, his professional tax accountant suggested him not to do so and wait till he gets more accurate information! Maybe the account didn't realize it would get delayed for almost another year!
Comment: @TPR it seems that either the account didn't think its going to take that long, or you should switch to another accountant. Ask him again.


What is the difference between a offside and a neutral zone infraction in the NFL?

Question: Throughout many NFL games, there is almost always one pre-snap call, and many of those are on the offense for a small flinch. During all of the games that I have watched, I see refs calling out mostly different penalties that are related to the false start. What are the key differences between these three penalties, encroachment, neutral zone infraction and offside?
Answer: There are quite a few fouls that can happen at the start of a down:

False Start: Movement of an offensive player prior to the snap, e.g. a lineman changing their stance or a receiver moving forward.
Encroachment: Movement of defensive player into the neutral zone prior to the snap who then touches an opponent or the ball.
Neutral Zone Infraction: Movement of defensive player into the neutral zone prior to the snap who causes the reaction of an opponent in close proximity.
Offside: Player lined up in the neutral zone, can be caused by both offense and defense.
Illegal Motion: One offensive player in the backfield is allowed to move parallel or backwards, all others have to be set for at least a second, if any of this is violated it's an illegal motion.
Illegal Formation: Offense must have 7 players at the line, eligible receivers left and right to their linemen and not between linemen. Failing to do so is an illegal formation.
12 Men On The Field: You are only allowed to have 11 men on the field, with the ruling being a bit more strict for offense, including the huddle.
Delay Of Game: If the offense fails to put the ball in play before the play clock runs out.

All of these fouls will cause a 5 yard penalty, but no automatic first down (in case of a defensive foul).
You can read more about this in the rules sections 7.4 (action at or before the snap), 5.1/2 (players and substitutions), 3.19/20 (scrimmage line, neutral zone, offside).
Answer: Offside:
A defender crosses the Line of Scrimmage before the snap (without touching an opponent).
Encroachment:
Offside, but with touching an opponent.
Neutral zone infraction:
This is basically the same rule as offside, but will usually be called when a defender causes an offense player to false start by committing an offside foul or a defender already lines up illegally (e.g. head sticking out).


Can freeze spray be used for pc dust cleaning?

Question: I've bought freeze spray instead of compressed air by accident. Can I use it as an alternative to clean dust from my pc?
Comment: Welcome to LifeHacks, fryz! You are asking whether a lifehack that you came up with will work. On this community, people ask for members to _suggest_ lifehacks. For example, "How can I put sunscreen on my own back?" We prefer that kind of question over yes/no questions like yours, which is why you've gotten two "close" votes. Sorry about that!
Comment: I sure would not use it on my PC.  I did computer repair for  a living for a while.
Comment: Please provide a link to this thing you refer to as "freeze spray" - it could be any one of a number of products
Answer: It probably would clean off dust BUT:

The temperature drop of components could lead to condensation on the surface, which could kill some of your hardware if the water shorts some contacts. So I would keep an eye on that an wait until everything is ensured dry.
If the spray contains chemicals that cause corrosion of contacts you could run into troubles after a while.
If the spray contains chemicals that are arggresive to plastic or gaskets it could cause your mounts to become brittle, rubber bearings to become stiff, coils to short out.

So check whats in the can. For example "Tetrafluoroethane" and "dimethyl ether" should be safe. But some Ethanols that maybe contained to prevent ice building up could cause corrosion of the upper problems.
Look for the warning signs on the can and check with GHS


Assalamu Walaikum.. I want to ask if is it haram to upload a cartoon girl with a hijab as my profile picture

Question: Is it haram to upload a cartoon girl with a hijab as my profile picture?
Comment: If you think it would be haram to use it as your profile picture how didn't you think it would be haram to post the picture in the question?
Answer: Refrain from using pictures with animate objects, rather use a picture of some scenery etc.
And Allah knows best.
Answer: As long as there is no haram activities, images and dolls are allowed in Islam. You can see Aysha (r.a), when married to prophet (s.a) used to play with dolls. Using the analogy, there is no wrong in using cartoon characters as profile picture

"The Messenger of Allah married me when I was six, and consummated the
marriage with me when I was nine, and I used to play with dolls." https://sunnah.com/nasai:3378
Comment: What does consummate mean?


From PSC to real location

Question: Using TelephonyManager.getAllCellInfo() I was able to get information about neighboring cell tower including cellid, but in case of UMTS I only get the PSC value.
Is it possible to know a location of a cell tower from its PSC and the MCC, MNC, LAC and CID of a neighbor cell tower?
Answer: The PSC field is optional into almost all apis to cell location databases out there, in most cases, only mnc, mcc, lac, cid and the radio type are required to proceed cell-base location. Check unwiredlabs for example.
Answer: Yes this is possible, but you would have to reference a database that includes lat/long and CID. There are companies that provide this information (e.g. OpenCellID) for which there is an API available.
Otherwise, you can dig through FCC/FAA registrations if you like, which may be more accurate, however I don't think there is an API.
If you are restricted to the attributes listed in your question, then I don't think it would be possible since none of these things are directly linked to lat/long.

From PSC to real location


complex polynom roots precision

Question: i am interested in finding roots of complex polynoms (with complex coefficients). i found that if the polynom has degenerate (multiple) root(s) then such algorithms like Newton and Durand-Kerner ones do not lead to the convergent results (simply speaking, the convergence is bad). does anyone in forum knows an algorithm to increase the accuracy (precision) of finding the degenerate roots (for the general case of complex polynoms) ? Thanks.
Answer: Hint: if $z_0$ is a root of order $k$ of $P$, then $z_0$ is a root of order $k-1$ of $P'$ (formal derivative). BTW, this is true in any field.
Comment: do you want to give an idea that removing degeneracy is made by P/P', and then to find the precise root of P/P' ?
Comment: @R.Goldov, $P/\gcd(P,P')$, as Robert Israel said in the other answer. $P'$ can have other roots that aren't roots of $P$.
Comment: Thank you, Martin-Blas. do you know an algorithm according which one could divide one polynom of degree n by another polynom of degree k (k<=n) ? i mean, not by hand but writing a computer code for that purpose. Thanks.
Comment: @R.Goldov, see many examples in https://rosettacode.org/wiki/Polynomial_long_division. But the better option is using some symbolic calculus program.
Comment: Thank you very much, Martin-Blas.
Comment: Suppose a complex polynom f(z) of the degree n has k multiple roots, and, respectively, n−l simple roots, where l=μ1+μ2+…+μk is the sum of the multiplicities of the degenerate roots. suppose the roots of the polynomial f are known (were found), and are equal to λ1,λ2,…λi,… does anyone in the forum know an algorithm to find a multiplicity of any root (degenerate, and simple) ? is it possible to express the multiplicity of any root (multiple, and simple) via f(z), f′(z), and gcd(f,f′) ?
Answer: Remove the degeneracy:  if $f$ is your polynomial, find the roots of $f/\gcd(f,f')$ instead.
Comment: Of course, with finite precision, $f$ and $f'$ are doomed to appear as if coprime ...
Comment: If the complex polynomial has large degree, for example, 100 or 1000, then it might be that there are several (many) multiple (degenerate) roots. how in that case to apply the method f/gcd(f,f') to remove degeneracy ?
Comment: It still works.  The roots of $f/\gcd(f,f')$ are exactly the roots of $f$ but with multiplicity $1$.  Yes, this is assuming exact arithmetic rather than finite precision.  With finite precision it is impossible to distinguish a multiple root from several roots close together.
Comment: Thank you, Robert. as i guess, gcd(f,f') could be found according Euclidian algorithm ? or may be there are other algorithms for that purpose ? - i mean, how one could divide one polynom by another polynom if the degree of the polynoms is large (hundreds, thousands ...) - is there special computer algorithm for that purpose ? Thanks.
Comment: Maple uses modular methods for gcd of polynomials over the rationals.  See e.g. Monagan and Margot, ["Computing Univariate GCD's over Number Fields"](https://books.google.ca/books?id=YF6OWK7XMAkC&pg=PA42&lpg=PA42)
Comment: Thank you very much, Robert.
Comment: Suppose a complex polynom f(z) of the degree n has k multiple roots, and, respectively, n−l simple roots, where l=μ1+μ2+…+μk is the sum of the multiplicities of the degenerate roots. suppose the roots of the polynomial f are known (were found), and are equal to λ1,λ2,…λi,… does anyone in the forum know an algorithm to find a multiplicity of any root (degenerate, and simple) ? is it possible to express the multiplicity of any root (multiple, and simple) via f(z), f′(z), and gcd(f,f′) ?
Comment: The multiplicity of root $\lambda$ is $\lim_{z \to \lambda} \frac{(z-\lambda) f'(z)}{f(z)}$.
Answer: At multiple roots, the steps or Newton and Durand-Kerner (which is also a Newton method) from one iteration to the next are almost co-linear. This can be used to detect this situation and to extrapolate the root. Of course in the complex plane and for iterations that are not constrained to the real axis, else the property "co-linear" is not very descriptive.
In Durand-Kerner you can also detect clusters in the current root approximations and set one of the cluster points to the center of the cluster. This was reported to increase convergence speed, if I remember correctly Victor Pan has many papers and tech-reports on polynomial root finding, its efficiency and accuracy.
Jenkins-Traub is theoretically in its convergence speed insensitive to multiplicities. However, it too suffers from the usual cancellation errors at multiple roots as it uses the quotient of polynomial value and something that converges to the derivative, which will eventually both be small numbers.

complex polynom roots precision


Linux Mint 20 Without a Dedicated Graphics Card

Question: I plan to get rid of Windows on my wife's laptop and install Mint 20 Cinnamon edition on it. The laptop is a bit old. So I just wanted to know, does it work nicely of an Intel graphics? I read a lot about it being pretty and all. And thought, pretty would mean it might need a dedicated GPU. The processor is Core i3. From what I know it is two generations older than the current ones on the market. I have to look at the specs in detail. Any advice on this would be appreciated. Thanks.
Answer:
And thought, pretty would mean it might need a dedicated GPU.

For games or CAD/3D modelling maybe. For normal day to day tasks - hardly required.

So I just wanted to know, does it work nicely of an Intel graphics?

Linux drivers for Intel graphics are considered top notch. Multiple people around me, me including, have laptops with integrated Intel graphics and I don't remember having any serious issues in a long time.
Comment: I installed Mint. And it seems to be handling stuff pretty well. Yes its no Ferrari. But I don't expect it to be. But is pretty zippy. Don't see any graphics/drivers issue now.. Thanks for the answer!
Answer: Drivers for intel video is in kernel, must be ok.
But let me raise one general problem I am facing when installing Linux on a 'old' PC:  After a while, users compare with newest, more powerfull friend's machine, and found that 'Linux is slow', but naturally in fact meaning 'hardware is slow' .
Probably you can explain that to your wife, but maybe it is a good moment to get a -eventually second hand- more powerfull CPU.
(Sorry if mistakes, my primary language is french)
Comment: Last 10 years (*maybe more)* general purpose intel cards are great even for medium performances on 3D.  I strongly agree.
Comment: Generally what I have seen, Linux machines handle older hardware faaar better than Windows. Can't say about MACs. Don't have experience about them.


should I have two buttons that do the same thing on the same page?

Question: I currently have a header and on that header there is a plus button with three options, one of them being add expenses. On the expenses page of my app, I can't decide whether there should be a second "add new" button or if I should only have the one option in the header. The header button will always be available on every screen, but requires two clicks while the "add new" is only available on the expenses but only requires one click. Here is the wireframe.
Answer: I don't think the problem is in the repetition, the redundancy in UX is not a serious issue. As for the UI, I think the biggest drawback is the proximity, one below the other, which in terms of page layout or structuring goes from redundant to obvious.
If the user already knows the + button can add an expense because they have already navigated through other screens of the application, on the expense screen there may be a fixed reminder button Add new in the place the new expense will occupy.
Answer: To me, the + doesn't tell me what I expect to happen. If you hadn't explained it, I would be guessing. Therefore, I would never click it. The plus should go next to expenses, because that is what you are adding.
For that matter, "Add New" What? Might sound obvious, but it could add a new category. Why not [ Add Expense ] There is room and it tells you EXACTLY what it does.
One other question: When you add, what order does it add them in? Does it depend on the sort? Let's say it is sorted desc, you click [ Add new ] and it goes to the top. Not that intuitive. Even worse, what if you are adding expense 21 and it is sorted Desc, you have to scroll to the top to see the newly added expense.


Why does the carrier wave amplitude have to be largest in amplitude modulation

Question: I don't understand the reason for the following statements in amplitude modulation

Here's equation 3-7 described in the text
Comment: You're storing information in the amplitude of your carrier signal.  What would happen if the amplitude of the information signal exceeded the amplitude of the carrier?
Comment: Try sketching an AM signal with \$m < 1\$ (try 0.5 or so), and again with \$m > 1\$.  What's the one with \$m>1\$ going to sound like if you demodulate it with a simple envelope detector?
Comment: It doesn't *have to be*, it just *is*, because of the way AM works.
Answer: Strictly speaking it doesn't. However if it isn't then demodulation gets much trickier and some would argue that the modulation is no longer purely amplitude modulation.

Lets consider an equation for an AM carrier modulated with a single sinewave. Lets consider that we perform the modulation by multiplication.
$$Y = (a\sin(\omega_st)+b)\sin(\omega_ct)$$
Where \$\omega_s\$ is the angular frequency of our signal and \$\omega_c\$ is the angular frequency of our carrier.
Now lets bash that equation around a bit to find the frequency components of our AM signal.
$$Y = a\sin(\omega_st)\sin(\omega_ct)+b\sin(\omega_ct)$$
$$Y = \frac{1}{2}a(\cos(\omega_st-\omega_ct)-\cos(\omega_st+\omega_ct))+b\sin(\omega_ct)$$
So our modulated signal consists of three frequencies, a carrier with an amplitude of \$b\$ and two sidebands eavh with an amplitude of \$\frac{1}{2}a\$.

So our attention turns to what the values of a and b should be. If \$a \leqslant b\$ then we are modulating the amplitude of the carrier. At the high peak of the signal the amplitude of the carrier will be b+a while at the low peak of the signal the amplitude of the carrier will be b-a.
But if \$a \gt b\$ then \$a\sin(\omega_st)+b\$ will drop below zero for part of the signal cycle. The amplitude of a signal cannot drop below zero, so with our multiplier based modulator what instead happens is the phase reverses. We will call this an over-modulated signal.
It takes quite an advanced modulator to actually implement this reversal properly, simpler modulators may instead saturate destroying information.

Ok so now we want to demodulate the signal, how do we do that? Turns out there are basically two methods.
The first is envelope detection. Basically we rectify the signal and look for the peaks. The key observation with this type of demodulation is it doesn't care about the frequency or phase of the signal only it's amplitude. In other words the result of demodulation is roughly.
$$D = |a\sin(\omega_st)+b|$$
If \$a \leqslant b\$, we have our signal with a DC offset, but if \$a > b\$ then parts of our signal will be inverted. So we cannot use envelope detection to correctly demodulate an over-modulated signal.
The other method is coherent demodulation. In this demodulation technique we multiply the signal by the carrier again. Then filter off the high frequency components.
$$D_\mathrm{uf} = (a\sin(\omega_st)+b)\sin(\omega_ct)\sin(\omega_ct)$$
$$D_\mathrm{uf} = (a\sin(\omega_st)+b)\frac{1 - \cos(2\omega_ct) }{2}$$
$$D = (a\sin(\omega_st)+b)\frac{1}{2}$$
So coherent demodulation can demodulate an over-modulated signal.
However in practice coherent demodulation is much harder to implement than envelope detection, because the frequency and phase of the carrier used for demodulation must match up with that used for modulation. Since the demodulator doesn't generally have an exact copy of the carrier used for modulation it must implement a system to estimate it.
Comment: why does \$a\sin(\omega_st)+b \$ drop below zero when \$ a > b \$
Comment: Because \$\sin(\omega_st)\$ varies between -1 and 1
Comment: So here's what I understand, so when \$a > b \$,  \$ a\sin(\omega_st)+b \$ becomes less than 1, that means \$Y = -C\sin(\omega_ct)\$ which can also be interpreted as \$Y = C\sin(-\omega_ct)\$ which is a 180 degree phase shift. Now this is hard to properly employ in modulators. And also it causes other difficulties during demodulation. So, it is better we keep modulation index less than 1. Did I get all of it right, Thank you.
Comment: Yeah thays right.


Purpose of the multidimensional NLSE/GNLSE

Question: I know the purpose of the NLSE (Evolution of a complex field envelope in a nonlinear dispersive medium). Usually I am solving the 1d-GNLSE when simulating the propagation of a light pulse through a material. But I also found several mentions of higher-dimensional NLSE (1d, 2d, n-d). Why do I want to solve the GNLSE/NLSE in higher dimensions, when do I want to use it, and how can I imagine that?
Answer: One classic example of the $d=1,2,3,$ NLSE is in nonlinear optics. Given a paraxial laser beam propogating in Kerr medium, a classical descriptive PDE is the following version of the NLSE:
$$i\psi _z ({\bf x},z) + \Delta _{\perp} \psi + |\psi |^2\psi = 0 \,, \quad {\bf x} \in \mathbb{R} ^d, \quad z\geq0 \, , $$
$$ \psi ({\bf x},z=0) = \psi_0 ({\bf x}) \in H^1 \,.  $$
The latter $H^1$ space is the Soboloev space with the norm $\|f\|_{H^1} = \sqrt{\| f \|_2 ^2 + \|\nabla f \|_2^2 }$.
So, there's a localized initial profile which propagates with the dimension $z$ and has a dispersion along the perpendicular one-dimensional or two-dimensional wave.
$d=3$ corresponds to ultra-short pulses, in which there is a temporal dispersion. In that case, with an appropriate scaling, you have the same equation with ${\bf x} = (t,x,y)$.
Inasmuch as I know, if you replace $z$ with $t$, then ${\bf x} = (x,y)$ accounts for the waves on the surface of a deep sea, but I don't know much about it.
For more information, take a look at The Nonlinear Schrodinger Equation, which deals with the kerr nonlinearity model in details. Chapters (1,2,5) will be sufficient, I think.


PHP mail() Header Injection Prevention

Question: This site nicely explains the problem.  Essentially, nearly all php mail() examples that are given are vulnerable to header injection attacks.  The referenced site gives a regex sanitation solution but I'm not satisfied with it.  Is there a built in header sanitation function?  What would one need to do to really protect against this sort of attack?
Answer: As a matter of fact PHP includes a function to check the validity of a provided address.
http://php.net/manual/en/function.filter-var.php
http://www.php.net/manual/en/filter.filters.validate.php
Ex: filter_var($_POST['from'], FILTER_VALIDATE_EMAIL) ? send() : die("You murdered me. D:");
Comment: I'd assume that valid email addresses can't contain characters that can cause header injection attacks (but that isn't guaranteed unless one read the spec).  Let's assume so.  What about injection  attacks with the subject?  filter_var won't help in that case (at least I don't think it will)
Comment: Nice! I didn't know about filter_var :)
Answer: This is how pear does it in their Mail package:
<code>function _sanitizeHeaders(&$headers)
{
    foreach ($headers as $key => $value) {
        $headers[$key] =
            preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i',
                         null, $value);
    }
}
</code>
Obviously, for this method to be adapted to work with the built-in mail() function, some work will need to be done.  Instead of working with associative arrays for headers, the mail() function just accepts a string.  So you (the user of mail()) would have to sanitize each piece of the header similar to the above as you build up the headers string.
I'd like to hear in the comments if this indeed covers every injection threat (from those that are more experienced with issues like this).
Answer: Clearly you can never trust data from users. The solution is not to rely on convinient sanitizing in the header function, but instead never trust DIRTY data from your users.
No matter when and how, but if your data is coming from outside you need to clean it. In this example a simple / would escape the /n character, and the attack would not work.
Comment: I agree with your assessment of the problem but my issue is how to go about sanitizing input.  For html you have html entities.  For sql you have prepared statements.  In both cases you don't try and do it yourself (because you'll most likely miss an edge case).  That's what I'm worried about here -- edge cases.  Sure the author's (and your) solution will fix the examples given.  But is this really a universal solution?
Comment: Magic Quotes is deprecated and being removed from php (last I checked). And I don't think it would solve these problems.
Comment: I understand. I've actually seen header injection risks before, but then it was not possible to inject because of the php's magic quotes. I wish I could recommend you a good sanitizing library, but I dont know of any good ones yet.

PHP mail() Header Injection Prevention


How to change permissions after migrating files?

Question: I migrated music files from my old Mac to my new Mac but I don't have the permissions to open the folder with the new files. The option to select the folder with the transferred files was grayed out when I used "Get Info".
Answer: It does not sound like you are comfortable with using the command line so here is a GUI based solution that you might try:
If you are able to Get Info on the folder of interest go the the very bottom section Sharing and Permissions.
By default this section is greyed out for all files/folders regardless of the owner/permissions.   You can gain access to this area by clicking on the lock ion in the lower right corner of the Get Info window.
Once you have input the admin password for the computer you should be able to edit the permissions on that file/directory.
You can recursively apply the changes made to the permissions by selecting Apply to enclosed items from the gear shaped dropbox in the lower left of the Get Items window.
If you are familiar with the command line there are alternatives to this approach but give the graphical method.
Comment: Of course it was hidden behind the gear icon, where all critical options should live. Thanks
Answer: Click "get info" for the folder/file in question and then in the window that opens, look at the bottom right of it.
There should be a padlock item next to the file permissions area. If the padlock is displayed in the "Locked" position, then click it ones to 'unlock' it, then the file permission sections should no longer be greyed out.
Answer: If you want to do this properly, you should check out this guide at apple.com.
If you want to change permissions of specific files/folders manually, you can use the chown unix command.


extjs 4 autogenerating a record id

Question: I have a map to which features can be added and removed and am using an extjs 4 grid panel as a view (MVC) to list the features. The idea is that the user can click an item in the grid and highlight it in the map, click a button to remove it etc. The features do not have a natural key so I need to make one up, just a number is fine. At the moment the map starts up with some features already on it so I am able to loop through and give each an id and add a record to the store for each to tie the 2 up, but ideally I want the store to take care of that when each record is added. I also have the problem that when a new feature is created I need to get a fresh new id to use but I'd rather not have to loop through all my features to find the highest id.
I am using myStore.add({id:1,name:'blah'...}) to add the records - should I be using this or insert?
Any help appreciated
Comment: ok I have found that myStore.last() should get me the last record and am able to get the last id from there and add one. I'd still like to know whether the store can generate the ids for me though.
Answer: Yes you can use the store last to figure out your last record, but my recommendation is to handle ID generation to the server side. Typically database sequencer is used to create IDs.

extjs 4 autogenerating a record id


Why was it necessary for Jesus to go through Samaria in John 4:4

Question: John 4:4 begins with the Greek word "edei" (meaning: It is necessary) implying that Jesus had to go through Samaria. What situation made it necessary for Jesus to travel through Samaria.
Answer: Jesus was going from Judea to Galilee (John 4:3). To get from Judea in the south to Galilee in the north, Jesus had to pass through Samaria in the middle.
Comment: @Mac'sMusings https://www.bible-history.com/maps/ancient-roads-in-israel.html show that there was no other way. There was no road through the Jordan valley as there is today. A detour through via the coastal road would have made the journey way too long. Jews avoided contact with Samaritan persons but there was never any prohibition regarding geography.
Comment: @Mac'sMusings Do you have a source for that? Mishnah Chagiga 3:4 as interpreted by the Talmud 24b strongly implies that food transported from Galilee to Judea was assumed to have passed through Samaria
Comment: That is ONE way - most Jews went a longer way to avoid contact with Samaritans.  So, this does not answer the question.
Comment: Jews regularly crossed into Peraea to avoid Samaria - However, I agree that the necessity here was born of a need to minister to the woman at the well and turn her into one of the most successful evangelists - she brought out her entire village!
Comment: Why not that He wants to save the Samaritan woman?
Answer: It wasn't necessary in the directional sense (physical sense). It was necessary in the spiritual sense. He was led to go there to meet the woman at the well. A similar example to this is Philip goes and stands by the chariot, except in this case, the words are used "The Spirit said to Philip" (Acts 8:29). When we do things in the physical realm there are not such unusual events. Similarly, Jesus going to see Lazarus... If you work out the 4 days from the time he heard the news, and the journey time, you see that he let Lazarus die purposely. This is difficult for people to understand, but in the large scheme of things its pretty simple really.


How is it possible for AWS to offer the same private network address to different customers?

Question: I've been studying subnetting and of course there's plenty I'm confused about.  One issue is as follows: my company uses AWS.  For our VPC let's say we have a private network address of 10.2.0.0 /16 CIDR.  My question is this: I have a feeling that they can offer this private address to other companies as well.  How is this possible?  I realize I'm confused about something deeper, but then again, that's precisely why I'm asking this question.  Thanks!
Answer: It's exactly the same way that any company can use, and reuse, the same private addresses. The private addresses don't get routed where they can conflict with each other.
I my company uses private addresses internally, and your company uses the same private addresses internally, there is no conflict since our two companies can only communicate through a different network, and the same private addresses in each company get translated to different addresses before reaching the other company.
A single company can do the same thing internally. NAT is not just to connect to the Internet, it can be used inside a company, too.
Comment: So in other words the private addresses aren't 'sitting' on the internet?
Comment: Private addresses cannot be routed on the Internet. Only public addresses will be routed on the Internet.
Comment: Thanks, Ron!  That makes a lot of sense.  I vow to learn more about routing!
Comment: What did you mean when you said, "Nat is not just to connect to the Internet, it can be used inside a company, too,"?
Comment: There are all sorts of use cases for NAT within a company. For instance, your company and mine both use the same private addressing range when we decide to merge. It could take a very long time to re-address one or the other company. We could NAT between the to formerly separate companies.
Comment: That makes perfect sense.  Thanks for clarifying!
Answer: I don't know exactly how amazon does it but I can easilly see a few ways to engineer this.
The key thing to remember is that IP addresses only matter to IP routers and endpoints. An ethernet switch with VLANSs doesn't care if VLAN1 and VLAN2 have overlapping IP ranges, all it cares about is which vlan the packet is on and which MAC address it is flowing between. So if each companies virtual private cloud had it's own VLANs and it's own routers connecting those VLANs then it would not be not a problem for those virtual clouds to have overlapping IP space.
Routers
Routers can be partitioned into smaller virtual routers using "vrfs" Linux can do the same thing through the use of "network namespaces".
Or of course you could just use software routers (either the built in routing facilities in major operating systems or something from a router vendor) and run them inside VMs.
Unfortunately as pointed out in another answer these solution's don't scale well to an operation the size of AWS. There are only about 4000 usable VLAN IDs and most routers were designed to support a handful of virtual network, not tens to hundreds of thousands. Ethernet's tree-based design is also a major scaling problem.
That answer also linked to a video at https://www.youtube.com/watch?v=Zd5hsL-JNY4 which explains how they actually do it. To summarize the answer is that the customer traffic is carried in an encapsulated form between VM hosts. Each packet from a client VM is wrapped in a VPC header, then wrapped in an outer IP packet before being sent across the underlay network.
For hosts on the same subnet, the VM host for the source VM intercepts the arp requests from the customer VM and looks up the destination details in a mapping service based on the combination of IP address and customer. The VM host can then use the response from the mapping service to both synthesize an ARP request for the VM and to send encapsulated data packets to the VM host for the destination VM.
For hosts on different subnets the VM host intercepts the arp request for the default gateway in the mapping service, determines it is a virtual gateway and crafts an apprpriate arp response. When the actual data packets are sent the VM host looks up the destination IP in the mapping service to determine where to send the encapsulated packet.
For performance reasons the mapping service runs a local instance on each VM host, which caches all the information about the networks of the customer's that have VMs on that host.
Answer: The real way this is done in Amazon is different from how you might imagine, as common solutions don't scale.  They did a talk in 2013 about this at re:Invent, which you can watch on YouTube:
https://www.youtube.com/watch?v=Zd5hsL-JNY4
However, the more general answer is "IP addressing is a matter of perspective."  More specifically, if your hosts never want to talk to the hosts of someone else who was allocated the same IP space, no one cares that you have the same IP addresses.  If you do, and you want to talk to each other, then through the use of some mechanism like NAT, you will change the IP addresses of the the hosts in network A from the perspective of network B.


How does fusing weapons affect durability?

Question: How does fusing weapons and items together affect durability? For example, if I fuse a boulder to a sword, will that change how times I can attack with the sword before it breaks? What if I fuse a sword that's never been used with a sword that is badly damaged?
Answer: Simply put, fusing can grant up to a +25 durability buffer. As long as this buffer exists the weapon itself won't be damaged and hits will drain the buffer instead.
Not every fusion material will give a full 25 durability buffer. Some "low quality" items seem to give less. In that case should you defuse the weapon and attach a different item you can still gain the residual bonus.
Once you consumed the full 25 points, fusing won't have any further effect on durability.
Source: empirical experimentation by a reddit user
Note: it is still unknown if "repairing" the weapon has any effect on the buffer itself...

ADD-ON: A clarification on the buffer mechanic, as asked by Stevoisiak.
The durability buffer you can get from fusing is stacked on top of the weapon durability and is not considered part of it by the game. While this does not affect the "number of uses" that you can get from the weapon it means that the weapon "color" indicator of its durability is NOT affected by the buffer.
To put it simply:

you have a never fused before weapon that is "about to break" (should be 3 durability left) and thus displayed in red
you fuse a diamond and gain a full +25 durability buffer
the weapon original durability won't go down until you consume said buffer but the weapon will still be displayed as red and "about to break".

Sadly this means that you can't really know how much "durability buffer" you have left on a weapon. Therefore if you really want to save a weapon that is about to break, fusing may not be your best option.
Try something else...
... I once heard that the old methods our parents used to clean up rust from weapons work even better now...
Comment: @Fredy31 With the caveat that the buffer is per weapon, not per fused material. Going from 125/100 down to 20/100 and then re-fusing will not increase you to 55/100, but leave you at 20/100 with the new fused item -- you can only benefit from the bonus durability once (though it can be over multiple materials if the fused item is replaced before those extra 25 hits)
Comment: @Fredy31 you obviously have to de-fuse before trying a new fusion. See the other question about that.
Comment: What do you mean by durability buffer? Does it mean only 25 durability will get used up on the weapon being fused to, then any other hits won't drain it?
Comment: @Stevoisiak I mean that the "buffer" is consumed before consuming the regular item durability but it is not seen as part of it.  If you have a weapon that is already "about to break" and fuse an item on it and get the durability bonus the weapon icon **will stay red** but the weapon won't get further damage until the buffer is consumed.
Comment: So, if I get it right: That buffer is basically a second ressource that prevents the weapon from being damaged until it is itself exhausted. So fusing a weapon right away is useful, because even if you fuse later, its gonna 'heal' the same amount. Basically, fusing right away makes the HP go from 100/100 to 125/100, and fusing later will just make the total hp go from 20/100 to 55/100
Comment: I didnt even know you could refuse. I thought I tried and was told 'This item is already fused with something'
Comment: @RavenDreamer correct.
Comment: @Fredy31 You tried to attach a new item to your weapon, but the game *refused* to let you do so.
Answer: As already said in the other answer, the majority of the items you can fuse add exactly 25 durability points at the time of fusing. This includes material, monster parts and other items.
The new durability bonus gets used up before the base weapon durability, whatever it is.
To add something to Ꮢedacted's answer:
A similar logic applies when fusing a weapon to another weapon, but instead of getting +25 bonus you add the attached weapon durabilty, which simply breaks when it's used up.
This means that if you attach two weapons only the attached one will get its durability reduced, and when it breaks you'll remain with the base weapon (with the same durability it has before the fuse).
However, you can't exploit this bonus forever, since only 25 extra durability points are allowed per weapon.
For example, a wooden stick has 12 durability points, if you fuse it with another one you'll get a weapon with 24 durability points. After the attached stick breaks, if you fuse a boulder on it you don't get the expected 25 durability points, but only 13 points (25 - 12 already used).
Not every weapon has a potential durability bonus of 25, for example:

rusty weapons, royal guard weapons, tree branches and torches only have 10
Gerudo weapons only have 5
bone weapons only have 3

Think about it before fusing anything valuable on this weapons!
Source, this Youtube video.
Also, take a look at this spreadsheet for further stats.


[16.04]Laptop behaves awkwardly when I'm running ubuntu

Question: This may seem strange. But last month I bought a new laptop from HP and I installed Ubuntu 16.04 along side windows 10.
From a month now, I'm observing quite unnecessary things going on and a bit strange.

The battery drains too quickly as compared with windows. I know that Ubuntu is not that power efficient but it lasts not more than 1 hour with general usage while on windows I get around 3.5-4 hours of battery life.
When I suspend it for like 20 minutes and I come back, it's on fire! God knows what happens but my laptop will be sickly overheating. When it is suspended then why the hell it starts heating up?
Fans spinning too fast like I'm on some heavy usage or doing 4k editing even when I'm only reading Quora on chrome. Strange, isn't it ?

My laptop is rocking a 6th generation core i7 with 12 GB of memory and Nvidia GTX 950M.
What can I do regarding these power management/overheating issues?
Comment: I think some newer processors (such as the Intel Skylake series) do not have great power management support under Linux yet, unfortunately.
Comment: Which graphics driver do you use? Check it in "System Settings" → "Software & Updates" → "Additional drivers".
Answer: A lot of reasons could be the culprit, and honestly it could be an unlucky combination all of the reasons combined. Every situation is unique. Here's what I would do:
Always - A good practice is to make sure your PC is currently up to date, run this command:
apt-get update

and then this command:
apt-get upgrade

Then I'd wait to see if that fixed the issue.
1 - I'd run the command top to see what processes and resources are being commonly used. I'd also have top running before it suspends so I can see it first thing when it awakens. I'd research each one to make sure its useful to my usage and needs.
2 - I'd also go through the Startup Applications List to see what apps are auto-starting. There shouldn't be but a few things running. Again, I'd research each one to make sure its useful to my usage and needs.
3 - I'd double check the settings in the Power Menu as well as the Brightness & Lock settings too. Could be a bad combination of settings.
4 - I'd also check Bluetooth and wireless settings, if left on they could easily draw from battery. Again, could be a bad combination of settings.
5 - Remember to save and exit from any apps you have running before suspending your laptop.
6 - I'd, personally, try a new fresh install with a new download and a freshly burned CD. I'd go so far as to try Lubuntu or Xubuntu just to see if they have better results with the Hardware.
Good Luck!


projection to the scheme

Question: Let $A$ be an $k$-affinoid algebra. Let $X=M(A)$ be the affinoid space associated to $A$ in the sense of Berkovich. There exists a natural morphism $\pi:X\to Y:=Spec(A)$ which sends $x$ to $ker (|\cdot|_x)$. In the book "Spectral theory and analytic geometry over non-archimedean fields" of Berkovich, he say that the functor $\mathcal{F}\mapsto\pi^*\mathcal{F}$  from the category of $\mathcal{O}_Y$-module to $\mathcal{O}_X$-module is exact and faithful. I don't know how to show that it is faithful.
Answer: The faithfulness and exactness follow from general facts about locally ringed spaces, once we have established some facts about the kernel map. Indeed, in Chapter 0 (6.7.8) of EGA I, it is shown that a faithfully flat morphism of locally ringed spaces induces an exact and faithful pullback functor on categories of $\mathcal{O}$-modules.
It is easy to check that the kernel map $\pi \colon \mathcal{M}(A) \to \textrm{Spec}(A)$ is a morphism of locally ringed spaces, but to show that it is faithfully flat requires some work. This requires you to show that $\pi$ is surjective and the induced map on all local rings is faithfully flat; these assertions are Proposition 2.1.1 and Theorem 2.1.4, respectively, of Berkovich's IHES paper.
For a more detailed proof of these statements, see lectures 14 and 15 from Mattias Jonsson's course notes.
Comment: As an aside, on p.33 of his book, Berkovich writes a ''strictly flat'' morphism of locally ringed spaces, but I believe he means ''faithfully flat''.

projection to the scheme


How do I erase/format a harddisk from a live CD?

Question: I need to format a drive containing an old install of Ubuntu 10.04, to install Vista (not my idea!) Vista setup apparently refuses to format non-FAT32 or NTFS partitions. However, I can't seem to format it from my live CD (Ubuntu 11.04) at all; I keep getting "device is busy" errors. What is the simplest way to format this drive?
Answer: From a live session start Gparted Partition Editor from System -> Administration:

Choose the drive you need to re-partition or format from the top right. Then select your partition (in this case /dev/sda1). By right click on the partition a menu pops up that lets you choose to Delete or Format this partition.
Partitions need to be unmounted before changing them
In case you install another OS it may be sufficient to just delete all partitions leaving the drive unpartitioned. Partitoning and formatting will then be done by the new OS's installer.
We have to keep in mind that private data on that drive will still be recoverable after deleting or reformatting partitions.
Comment: If they're NTFS or FAT32 partitions, then yes, Vista can natively use them. If they're anything else you'd need a workaround. The problem with having eight partitions though is that Windows will accept only four *primary* partitions. I don't know how interchangeable logical partitions are with extended partitions. It's probably best to back-up the data and reformat to Windows native file systems.
Comment: delete partition with `dd if=/dev/null of=/$hd` ($hd=[/hda1|/sda1|...)] or if you're more paranoid `if=/dev/random` or even urandom
Comment: I have a lot of partitions to format (about 8), do I have to format them all and can Vista then use them as one?
Comment: I'm fully aware of information security, but I don't consider it a problem for me as it was only my old school laptop.
Comment: It's going to my sister cause she broke her last laptop... how long will this one last I don't know. I upgraded recently to a ThinkPad. Thanks for your concern though. If I was worried about security of data I would do a basic secure shred if there was anything worth having I guess.
Answer: The simplest way, I would argue, is to put the Windows Vista DVD in the drive and start the installation process.
The Windows Vista DVD should be capable of formatting the disk to the Windows native partition(s) (NTFS or FAT32) you require for Windows installation.
This will cut out one step in the process.
Is that an option for you? Or do you have some special need to use a Linux Live CD?
Remember to first back-up any valuable data on partitions you plan to nuke.
Comment: Damn. OK, another option that I like is to use a [GParted Live CD](http://gparted.sourceforge.net/livecd.php). If this thing can't delete a partition table then the next step is to get something like, for example, the [Western Digital Diagnostics disk](http://support.wdc.com/product/download.asp?groupid=613&sid=30⟨=en) to write 0's to the whole disk. NB: This can also be achieved using the `dd` command in a terminal.
Comment: I tried this. Vista refuses to format it! Ugh.


Is there more to an interface than having the correct methods

Question: So lets say I have this interface:
public interface IBox
{
   public void setSize(int size);
   public int getSize();
   public int getArea();
  //...and so on
}

And I have a class that implements it:
public class Rectangle implements IBox
{
   private int size;
   //Methods here
}

If I wanted to use the interface IBox, i can't actually create an instance of it, in the way:
public static void main(String args[])
{
    Ibox myBox=new Ibox();
}

right? So I'd actually have to do this:
public static void main(String args[])
{
    Rectangle myBox=new Rectangle();
}

If that's true, then the only purpose of interfaces is to make sure that the class which implements an interface has got the correct methods in it as described by an interface? Or is there any other use of interfaces?
Comment: Remember, interfaces aren't specific to Java.  All OOP languages have them in some form or another, though not always as explicitly defined as Java.
Comment: Technically, all strongly-typed OOP languages have them in some form or another.  Untyped, or duck typed, languages don't have a similar concept.
Comment: @Jared Aren't you confusing strong typing with static typing, and "untyped" with dynamically typed?
Comment: Polymorphism can be accomplished via interfaces also. Check the last section of this page http://codenuggets.com/2014/06/20/java-interface/
Comment: http://stackoverflow.com/a/24436493/1286942
Comment: What do you mean by "correct methods"?
Answer: Interfaces are a way to make your code more flexible. What you do is this:
Ibox myBox=new Rectangle();

Then, later, if you decide you want to use a different kind of box (maybe there's another library, with a better kind of box), you switch your code to:
Ibox myBox=new OtherKindOfBox();

Once you get used to it, you'll find it's a great (actually essential) way to work.
Another reason is, for example, if you want to create a list of boxes and perform some operation on each one, but you want the list to contain different kinds of boxes. On each box you could do:
myBox.close()

(assuming IBox has a close() method) even though the actual class of myBox changes depending on which box you're at in the iteration.
Comment: There is nothing in this answer that is exclusive to *Java interfaces*. The same applies equaly well to abstract classes, or even concrete ones. I would expect a good answer to mention the ability to implement *multiple* interfaces, and when/why that would be useful.
Comment: How did this get selected as the answer? It's a brief description of why polymorphism is useful, but as the poster above said, I would expect a better explanation of multiple interfaces and even more importantly when it is appropriate to use an interface vs an abstract class.
Comment: This has very little to do with explaining interfaces and everything to do with the basics of polymorphism
Answer: What makes interfaces useful is not the fact that "you can change your mind and use a different implementation later and only have to change the one place where the object is created". That's a non-issue.
The real point is already in the name: they define an interface that anyone at all can implement to use all code that operates on that interface. The best example is java.util.Collections which provides all kinds of useful methods that operate exclusively on interfaces, such as sort() or reverse() for List. The point here is that this code can now be used to sort or reverse any class that implements the List interfaces - not just ArrayList and LinkedList, but also classes that you write yourself, which may be implemented in a way the people who wrote java.util.Collections never imagined.
In the same way, you can write code that operates on well-known interfaces, or interfaces you define, and other people can use your code without having to ask you to support their classes.
Another common use of interfaces is for Callbacks. For example, java.swing.table.TableCellRenderer, which allows you to influence how a Swing table displays the data in a certain column. You implement that interface, pass an instance to the JTable, and at some point during the rendering of the table, your code will get called to do its stuff.
Comment: That's a pretty good answer ,I like it when you gave examples from java package classes...
Comment: @Powerslave:paraphrase it more like What makes interfaces useful is not [the ability to write code where you have to change only one line when changing the impementation] but rather [the ability to write code where you don't even specify an implementation at all].
Comment: I liked `you can write code that operates on well-known interfaces, or interfaces you define`
Comment: Wait a moment... What makes interfaces useful is not [the ability to use any implementation you like], but rather [the ability to use any implementation you like]? Mentioning *the opposite case* is pretty much a good point though.
Comment: @MichaelBorgwardt That sounds way better. :) Thanks for clarifying!
Answer: One of the many uses I have read is where its difficult without multiple-inheritance-using-interfaces in Java :
class Animal
{
void walk() { }
....
.... //other methods and finally
void chew() { } //concentrate on this
}

Now, Imagine a case where:
class Reptile extends Animal
{
//reptile specific code here
} //not a problem here

but,
class Bird extends Animal
{
...... //other Bird specific code
} //now Birds cannot chew so this would a problem in the sense Bird classes can also call chew() method which is unwanted

Better design would be:
class Animal
{
void walk() { }
....
.... //other methods
}

Animal does not have the chew() method and instead is put in an interface as :
interface Chewable {
void chew();
}

and have Reptile class implement this and not Birds (since Birds cannot chew) :
class Reptile extends Animal implements Chewable { }

and incase of Birds simply:
class Bird extends Animal { }

Comment: @CHEBURASHKA And bad naming. If `Reptile` "chews", than not itself is "chewable". The convention of (sometimes) naming interfaces *Whateverable* should only be applied where it makes perfect sense. Naming the interface `Predator` would be more appropriate here.
Comment: @Powerslave It's correct imho, a reptile is "able to chew"/"chewable". A hawk is a predator but still not able to chew... just nitpicking but "chewable" can be defined better in the documentation of the interface.
Comment: I don't get it. All it seems like is that interfaces are a good way to make sure you implement the same methods in each class that implements it, (eg. so it prevents me from making the stupid choice of a Bird class with run() and a Dog class with runn() -- they're all the same). But by paying attention and making my classes have the same method formats/structures, couldn't I achieve this same thing? Really seems like interfaces just make sure the programmer isn't being forgetful. Also, interfaces don't seem to save me time; I still need to define the method in each class that implements it.
Comment: Superb.. Explained very well. Thank you..!
Comment: @AlexG - i told one of the many uses dude :)
There are more, we had barely scratched the surface to answer the question in a simple fashion !
Comment: But still, `Chewable` could be an class extending from `Animal`, and `Bird` extends from it. Would be better since you could give the `chew()` a body so all sub-classes automatically know how to chew by default instead of repeating code, this is not the best example, but still..
Answer: The purpose of interfaces is polymorphism, a.k.a. type substitution. For example, given the following method:
public void scale(IBox b, int i) {
   b.setSize(b.getSize() * i);
}

When calling the scale method, you can provide any value that is of a type that implements the IBox interface. In other words, if Rectangle and Square both implement IBox, you can provide either a Rectangle or a Square wherever an IBox is expected.
Comment: Why is the purpose of interfaces polymorphism, if I can already achieve that in Java with subclassing and method overriding?
Comment: Hey, I never said Java had any kind of conceptual integrity. Type substitution is the purpose of all subtyping. Java happens to have more than one subtyping mechanism, none of which are particularly good.
Comment: It's the same thing, except that interfaces must omit any implementation. Classes can therefore implement more than one interface.
Comment: I never said anything about conceptual integrity as well. But let's move on. If you can scale every IBox with your method, shouldn't it be an operation declared on IBox: IBox.scale(int)?
Comment: We wouldn't want to couple Integer to IBox, that's why we don't make it a method on Integer. And the number of methods on an interface is decided by the consistency and cohesion of the abstraction it expresses, not how cumbersome it would be to implement it. Anyway, thanks for your answers Apo.
Comment: I asked, because you could also say that the primary purpose of interfaces is abstraction (i.e. decoupling from implementation), and just like any Java type (be it declared as class or interface) they allow for polymorphism through inheritance.
Comment: Why not make it a method on Integer? It doesn't matter to me either way except that the more methods you add to an interface, the more cumbersome it is to implement.
Answer: Interfaces allow statically typed languages to support polymorphism.  An Object Oriented purist would insist that a language should provide inheritance, encapsulation, modularity and polymorphism in order to be a fully-featured Object Oriented language.  In dynamically-typed - or duck typed - languages (like Smalltalk,) polymorphism is trivial; however, in statically typed languages (like Java or C#,) polymorphism is far from trivial (in fact, on the surface it seems to be at odds with the notion of strong typing.)
Let me demonstrate:
In a dynamically-typed (or duck typed) language (like Smalltalk), all variables are references to objects (nothing less and nothing more.)  So, in Smalltalk, I can do this:
|anAnimal|
anAnimal := Pig new.
anAnimal makeNoise.

anAnimal := Cow new.
anAnimal makeNoise.

That code:

Declares a local variable called anAnimal (note that we DO NOT specify the TYPE of the variable - all variables are references to an object, no more and no less.)
Creates a new instance of the class named "Pig"
Assigns that new instance of Pig to the variable anAnimal.
Sends the message makeNoise to the pig.
Repeats the whole thing using a cow, but assigning it to the same exact variable as the Pig.

The same Java code would look something like this (making the assumption that Duck and Cow are subclasses of Animal:
Animal anAnimal = new Pig();
duck.makeNoise();

anAnimal = new Cow();
cow.makeNoise();

That's all well and good, until we introduce class Vegetable.  Vegetables have some of the same behavior as Animal, but not all.  For example, both Animal and Vegetable might be able to grow, but clearly vegetables don't make noise and animals cannot be harvested.
In Smalltalk, we can write this:
|aFarmObject|
aFarmObject := Cow new.
aFarmObject grow.
aFarmObject makeNoise.

aFarmObject := Corn new.
aFarmObject grow.
aFarmObject harvest.

This works perfectly well in Smalltalk because it is duck-typed (if it walks like a duck, and quacks like a duck - it is a duck.)  In this case, when a message is sent to an object, a lookup is performed on the receiver's method list, and if a matching method is found, it is called.  If not, some kind of NoSuchMethodError exception is thrown - but it's all done at runtime.
But in Java, a statically typed language, what type can we assign to our variable?  Corn needs to inherit from Vegetable, to support grow, but cannot inherit from Animal, because it does not make noise.  Cow needs to inherit from Animal to support makeNoise, but cannot inherit from Vegetable because it should not implement harvest.  It looks like we need multiple inheritance - the ability to inherit from more than one class.  But that turns out to be a pretty difficult language feature because of all the edge cases that pop up (what happens when more than one parallel superclass implement the same method?, etc.)
Along come interfaces...
If we make Animal and Vegetable classes, with each implementing Growable, we can declare that our Cow is Animal and our Corn is Vegetable.  We can also declare that both Animal and Vegetable are Growable.  That lets us write this to grow everything:
List<Growable> list = new ArrayList<Growable>();
list.add(new Cow());
list.add(new Corn());
list.add(new Pig());

for(Growable g : list) {
   g.grow();
}

And it lets us do this, to make animal noises:
List<Animal> list = new ArrayList<Animal>();
list.add(new Cow());
list.add(new Pig());
for(Animal a : list) {
  a.makeNoise();
}

The advantage to the duck-typed language is that you get really nice polymorphism: all a class has to do to provide behavior is provide the method.  As long as everyone plays nice, and only sends messages that match defined methods, all is good.  The downside is that the kind of error below isn't caught until runtime:
|aFarmObject|
aFarmObject := Corn new.
aFarmObject makeNoise. // No compiler error - not checked until runtime.

Statically-typed languages provide much better "programming by contract," because they will catch the two kinds of error below at compile-time:
// Compiler error: Corn cannot be cast to Animal.
Animal farmObject = new Corn();
farmObject makeNoise();

--
// Compiler error: Animal doesn't have the harvest message.
Animal farmObject = new Cow();
farmObject.harvest();

So....to summarize:

Interface implementation allows you to specify what kinds of things objects can do (interaction) and Class inheritance lets you specify how things should be done (implementation).
Interfaces give us many of the benefits of "true" polymorphism, without sacrificing compiler type checking.
Comment: This is the text of my answer to another question: http://stackoverflow.com/questions/379282/why-the-use-of-both-a-base-class-and-an-interface-in-polymorphism/379491#379491.  But, they're related answers.
Comment: So may I ask, how does a duck typed language distinguish between Animal.water() (which, the prudish farmer used to say that it takes a leak) and Plant.water() which he uses to water plants. Ambiguity is the enemy. Any amount of verbosity necessary to overcome ambiguity is acceptable IMO.
Comment: Yep..ambiguity is the name of the game with duck typed languages.  When working professionally in a duck typed language, it's not uncommon to see members (methods and variables) with names that are 50-100 characters in length.
Comment: Another big downside of duck typed languages is the inability to do programmatic refactoring based on static analysis - try asking a Smalltalk image for the list of all callers of your printString method...you will get the list of all callers of ALL printString methods....
Comment: ...because the caller of Automobile#printString cannot be programmatically differentiated from the caller of NearEarthOrbit#printString.
Comment: I guess I'm glad both options exist.  I like the reliability of stamping an interface on something to say "THIS IS A DUCK", but I can see how it's quite unnecessary (and even harmful) on smaller projects with smaller teams.
Comment: You are confusing strongly typed with statically typed, and weakly typed with dynamically typed.
Comment: According to wikipedia, the terms "strongly typed" and "weakly typed" are very versatile - and have been used in this way in the past.  However; statically typed and dynamically typed are much more precise.  I've edited the response to use that terminology instead.  Thanks.
Comment: You should have made the pig fly... much funner.
Answer: Normally Interfaces define the interface you should use (as the name says it ;-) ). Sample

public void foo(List l) {
   ... do something
}

Now your function foo accepts ArrayLists, LinkedLists, ... not only one type.
The most important thing in Java is that you can implement multiple interfaces but you can only extend ONE class! Sample:

class Test extends Foo implements Comparable, Serializable, Formattable {
...
}

is possible but

class Test extends Foo, Bar, Buz {
...
}

is not!

Your code above could also be: IBox myBox = new Rectangle();. The important thing is now, that myBox ONLY contains the methods/fields from IBox and not the (possibly existing) other methods from Rectangle.
Comment: Is 'List' supposed to be an interface member?
Comment: List is an interface in the java collections library.
Comment: List is an interface in the standard Java library (http://java.sun.com/javase/6/docs/api/java/util/List.html). He's just using it to illustrate his point.
Answer: you could do
Ibox myBox = new Rectangle();

that way you are using this object as Ibox and you don't care that its really Rectangle .
Comment: That means we could write like this?! > Rectangle inst = new Rectangle ();
Comment: @Mr.Hyde If you later want to add `Square` you'd have a problem.... if you try to do it without interfaces, you cannot guarantee that `Square` and `Rectangle` have the same methods... this can result in a nightmare when you have a larger code base... Remember, interfaces define a template.
Answer: I think you understand everything Interfaces do, but you're not yet imagining the situations in which an Interface is useful.
If you're instantiating, using and releasing an object all within a narrow scope (for example, within one method call), an Interface doesn't really add anything. Like you noted, the concrete class is known.
Where Interfaces are useful is when an object needs to be created one place and returned to a caller that may not care about the implementation details. Let's change your IBox example to an Shape. Now we can have implementations of Shape such as Rectangle, Circle, Triangle, etc., The implementations of the getArea() and getSize() methods will be completely different for each concrete class.
Now you can use a factory with a variety of createShape(params) methods which will return an appropriate Shape depending on the params passed in. Obviously, the factory will know about what type of Shape is being created, but the caller won't have to care about whether it's a circle, or a square, or so on.
Now, imagine you have a variety of operations you have to perform on your shapes. Maybe you need to sort them by area, set them all to a new size, and then display them in a UI. The Shapes are all created by the factory and then can be passed to the Sorter, Sizer and Display classes very easily. If you need to add a hexagon class some time in the future, you don't have to change anything but the factory. Without the Interface, adding another shape becomes a very messy process.
Answer: WHY INTERFACE??????
It starts with a dog. In particular, a pug.
The pug has various behaviors:
public class Pug {
private String name;
public Pug(String n) { name = n; }
public String getName() { return name; }
public String bark() { return  "Arf!"; }
public boolean hasCurlyTail() { return true; } }

And you have a Labrador, who also has a set of behaviors.
public class Lab {
private String name;
public Lab(String n) { name = n; }
public String getName() { return name; }
public String bark() { return "Woof!"; }
public boolean hasCurlyTail() { return false; } }

We can make some pugs and labs:
Pug pug = new Pug("Spot");
Lab lab = new Lab("Fido");

And we can invoke their behaviors:
pug.bark() -> "Arf!"
lab.bark() -> "Woof!"
pug.hasCurlyTail() -> true
lab.hasCurlyTail() -> false
pug.getName() -> "Spot"

Let's say I run a dog kennel and I need to keep track of all the dogs I'm housing. I need to store my pugs and labradors in separate arrays:
public class Kennel {
Pug[] pugs = new Pug[10];
Lab[] labs = new Lab[10];
public void addPug(Pug p) { ... }
public void addLab(Lab l) { ... }
public void printDogs() { // Display names of all the dogs } }

But this is clearly not optimal. If I want to house some poodles, too, I have to change my Kennel definition to add an array of Poodles. In fact, I need a separate array for each kind of dog.
Insight: both pugs and labradors (and poodles) are types of dogs and they have the same set of behaviors. That is, we can say (for the purposes of this example) that all dogs can bark, have a name, and may or may not have a curly tail. We can use an interface to define what all dogs can do, but leave it up to the specific types of dogs to implement those particular behaviors. The interface says "here are the things that all dogs can do" but doesn't say how each behavior is done.
public interface Dog
{
public String bark();
public String getName();
public boolean hasCurlyTail(); }

Then I slightly alter the Pug and Lab classes to implement the Dog behaviors. We can say that a Pug is a Dog and a Lab is a dog.
public class Pug implements Dog {
// the rest is the same as before }

public class Lab implements Dog {
// the rest is the same as before
}

I can still instantiate Pugs and Labs as I previously did, but now I also get a new way to do it:
Dog d1 = new Pug("Spot");
Dog d2 = new Lab("Fido");

This says that d1 is not only a Dog, it's specifically a Pug. And d2 is also a Dog, specifically a Lab.
We can invoke the behaviors and they work as before:
d1.bark() -> "Arf!"
d2.bark() -> "Woof!"
d1.hasCurlyTail() -> true
d2.hasCurlyTail() -> false
d1.getName() -> "Spot"

Here's where all the extra work pays off. The Kennel class become much simpler. I need only one array and one addDog method. Both will work with any object that is a dog; that is, objects that implement the Dog interface.
public class Kennel {
Dog[] dogs = new Dog[20];
public void addDog(Dog d) { ... }
public void printDogs() {
// Display names of all the dogs } }

Here's how to use it:
Kennel k = new Kennel();
Dog d1 = new Pug("Spot");
Dog d2 = new Lab("Fido");
k.addDog(d1);
k.addDog(d2);
k.printDogs();

The last statement would display:
Spot Fido
An interface give you the ability to specify a set of behaviors that all classes that implement the interface will share in common. Consequently, we can define variables and collections (such as arrays) that don't have to know in advance what kind of specific object they will hold, only that they'll hold objects that implement the interface.
Comment: @niranjan kurambhatti i can make all classes to extend dog but still why interface??
Answer: Don't forget that at a later date you can take an existing class, and make it implement IBox, and it will then become available to all your box-aware code.
This becomes a bit clearer if interfaces are named -able. e.g.
public interface Saveable {
....

public interface Printable {
....

etc. (Naming schemes don't always work e.g. I'm not sure Boxable is appropriate here)
Answer: A great example of how interfaces are used is in the Collections framework.  If you write a function that takes a List, then it doesn't matter if the user passes in a Vector or an ArrayList or a HashList or whatever.  And you can pass that List to any function requiring a Collection or Iterable interface too.
This makes functions like Collections.sort(List list) possible, regardless of how the List is implemented.
Answer: This is the reason why Factory Patterns and other creational patterns are so popular in Java. You are correct that without them Java doesn't provide an out of the box mechanism for easy abstraction of instantiation. Still, you get abstraction everywhere where you don't create an object in your method, which should be most of your code.
As an aside, I generally encourage people to not follow the "IRealname" mechanism for naming interfaces. That's a Windows/COM thing that puts one foot in the grave of Hungarian notation and really isn't necessary (Java is already strongly typed, and the whole point of having interfaces is to have them as largely indistinguishable from class types as possible).
Comment: You are confusing strong typing with static typing.
Answer:
the only purpose of interfaces is to make sure that the class which implements an interface has got the correct methods in it as described by an interface? Or is there any other use of interfaces?

I am updating the answer with new features of interface, which have introduced with java 8 version.
From oracle documentation page on summary of interface :
An interface declaration can contain

method signatures
default methods
static methods
constant definitions.

The only methods that have implementations are default and static methods.
Uses of interface:

To define a contract
To link unrelated classes with has a capabilities (e.g. classes implementing Serializable interface may or may not have any relation between them except implementing that interface
To provide interchangeable implementation e.g. strategy pattern
Default methods enable you to add new functionality to the interfaces of your libraries and ensure binary compatibility with code written for older versions of those interfaces
Organize helper methods in your libraries with static methods ( you can keep static methods specific to an interface in the same interface rather than in a separate class)

Some related SE questions with respect to difference between abstract class and interface and use cases with working examples:
What is the difference between an interface and abstract class?
How should I have explained the difference between an Interface and an Abstract class?
Have a look at documentation page to understand new features added in java 8 : default methods and static methods.
Comment: I removed java-8 tag as the *question* did not ask anything about java-8 (and actually was asked long time before java-8). Tags are for questions, not for answers.
Answer: The purpose of interfaces is abstraction, or decoupling from implementation.
If you introduce an abstraction in your program, you don't care about the possible implementations. You are interested in what it can do and not how, and you use an interface to express this in Java.
Comment: If all structured programming is abstraction (your claim), then interfaces are abstractions in that abstraction.
Comment: The purpose of all structured programming is abstraction. Why would you say that the purpose of interfaces is abstraction, since I can achieve the exact same thing using generics and class composition?
Answer: If you have CardboardBox and HtmlBox (both of which implement IBox), you can pass both of them to any method that accepts a IBox. Even though they are both very different and not completely interchangable, methods that don't care about "open" or "resize" can still use your classes (perhaps because they care about how many pixels are needed to display something on a screen).
Answer: Interfaces where a fetature added to java to allow multiple inheritance. The developers of Java though/realized that having multiple inheritance was a "dangerous" feature, that is why the came up with the idea of an interface.
multiple inheritance is dangerous because you might have a class like the following:

class Box{
    public int getSize(){
       return 0;
    }
    public int getArea(){
       return 1;
    }

}

class Triangle{
    public int getSize(){
       return 1;
    }
    public int getArea(){
       return 0;
    }

}

class FunckyFigure extends Box, Triable{
   // we do not implement the methods we will used the inherited ones
}

Which would be the method that should be called when we use

   FunckyFigure.GetArea();

All the problems are solved with interfaces, because you do know you can extend the interfaces and that they wont have classing methods... ofcourse the compiler is nice and tells you if you did not implemented a methods, but I like to think that is a side effect of a more interesting idea.
Comment: You might want to make a difference between multiple implementation inheritance and multiple interface inheritance in your answer, otherwise it gets confusing.
Answer: Here is my understanding of interface advantage. Correct me if I am wrong.
Imagine we are developing OS and other team is developing the drivers for some devices.
So we have developed an interface StorageDevice. We have two implementations of it (FDD and HDD) provided by other developers team.
Then we have a OperatingSystem class which can call interface methods such as saveData by just passing an instance of class implemented the StorageDevice interface.
The advantage here is that we don't care about the implementation of the interface. The other team will do the job by implementing the StorageDevice interface.
package mypack;

interface StorageDevice {
    void saveData (String data);
}

class FDD implements StorageDevice {
    public void saveData (String data) {
        System.out.println("Save to floppy drive! Data: "+data);
    }
}

class HDD implements StorageDevice {
    public void saveData (String data) {
        System.out.println("Save to hard disk drive! Data: "+data);
    }
}

class OperatingSystem {
    public String name;
    StorageDevice[] devices;
    public OperatingSystem(String name, StorageDevice[] devices) {

        this.name = name;
        this.devices = devices.clone();

        System.out.println("Running OS " + this.name);
        System.out.println("List with storage devices available:");
        for (StorageDevice s: devices) {
            System.out.println(s);
        }

    }

    public void saveSomeDataToStorageDevice (StorageDevice storage, String data) {
        storage.saveData(data);
    }
}

public class Main {

    public static void main(String[] args) {

        StorageDevice fdd0 = new FDD();
        StorageDevice hdd0 = new HDD();
        StorageDevice[] devs = {fdd0, hdd0};
        OperatingSystem os = new OperatingSystem("Linux", devs);
        os.saveSomeDataToStorageDevice(fdd0, "blah, blah, blah...");
    }
}

Comment: same thing can be done with abstract class StorageDevice  and FDD and HDD classes extending StorageDevice class. but if we use abstract class we cant take advantage of multiple inheritance.


can I change the date of travel to the UK after filling out the online form?

Question: After filling out my online form I had to change the date of my travel to UK, what can I do?
Answer: It shouldn't be a big deal. Plans change. I've changed my dates of travel after obtaining visas plenty of times. If you haven't submitted the form, you may cross out the dates and change them with a pen.


Tiny orbital body detection

Question: What technology would be required to detect a coconut-sized sphere in Earth orbit, at the average altitude of communications satellites?
Comment: PESA radars like Don-2N radar
Comment: Thank you.
If I can take it further: if that kind of radar was not being intentionally used for the specific purpose of seeking an object of that size, would it nonetheless be detected as a matter of course - in other words, in the course of whatever other purposes the radar might be being used for?
Many thanks.
Comment: The question is not very clear, perhaps this experiment will be the answer to this question. - https://space.stackexchange.com/questions/35151/what-steel-ball-was-thrown-out-of-the-iss-to-help-test-how-well-ground-stations/35152#35152
Answer: In general, there are two ways to detect objects:
Active detection (Radar) and passive detection (optical systems, i.e. telescopes).
Active systems are used for objects close to earth, as the radar systems need to send out their own signal which then gets reflected by the objects. Passive systems are used for objects that are further away, they use the reflection from sunlight (not necessarily visible light, though).
There are also very different types of "communications satellites". The StarLink system is in close orbit (LEO), most western countries utilize satellites in GEO for satellite TV, Russians have to rely on satellites in the Molniya-Orbit, which is highly elliptical and can be in LEO or further away than GEO.
As for radars, which are best for LEO, the size threshold is about 0.5cm-2cm, depending on the radar system.
Optical systems are quite different regarding the detected size, their threshold generally ranges from 15cm ("might detect coconut") to 1m ("won't detect coconut"). These systems rarely watch for random objects in orbit.
Some radar systems keep scanning different regions of the sky, so they have the best odds to find something in lower orbits. An example that could randomly find such an object would be the German FGAN TIRA (potentially aided by the Effelsberg receiver antenna), which could detect your metallic coconut up to a height of 1500km, or the US' Haystack LRIR (potentially aided by HAX). Both do Beam Park experiments.
And just for completeness, there are also optical systems for LEO detection, for example liquid mirror telescopes, but they are mostly being used for statistical analysis.
Note that some of my information might be outdated. It comes from a lecture about space debris, that was a few years back.
Edit, for readability:
Phased Array Warning System (PAWS) - 1980
COBRA DANE - 1977
Eglin radar - 1961
Fylingdales SSN Radar - 1963
Globus II SSN Radar - Before 1998?
FGAN TIRA - 1970
"Monge" Tracking Ship - 1992
Haystack LRIR/HAX - 1960
Effelsberg receiver antenna - 1971
GRAVES Electronic Fence - 2005
Comment: This is so helpful, thanks indeed. 'History of space debris' is broadly what I'm after - specifically the historical point we gained capacity to detect LEO objects of that size.
Thanks again for setting out so clearly where to go from here...
Comment: I edited in the notable radar systems I know, including the dates when they became operational. Most of the earlier ones were originally constructed during the cold war to detect missiles, though, so they wouldn't have found your iron coconut randomly and by themselves.

Tiny orbital body detection


Create gradient around line in a brochure

Question: I want to do create gradients along the folds of a tri-fold brochure in Photoshop, similar to the first photo. Is there any straightforward way to do this without messing up the layers?
Comment: Hi Ian. What have you tried, what didn't work? I have a feeling that the most straightforward approach would be learning about Photoshop tools: in a most basic scenario you'd need a gradient tool and that's it
Answer: The quick and dirty way is to:

create a new layer

select a rectangle, the size of your "page"

use the gradient tool to create a black to white gradient

set blend mode to multiply

alt drag to duplicate, edit transparency to suitable

The correct way is to do it in illustrator, or any other vector program.
Answer: Simply create 2 shapes, filled with a black to transparent gradient. Align the 2 shapes so they butt against each other and have opposing gradients (One at 0° and the other at 180°).
Reduce the opacity of the two shapes. In this sample the right gradient is set to 20% opacity and the left is at 25% opacity. There needs to be some variation in opacity to better convey the "fold" aspect.

Just the shapes on white for clarity....

If you feel the need, based upon the underlying artwork, you may want to set the Blending Mode for these gradient shapes to Multiply.
Answer: You obviously want to create an illusion of surface curvature around the fold. Your case is difficult. The image is quite dark. Darkening it more doesn't look right as the only effect. But you can make the other side brighter - like a reflection highlight.

Sorry for not using Photoshop, but this is possible in any program which has layers, opacity adjustment and blending modes. There are 2 blurred reduced opacity layers with blending mode hard light. One makes the left side brighter and the other makes the right side darker.
The job starts by inserting a new empty layer and filling a rectangular area around the fold with white. The selection should be higher than the page because the next step needs spare height.

Let the new layer have blending mode Hard Light. Remove the selection and apply Gaussian blur. Good amount of blur leaves just the fold line nearly white:

Duplicate the white layer, invert it to black:

Make rectangular selections and delete black and white above and below the print area. Remove black from the left side and remove white from the right side. Reduce the opacities to be able to see the fold properly:

As you see the dark page takes much more effect from white. Balance the sides by adjusting the layer opacities. You can also stretch or squeeze the widths of the blurred zones if needed. It doesn't change their effect depths:

Layer opacities are now 64% for the black and 11% for the white.


How to reliably identify a certificate as intermediate certificate?

Question: As per the title, is there a way to reliably identify a certificate as an intermediate certificate?
I can identify if a certificate is a root certificate. But i can not tell the difference between an intermediate certificate and end/leaf certificate. Is there anything that would? such as one of the extensions?
Answer: An intermediate differs from a leaf certificate in that it is allowed to sign other certificates, i.e. basic constraints CA:true. It differs from a root certificate in that it is not self-signed, i.e. the issuer is not the certificate itself.
Comment: thanks, this is exactly what i was thinking/looking into; the extension: Basic Constraints ( 188.8.131.52 )
Answer: Your question sounds like you want to read more about Certificate Path Validation, e.g. in RFC 5280.
Comment: this would mean i have the complete chain tho. i would like to know without having a complete chain.


Why would there be a binary incompatibility between packages for different Linux distributions?

Question: The Linux Standard Base project is an effort to create a binary compatibility between different Linux distributions. But why would this be necessary? The implication is that the source code for the package works on any distribution, but when compiled, it would no longer work on any except that for which it is compiled. I thought the Linux kernel was monolithic and did not change from distribution to distribution. Why would the binary hooks to the kernel be any different on one distribution than they are on another?
Comment: And https://unix.stackexchange.com/questions/227910/will-my-linux-binary-work-on-all-distros
Answer: After doing some more research on this question, I found that there are basically two reasons why a binary sometimes will not work on a different distribution (with the same hardware) and both involve shared libraries. Since the other similar questions have rather obtuse accepted answers that do not make this clear, I am posting a simplified answer here.
(1) The first issue is that shared libraries may be located in a different places on different distributions. This should not matter because applications should always look for libraries on the LD_LIBRARY_PATH. However, apparently some badly written applications do not use LD_LIBRARY_PATH, but instead use a hardcoded path to a library, resulting a distribution-level incompatibility.
(2) The second issue is that shared libraries can vary from distribution to distribution. Usually it is only relatively obscure or advanced functions that are different, but if the application uses an API call that for some reason is in the .so of one distribution, but not present in that of another, then there will be an incompatibility. It's sort of analogous to "DLL hell" on a PC.