SVN changelist all my checkouts

Question: Lets say I have 100+ files that I've checked out.  Is there a way I can add all of them to a changelist without specifying them one by one, or adding them to file?
Comment: Can you clarify your question a bit?  I'm not sure what you are looking to achieve.  Thanks.
Answer: Was operating system are you using?
I'm going to assume Linux.  Try something like this:
ls *.c *.h */*.c */*.h | xargs svn cl source

This will add all C and header files in the current and immediate subdirectories to the changelist source.  The above command may have trouble with whitespace in filenames.  For something more sophisticated, try this on for size:
find . -name .svn -type d -prune -o -type f -print0 | xargs -0 svn cl source

This will add all normal files not located under .svn directories to the changelist source.  This also works with whitespace in filenames.
Comment: That first command could be simply written `svn cl source *.c *.h */*.c */*.h`! [Don't parse the output of ls](http://mywiki.wooledge.org/ParsingLs), and it's not as if you were getting any use out of it.
Comment: Of course, that's much better than my first example.  I was just trying to provide in-between a simple svn command a and a find, pipe, xargs, svn command, but I guess I didn't go far enough.
Comment: @Amir so, have you decided on a final answer?
Answer: You are not really clear about what you want: you say that you checked 100+ files out, but you want to add them to the repository.  I'll go over both adding files already in a workspace and committing modifications in a workspace.
To add a directory tree to an already checked out working copy, use svn add --force . which will add all the unversioned files in your working copy starting at the current directory (even though the current directory is versioned).  The added files will still need to be committed to the repository.
To commit modifications, you can run svn commit -m "*insert comment here* . which will commit all the changes in the working copy from the current directory down to the repository.
Comment: I just want to add a bunch of files to a changelist.
Comment: A change-list is the set of files in a revision record in the repository, this is read-only.  You cannot modify a record after the fact in Subversion.  If you are asking to commit all modified files, then you would commit based on the top of the tree.
Answer: I usually rely on my text editor to achieve this, as I need visual confirmation I'm on the right path.  Let's use vim here, but emacs can equally do well.
launch vim with a new buffer in the project root
then inside vim run
:r !svn st

This will read output from svn st into your buffer.  You can eye-ball it to ensure it's what you expect, or delete entries outside your change list.
M project/path/to/file1
M project/path/to/file2
M project/path/to/file3
M project/path2/to/file1
M project/path23/to/file1

You could then use your editor magic to turn these into commands.  For example::
:%s/^M/svn cl change/

which will turn the lines above to
svn cl change project/path/to/file1
svn cl change project/path/to/file2
svn cl change project/path/to/file3
svn cl change project/path2/to/file1
svn cl change project/path23/to/file1

You could then send these commands to your shell::
:w !bash

This should give you back the output of each command in the quicklist window.
This might look more verbose than the other solutions, but you get to see the whole process visually for confirmations (think emacs dired mode), and with svn inability to rewrite history this prevents mistakes.
These commands stay in your ex history so you don't usually need to type them again, just recall them from your history.

SVN changelist all my checkouts


Where do computer graphic engineers look for job ads?

Question: This is kind of a meta-question: We are a neuroscience lab looking for an engineer to develop virtual environments for experiments. Since it's not our usual field of job advertisement we do not know where computer graphics people usually look for job ads. A top-3 list of of places you would frequent to look for jobs would be very much appreciated.
Comment: Questions asking for recommendations are off-topic on this site. Please see the [help section](https://computergraphics.stackexchange.com/help/on-topic) on what to ask here.
Comment: You might try posting ads on game development/programming oriented sites, if owners accept it. I *think* that more people who check out such websites are likely to be interested in graphics programming in general, compared to "regular" job sites (that's true for me, at least ;))
Comment: Interesting, in the institute Im doing my PhD right now the neuroscientists want to build VR enviroment, too. After some discussion and confusion I realised that they do not want to build a VR headset for mice, which I deemed basically impossible, but they want to build a cave https://en.m.wikipedia.org/wiki/Cave_automatic_virtual_environment and that should be doable. I would advise to be carefull about the usage of VR which has nowdays quite specific meaning.
Answer: There are several major Computer Graphics publications that have a jobs section. Try Siggraph for example. I'm pretty sure I saw a similar thing for Eurographics, but I can't find it right now.
Furthermore, you can look for applicants at the conferences themselves, if you have the resources to do so.
If you accept students that just finish university, you should put up an ad there (or tell the computer graphics professor to spread the word - my professor was kind enough to distribute offers to us every now and then).
Apart from that, you'll probably find most graphics programmers in computer games related fields. Gamasutra has a jobs section, although I'm not sure they let non-games related companies advertise there.
Moreover, Stackoverflow has a job offers section. I never really used it myself, but it's probably worth looking into. I got quite a few computer graphics related offers, so my guess is that you can advertise specifically to people with tags like OpenGL and Rendering as their favourite tags.
Comment: Thanks. We actually tried stackexchange, but they told us that they changed their business model and would rather be suited for recurring job offers than for a one time offer.
Answer: That's a tough one. This is going to be anecdotal evidence, but in the case of other graphics programmers I know and myself, each of us has a selection of companies we hold in high esteem based on their achievements, and we watch their websites for job postings. Getting on people's "employer wishlists" is difficult for obvious reasons, though, especially if the job isn't "glamourous" like games or film VFX.
What does work sometimes is approaching candidates on LinkedIn (personally, I've had several instances where approaches led to successful processes and then job offers, and I accepted one of them), but I would strongly suggest being as up-front with the details as possible (preferably in the very first message you send). There's nothing more irritating than a recruiter who "will tell you everything, but only over the phone/after we connect".


Ties with dots in Haydn

Question: Here's an example of ties with dots on the end tied note in a Haydn String Quartet (Op. 76 No. 2). There appear to be many differing views on how these are to be interpreted and played. What do you think, all?
Comment: Ah, I think I understand. Are you asking about precisely when to release the staccato quarter notes?
Comment: Please add the movement and measure numbers.
Comment: String Quartet No. 61 in D minor, Hoboken III:76, Allegro, first movement, several instances. My editions don't show the bar numbers.,

But this is not in fact specifically about Haydn, as this occurs in various other works from various times as well. I thought Haydn scholars would be the best bet for some insight into this seemingly contradictory notation.
Comment: Thanks. Please consider adding that to the question itself. It would also be helpful to know what the "differing views" are. The recordings I've listened to so far all play them exactly the same way.
Comment: BTW, the measures in your image are 115 – 117.
Answer: The general idea of a staccato dot is to make the note concerned half as long as it usually is. So a quaver tied to a (staccato) dotted crotchet would be played for as long as just a crotchet's worth length.
I think the idea of dotting here is to ensure that the rest is 'played', and not bled into by the tied note. So it could have been written as a quaver tied across the bar to another quaver, followed by a crotchet rest. Why Haydn decided to represent his piece as he did, we'll never know, but the staccato dot is not an exact thing, so gives the player some degree of wiggle room. Trouble is, when a quartet is playing, there must be total agreement, otherwise it'll all sound sloppy. So that needs to be reached in rehearsals, mainly by feel rather than counting.
My violin teacher from years gone by would have replaced that rest by a sniff - of pre-determined length! But certainly longer than merely a quaver's value.
EDIT: as Alexander Woo points out, there is a crescendo marked for each as well, so the cut-off point for each tied note needs to be orchestrated. Not sure how that affects the length of the two tied notes, but worth mentioning.
Comment: The crescendo on the note is part of the gesture - I think a better answer would also incorporate that.
Comment: "sniff" as in nasal inhalation?
Comment: @phoog - don't know any other 'sniff'.
Comment: Me neither, but there was always the possibility that there was some sniff I hadn't heard of.  One of my music teachers when I was in my mid teens had a very effective sniff for a preparation and cue when he was conducting from the keyboard.  He did it very loudly in rehearsals and silently in performances.

Ties with dots in Haydn


Name assigned to the scrolling images in the camera app

Question: Odd question, but i am trying to recall what the small horizontal scrolling set of thumbnail images under a photo is called (in the iPhone camera app)
Answer: The term i sought was "scrubber".. Caught a reference watching "Altered Carbon" and my brain immediately recalled this question from weeks ago. ;) I found a few references on the web to confirm.
Answer: Apple doesn't seem to have given it a name, referring to it as 'the thumbnails' in the user guide.

While viewing a photo, swipe the thumbnails to browse photos, then tap a thumbnail

View photos and videos - iPhone User Guide
The trouble with referring to it by 'thumbnails' is that it is heavily based on context. For example, if someone just said 'the thumbnails in the Photos app' I'd first think of the main grid of thumbnails before a photo is selected.
Comment: I too saw that, but i know that when the UI was improved, there was a specific word, something like "scratcher" etc.. I am asking as i am seeking git repositories etc that may help me put together something similar and wanted to search stacker with that particular term.


Parabolic speaker dish diameter

Question: I am trying to design a parabolic speaker to allow an audio signal to be emitted in only a single direction. For a single acoustic tone with wavelength $w$, what should the diameter of the reflector dish be? Wikipedia states that the diameter should be at least twice the wavelength, but does not explain why.
Answer: The beamwidth of a parabolic dish is on the order of $BW \approx 70\dfrac{\lambda}{D}$ measured in degrees. Depending on the illuminator (source) the factor "$70$" may vary between $60$ and $100$, or so. The shape of the illumination (buzzword: "tapering") itself determines the size and number of sidelobes that may cause uncontrolled multiple reflections/reverberations.
You have to define what the longest wavelength (lowest frequency) of interest to you is because that will determine your maximum spatial extent of the signal at that frequency.
Note though that since the spectrum of music can be several octaves wide a parabolic reflector will show marked variation in its beamwidth across the frequencies as a result of which if you are not on or very near the axis you may hear spectral filtering distortion commensurate with your off-axis angle.
For the quoted beamwidth formula to hold you need a few wavelengths wide diameter, otherwise the wave from the source just diffracts strongly around the perimeter and you get very little collimation.
Comment: Thanks for this! I'll sketch a diagram in the morning just to consolidate, then double check here if that's okay.
Answer: Three main reasons:

reduce diffraction/interference related effects (occur when $\lambda$~D)
increase directionality (beamwidth $\propto \frac\lambda D$)
increase gain ($\propto \left(\frac D \lambda \right)^2$)

where $\lambda$ is sound's wavelength and D the dish's aperture.
As to why the minimum limit of $D/\lambda$ is suggested to be $2$: I think its a rule of thumb heuristic motivated by practical engineering. In real world applications, the ratio would in fact be higher and its minimum would be decided by the min-max of supported bandwidth.

Parabolic speaker dish diameter


Will origin country of backlink affect how the page ranks in another country

Question: My website ranks well in the US compared to other countries. Recently, a reputed website hosted and headquartered in the UK linked us from one of their articles. The link was do-follow. Will this link help rankings in the US?
Answer: It Should
If a search engine understands that your website would be of interest to people in both the US and the UK (and backlinks from both would suggest that it should), then a strong backlink from websites focused on either country should improve your overall SEO performance in both.


What would a person need to be able to do to be a saint while he was yet alive?

Question: Normally, sainthood isn't formally considered for an individual until 5 years after the death of a person. If one was determined enough, how could they go about achieving becoming saints and perhaps even become recognized as such by the the Pope, after, and moreover, before one's death?
Comment: I don't think he meant "strive to get yourselves formally declared as saints" I think he meant "strive to act like saints".
Comment: One of the main characteristics of sainthood is humility. Being determined to become a saint  almost certainly rules you out of contention.
Comment: @DJClayworth Pope John Paul II more than once said: "Make yourselves saints and do it quickly!"
Comment: @curiousdannii before ones death. I think if people can work hard for good if only for the title, before they die; it would offer self-actualization. Maybe one day we all can qualify to be Saints.
Answer: What would a person need to be able to do to be a saint while he was yet alive?
Formally declared saints are chosen ultimately by the pope, but only after a thorough investigation of the life, writings, and legacy of the saint candidate. No stone is left unturned. Testimony from witnesses and experts, physical evidence, and the entire life of the person is examined with fine detail. Every skeleton in the closet is taken out, and all dirty laundry looked at — if any exists, that is.
The classic requirements for consideration would be as follows:

Evidence of having led an exemplary life of goodness and virtue worthy of imitation, having died a heroic death (martyrdom), or having undergone a major conversion of heart where a previous immoral life is abandoned and replaced by one of outstanding holiness - What Are the Requirements for Sainthood?

Most Roman theologians consider the minimum time of living a saintly life after an immoral lifestyle is abandoned to be five (5) years although exceptions could be made.
On July 11, 2014, Pope Francis slightly somewhat altered these requirements.

Pope Francis has introduced a new pathway to Catholic sainthood, recognizing those who sacrifice their lives for others.
The new category, introduced in a official letter from the pope on Tuesday, is "one of the most significant changes in centuries to the Roman Catholic Church's saint-making procedures," Reuters reports.
Before the change, there were three categories that provided a path to sainthood: being killed for the faith (martyrdom), living a life heroically of Christian virtues and having a strong reputation for religious devotion. The process of becoming a saint begins after an individual's death.
According to the Vatican's official news service, the new category has five main criteria:

The individual must freely and voluntarily offer their life in the face of "a certain and soon-to-come death"

There must be a "close relation" between "the offering of one's life and the premature death of the one who offers it."

The person must show Christian virtues, at least to an ordinary extent, before and after offering their life.

They must have a "reputation for holiness" at least after their death.

They must have performed a miracle. This is a major difference from the "martyrdom" category, which does not require a miracle.

Archbishop Marcello Bartolucci, secretary of the Vatican Congregation for Saints' Causes, said that this is intended "to promote heroic Christian testimony, (that has been) up to now without a specific process, precisely because it did not completely fit within the case of martyrdom or heroic virtues," according to Catholic News Service.
The current categories are insufficient "for interpreting all possible cases," Bartolucci added.
The pope's letter announcing the new category is called "Maiorem hac dilectionem," which is taken from this passage in the Gospel of John: "Greater love than this no man hath, that a man lay down his life for his friends."
According to The Associated Press, "examples of people who might fall into that category include those who take the place of someone condemned to death or expectant mothers with fatal diseases who suspend treatment so their babies can be born." - Pope Francis Announces New Path To Sainthood

The point that "they must have a 'reputation for holiness' at least after their death," reminds me of the life of St. Benedict Labre when he died:

Benedict Joseph Labre probably evoked similar feelings in many who encountered him, and yet when he died the cry went up "the saint is dead! the saint is dead!"

Further information may be gleaned from the following article(s):

Pope approves new path to sainthood: heroic act of loving service
Comment: I am concerned that there has been no Christian comment as to how the NT addresses all Christians in all the 1st century congregations as "saints" - and living saints, at that! St. Paul wrote, "To all who are in Rome, beloved of God, called saints" (Rom. 1:6). In his first epistle to Christians in Corinth he greeted them as "those sanctified in Christ Jesus, called saints" (1:2). In his second epistle to them he said, "...this service is not only supplying the wants of the saints..." (9:12). Do these biblical salutations from the pen of St. Paul count for nothing?
Comment: @Anne You have the essence of a very possible excellent question. You may wish giving it some thought?
Comment: I shall, and hope that you might favour such a question with an answer!
Comment: @Anne I can only try!
Answer: Aspiring to sainthood is certainly a good way to orient one's life. The opportunity to "offer one's life" may not arise right away, but the opportunity to develop a "reputation for holiness" is always available. And, in fact, growing in holiness each day might be exactly the preparation a person needs so that if and when the time comes to "offer one's life," the person is prepared.
Take a look at St. Gianna Beretta Molla, for example, beatified by Pope John Paul II in 1994, 32 years after her death, and canonized in 2004, relatively fast track. She was not a member of the clergy or a religious order as so many of the canonized are. She was not celibate. She did not found an order. She lived an ordinary life, marrying and raising children, practicing medicine, and practicing her faith through the Catholic Action apostolate.
When the time came to "offer her life," refusing to save her own life at the risk of her unborn child's, she was prepared to witness to her faith by making that decision. You can learn more about her here: St. Gianna Beretta Molla.
Answer: I think the main way to be considered a saint while still alive is to perform miracles or have miraculous things happen to you. Many saints are called saints while still alive, however I think most saints don't want to be acknowledged as saints as most saints are very humble.
A good example of how you can be known as a saint while being still alive is to be a visible stigmatist; Padre Pio and others were stigmatists. Most are women and there are various kinds.  The reason I specify visible is because some saints have had invisible stigmata (which are supposedly more painful then the visable kind).
Another way to be known as a saint but a more subtle one would be to hold uncommon amounts of wisdom and knowledge in holiness and share that knowledge with others.    Another reason why, besides humility, saints wouldn't' want to be publicly known as saints is because saints always attract people wanting to do evil to go against them. Saints with uncommon wisdom often get attacked and slandered by others, making it hard to distinguish between saints and charlatans.
Comment: Like talking to God in your dreams?
Answer: Get bodily ascended into Heaven by God like Enoch or Jesus.
The Catholic definition of a "saint" is "someone we know has gone to Heaven". Normally, this occurs after a person's death; however, there were a few cases in the Bible where individuals were bodily taken into Heaven while still alive: Enoch, before the Flood, and Jesus, after His resurrection. Some Protestant groups believe that prior to the Second Coming, God will take up the faithful during the Rapture, but unless something similar occurs, it is very unlikely that someone from the modern day will enter Heaven while still alive.
Comment: Unfortunately, this is only partly true. According to Catholicism, both Enoch and Elijah are in the Heavenly Paradise ((Eden) waiting for their time to return to the world and then they will become the two witnesses mentioned in the Apocalypse and will be martyred for their faith.
Comment: My understanding of the Catholic concept of sainthood is that it's simply a list of "these are the people we know *definitely* got into heaven", and that the requirements they put on it are simply so that they can be absolutely sure that they didn't wind up somewhere else.
Comment: Ah, yeah you're right. Sorry, it seemed like you weren't writing about Catholicism, but now I see what you've written does fit exactly.


Who should pay for the removal and reinstallation of the screens for the exclusive use balcony when HOA needs to remodel the balcony?

Question: My HOA is doing this renovation project, which needs to get access and modify the balcony (where I have my screens), and asking me to pay the cost of removing and reinstallation? Do I have the right to request HOA to pay for it? Because this is a HOA project. If not for HOA project, I would not need to remove and reinstall it back. I am in California. In addition, before the project starts, no one came in my unit to inspect it, and I do not see any need for this renovation. Thank you.
Answer: It depends on the details of your condo's declaration. It's very common for balconies to be limited common elements, that is, the balcony is actually owned by the condominium as a whole, but you are entitled to exclusive access to it. Depending on the details of the declaration the HOA may be entirely responsible for maintenance of the balcony or the owner may be partially responsible. The declaration may also state whether owners are allowed to make modifications like installing screens.
To figure out whether the HOA needs to pay for the screens you installed you'll have to look at the declaration in detail and probably consult a lawyer.


Is there any way to download and install ei capitan offline?

Question: Now i'm having yosemite in my mac and I've been trying to update my mac from yesterday.My wifi has some problem so it might be the problem to download ei capitan it disconnect each and every time when i resumed it.Finally it starts from beginning. So I'm planning to download it through offline. Please anyone shed some light on this question
Answer: Yes.

Download the installer you want and then disconnect from all networks.
Use that installer to make a USB drive that boots and installs the OS.
Comment: It's not likely this will fix your issue, but feel free to ask a follow on question on where the install logs are stored so we can help you analyze them once this fails (assuming this attempt fails). I'm hoping you are right on the cause of your issue and this works!
Answer: There's clearly no way you can download anything offline. It sounds like you are encountering problems with the download server or your internet connection.
You could download the El Capitan installer on another more reliable Mac computer WITHOUT installing it and afterwards make a bootable USB-stick, from which you can install the OS offline.
What you need is a USB-stick drive of minimum 8GB and the free program DiskMaker X. (http://diskmakerx.com). Be advised that DiskMaker X erases the USB-stick, so don't use one with data already on it. The process of making the bootable USB-stick is pretty self explanatory once you start the program.
Good luck.


Why is this question closed? I am finding no satisfactory answers from the personal comment

Question:
I have a question about my Physics Stack Exchange post:  Can time dilation be used to prove that relativistic mass does not really increase at speeds near $c$?
Comment: *Welcome to Stack Exchange!* There are [almost 200 SE sites](https://stackexchange.com/sites#name) and there are large variations in the speed and aggressiveness of quick-closure. At 70+ questions per day and [over 11,000 existing questions tagged special-relativity](https://physics.stackexchange.com/questions/tagged/special-relativity) it's pretty common for first questions on this topic to stay open. As the answer points out, unless you can differentiate your question from the linked ones (e.g. I've read these answers and they don't address X) it will stay closed here in Physics SE.
Answer: You should see two other questions linked at the top, where it says it's a duplicate:

If you think your question is really different from these other questions discussing relativistic mass, please edit it to explain why the answers to these other questions don't answer your question.
Answer: You've chosen not to respond to clarifying questions about how you're defining relativistic mass.  This makes it entirely unclear what you're asking, and is sufficient reason to close the question regardless of whether there are any duplicates out there.


Why do mirrors not follow brewster's angle?

Question: Normally a material will have an angle where the reflected light is completely polarized. Now say we have a mirror (implemented by a conductive silver coating) that reflects most of it's incident light. https://physics.stackexchange.com/a/10925 says that this imperfect mirror will be mostly linearly polarized, but not at the brewster angle. Why is this? The derivation for the brewster angle assumes non-magnetic materials, but does not assume non-conductive materials I believe.
Answer: I think you may have misunderstood the answer to the question you cited.  It says that light reflected from a silvered mirror will be mostly unpolarized.  This is true whether the silver is on the front or back surface.  There is a very slight polarization due to the less than ideal properties of the silver.
The front surface of a back-surface silvered mirror will reflect highly polarized light, but whatever gets past the front surface will be almost perfectly reflected by the silvered back surface.
Answer: Brewster's angle relates the index of refraction to a polarization phenomenon
in reflection from a dielectric (insulator) material.   Most mirrors are
silvered (have a metal coating), and the equivalent dialectric constant
for a metal is ... infinity.   That predicts a Brewster's angle
of 90 degrees, which is geometrically unavailable to an experimenter.
$$ \Theta_{B}  = arctan({\eta_{metal} \over {\eta_{air}}})  = arctan({{\infty} \over 1})$$
The ninety degree angle is simply not a glancing incidence possibility for
a reflection to be observed.   It is not incorrect to say that metallized
mirrors DO follow Brewster's angle.
Comment: i know a perfect conductor has zero resistance but why would it have infinite dielectric constant?
Comment: @roobee - the dielectric constant measures the material's response to an electric field: the response of a metal is (to a good approximation) to completely cancel the field inside the material, i.e. to polarize VERY completely.
Comment: I learned electromagnetism by learning conceptually E and H, and then learning that they follow certain equations called Maxwell's equations, which included a variable called permittivity in one of those equations. That equation being D=epsilon*E, where D being just another variable. Would you be able to explain how from that base I could know that epsilon physically means some quantity that is proportional to "polarization of the metal", and how I would quantify that "polarization of the metal"?
Comment: @roobee  The dielectric constant, epsilon, is the ratio of D (external electric field) to E (internal electric field after material charge rearranges).    For a metal, with the internal E field approximately zero, that ratio is infinite.
Comment: I don't know why D would represent the external E field, but I suppose so long as the variable called D isn't infinity the math works out for making epsilon infinite.

Anyways, since I was asking about a real-life mirror implemented by silver which isn't a perfect conductor, would I be able to see reflected polarized light by looking near the 90 degree angle?


How can I make a SelectBox required in qooxdoo?

Question: How can I force a user to make a selection from a qooxdoo SelectBox? I would like the SelectBox to initially appear with an empty selection (or better yet, a "Please select..." message). I would like form validation to fail if the user has not made a selection, and the selectBox to appear with the red "invalid" decoration and "required" tooltip, just like a required textField.
Similarly for RadioButtonGroup: is there a way to make the group initially appear with no button selected, and not become valid until a selection is made?

Later... this seems to work for the SelectBox case:
var genderSlct = new qx.ui.form.SelectBox();
genderSlct.add(new qx.ui.form.ListItem("")); // initially selected null item
genderSlct.add(new qx.ui.form.ListItem("Male", null, "M"));
genderSlct.add(new qx.ui.form.ListItem("Female", null, "F"));
...

myForm.getValidationManager().setValidator(function(items) {
    var valid = true;

    if (genderSlct.getSelection()[0].getModel() == null) {
        genderSlct.setValid(valid = false);
        genderSlct.setInvalidMessage("Please select your gender.");
    }
    ...

    if (valid) {
        genderSlct.setValid(true);
        ...
        return true;
    } else {
        return false;
    }
});

Later still... Found a solution for the RadioButtonGroup as well:
To get that initial unselected state, add an invisible first listItem with null model:
myRbg.add(new qx.ui.form.RadioButton("").set({
     model: null, visibility: "excluded"
}));

Then add the same style of code as for the selectionBox to the form validator.
Answer: Check out this demo which offers exactly which your looking for in the SelectBox case:
http://demo.qooxdoo.org/2.0.1/demobrowser/index.html#data~Form.html
You can simply check for the selection in the validator.


Hyundai i20 2012

Question: I have a Hyundai i20 2012 model. The car started to loose power, like fuel starvation. This morning the car do not want to start.
I checked all areas...fuel pump and strainer, all fuses, all electrical plugs.
The fuel pump works the moment you cycle the ignition. I investigated all areas, but the last area was fire to the spakplugs.
There was no spark out of the coils.
Can the keycode be lost?
Can it be the electronic board?
Please advise
Comment: Welcome to Motor Vehicle Maintenance & Repair! Did you actually check pressure at the fuel rail? There are situations where the pump motor runs, but has no output. Without checking the pressure, you just don't know.
Comment: Thank you for the feedback. I did not test the pump pressure with a pressure hauge. I removed the fuel pressure pipe on the manifold, and there was enough pressure. Enough meaning that when I started loosening the 2 nuts on the flange mounting, the pipe pushes itself out. I cycledctge ignition, and the visible amount of fuel coming out was a ckear indication that there was enough pressure. What concerns ne is that there is no spark on the plugs. I took one coil out with the sparkplug, and there was no spark if I turn the engine with the ignition
Comment: Something to remember, volume does not equal pressure. It appears it all may be working, but with zero back pressure, the flow can be great. Once the pressure is there, flow might be reduced to zero (or near it). It's one of those things you cannot assume is good just from seeing the flow. If the regulator is not working and allow free flow of fuel, there won't be any (or very little) pressure at the injectors, which is the same as no fuel flow at all. Just one way which might be causing your symptoms.
Comment: Thank you for the advise again. I noticed that after all tests, the fuel rail still have a lot of pressure remaining. I have ooened up the flage fitting, andctge pressure popped the o-ring seal! Must the pressure remain in the fuel rack after the engine is switched off?
Answer: I managed to find the problem on my i20.
The timing chain slipped on the intake cam shaft
This is very strange for me. this is the first time that I experience this
The chain slipped the moment the engine kick back after it is switched of
When I turned the engine anti-clockwise, the chain slipped
I removed the front covert and inspected the tensioner, and this is still in good mechanical working order.
The car services were done to date. The odo reading is 132000km. The chain lasts longer than that.
I removed the timing chain also, and inspected the chain and found still in order.
What can be the cause of this?
Comment: Its imperative if you check your engine timing guides as well as the guide tensioner, slipped chain/out of time will destroy your non-interference engine. In these engines the tensioner goes bad , you will need to retime the engine.

Hyundai i20 2012


Why do high altitudes have larger diurnal temperature variation than lower altitudes?

Question: It seems like the lack of atmosphere should not be playing a role in the diurnal temperature variation because that's what makes it colder. Mountains are not that dry, usually.
Comment: It may be better to ask this over at http://earthscience.stackexchange.com/
Comment: You have to take radiation cooling and heating into account. The temperature of free space is given by the radiation that's in it, which moves at the speed of light, i.e. without matter a volume of space with dimension $L$ "cools and heats up" on a timescale that is given by $L/c$. Throw matter in there and now you have much slower heating and cooling because the effective speed of light is much, much smaller as photons are absorbed and re-emitted many times before they can escape to the vacuum.
Answer: The answer is in the EM absorption/emission profile of the atmosphere with height. Visible wavelengths pass through the atmosphere unheeded, except for clouds. IR is somewhat absorbed by carbon dioxide. That same carbon dioxide emits IR radiation too, allowing it to cool. Atmospheric parcels at higher elevations have less intervening carbon dioxide between them and cold black space. This means faster cooling, but the effect is not very strong.
At very high altitudes, a different process dominates. UV light is absorbed high in the atmosphere. Although there is much less UV light from the sun than visible light, the part of the atmosphere effected is very low density, so that UV can have a large effect.
Even further up, X-rays and solar wind charged particles cause ionization and a huge amount of heating. Charged particles interact at the magnetic poles (auroras). X-rays and hard UV hit the day side, cause a big diurnal perturbation.


Does CSRF work if your browser has stored cookies?

Question: So say I've stored Facebook cookies, so that I don't have to login every time I visit Facebook. Would a CSRF attack on Facebook work(assuming they don't have CSRF protection), if I don't currently have a browser tab open logged into Facebook?
Comment: The key here is that any website can make you "visit" Facebook by issuing a cross-origin request that exploits a CSRF vulnerability in the background. (E.g. by loading Facebook in a hidden frame, as an image, via AJAX, etc.)
Comment: Generally speaking having a session cookie stored is a *requirement* for CSRF.
Answer: Though there are some details that impact this, going by the general principles, the answer is YES.
An attack exploiting CSRF would attempt to execute some function of the target site (facebook, in your example) in the browser context.
So the key test is: If you open facebook in a tab (in the scenario you mentioned), would it give you a logged-in session directly. It appears that it would. In that case, it meets the conditions necessary to mount a CSRF attack.
There are many nuances. For example: Vulnerability != Exploit. i.e., though the attacker may get CSRF to work (and produce a POC to get a bug bounty or complete a VA/PT assignment) - there may be nothing there to exploit due to other protections. e.g., if additional auth is required to really do any damage.


Django e-commerce 1.2, missing settings.py file

Question: I'm reading the Django 1.2 e-commerce book by Jesse Legg.
I have used Django before and had no problems doing the usual basic stuff (admin apps etc).
However I'm stumped on this one.
Near the bottom of Page 17 it says:
"""
we will create our settings file and a root URLs file in our project module:
ecommerce_book/settings.py and ecommerce_book/urls.py. It is recommended
that you copy these files from the companion source code.
"""
The settings.py file is not in the companion source code. I have emailed the author and Packt but so far no reply.
Does anybody know how to locate this settings.py file?
I'm familiar with the usual method suggested i.e.
python django-admin.py startproject ecommerce_book
However, the author seems to be saying there is a custom settings.py file which needs to be used in this particular case. (but it's not included in the downloaded source code)
Answer: python django-admin.py startproject ecommerce_book

Though I'm not sure this initial settings.py will be the same you want. To the praticular settings.py contact authors or publishing.
Comment: the author seems to be saying there is a custom settings.py file which needs to be used in this particular case. (but it's not included in the downloaded source code)


Preseeding Ubuntu Server

Question: I am in the process of creating an automated install disc for Ubuntu Server 10.10. Is it possible to set up package selection within the preseed file (what groups of packages to install etc.)? If so, how can this be done?
Answer: At a high level, the key part of creating is a preseed file that can specify options that the installer asks you. An example preseed file can be found at the debian website. The example provides most of the options that you may want to modify.
When it gets down to implementation, there are a few more steps to be followed:

Obtain the image. You can choose between a full image and a mini iso which downloads a fresh copy of packages off the internet. The process is slightly different, but mostly analogous.
Once you have the image, you need to extract files from the iso. There might be a one-step way to do this, but this is how I've always done it like this:
sudo mount -o loop -t iso9660 mini.iso /mnt
cp -rf /mnt /path/to/extractdir
sudo umount /mnt

Now you create the preseed file that you want to use. In the mini iso, since you don't really have a hierarchy, just put it in the root folder. In the regular server install, put it in the preseed folder. It is your choice where you want to put it/what you want to call it.
Once you have the preseed, you need to specify it to the kernel. In the mini iso, you need to edit text.cfg, or in the full install, isolinux/text.cfg to include your preseed by editing the APPEND line as follows:
APPEND arg1 arg2=value2 arg3 ... file=/cdrom/path/to/preseed/file locale=en_US console-setup/ask_detect=false console-setup/layout=us --

Don't remove existing values unless you know what you're doing

Once you're done modifying the preseed and text.cfg files, you need to repack things as an ISO. To do this, you need to put isolinux on the CD to make it bootable. Now, cd to the root directory of the extracted image, and do the following [taken from the syslinux website:
cd /path/to/extractdir
mkisofs -o output.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -T .

You need to add the -l (or -iso-level 2)flag to support longer file names.
Your iso is at output.iso and ready to be burned!
Answer: Ok, I spent WAY too much time figuring out how to get this to work. Shroff, your example, though close, isn't quite there.
At least the last part of it.
The last step, with the mkdir CD_root, and mkisofs is slightly off.
If you did the
sudo mount -o loop mini.iso /mnt
cp  -fr /mnt/ ./new_image
sudo umount /mnt

The next steps get fuzzy in your example.  The editing the text.cfg, and placement of pressed.txt (name I used) is right.  So the following:
cd new_image
chmod 777 .
vim pressed.txt
vim text.cfg

Next step:
cd ..
mkisofs -o output.iso -b isolinux.bin -l -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table new_image

I was lost when dealing with the isolinux/isoliunux.bin, and the CD_root.  Appartnetly the copy-paste you stole from syslinux website doesn't apply to the ubuntu images.
Hope this helps everyone else!
Comment: I'm sorry to hear that it didn't work for you, but isolinux/isolinux.bin exists in the iso, and you can use it just the way they do at the syslinux website. It worked perfectly for me when I did it =)

Preseeding Ubuntu Server


Can I apply for an Italian seasonal work visa while in Italy?

Question: I am a South African citizen; I am looking for a seasonal job in Italy. If I am on holiday in Italy and find a job while there, will I have to return to South Africa to apply for the worker's visa from RSA? Or would it be possible to apply in Italy for the visa, or would I have to come back to South Africa anyway?
Comment: Have you researched the different types of visa available and do you have one in mind? It's not obvious to me that there would be. In particular, how long would your total stay be?
Answer: No, you can't
La Polizia di stato states :

Foreign workers must obtain the required visa from an Italian consulate in their country of origin or residence.

Or would it be possible to apply in Italy for the visa

There are no Italian consulates in Italy and visas aren't issued on the country soil

You would be tempted to apply for a residence permit, but this again isn't a possibility, as you aren't allowed to reside on the basis of a tourist visa.
You need the relevant national D visa and also the relevant work authorization to be allowed to work in Italy and this can only be done from South Africa


Norm of the product of an isometry and a bounded operator

Question: Let $A$ be a bounded operator and $V$ a linear isometry, both defined on a complex Hilbert space $H$ (infinite dimensional). I could
easily prove that $\|VA\|=\|A\|$. But, I just couldn't prove
that $\|AV\|=\|A\|$. Is this last property correct, and if yes could you supply
a proof?
Comment: Thanks Jonas...I am relieved! I just could not do it and to be honest I statrt to find counterexamples but this result appeared without proof in Kubrusly book. Now, I think he means $\|BV^*\|=\|B\|$.
Answer: You were correct to doubt that.   It is false in general that $\|AV\|=\|A\|$ when $V$ is an isometry.  If $V$ is any nonunitary isometry, there is a nonzero $A\in B(H)$ such that $AV=0$, because the range of $V$ is a proper closed subspace of $H$, so $A$ can be chosen to be $0$ on this range but nonzero elsewhere.  In particular, $I-VV^*$ is the projection onto the orthogonal complement of the range of $V$, and $(I-VV^*)V=0$, while $\|I-VV^*\|=1$ unless $V$ is unitary.
For a very concrete example, on $\ell^2$ take $V(x_0,x_1,x_2,\ldots)=(0,x_0,x_1,\ldots)$, and $A(x_0,x_1,x_2,\ldots)=(x_0,0,0,\ldots)$.
You mention that perhaps your source meant to say that $\|AV^*\|=\|A\|$ when $V$ is an isometry on $H$ and $A$ is a bounded operator on $H$.  This is true and easy to show using the fact that $\|X^*\|=\|X\|$ for all $X\in B(H)$ and the result you already proved.


Peterson's vs. Bakery Algorithm

Question: From my CS course, the Peterson's Algorithm and the Bakery Algorithm both are solutions which satisfy the 3 requirements of any solution to the critical section problem. a) What are their adv/disadv over each other , and b) if they already solve the critical section problem, why do we need semaphores?
Answer:
a) what are the advantages/disadvantages over each other?

According to the lecture note: Sections 17.4.1 and 17.4.3, we can summarize as follows:

The original Peterson's Algorithm works with only 2 processes.
The Peterson's algorithm requires multi-writer registers while the Bakery algorithm uses only single-writer registers.
Both algorithms are starvation-free. Furthermore, the Bakery algorithm offers a strong near-FIFO guarantee.
Both algorithms work with atomic registers. However, the Bakery algorithm works with even weaker registers (safe registers actually, see here).
The Bakery algorithm uses unbounded registers. Nevertheless, this problem can be fixed.

b)  If they already solve the critical section problem, why do we need semaphores?

A Semaphore is a generalization of mutual exclusion locks. Each Semaphore has a capacity, denoted by $c$ for brevity. Instead of allowing only one thread at a time into the critical section, a Semaphore allows at most $c$
threads, where the capacity $c$ is determined when the semaphore is initialized. (See the book "The Art of Multiprocessor Programming" by Maurice Herlihy and Nir Shavit; Section 8.5).
Answer: They don't work for multiprocessors and modifying them to solve them is a hassle.
Whereas semaphores are simply mathematical methods to create process precedence graphs for concurrent execution.
Just an integer variable, that's it.

Peterson's vs. Bakery Algorithm


How to install Venia PWA Theme on Magento 2.3 using cPanel on Dedicated Server?

Question: I have used git to clone pwa-studio theme, but still unable to run commands like yarn install. Tried installing node.js/npm  but couldn't because I am on a dedicated server. From where do I install the pwa-studio theme without any error and how?
Answer: I hope this will help you,
You will see the pwa-studio directory in /var/www/html/mage0.
Enter into this directoy:

cd pwa-studio/

Run

yarn install

Specify the Magento backend server in .env file.

cp packages/venia-concept/.env.dist packages/venia-concept/.env

Open this .env file and find MAGENTO_BACKEND_URL.

MAGENTO_BACKEND_URL="https://magento-2-local/" # your local path

Find the deployVeniaSampleData.sh file in
/var/www/html/mage0/pwa-studio/packages/venia-concept/ directory. and copy this
file in your Magento root directory. Now it must look like
/var/www/html/mage0/deployVeniaSampleData.sh Now run:

bash deployVeniaSampleData.sh

After successful installation run:

bin/magento setup:upgrade bin/magento
indexer:reindex bin/magento
cache:flush

Now go back to pwa-studio directory /var/www/html/mage0/pwa-studio and
start Server.

yarn run build or sudo yarn run build

Run server, Use any of the following commands from the project root directory to start
the server:

yarn run watch:venia
  yarn run watch:all
  yarn run build && npm run
  stage:venia

Now browse the application, you will the application url on terminal like:
PWADevServer ready at https://magento-venia.local.pwadev:8001
Thanks,


Asp.NET MVC Custom Validator For a View Model?

Question: I am using custom view model classes as DTO objects to hold data for display on my View pages. I have applied validation via the DataAnnotations library to perform server side validation on the properties of these classes. Here is a simple example:
<code>[DisplayName("Customer Account Id")]
[Required(ErrorMessage = "* Account Number is required")]
[StringLength(16, ErrorMessage = "* Account Number must be 16 characters in length", MinimumLength = 16)]
public string CustomerAccountId { get; set; }
</code>
If someone submits a search and this field does not come through or comes through at a length that is not 16, validation fails, and an error message is displayed on the page via the ValidationMessage HtmlHelper:
<code><%= Html.ValidationMessage("CustomerAccountId")%>
</code>
Now I need to add the ability to search by account id OR a combination of First/Last name. My question is this:
How do I apply conditional validation? If I submit a search with First/Last name, I don't want validation to fail because an account number was not passed through as well. I found this link, which shows how to implement a custom validator, but it seems like this applies to 1 property. How do I pass an entire object model through, and pass back the appropriate validation error messages to the appropriate fields to be displayed on the page? Is this possible?
Answer: You can implement IDataErrorInfo. (The class name is misspelled in the article title, but the code is right.)


How to design an email system?

Question: I am working for a company that provides customer support to its clients. I am trying to design a system that would send emails automatically to clients when some event occurs. The system would consist of a backend part and a web interface part. The backend will handle the communication with a web interface (which will be only for internal use to change the email templates) and most important it will check some database tables and based on those results will send emails ... lots of them.
Now, I am wondering how can this be designed so it can be made scalable and provide the necessary performance as it will probably have to handle a few thousands emails per hours (this should be the peek). I am mostly interested about how would this kind of architecture should be thought in order to be easily scaled in the future if needed.
Python will be used on the backend with Postgres and probably whatever comes first between a Python web framework and GWT on the frontend (which seems the simplest task).
Answer: This is a real good candidate for using some off the shelf software.  There are any number of open-source mailing list manager packages around; they already know how to do the mass mailings.  It's not completely clear whether these mailings would go to the same set of people each time; if so, get any one of the regular mailing list programs.
If not, the easy answer is
<code>$ mail address -s subject < file
</code>
once per mail.
By the way, investigate the policies of whoever is upstream from you on the net.  Some ISPs see lots of mails as probable spam, and may surprise you by cutting off or metering your internet access.
Answer: A few thousand emails per hour isn't really that much, as long as your outgoing mail server is willing to accept them in a timely manner.
I would send them using a local mta, like postfix, or exim (which would then send them through your outgoing relay if required). That service is then responsible for the mail queues, retries, bounces, etc. If your looking for more "mailing list" features, try adding mailman into the mix. It's written in python, and you've probably seen it, as it runs tons of internet mailing lists.
Comment: Yep use a local MTA, monitor the queue lengths and delivery status.
Answer: This sound to me, that you're trying to optimize for batch processing, where the heat doenst happen on the web interface but in the backend. This also sounds a job for a queuing architecture.
Amazon offers queuing systems for instance if you really need massive scale. So you can add multiple machines on your side to deliver the messages as eMails. So you allow one machines only taking perhaps 100 messages from the queue at one time.
The pattern with eMail systems should be asychonous, so have a look at other asynchonous archictures if you dont like queues.
Answer: You might want to try Twisted Mail for implementing your own backend in pure Python.

How to design an email system?


How can I have a seperate texture and UV map for each of my different vertex groups?

Question: I have ten different image textures, and I have sorted each face in my mesh into 10 corresponding vertex groups. I'd like to associate each group with their image, and have a unique UV map for each one. How would you do this? How do vertex groups and UV maps interact with textures?
Comment: They don't, as far as I know vertex groups and UV coordinates are totally independent. What are you trying to do, can you post a screenshot of what you want?. If I understand correctly to assign a different image to each face you don't need vertex groups or even multiple UV coordinates, layers at all. Simply unwrapping each face independently as an island and assign a different material to each face, each material will hold it's own image. A basic Unwrap > Reset should probably suffice
Comment: You add multiple materials to an object, then [assign a material to selected faces](http://blender.stackexchange.com/q/516/935)
Answer:
How do vertex groups and UV maps interact with textures?

Vertex groups are ,like the name suggests, just a grouping of vertices and don't store any information about textures.
the UV map is what connects the two together, it defines for each face in a mesh what part of the texture it has to show when rendered.

How can I have a seperate texture and UV map for each of my different vertex groups?

I'll work with a subdivided cube and two textures.

I will assign the cube two textures,one to the top faces and one the right faces, both defined in vertex groups with their respective names.

add as many UV maps as you need, it's a good idea to give them meaningful names.

the workflow is as follow:
-In edit mode ,make sure nothing is selected (press A once or twice).
-select the right texture in the UV image editor
-select the right UV map from the list
-select the right vertex group, and click on selected
-press W and select one of the UV unwrapping methods.
if you are not happy with how the UV is mapped to the texture you can either adjust it manually in the Image editor or do it again with a different unwrapping method.

once done, you repeat the same process with the other textures as necessary.


Registering an Iranian domain as an American citizen

Question: I'd like to register a .ir domain for a neat domain hack, but it seems to be quite difficult as it's Iranian. Every site I've seen requires either an Iranian National ID (which I don't have) or passport information. Is it safe to give these sites my passport information? Thanks.
Comment: in case you are not a spy, i would say, it should be safe. But...what do you mean with _safe_? Is there something special, what you are afraid?
Comment: @Evgeniy do you know about identity theft? millions of people each year are impacted by this with huge personal and financial consequences...
Answer:
I'd like to register a .ir domain for a neat domain hack, but it seems to be quite difficult as it's Iranian.

This is not the only problem you have to take into account. Once you get the domain of your wish, if you do, you have to remember that the domain, and its use, is still bound to Iranian laws. You may lose it, or worse, if you do not abide by those laws and all registry regulations about disputes, etc.
Imagine that the contract (which you sign during registration) stipulates that any kind of dispute on the name has to be settled only in front of a court located on Iranian soil. What will you do in case of problems?
You can ignore this, but if you buy a domain to use as a hack, and build something successful on top of it, events like that can be devastating.
Which all boils down to: is your domain hack worth all the risks?

Is it safe to give these sites my passport information?

This question can not be replied to. You have to trust your registrar, the registry, and any networks in between where your personal data will transit.
Sending personal data to anyone makes you potentially a future victim of identity theft.
Is this risk worth your domain hack? No one except you can know and reply to this.
Answer: This is not your father's .ly
Libya was under the control of Muammar Khadafi, author of the Pan Am 103 bombing and many other horrors.  But Libya farmed out their TLD to a western company for hard cash, so it wasn't completely reckless to have all those adverb sites ending in .ly.
Iran makes full use of .ir internally.  Your site would be a guest of the Iranian government.  Your site would need to comport itself in line with Iranian government values, which as a "revolutionary" (read: nationalist, xenophobic) government founded in religion, will have a very high standard for conduct.
No free speech, corporate veil, nor Safe Harbor
So all the content you host or link to would need to conform with legal (moral) requirements of the government of Iran.  Which would hobble your speech rather painfully.  It would also have countless blind-sides, like so much as mention the existence of Judaism, or even promote the US military, ka-zinga!
I think you would have a great deal of difficulty retaining the domain, unless you had Iran experts curating every bit of content.
Further, Iran has no concept of DMCA "Safe Harbor".  You know, the thing that lets you run a bulletin board where users generate content (UGC) and your corporation is not personally liable  when a user posts a cut-and-pasted copy of a copyrighted newspaper article.
For that matter, Iran doesn't even recognize the idea that employees and officers of a corporation should be generally shielded from liability for corporate activities which didn't intentionally break the law.
So they not only get to come down on your company for a random user's pro-Israel statement, they punch through the corporate veil and come after you personally!  "What'd I do!?"
The US Government would not approve
Since Trump reimposed sanctions on Iran, US actors are very limited in whether and how they can do business in Iran.  This itself is a legal minefield, and you'll need experienced counsel on board to guide your every move, or you could find yourself in dutch with the US government also.
Being trapped in the middle between a very powerful and very dangerous government... man, that must be one heck of a domain  hack!
Exposing your users to hacking
The most powerful cyber-warfare operations are the "state level actors".  They not only have the sheer depth of resources to do whatever they need, but they also have traditional spy stuff (which hackers normally do not have): SIGINT (traditional phone etc. monitoring)) and HUMINT (ability to place spies in physical locations).
Iran was probably an also-ran player... but then, Stuxnet happened.  This motivated Iran to "up their game" in a big way.  They now have one of the leading nation-state hacking operations.
And you want these guys to control your TLD.  Probably a big part of why Iran would even consent to this is the possibility of manipulating your TLD to their advantage.


Can we listen to Rudra sukta if yajnopaveet is not done?

Question: See, here i am not talking about chanting but listening. I belong to Kshatriya Varna by birth, but haven't done Yajnopaveet yet as no one in our family has done. So, can i just listen to rudra sukta of yajurveda?
Comment: It is commendable that you're asking for permission in an age where Gayatri mantra is blasted on loudspeakers for everyone to hear/chant. The reason behind restricting access of Vedas to Dwijas is similar to restricting access to nuclear codes to military personnel. If it's misused (as was the case by asuras), even the Deva granting boons faced trouble e.g. Shiva from Banasura. In Kali Yug, the problem is more severe, as people misinterpret Vedas because of their nastik nature. If your family has Bruhaspati or Purohit, ask them at least, instead of listening chantings on youtube.
Comment: Please do not accept answers which doesn't cite authentic sources.
Comment: @Rudra Looks like you're a new user, I would encourage you to take a [tour](https://hinduism.stackexchange.com/tour) of the site. This will help you to understand how this site functions. If you need any help further, you may ping me in [main chatroom](https://chat.stackexchange.com/rooms/15189/hinduism) .
Answer: No, there is no problem in listening. But remember, not to chant. Also, only listen after bathing and when your mind is pure.
Comment: Welcome to Hinduism StackExchange! Answers posted here must be backed up by authentic sources. Kindly do so. Otherwise such answers will be deleted after 30 days of citation notice. Please visit help section to learn more.


What is the relation between the power dissipation in resistor and the temperature rise

Question: Which relation we use to calculate the temperature rise in resistor using the power dissipation.     If we take P=R*I^2 from resistor, how much the resistor heats in this case ?  I know that in transsitor the relation between the power dissipation and the temperature is given by: Pd = (Tj-Ta)/theta(ja), I try to find the relation of the resistor dissipation but i didn't find anything helpful!
Thank you for your help.
Comment: Can we use the Stefan-Boltzmann Law, if we suppose that the thermal energy is transferred by radiation ?
Comment: It depends on the Resistor. Think about: Casing, Airflow, Heatsink, outside temperature. Look at datasheets: [Datasheets](http://www.srt-restech.de//index.php?option=com_content&task=view&id=46&Itemid=95⟨=en). There you will have the power dissipation rating.
Comment: If you want to calculate it, then you need to define the geometry(I suggest a cube) and calculate the heat dissipation coefficients for the surfaces. Then you need to find the thermal equilibrium, to get the final temperature(where dissipation=power input).
Comment: The datasheets give you the rating power dissipation and not the applied power (it's depend on the current flow the resistor)
Comment: They give you the maximum power that can be dissipated without a heatsink in a standard environment(at room temperature, standard air pressure and so on). So yes, they don't give it.
Answer: The relationship in both cases is Temperature Rise = Power * thermal resistance.

Tj-Ta is the temperature rise (from "junction" to "ambient)
theta(ja) is the thermal resistance.  And the assumption is that the data sheet gives you this value.

This relation works just like E=IR only it's temperature and heat instead of voltage and current.  The relationship you gave for the transistor is in a less useful form for this purpose.  You want to apply a little algebra and thus come up with:
Tj-Ta = Pd * theta(ja)
This works for resistors as well, assuming the data sheet will give you a theta value from the resistor body to air.  That's the equivalent of junction-to-ambient.  In all but high-power pulse operation, it's just assumed that the resistor transfers all of the dissipated power to its body, and you only worry about how it transfers to the surrounding air.
Actually, in the real world, both the resistor and the transistor can transfer a considerable amount of heat out through its leads (or pads).  Since your stated equation only mentions junction-to-ambient, that's all that's addressed here.
If you can't get a theta value, you'd have to come up with an allowable maximum temperature for the resistor, and use the resistor's stated power rating to arrive at a value for theta.


How can I book a flight plan found on Matrix Airfare Search?

Question: When I find a flight I like on the Matrix Airfare Search, it spits out a bunch of travel agent secret codes™.  If I look for the same flight on the airline's web site, I often get much higher rates.  As an example, looking at a flight from Cape Town (CPT) to New York (JFK), on December 31, 2013, I get the following from Matrix:

Cape Town (CPT) to New York (JFK) - Tue, Dec 31
  Turkish Airlines Inc.    Cape Town (CPT) to Johannesburg (JNB) - Tue, Dec 31
  Turkish Airlines Inc. 41    Dep: 4:30PM Arr: 6:35PM 2h 5m   Airbus A330  Economy (T)
  Stop in JNB      1h 10m
Turkish Airlines Inc.  Johannesburg (JNB) to Istanbul (IST) - Tue, Dec 31
  Turkish Airlines Inc. 41    Dep: 7:45PM Arr: 5:30AM 9h 45m  Airbus A330  Economy (T)
  Layover in IST   Wed, Jan 1  1h 55m
Turkish Airlines Inc.  Istanbul (IST) to New York (JFK) - Wed, Jan 1
  Turkish Airlines Inc. 3 Dep: 7:25AM Arr: 11:25AM    11h 0m  Airbus A330  Economy (T)

Cost per passenger (including taxes & fees)   $781.60
  Total cost for 1 passenger  $781.60

Provide this information to a travel agent to help them match the fares found.
  Make sure to provide the exact booking and fare codes shown.
  Fare 1: Carrier TK TA2PXOW CPT to NYC (rules)
  Passenger type ADT, ONE-WAY-ONLY fare, booking code T
  Covers CPT-IST (Economy), IST-JFK (Economy) $406.54
  USDA APHIS Fee (XA) $5.00
  US Immigration Fee (XY) $7.00
  US Customs Fee (YC) $5.50
  Turkish Int'l Airport Service Charge (TR)   $6.80
  (YR)    $278.40
  US International Arrival Tax (US)   $17.20
  South Africa Passenger Service Charge (ZA)  $32.40
  South Africa Air Passenger Tax (WC) $18.70
  South Africa Passenger Safety Charge (EV)   $1.60
  South Africa Passenger Services and Security Charge (UM)    $2.00
Subtotal per passenger    $781.60
  Number of passengers    x1
TOTAL AIRFARE & TAXES $781.60
  Changes to this ticket will incur a penalty fee.
  Fare construction (can be useful to travel agents)
  CPT TK X/IST TK NYC 406.06TA2PXOW NUC 406.06 END ROE 10.146090 XT 1.60EV 2.00UM 18.70WC 32.40ZA 6.80TR 5.50YC 7.00XY 5.00XA 17.20US 278.40YR

For this search, I specified USD as the currency, but left the Sales City field blank.
When I try to book the same flight on the Turkish Airlines web site, I get a rate of €797 (~USD$1079), or a USD$298 difference.
By looking at the details of the two sites, I see that it is indeed selling me the same flight.
How can I take advantage of the Matrix-provided travel agent secret codes™ to book the flight at the lower price? Or must I go through a travel agent to use these codes?
Comment: Try booking on Expedia, Orbitz, etc
Comment: I've seen the opposite happen as well.
Comment: Try rome2rio. For me they seem always cheaper then the matrix. e.g $624 for one way CPT->NYC on nov 12th versus $7031! on matrix.
Comment: Matrix does not cover most low-cost carriers, but for your regular mainline IATA airlines, if the fare's not there you're unlikely to find it elsewhere.
Comment: @gerrit: Yes, I've noticed that as well, but that doesn't frustrate me :)
Comment: I think you've made a mistake when you added the flight details - the flight details are on QR, but the fare information is for TK.
Comment: @Flimzy Unless you find out about the cheaper option *after* you've booked a more expensive alternative...
Comment: Related Q: http://travel.stackexchange.com/q/65974/32134
Answer: I'm not aware of any online booking engine that lets you book arbitrary fare constructions, so in practice you've got four options:

Print out the fare construction and go to a travel agent in person.  (This is what I do for personal travel.)
If you already have a personal relationship with an agent, or your company has a designated one, you can e-mail them and ask to book.  ("Cold-emailing" random agencies with complex itineraries is unlikely to work, since they will assess it as a lot of work for low commission and uncertain reward.)
Call the airline and book over the phone.  (Fiddly, because reading out and double-checking gibberish fare constructions is not much fun.)
For heavy users and experts only: Sign up to a GDS and become your own travel agent, so you can issue any ticket you like.  This is not a straightforward process, setup fees are considerable and you're looking at at least $50/mo or so for a subscription, but it might be worthwhile if you fly several times a month.  Here's a (partly outdated) Flyertalk thread about the topic.
Answer: We just created https://bookwithmatrix.com, a site that lets you simply copy and paste the itinerary from ITA Matrix and get links to the major OTAs (online travel agents) where you can make the booking. As jpatokal mentioned, for the most complex fares you may have to talk to a travel agent, but this looks at the fare construction and tries to build the itinerary for 95% of flights you can find.
Comment: Where does the 95% statistic come from? Do you have some actual data?
Comment: @JoErNanO We haven't been able to do automated testing yet, but as a part of our testing, we've done about 50 different itineraries with open jaws, multiple airlines, and stopovers in the US and internationally and all but one of them were bookable; let us know if you find any itineraries that are not, and we'll see what we can do there!
Comment: If that's the case then I don't think you should be claiming results from statistics you don't have.
Comment: @nsn you're right; we currently refer you to other websites, but they usually don't respect the booking codes provided. We're working on becoming a full-fledged travel agency ourselves so that we can help you book exactly the booking code/fare construction ITA gives
Comment: @incaren that would be quite cool. Don't forget to let us know.
Comment: It's not spam in this case. Repeated claims that cannot be substantiated will lead to moderator intervention @JoErNanO is this sufficient?
Comment: I congratulat you for your work, but that doesn't seem what most people are looking for when they ask for ITA codes. You seem to scrape the page rather than use the codes given by it. You than find flights like that, but not based on the ita matrix codes.
Answer: Most likely where you are hitting issues is with the "sales city".
Your output from ITA shows a flight from South Africa to the US, but the price is displayed in US$.  This means that within ITA you've changed the "Sales City" from it's default (which would have been CPT, your origin city) to somewhere in the US, otherwise it would have display the price in South African Rand.
Airlines frequently price fares differently depending on where you buy them - a trip bought in the US might cost more or less than the equivalent trip bought in the UK, Turkey or South Africa.  In general, a travel agency in one location can not access the fares available for sale in a different location - and that includes online travel agencies.
When you book a flight directly from the airline they will often use the departure city as the "sales city", and that's what ITA defaults to if you don't change it.  When that happens the price will be generated in local currency for that location, and using the pricing available for that country.  By changing the sales city you can change the currency and the price, but you end up with something that can only be purchased in the country that you've set the sales city to.
Presuming you got the price you've quoted above with the sales city set to somewhere in the US, any US travel agent - including any US-based travel website - should be able to get you that price.  As you haven't given dates I can't confirm that, however checking on Orbitz for a few dates in December I do see CPT-JFK available on Turkish Airways for ~US$790 - a few dollars more than you've got above, but in the same region.
Comment: Very informative! This means we want to know the sales city, or at least country, for the various online travel agents ...
Comment: As per my comment above I think you may have entered the wrong flight details - however the Qatar Airways (QR) flights you've entered can be booked on Orbitz for $770 on the dates shown
Comment: @Doc: Indeed; I see the same on Orbitz, too. And I find the matching TK flight as well. Thanks.
Comment: Changing the currency field on ITA doesn't change the sales city.
Answer: According to this resource, you can use some of ITA's routing language with Hipmunk.
Answer: What I have done is this: (not just for Google Matrix but other flight search engines too)

Print out or write down all the travel agent secret codes™.
Telephone the airline, tell them how I found the flight and that I need more details, asking the which of the secret codes™ they need me to read out to them.
Write down the price they tell me, assuming it's not something special that's only available through certain agents etc. (I'm not claiming to understand much of this secret stuff.)
Armed with all this information, head to a physical travel agent or two.
If visiting more than one travel agent, make sure the last one has something like a "We guarantee to beat any price" offer. Flight Centre should have this policy in most countries they operate in.
Profit! <code>(-:</code>
Comment: For the specific case of Matrix, all you need is the two lines after "Fare construction" at the end.
Answer: Just call the airlines shown on the itinerary (if American, call American), and tell them the details of the flight. I booked mine easily, and I only paid an extra 25 bucks as booking charge. The price was as came up on the ITA search engine.


Computer too slow

Question: I am using Windows Vista Home Premium 64 bit in my HCL Beanstalk machine with 1 GB RAM.  The processor is Core 2 Duo. But my system has become too slow to work. "Not Responding" messages have become frequent. It gets stuck whenever i try to open any application. It shows up even if i open My Computer. I have formatted my machine 3 times but the problem still exists. I tried to install windows xp but the audio driver was not working so i had to reinstall Windows Vista.
Also want to know if system problem can affect broadband connection as the connection gets lost many times in a day.
Comment: It sounds like your HDD is failing if reinstalling your operating system does resolve performance related problems.
Comment: Did your computer work fine in the past? If it did you can ignore all RAM/memory comments because that is not the problem. (Having said that: adding a few GB of memory will speed things up and is cheap. But if the computer *recently* started showing those problems then there is most likely another problem.  One of the likely candidates for new problems on older but reinstalled machines has already been mentioned: A failing HDD. Check the eventviewer for messages which can confirm that (or which can show something completely different).  (Start, run, `eventvwr.msc`).
Comment: I'd use a lightweight user friendly linux distro on that pc, vista is the worst desktop windows ever made, and you're using it on a 1 GB ram machine!
Comment: Your computer is simply old. Vista needs at least 3 GB RAM to work with reasonable performance, not to mention other components. You can try installing Windows 8 to boost it a bit, but don't expect miracles.
Answer: One of the best and cheapest ways to improve performance on a PC is to increase the RAM.  I would try installing 2 GB of RAM and see if that helps at all.  If not, I would suggest backing up your data as soon as you can and get a new hard drive. As Ramhound said, it is also very likely your HDD is failing.  Also, you could try running Disk Defragmentor which comes with Windows systems.  This will rearrange the data on the HDD closer together to improve performance.
Answer: Windows Vista is very hardware hungry and required an unreasonable amount of RAM and processing power to run efficiently. Now with more modern computers that wouldnt be a problem but your machine only has 1gb of RAM and im sure Vista uses about 660mb of that, I could imagine you dont have the most powerful processor in there either. This doesnt leave much left over to run other applications, or do much at all really.
I think you should update some of your machine hardware like the RAM and the processor or better yet build or purchase a newer more powerful machine which comes with windows 7.
Times are hard for everyone right now though so if buying one isnt an option then go back to re-installing XP, try and find the correct sound drivers online as well as the drivers for all your other hardware and you should be good to go and much better off than with Vista.
Microsoft are aware Vista was a terrible operating system hense its relatively short lifespan compared to windows XP
Comment: I disagree with both statements. Many people found vista horrible because it was new and *different*.  After they got used to it win7 was fine, and win7 is very close to vista with SP1.  Also win7 runs fine on netbooks with 1GB RAM. The posted computer is probably a lot faster than that. I suspect that the problem is either malware or some hardware problem (such as a failing HDD)).
Comment: @Hennes +1 Vista/7 have the same requirements and often Vista uses less RAM for me compared to 7. Nice to see that some users here have such a deep understanding and don't post such nonsense :)
Comment: a clean install of windows XP on a 32 bit system uses around 120MB of RAM while both windows Vista and Windows 7 use over 500MB more than that. His system (only having a core 2 duo processor and 1GB of RAM definintely isnt that fast and it is no secret that 1GB of RAM running Windows Vista is a big ask. I would at least increase to 2GB. without debating about which is the best operating system, the answer to the original question is his machine is far too weak to run windows Vista and should either be upgraded or the operating system changed to XP
Comment: my HDD temp is around 56 degree C as its kept in a box. Can this afeect my system's performance( my monitor screen does go black on summer days)? Also I installed HD Tune to check for bad sectors in my disc but could not find any. I am unable to work out whether it is because of RAM or any other hardware component is not functioning properly. And this problem is not recent. Its been around 1.5 yr @Karan. I have formatted it around 3-4 times.
Comment: Do whatever you can to keep your machine as cool as possible. If you have always had this problem i stand by my original answer stating that your machine is just too weak to run Vista. the vast majority of your computer hardware is being taken up by the operating system leaving you with almost nothing left to do anything else

Computer too slow


Limit file format when using ?

Question: I'd like to restrict the type of file that can be chosen from the native OS file chooser when the user clicks the Browse button in the <input type="file"> element in HTML. I have a feeling it's impossible, but I'd like to know if there is a solution. I'd like to keep solely to HTML and JavaScript; no Flash please.
Comment: I can, but I have a solution working with JavaScript - it removes the annoyance of uploading a file *then* getting the "Wrong file!" error.
Comment: Its easily possible with PHP, but I don't know if you can use that so I won't post the code.
Comment: One thing to note is that while it is not great for validation, accept will limit the visible files to the accepted ones while the user is browsing them (at least in some browsers ...). So this is more a UI ergonomy feature than a validation one.
Comment: Also see more recent question: https://stackoverflow.com/questions/181214/file-input-accept-attribute-is-it-useful
Answer: Strictly speaking, the answer is no. A developer cannot prevent a user from uploading files of any type or extension using front-end validation (HTML/JavaScript).But still, the accept attribute of <input type = "file"> can help to provide a filter in the file select dialog box provided by the user's browser/OS. For example,

<input type="file" accept=".xls,.xlsx" />

should provide a way to filter out files other than .xls or .xlsx. Although the MDN page for input element always said that it supports this, to my surprise, this didn't work for me in Firefox until version 42. This works in IE 10+, Edge, and Chrome.
So, for supporting Firefox older than 42 along with IE 10+, Edge, Chrome, and Opera, I guess it's better to use comma-separated list of MIME-types:

<input type="file"
 accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel" />

[Edge (EdgeHTML) behavior: The file type filter dropdown shows the file types mentioned here, but is not the default in the dropdown. The default filter is All files (*).]
You can also use asterisks in MIME-types. For example:

<input type="file" accept="image/*" />
<input type="file" accept="audio/*" />
<input type="file" accept="video/*" />

W3C recommends authors to specify both MIME-types and their corresponding extensions in the accept attribute. So, the best approach is:

<input type="file"
 accept=".xls,.xlsx, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel" />

JSFiddle of the same: here.
Reference: List of MIME-types
IMPORTANT: Using the accept attribute only provides a way of filtering in the files of types that are of interest. Browsers still allow users to choose files of any type. Additional (client-side) checks should be done (using JavaScript, one way would be this), and definitely file types MUST be verified on the server, using a combination of MIME-type using both the file extension and its binary signature (ASP.NET, PHP, Ruby, Java). You might also want to refer to these tables for file types and their magic numbers, to perform a more robust server-side verification.
Here are three good reads on file-uploads and security.
EDIT:  Maybe file type verification using its binary signature can also be done on client side using JavaScript (rather than just by looking at the extension) using HTML5 File API, but still, the file must be verified on the server, because a malicious user will still be able to upload files by making a custom HTTP request.
Comment: I wish we had a choice to exclude files as well, for example `exclude="exe"`.  ¯\_(ツ)_/¯
Comment: @Sandesire I don't think that you can restrict file sizes in HTML. It's possible using JavaScript, as you suggested.
Comment: To clarify Edge behavior further (according to my tests), it will add different filters based on what you specify, but a) it's not bundled, so it will list each extension as a separate option and b) it will always add some in-build extensions such as .html, and c) as already stated, it will always pre-select (*). Which makes it a big mess and useless in most cases. I voted on the uservoice link, let's hope they listen sooner or later.
Comment: From my personal experience this looks like a good answer, the mime type alone will not work on all browsers.
Comment: Incidentally `accept` still doesn't work in Edge: https://stackoverflow.com/questions/31875617/input-accept-attribute-in-microsoft-edge#32214646. More details here: https://wpdev.uservoice.com/forums/257854-microsoft-edge-developer/suggestions/13661175-full-spec-support-for-accept-in-input-type-file
Comment: Is there such an easy way to restrict file size too?
I know how to do it with JS/jQuery, would be nice to know though.
Comment: You're right more or less. Edge doesn't select the filter as the default filter in the file select dialog box; the filter appears at the bottom end of the list. :-)
Comment: The file type filter dropdown shows the  **All files (*)** as default one. Based on your answer, I will get xls and xlsx formats. But still user can change it to default one.
Answer: There is the accept attribute for the input tag. However, it is not reliable in any way.
Browsers most likely treat it as a "suggestion", meaning the user will, depending on the file manager as well, have a pre-selection that only displays the desired types. They can still choose "all files" and upload any file they want.
For example:

<form>
    <input type="file" name="pic" id="pic" accept="image/gif, image/jpeg" />
</form>

Read more in the HTML5 spec
Keep in mind that it is only to be used as a "help" for the user to find the right files.
Every user can send any request he/she wants to your server.
You always have to validated everything server-side.
So the answer is: no you cannot restrict, but you can set a pre-selection but you cannot rely on it.
Alternatively or additionally you can do something similar by checking the filename (value of the input field) with JavaScript, but this is nonsense because it provides no protection and also does not ease the selection for the user. It only potentially tricks a webmaster into thinking he/she is protected and opens a security hole. It can be a pain in the ass for users that have alternative file extensions (for example jpeg instead of jpg), uppercase, or no file extensions whatsoever (as is common on Linux systems).
Comment: for additional information see http://stackoverflow.com/questions/181214/file-input-accept-attribute-is-it-useful
Comment: Although it is true that's it's impossible to prevent the user from selecting ANY type of file eventually, these days you can take advantage of the HTML5 File API and work with the selected file for upload, before it is actually uploaded to the server, including detecting its type, size and more. Give it a try. It's very easy to use, yet very powerful and useful.
Answer: You can use the change event to monitor what the user selects and notify them at that point that the file is not acceptable. It does not limit the actual list of files displayed, but it is the closest you can do client-side, besides the poorly supported accept attribute.

var file = document.getElementById('someId');

file.onchange = function(e) {
  var ext = this.value.match(/\.([^\.]+)$/)[1];
  switch (ext) {
    case 'jpg':
    case 'bmp':
    case 'png':
    case 'tif':
      alert('Allowed');
      break;
    default:
      alert('Not allowed');
      this.value = '';
  }
};
<input type="file" id="someId" />

JSFiddle
Comment: @Joe .. well .. i try to provide direction and a sound logic. Not fully implemented solutions for every case. I trust the viewers to use common sense when copy/pasting code from the web ;)
Comment: @joe, it is an example... it can extend to whatever extensions you want to allow.
Comment: How about "Some.File.jpg"? Perhaps that regex line needs to read:
var ext = this.value.match(/\.([^.]+)$/)[1];
Comment: Issue with this approach is that something could still technically be a jpeg even if it doesn't end with that extension. Extensions !== mime types
Comment: I use a FileReader and file input element with an extra if else statement. I use this example and it works perfectly. The code is clean and easy to understand. The accept function for the file element doesn't really work. I need to allow m3u and m3u8 files. Many web browsers work individual at the accept function for the file element.
Comment: yeah, you can. but  you DIDN'T! and maby somebody copied it already! and what about files with correct mime type but no extension?
Answer: Yes, you are right. It's impossible with HTML. User will be able to pick whatever file he/she wants.
You could write a piece of JavaScript code to avoid submitting a file based on its extension. But keep in mind that this by no means will prevent a malicious user to submit any file he/she really wants to.
Something like:
function beforeSubmit()
{
    var fname = document.getElementById("ifile").value;
    // check if fname has the desired extension
    if (fname hasDesiredExtension) {
        return true;
    } else {
        return false;
    }
}

HTML code:
<form method="post" onsubmit="return beforeSubmit();">
    <input type="file" id="ifile" name="ifile"/>
</form>

Comment: @Joe: stop saying that my answer sucks! :-) Anyway, it's not a perfect solution. As I said in the beginning of it: "it's impossible" to do what OP wants. But you can have **some** degree of help for the user if you only let him/her choose files with certain extensions. **REAL** file type validation must be done **server side**.
Comment: @JoeHopfgartner : Dude, you're being overly harsh for Pablo here. clientside validation is done in tons of places and although not foolproof (there should [b]always[/b] be serverside validation included) it can save the user quite some time (no postback for a stupid extension check etc).
While the script given by Pablo is not perfect, it is merely intended to be an example of how to tackle this issue...
Maybe you should email the tech guys at Microsoft and ask them to remove Clientside validation from their ASP.NET validators since it's all plain rubbish to you...
Comment: there is a fully valid html attribute for that so it is possible. it is just not respected by browsers, but thats a standardization problem. as well as any stuff handled client side in unprotected markup cannot restricted anything java script is no solution.
Comment: Very good point. I will add a second PHP checker just in case. Can't be too careful!
Comment: Well, it does no harm if I'm using a PHP validation script too, so I'll use both.
Comment: Thank you :-) I actually already have that code to limit the type, but good suggestion!
Comment: it does harm. because somebody might rely on it and forget the server side validation. and why have it redundant if its not reliable? and it is also a potential pain in the ass for the user. the only point i see in it is to save bandwidth by blocking the upload before it happens.
Comment: Pablo is just tryna help jeezz
Comment: js validation is no protection whatsoever. it does not ease the selection for the user by displaying only relevant files. it is just unnecessary code with the potential to be a pain in the ass for users that for example have 4 letter or uppercase file extensions which you didnt take care of in your script. or trick some webmaster into thinking he/she is protected. i cant see any good in this method. you can youse the html attribute to ease the selectino for the user if its supported and you must do the validation server side. this here can only save some bandwith.
Comment: here is the best example: http://stackoverflow.com/questions/4328947/limit-file-format-when-using-input-typefile/4329103#4329103 -> now your file may be named "me.jpeg". it is blocked altough its perfectly valid and you may end up with a frustrated user that quites your site because he/she cannot upload his/her profile picture
Answer: Technically you can specify the accept attribute (alternative in html5) on the input element, but it's not properly supported.
Comment: True, it's best not to use this for security, but it definitely helps usability on browsers that support it.  Users are shown only the files that the site allows (not all the other junk they might have in the same folder) and they don't have to go through the whole upload process to be given an error, they will know straight away.  Coders *should* use this.
Comment: W3Schools browser support fail! It's a shame really. It is also a security concern - people can hack past client side code and upload whatever they want.
Answer: You can use the "accept" attribute as a filter in the file select box.
Using "accept" help you filter input files based on their "suffix" or their "MIME type"
1.Filter based on suffix:
Here "accept" attribute just allow to select files with .jpeg extension.
<input type="file" accept=".jpeg" />

2.Filter based on "file type"
Here the "accept" attribute just allows you to select a file with "image/jpeg" type.
<input type="file" accept="image/jpeg" />

Important: We can change or delete the extension of a file, without changing the meme type. For example it is possible to have a file without extension, but the type of this file can be "image/jpeg". So this file can not pass the  accept=".jpeg" filter. but it can pass accept="image/jpeg".
3.We can use * to select all kinds of file types. For example below code allows to select all kinds of images. for example "image/png" or "image/jpeg" or ... . All of them are allowed.
<input type="file" accept="image/*" />

4.We can use comma ( , )  as an "or operator" in the select attribute. For example to allow all kind of images or pdf files we can use this code:
<input type="file" accept="image/* , application/pdf" />

Answer: Use input tag with accept attribute
<input type="file" name="my-image" id="image" accept="image/gif, image/jpeg, image/png" />

Click here for the latest browser compatibility table
Live demo here
To select only image files, you can use this accept="image/*"
<input type="file" name="my-image" id="image" accept="image/*" />

Live demo here

Only gif, jpg and png will be shown, screen grab from Chrome version 44
Comment: Thanks!  In Chrome on Win10, if I use `accept="image/*"`, it says "Image Files" instead of "Custom Files" in the file picker, which is nice for the end user.
Comment: But user can change it and upload the other extension file
Comment: @PrashantPrajapati Yes, thats how browsers are made, there should be corresponding validation in server.Browser functionality is just for better user experience.
Answer: I know this is a bit late.
function Validatebodypanelbumper(theForm)
{
   var regexp;
   var extension =     theForm.FileUpload.value.substr(theForm.FileUpload1.value.lastIndexOf('.'));
   if ((extension.toLowerCase() != ".gif") &&
       (extension.toLowerCase() != ".jpg") &&
       (extension != ""))
   {
      alert("The \"FileUpload\" field contains an unapproved filename.");
      theForm.FileUpload1.focus();
      return false;
   }
   return true;
}

Answer: You could actually do it with javascript but remember js is client side, so you would actually be "warning users" what type of files they can upload, if you want to AVOID (restrict or limit as you said) certain type of files you MUST do it server side.
Look at this basic tut if you would like to get started with server side validation. For the whole tutorial visit this page.
Good luck!
Answer: As mentioned in previous answers we cannot restrict user to select files for only given file formats. But it's really handy to use the accept tag on file attribute in html.
As for validation, we have to do it at the server side. We can also do it at client side in js but its not a foolproof solution. We must validate at server side.
For these requirements I really prefer struts2 Java web application development framework. With its built-in file upload feature, uploading files to struts2 based web apps is a piece of cake. Just mention the file formats that we would like to accept in our application and all the rest is taken care of by the core of framework itself. You can check it out at struts official site.
Answer: I may suggest following:

If you have to make user select any of image files by default, the use accept="image/*"
<input type="file" accept="image/*" />
if you want to restrict to specific image types then use accept="image/bmp, image/jpeg, image/png"
<input type="file" accept="image/bmp, image/jpeg, image/png" />
if you want to restrict to specific types then use accept=".bmp, .doc, .pdf"
<input type="file" accept=".bmp, .doc, .pdf" />
You cannot restrict user to change file filer to all files, so always validate file type in script and server
Comment: This was what I was looking for: accept=".bmp"  Works fine on chrome.
Answer: Building on the previous answers of using the accept attribute, you can accomplish this using the File API. This also gives you access to the file contents should you use FileReader to do some local parsing or data handling.
First create an input element, here you could apply the file type to the accept attribute but for the example it will allow you to select all file types.
<input type="file" name="upload" accept="*" multiple>

Next we need to listen to the 'change' event on the input element.
var upload = document.querySelector('input[type="file"]');
upload.addEventListener('change', function() {});

Inside the function you'll be able to access the files object of the input.
var files = this.files

We can't just iterate over the object since it isn't an array, however we can use the item() function to access our File object from the list.
for (var i = 0; i < files.length; i++) {
    var file = files.item(i);
}

Now that we have our File object, we can access its name and type properties and do our file check here. In this case I'm checking to see if it's a .txt file and printing a message if it isn't. You can check the name against a regex pattern for the file type or check the type against its MIME type.
if (!file.name.match(/.txt$/i) || file.type != 'text/plain') {
    console.log(file.name + ' is not a .txt file.');
}

var upload = document.querySelector('input[type="file"]');
upload.addEventListener('change', function() {
    var files = this.files;
    for (var i = 0; i < files.length; i++) {
        var file = files.item(i);
        if (!file.name.match(/.txt$/i) || file.type != 'text/plain') {
            console.log(file.name + ' is not a .txt file.');
        }
    }
});
<input type="file" name="upload" accept="*" multiple>

File API is very well supported for modern browsers. By combining this with the accept attribute you can easily filter what the local user can select in an upload and provide useful feedback. If you are uploading the file, you should still check and validate the file type on your backend.

Limit file format when using ?