HTML5 validation & custom autofocus position

Question: I'm building web form where I'm using simple HTML5 validation.
<input type="text" required />

By default, when I click on the "SUBMIT" button browser HTML5 validation would kick in, scroll the page and focus on the empty required field. Problem is that browser would scroll up just enough to place the field inside viewport, at a very top of the screen. In some cases I might have absolute positioned elements at a top that would overlap the field.
I wonder if it's possible to scroll, let's say 100px more when validation kicks in, or even move the filed to the middle of the screen.
Note that I'm looking for simple JS or CSS solution that works with default HTML5 validation. I'm aware that I can achieve this if I implement custom validation script but I'm trying to stay lean.
Thanks
Comment: why not this `$("#id").focus()`
Comment: OPUS: That would do exactly the same
Answer: You could trigger the validation youself with checkValidity(), and if that returns false, scroll another 100px down (because checkValidity() allready pushes you to the element).
If you set the form to 'novalidate' and than onsubmit check the form, you have a better control over it.
Comment: Sounds interesting. I'll give it a try now.


Is a DBMS (MySQL, SQL Server….) interpreted or compiled?

Question: I mean, in the terms of the SQL queries, Are they compiled or interpreted in a low level?. How it works internally, It is a SQL statement interpreted or compiled?.
Comment: Are you asking about MySQL specifically, or any DBMS? Because different DBMSes are at different points on the compile-vs-interpret spectrum
Answer: It's typically working like this:

    SQL String ---[Optimizer]---> Execution Plan ---[Execution]---> Result

I personally like to see the optimizer (query planner) as something very similar to a compiler. It's transforming the SQL statement into something that is more easily executable. However, it's not nativity executable on the chip. This "compilation" is rather expensive--just like compiling C++ code. That's the part where different execution variants are evaluated; the join order, which index to use, and so on. It's a good practice to avoid this whenever possible by using bind parameters.
The execution plan is then taken up for execution by the database. However, the strategy is already fixed. the execution is just doing it. This part is kind of interpreting the execution plan, not the SQL.
After all, it is, somehow, similar to Java or .NET where the compilation turns the source code into a binary form that can be interpreted more easily. If we ignore JIT for this argument, the execution of a Java program is interpreting this meta-code.

I have used this way to explain the benefit of using bind parameters for (Oracle) performance in my free eBook "Use The Index, Luke".
Comment: Please correct me if I'm wrong: You might want to add that the Optimizer can use caching for the execution plan, which would explain the advantage of bind paramers.
Answer: In modern SQL environments it is a staged approach where you make a decision at a certain level of the workflow whether or not you want to re-use and existing compiled block or start all stages again  if you get a better plan for a certain combination of arguments.
I think it is a pay off between (re-) compiletime and execution time of the (then compiled to executable code) result. Depending on complexity of the query, a recompile applying the specifics of the given arguments at runtime may not be worth the effort if execution time of the existing code is already low because of foreseeable minimum resource consumption (e.g. read two rows and return).
With higher query complexity and estimated resource consumption(many huge tables involved, crucial index choice, possible table scan), the granularity of your statistics comes into play. i.e. if you have selectivities, outliers, range selectivities, avg. field sizes, physical map sizes, etc. the optimizer may come to very different conclusions with different sets of arguments.
Calculating the best plan for a 25-join statement with 10++ variable arguments might take its time and resources. If the result is faster and more efficient than the one-for-all version it is worth the effort. Especially it the given set of arguments may contain game changers and the query will be re-executed frequently.
Finally, your mileage may vary with each vendor ;)


Would it be a bad idea to call attention to my improved questions to gain upvotes? If not, what is the best way to call attention to the posts?

Question: I'm trying to get my question ban lifted. I went back and made some changes to my questions, and now I feel that the questions are fit for upvotes. However, the questions are old and so may not receive any attention from other StackOverflow users for a while.
Comment: If you edit, the question will get bumped to the front page, and people will look at it & possibly upvote. Also, if you post a link to it here, and it is really good, people will look and upvote. It's called the "Meta Effect".
Comment: I maintain that you are providing some very low quality answers to some questions, which will ***not*** help you out of your ban, and could lead you to an answer ban.. Just googling a library that looks half-relevant to something or finding some documentation to read and linking it usually isn't enough, like [here](http://stackoverflow.com/questions/26976097/detect-input-devices-connected-to-ios-device/26977668#26977668) and [here](http://stackoverflow.com/a/29641122/4686625).
Comment: Another thing, please don't [repeat questions](http://meta.stackoverflow.com/q/290259/215552) to meta.SO to gain that attention...
Comment: Beware of irritating users, or generally calling attention to content failing the standards though...
Answer: Editing your question will naturally bump it. Additionally, users with 75+ rep can offer bounties to draw attention to their question:

What is bounty?
A bounty is a reputation reward you can put on a question to get it
  more attention for exactly one week.
When should I place a bounty?
In order to get good answers, you have to put effort into the
  question. Edit the question to provide status and progress updates.
  Document your own continued efforts to answer the question. This will
  naturally bump the question and get more people interested in it.
However, if after doing this, you feel a particular question still
  isn't getting enough attention, adding a bounty may help.


Black and green patches at the inside of vaccum

Question: Is it safe to eat this ribeye? It has some green and black patches inside of the vacuum. It was in the freezer for 2 months.
Comment: the green patches look like tiny leaves, at least with the quality of the image you put here. I can't tell what the black is, not enough detail in the image.
Comment: I'm quite puzzled by the question. I see two green leaves, like Esther, and three small black seeds which remind me of black caraway. It's very obvious that they aren't spots within the meat. I also see that the meat surface isn't bright red, but it has the slightly greyish look of oxygenated meat, and no noticeable spots. What is it that you're asking about, is it the spices, or are you seeing something on the meat that isn't clear in the photo?
Comment: The black and green do not look like results of the time in the freezer. If that meat is packed vacuum, those leaves were already in it. Did the vacuum break?
Answer: All good, I ate it and it was all fine.


Do you get reputation for self-answered questions?

Question: From time to time I ask a question on Stack Overflow. The community is incredibly fast and correct, but sometimes I beat them to it and answer my own question after some research.
Not that it matters a lot, but I used to earn some reputation when answering my own question. This time though, I didn't get any. Is there a limit on answering your question, or has there been a change of policy?
Comment: I am assuming you mean this: http://stackoverflow.com/questions/8485971/nested-relations-in-drupal
Comment: _I used to earn some reputation when answering my own question_ really? could you provide a link to an example of such answer?
Comment: Yup, that's the one
Comment: You mean you gained 15 rep from having your own answer accepted?
Comment: No no no. I got 2 rep from time to time when answering my own question
Answer: You can answer your own question - you will get reputation if it gets upvoted (assuming you did not mark it as Community Wiki).
There is no time limit for getting reputation for upvotes... I am still getting some rep for posts over 3 years old.
Additionally, if someone else starts a bounty on one of your questions, they can award their bounty to your self-answer, and it will be considered by the system if the bounty is to be awarded automatically.
You don't gain any reputation from accepting your own answer, and you can't award a bounty that you started to your own answer.
Comment: "`You don't gain reputation from accepting your own answer.`" -- Thank you for confirming. I have searched meta se and so and finally found exactly what I needed. I did't even see this in http://stackoverflow.com/help/self-answer.
Comment: Ok, thanks for this clarification. I must of gain the reputation in another way I guess :-)
Comment: @Michiel - Answering questions is the best way to gain reputation. 10 points per upvote instead of a single 2 points per accept.
Answer: You don't get reputation for accepting your own answers, as @Oded already mentioned, but you will get the reputation from upvotes on your answer which show that people got help from your answer.
If you have faced a problem and couldn't find a solution, and had found a proper solution for it later and want to store it somewhere easy to find, you have something useful that is worth posting a question about. This will save other people the trouble you took, so there is no harm in posting it on the appropriate Stack Exchange site.
Answer: Policy apart, you are supposed to do the research first and ask later, I guess. That way, you have not only been getting some unfairly gained reps (unfairly because you did what you should have done anyway and because you did it too late for the question and too early for the others to catchup), but ... [let me post this much first -may edit to add more] :) :)
Comment: Answering your own questions is explicitly encouraged. You can even ask a question and answer it yourself if you already know the answer. ([link](http://meta.stackexchange.com/questions/17463/can-i-answer-my-own-questions-even-those-where-i-knew-the-answer-before-asking))
Comment: Some issues are very difficult to find solutions to.  I've run into some very obscure programming problems in the past and asked on SO after many hours of researching.  I didn't stop researching just to wait and see if I had any answers, and yes, sometimes I found the solution on my own.
Comment: I disagree about "unfairly gained reps" - if the answer is good, it doesn't matter who posted it - even the one asking the question.
Comment: @Kris: no amount of smileys make a post down vote proof :) :) :)
Comment: Indeed. Sometimes it took me days or weeks to find a decent solution. And when I found it, I want to share it with the community. So I don't see any harm in answering your own questions if you've got the proper solution to it...
Comment: @AndyE'shead: You have obviously missed the smileys at the end: That was not supposed to be some serious solution offered.
Comment: @Michiel: Same as above.
Comment: Yep, saw that, deleted.
Comment: @Kris: I know :-)


Damaged cog while taking it off

Question: Damaged my cog while taking it off. Is there any possibility of repairing it?
Comment: It seems to be a steel cog (although plated?).  So, yes you could probably have it repaired.  However I suspect it's not worth putting that effort in, and replacing the cog would make more sense.  If you search for Miche 15T cog you'll probably have no trouble finding a direct replacement.
Comment: How did you try to take off that cog? That damage is impossible to produce when you take off the cog in the way it's supposed to be taken off. Which is: 1. Take off the circlip (https://en.wikipedia.org/wiki/Circlip), and 2. effortlessly slide the sprocket off the axis. I guess you have taken a shortcut around 1, one way or another...
Comment: Looks to me like the tooth spacing is reduced on one side and lengthened on the other. This would add  a pressure point such that one link was taking nearly all the force, at best increase chain wear, and the damaged and weakened tooth taking all the load - probably fatiguing it to failure.  Ergo Replace it is the only responsible advice you should get.
Comment: My money is on a material default in the steel.
Comment: @cared default --> defect ?
Answer: Sprockets are wear parts anyway so just replace. Welding would be relatively expensive and I strongly suspect it would damage the heat treatment state of the steel.
Answer: Top preference would be a replacement.  These cogs are not expensive.
A second idea - It looks symmetrical, so I'd suggest using a small file to blend any burrs or daggy bits that might catch the chain, and then just flip it over so the "miche" branding is on the opposite side.
That way the wear will be on the back of the curve, and you can get some more life out of it.
If this is on a fixed gear bike where you do skid braking, I'd just replace it.
Comment: That looks like a structural crack. I would replace it and be done with it. If you are going to try to repair it, it should be welded.
Comment: @DuncanC possibly - I thought it was a gouge on both sides from a tool.    The point about flipping the cog is that point will be in compression, not tension.   If a repair is expected, brazing might be an adequate solution.  I doubt soldering would be up to the task.
Comment: I used the term "welded". Agreed that soldering would not be up to the task. Solder is much too soft for a load-bearing repair.

Damaged cog while taking it off


Does landscape fabric (filter fabric) get clogged? If not, why not?

Question: I have a drainage problem to solve and I'm considering a French drain.  I have read in dozens of places that various drainage systems (including French drains) are usually lined or wrapped in a landscape fabric/filter fabric to prevent sediment from getting in an clogging up the drain.  But nobody seems to ask or answer the next logical question: what prevents the sediment from clogging up the fabric instead?  Aren't you just pushing the problem up one level?
Comment: I think that the first approach to consider for a drainage problem should be regrading of the surface. Only if there are insuperable, or at least major, negative factors for regrading should underground drains be considered. There is now a product on the market which is in between a swale and a French drain. These are lengths of porous rubber which conduct water and which are installed in trenches. I think they can be exposed to the surface or shallowly buried.
Answer: Think about how a coffee filter works.  You have a paper filter clogged with wet coffee grounds.  The water slowly passes through the filter paper and you have a thin film of water between the filter and the funnel.  That film from the entire surface of the filter paper flows to the bottom of the funnel.  By the time it all aggregates and flows out of the funnel, you get a stream of fast-moving coffee.  That's what goes on with the filter fabric and the drain.
The drain channel is sized to move water at a certain rate.  There is typically a perforated pipe that offers unimpeded flow to the water once inside, so it is quickly carried away.  The water gets into it by traveling through big gaps between large stones, and some of it even travels through the stone gaps.
If the drain system is at the surface of the ground, much of the water will get there by flowing over the ground until it reaches the stones.  Some of it gets there by flowing through the soil; flowing much slower, through much smaller paths between dirt grains, over a much bigger area.  If the drain is completely buried, like around the footers of your house foundation, all of the water will get there by traveling through the soil.
The filter fabric is porous, and acts like a barrier to separate the soil from the drain.  It gets clogged with fine soil, but not really different from the soil the water is passing through to get there.
So you have a lot of water collecting in the soil over a very large area.  It moves slowly through the tiny gaps in the soil, but that's a lot of water moving slowly.  It passes through the fabric barrier at the perimeter of the drain system, which has a lot of surface area, and the aggregated water becomes the stream flowing through the channel.
If filter fabric is only placed around the drain pipe, the stone in the channel fills with silt until there isn't really a difference between the stone channel and the soil.  The water moving through the soil will find its way into the perforations in the pipe, but you're aggregating slow-moving water from a few small holes, so you only get a trickle through the pipe.
Comment: If the system is installed right, you should get use from it on the order of decades before this kind of situation develops.  If you didn't have fabric around the system, it could be useless in a few years.
Comment: Wait, don't paper coffee filters get too clogged to function after a few uses?  That's exactly what I'm concerned about happening with landscape fabric.
Comment: If that happens around the drain, the finest particles could gravitate to the fabric.  Keep in mind, though, that the pores in the fabric aren't holes that match the shape of the soil particles, so that particles the right size plug the pore like a cork in a bottle.  They're irregular, and it's difficult for soil particles to totally clog it up.  Also, water gets through the fabric slowly, by capillary action, it isn't like a fast-moving stream is driving soil deep into the fabric.  Over a very long time, it's possible for portions of the fabric to have reduced flow.  (cont'd)
Comment: On the other hand, your point about effectively increasing the diameter and surface area of the fast-moving drainage channel is well-taken.  The more fabric surface area surrounds the channel, the faster water can flow through the fabric into the channel.  That part makes a lot of sense.  I'm still concerned about the "coffee filter" clogging up though.  That's why coffee filters are disposable....
Comment: @Craig, coffee filters don't really get "clogged", they just get disgusting.  That's why they're disposable.  :-)  Soil does consist of particles of different sizes.  When it is compacted, there isn't movement.  If it's disturbed (wetting and drying creating cracks, roots creating channels, organic material decomposing, etc.), moving water can carry the smallest particles through the voids (leaving bigger voids through which bigger particles can be carried).  That's what sometimes happens with earthen dams, and how they eventually spring leaks.  (cont'd)
Comment: At some point, if the drainage system got too degraded and it took too long for water to be drained away, it might need to be "serviced".  If that happened, you would at least still have a clean drainage system that you could reuse.  Pull out the stones and pipe, replace the fabric, and put everything back.  If you didn't have the fabric, or the fabric just wrapped the pipe, you would need to excavate and dispose of all of the silt-filled stone (or excavate and wash the massive amount of stone and deal with the resulting dirt).  (cont'd)
Answer: The problem is not cut and dry and depends in part on the soil type and filter fabric pore size. Filter fabric will more likely become saturated with sediments that are fine, like clays and muck soils. Sandy soils and sandy loams it should last much longer because the grain size is larger.
Comment: Hello, and welcome to Home Improvement. Thanks for the answer; keep 'em coming. And, you should probably [take our tour](//diy.stackexchange.com/tour) so you'll know how best to contribute here.


What is a simple argument to prove that the stars in the sky are further away from the Earth than the Moon?

Question: How do we know, without using modern equipment, that the stars are further away than the moon in the night sky? Further, is there a simple and actionable argument to prove that this is indeed the case? Additionally, I would like to know how people in earlier times knew this fact without having access to modern equipment, including telescopes.
Comment: Do you need something more sophisticated than "When a star is behind the moon, we can't see the star"? When we can't see Bob because Alice is blocking our view of him, we readily deduce that Alice is closer to us than Bob.
Comment: We went to the moon without stopping at any stars on the way? (OK, I guess Saturn V + Apollo still counts as "modern" ;-).)
Comment: [Meta post](https://physics.meta.stackexchange.com/q/12773/179151) about the closing of this question
Comment: Would a telescope and a diffraction grating qualify as "modern equipment"? If not, you can use the Balmer lines to make a strong argument that the stars and the sun must be pretty similar. Since stars appear much smaller than the sun, they must be further away.
Comment: I agree with your observation about the *simplicity* of the proof using occlusion, @BolucPapuccuoglu. However, *if there is no valid counter- argument, a simpler argument is perhaps more desirable than a complex one*. On the other hand, I am very much interested in all possible answers and invite you to add any answers (or the related question [here](https://physics.stackexchange.com/questions/536343/how-are-the-relative-distances-of-celestial-objects-from-the-earth-calculated-us)) which might require sophisticated argumentation or ones that may involve the use of modern equipment.
Comment: @BolucPapuccuoglu: nice we can test it out with the sun also, during solar eclipse ;D
Answer: The fact of parallax in the observed position of the moon was known in ancient times. This makes possible a calculation of the distance of the moon in terms of Earth radii. No parallax was then observed for the Sun. The first known calculation of the distance to the moon is generally attributed to
Hipparchus of Nicaea
Comment: Thanks for the answer and the explanation. If possible, please elaborate on or pass any references on how, if possible, one can know relative distances of celestial objects without using multiple observations related to positions, that is, by using a *snapshot* of the night-sky which can contain information about the intensity, wavelengths and other information related to the celestial objects.
Comment: This is a different question, and it would have to be asked as such. It occupies a chapter of my book, https://www.troubador.co.uk/bookshop/computing-science-education/light-after-dark-i/. A snapshot contains very little information. For near planets, we can use radar. Beyond the range of parallax measurements, we use standard candles - the luminosity of objects whose absolute luminosity is known from studies of near (almost) identical objects. For the furthest galaxies, we can only use red shift.
Comment: @kb314 Re, "Thanks for the answer and the explanation, but I need to know how to defeat the balrog _with one hand tied behind my back._"  Why? Science is not a sport with sporting rules and level playing fields. Science is an all-in quest for knowledge, and scientists consider _all_ of the available facts when constructing their theories.
Comment: I have posted the extended probing into this topic as [a separate question](https://physics.stackexchange.com/q/536343/254821). Thanks for the reference, which I will read at leisure, but it will be great to have a concise answer summarizing the general nature of the ideas which are used to calculate distance of such objects, using *snapshot*-like information.
Comment: @SolomonSlow, I agree with you. However, my formal training in orbital mechanics has, it is clear now, not exposed me to several methods for determining orbital positions other than using position (or velocity) data at several time steps. My comment was intended to express my curiosity about those methods.
Comment: @kb314: The simple answer is that (to the best of my knowledge, anyway) we can't tell distances from a single snapshot without using modern technology - that is, anything later than the invention of the telescope & Newton's theory of gravity.  You need multiple observations, then you can see the moon occult stars (observations over time), or measure parallax (observations over space).
Answer: Lunar occultations. Just missed the moon block Mars last month. Not sure when Mars will block a star, thereby proving the stars are further than the moon.
Comment: The moon occasionally occults Aldeberan, the red star which is one eye of Taurus the Bull. Unless it's full at the occultation, the star either vanishes behind or reappears from behind the dark limb of the moon. It's a naked-eye event, but you have to know where to be and when to look. A rabbit hole: https://occultations.org/
Comment: @kb314 not when it goes behind (reappear from) the dark limb for a waxing (waning) moon. Moreover, multiple observers can verify that the occultation is not visible from all latitudes.
Comment: Occultations are the simplest and most directly observable fact, but the two stage process (observe the moon occult mars, then watch mars occult a star) seems complex.  You can directly observe lunar occultation of stars, simply demonstrating that stars are more distant.
Comment: @rob according to Sky magazine, they come in groups of 49, and the last one was Sept 2018. But: "The moon will reach a northern extreme in the constellation Taurus in the year 2025. At that juncture, the moon will be occulting Alcyone, brightest star in the Pleiades star cluster. That'll happen on a monthly basis from September 5, 2023 to July 7, 2029. "
Comment: Ok! Simple enough. But is there no other argument than occlusion? There could be a counter-argument that the star is becoming less visible because of lower intensity compared to that of the moon.
Answer: If you don't mind modern equipment, there are some arguments. For example, we have sent spacecraft out well past the moon to get to other planets. As you approach a planet, the direction to it changes. Eventually, there it is beside you instead of in front. But the stars have mostly not changed their apparent direction at all.
Every year, the Earth goes around in an enormous circle. The size is something like the distance to the nearer planets. You would expect to see nearer stars move past the more distant stars. Something like the nearby trees appear to move past distant mountains when you drive on the freeway. And this has been seen. But the motion is tiny. It takes extremely careful measurements to see it. The biggest shift is less than 1 arc second = $1/3600$ degree. Given the size of Earth's orbit, this puts the nearest star at about 4 light years away, much much farther than the moon and planets. Most stars are so far away that no change can be seen.
Modern research has shown that stars are bright like the sun. Given that they appear to be faint little dots, they must be far away. First because something so bright appears to be so faint. And second, something so big looks like a point, not a disk.

Edit - Measurements with early telescopes in the 1600s
As Charles Francis' answer says, the Hipparchus calculated the distance to the moon is $60$ $1/2$ Earth radii, and the distance to the Sun is $2550$ Earth radii. More measurements became possible after the invention of the telescope. For example, Galileo discovered 4 moons of Jupiter in 1609 or 1610.
Wikipedia article on Romer's determination of the speed of light says that in 1671 - 1676, Romer made the first crude measurements of the speed of light, and used it to find some distances. Predicted times of eclipses of the moons of Jupiter were off by up to 15 minutes. He attributed this to the time it takes light to travel from Jupiter to Earth. The time varies as the orbits of Earth and Jupiter bring them closer together or farther apart.
He found light takes much less that 1 sec to travel an Earth diameter. The time to travel from the Sun to the Earth was 10 - 11 minutes. This confirms the Sun-Earth distance is much bigger than the distance to the moon.
The distance from the Sun to Jupiter was part of the calculation. Romer only had crude Earth-Sun distances, so his Earth-Jupiter distances were also crude. This website gives the Earth-Jupiter distances used by Romer as 3.95 to 5.75 Earth-Sun distances. Again, much bigger than Earth-moon distances.
Answer: the occlusion of stars by the moon is a simple and easy way to prove your point.
the one being occluded (blocked from view) must be behind the object obstructing the view, therefore further away from the observer.
Comment: This is a simplest answer. The moon is in front of the stars - you can tell this because the moon covers over the stars it passes over.
Answer: We have used radar ranging to determine the distance to the Moon, the Sun, Mercury, Venus, Mars, Jupiter, the Galilean satellites, Saturn, the rings of Saturn, and Titan.  We have fired radio signals at stars and have not observed a return signal.  Either stars are closer than the moon and somehow invisible to radar (which would be very surprising for a ball of plasma having the blackbody radiation spectra we observe from stars), or stars are much further away.
Passing back in time a bit...
Hipparchus (ca. 140 BCE) used the shadow of the Moon on the Earth during a solar eclipse to estimate that the Sun is about 2500 Earth radii (getting the ratio of Moon distance to Earth radius within about 10% and getting the ratio of Sun distance to Moon distance 10-times too small).
Ptolemy (ca. 150 AD) used an epicyclic model of planetary motion to lower bound the distance to the celestial spheres to more than 20,000 Earth radii (which is bazillions of times too small).
So the stars are at least 8-times further away than the Moon.
Comment: Did the radar measuring worked with the sun?
Comment: @PaŭloEbermann : Yes: http://adsabs.harvard.edu/full/1966ApJ...146..356J  .  Technically, that article ranges the solar corona, but in the context of this question, that should be "close enough".
Answer: Compare angular sizes of stars and sun. Sun has angular size of $\approx 32 \,'$ and our closest star Alpha Centauri A has angular diameter of $0.007\,''$. This gives of angular size ratio between them as about $270\,000$ times, which correlates very well with real distance ratio between them and Earth. You don't need a measurement device for this. You can see sun's visual diameter by putting some dark black glass in front of eyes. And stars are merely  like "dots" when we look at them at night. Because sun is just an ordinary G-type main-sequence star, it's not that hard to conclude that other stars in a night sky is far far more distant than our sun.
Now moon has comparable angular diameter with that of sun. It would be unwise to expect that moon mass would be greater or comparable to that of sun, thus it's natural to conclude that moon can only be at a distance closer to Earth than that of our sun. So by concluding it we imply that stars are also a lot more distant than moon.
Comment: Most of this already pre-supposes things like "stars are similar objects to our sun". Also why would the moon-sun expectation "unwise"?
Comment: @PaŭloEbermann Yes, there is such assumption. We need to start from something. Why moon radius can't be comparable to sun ? Well, unless you live in a binary star system, it's unnatural. Hypothetically if you would live in a binary star system, moon should shine like a star, but now it has very low intensity of light, meaning it's not a star. However I agree that second paragraph is not a firm proof.
Answer: If you take it as a given that the Earth is revolving around its axis once per day than you could make the argument that anything that does not move (after subtracting the apparent movement due to the Earth's rotation) must be far away, or it would fall down.
Satellites have a short orbital period, the Moon a longer one, everything else must be "very very far away". Of course things are complicated by Earth's orbit around the Sun; if that's not a given then one is stuck with Ptolemy's curly trajectories for the planets, but the general idea still holds.


How to access a network folder from SharePoint 2013 using a service account

Question: I have a 3GB file which needs to be accessed via SharePoint 2013 site.
No problem to put it on a network drive and setup a link in SP.
However, that would require granting permissions twice for each user - to a SharePoint site and to a network folder.
Is there any way to access the file via a SharePoint (service) account and then giving it to people who have access to a site? Something similar to "Secure Store" target app for data sharing.
Any other ideas how to share a 3GB file through SP appreciated.
Answer: As long as the user are signed in to the Active Directory, and the computer is in the same domain as the network drive, there are no need to sign in again. You could try that on a client machine and not from the server.
What you could do to improve findability is to give the SP_SearchContent account (your crawl account) read access to the network drive and crawl the content with the search service application. That way users can search for documents in the search center and make use of all the powers SSA have to give. It's easily set up and works as a charm. The best part is that it also takes document and folder permission into account, meaning users can only search for documents they have at least read access to.
Comment: Thanks for your comment. The problem is not about signing in twice, but about setting permissions twice. The scenario would like this: 1) Upload the file to a network drive 2) Grant access to this file to a user 3) Display a link to the file on a SP site 4) Grant access to the SP site to a user. For every other user, if they want access the file via SharePoint, repeat 2) and 4). I am trying to find out a way of having only one step for that, instead of two.


What should I look out for in multiplayer?

Question: I haven't played much online, but I've read of at least one bug caused by modders. What should I look out for in multiplayer and how can I protect myself other than the usual either to not play online or to only play with people that I know would not do things that they know may negatively affect my game (though to define it so broadly, it's hard to imagine anyone to be such a saint)? For example, what are common bugs and trolls and what can I do if I am affected by them (other than the usual methods of abstinence)?
Answer: The main thing that i would look out for is anytime people ask to look at your item, there are a lot of players online that will try and get rare gear by simply stealing it from you.
Other things that i have seen include getting players into fights they can't win and then not helping so they die. presenting trades that are massively one sided against the player.
You will also run into hackers that you need to worry about, i find they ruin the game more than anything else - people out there who have invincibility shields and million damage rifles that just plow through the game while you do nothing just takes the fun out of it.
Bug wise the main one is item duping see this thread to see the main ways this is done Link this has also been used as a scam to take players gear in the promise it will get duped and then just stealing it.


How to Sync Menu, Widgets and other masters from Main Website to its Sub Site

Question: I am using Wordpress Multisite Network and i am having problems regarding masters to its subsite. I am not able to see the widgets or Menus which were created on Main website to its Sub-site. When i am going to check in the Database whole tables are different of every subsite. So is there any way to Sync Masters like category, Widgets, Menu, Settings etc of Sub-site to its Main Website.
Any help would be appreciated.
Thanks in Advance.
Comment: Your subsites are not connected per default. Did you already stumble upon functions like [wp_get_sites()](http://codex.wordpress.org/Function_Reference/wp_get_sites) or [switch_to_blog()](http://codex.wordpress.org/Function_Reference/switch_to_blog)?
Comment: yes @Sven do you have any solution ?
Answer: That's an old question, if someone like me landed on this page and want some-sort of custom solution for WORDPRESS MULTISITE MENU sharing across all network sites,
Not only menu you can use the same method to share anything other then widgets across all the network sites.
here is the solution : Edit your Header.php
<code>//store the current blog_id - Use this function at the start of the function that you want to share

global $blog_id;
$current_blog_id = $blog_id;

//switch to the main blog which will have an id of 1
switch_to_blog(1);

//output the WordPress navigation menu - incase of menu-sharing use this

wp_nav_menu(
   //add your arguments here
);

//switch back to the current blog being viewed - before ending of the function

switch_to_blog($current_blog_id);
</code>
Answer: On default is each site in the network a single site in the context, menu, settings, widgets. But you can sync about custom source or plugins, like

http://wordpress.org/extend/plugins/wp-multisite-mirror/
http://wordpress.org/extend/plugins/yd-wpmu-sitewide-options/

Also you can use the Multilingual Press plugin. This have a API fit synchronization about the sites, there habe a relationship between different sites.
Comment: Thnx for replying @bueltge. I am using above plugins now. Hope i'll succeed on this.
Comment: I implemented yd-wpmu-sitewide-options plugin. But when i create new sub-site and click to visit that sub-site, "Whoops! Page Not Found" error occurs.
Comment: More a question for the support forum of the plugin, maybe a bug.
Comment: Ok. Thnx @bueltge


What is the remainder when $ 6^{65} $ is divided by 80?

Question: In the solutions it used Chinese remainder theorem in the following way: $6^{65}\equiv 1 \pmod 5 $ and $ 6^{65} \equiv 0 \pmod{16} $. I can see how they got the first congruence but am really struggling to see it for the second one. Any help would be much appreciated!
Comment: $6^{65}=2^{65}3^{65}$, which is a multiple of $2^4=16$.
Answer: $6^{65}=2^{4}2^{61}3^{65}$ is clearly a multiple of $16$.
Answer: If $m=pq$ you have an arrow $\mathbb{Z}/m\mathbb{Z}$ (remainders by $m$) to $\mathbb{Z}/q\mathbb{Z}$ (remainders by $q$) which is simply processed by "redividing" the remainder mod m by $q$ call this arrow $\phi_{q,m}$.
Now, by Chinese remainder theorem and Bezout, you see that, if $m=pq$ and if $p,q$ are coprime, the arrow
$$
\phi_{p,q;m}: \mathbb{Z}/m\mathbb{Z}\to \mathbb{Z}/p\mathbb{Z}\times \mathbb{Z}/q\mathbb{Z}
$$ such that
$$
\phi_{p,q;m}(h)=(\phi_{p,m}(h),\phi_{q,m}(h))
$$
is one-to-one. Then, with $m=80, p=5,q=16$ you get that there is only ONE number $h\in \mathbb{Z}/80\mathbb{Z}$ such that $\phi_{5,16;80}(h)=(1,0)$, it is of the form $16k$ hence $k=1$, you get $6^{65}\equiv 16 \mod 80$.
Answer: $$6^4\equiv16\pmod{80}\\16\times6=96=80+16\Rightarrow 6^{4+n}\equiv16\pmod{80}, \text{ for all }\space n\ge1$$
Consequently $$6^{65}\equiv16\pmod{80}$$
Answer: Note:
$$\begin{align} 6 &\equiv 1\pmod 5 \\
6^{61} &\equiv 1 \pmod 5 \\
6^{61}\cdot 2^4 &\equiv 1\cdot 2^4 \pmod {5\cdot 2^4}\\
3^4 &\equiv 1\pmod{80}\\
6^{61}\cdot 2^4\cdot 3^4 &\equiv 1\cdot 2^4\cdot 1 \pmod{80}\\
6^{65} &\equiv 16 \pmod{80}.\end{align}$$


Internet Explorer Cuts Off Phrase "Search Entire Store Here"

Question: search box with wording "Search Entire Store Here" shows fine in Chrome but only shows half of this phrase in Internet Explorer
Comment: It is a  css problem. and it is general issue to fix by designer or programmer. no one can help you without showing your website.
Answer: You could try adding a fixed height for that element and if that still doesn't work in IE maybe using <code>!important</code> would help. Or if 'height' property isn't what you're looking for, maybe the 'line-height' would do the trick.


Is there a limit to the integer size representing a native token supply?

Question: Is there a limit to the integer size representing a native token supply in  Plutus? Does it share the same limit as Haskell GHC's native Integer representation of ~16GB (if I am not wrong). Does Plutus also use the GMP library for token supply?
Answer: Native tokens supplies are indeed unbounded integers. While the current implementation relies on GHC native Integers, the practical limit is much lower since it needs to fit in a transaction for which there's a maximum size of a few kilobytes.
Comment: "it needs to fit in a transaction" -- Depending on your minting policy, you could create tokens in multiple transactions. There is a max in a single transaction, but I don't know if there is a limit to he number of transactions that create that token.
Comment: That is correct, but, if you wanted to group those tokens into one UTXO, the output would need to fit in a transaction. Still, you're right, in a system doing some aggregation across the entire set, the number could be arbitrarily large.


Eclipse will not find ADT plugin on Mac

Question: Eclipse will not recognise the ADT plugin on my Mac (running OSX 10.5.8.)
I have followed all instructions on the developers website:

installed Android SDK Tools, SDK platform Tools and Android 4.1 (API 16)
installed Eclipse Classic and restarted.

When going to Eclipse, Preferences, there is no option called Android
Can any one help?
I have already uninstalled and reinstalled everything and also tried different versions of eclipse, but this has still not helped
Answer: You need to install the Eclipse plugin for Android options to show up in its preferences.
Just follow along the official docs to install the plugin in Eclipse and get it to point to the sdk you've downloaded.

Eclipse will not find ADT plugin on Mac


Autonomous Loop channel

Question: Can I have an autonomous loop channel with myself where I would suck all excess inbound/outbound capacity to/from channels I have with other parties? In such a case, I would not have to even burden Bitcoin blockchain with the looping activity.
Comment: Could you elaborate how a channel would be able to buffer for all other channels? Do you for example propose to have a wumbo channel between two nodes you control with large balances on both sides?
Comment: I thought about it and I came to the same conclusion as you, to have two nodes I control and big channel between. My first naive thought that lead me to pose the question would require a channel with three parties connected to it where I would represent two parties and the third party would be a node of others for connection to the LN.
Answer: Yes you can rebalance your channels by creating circular onions. That will also cost you routing fees which are currently low.
However in order to get onchain funds you would have to close a channel (or open a channel if you want more liquidity). This means you cannot really swap on chain with off chain funds to provide yourself with inbound liquidity - wich is what loop / submarine swaps are for.
If you use c Lightning you can use the rebalce plugin https://github.com/lightningd/plugins/tree/master/rebalance or the drain plugin: https://github.com/lightningd/plugins/tree/master/drain depending on what exactly you want to do you might have to fork these plugins

Autonomous Loop channel


Can I install insulation on the ceiling of an old unfinished basement?

Question: Can I install insulation on the ceiling of an old unfinished basement? I have a bungalow home with hardwood floors.
Comment: Is the basement conditioned (heated/cooled)? If so then adding insulation to the ceiling doesn't accomplish anything
Comment: Yes. That it the normal thing to do.
Comment: I did on  a place when I lived Maine, made a big difference upstairs in the living areas.
Answer: Actually adding insulation is both beneficial for sound reduction and heat retention.  When you insulate your floors you prevent heat loss from your basement, especially if you live in Northern States where it gets cold like me.  This also helps keep rooms at even temperatures which makes your HVAC system operate more efficiently.  Also, if you're outside walls in your basement are not insulated then I wouldn't install it in the floor. As it would be more beneficial to get those outside walls done first then insulate the floor. You'd be well on your way to a finished basement as well.  Python is right about doing it completely or not at all.  Hope this helps!
Answer: Yes.  If you're using bats with a vapor barrier put the vapor barrier side against the wood floor.
Even if the basement is conditioned another benefit of insulation is to reduce noise transmission from any appliances (like air handlers) that may be running down there.
Comment: Roxul Safe'n'sound is one product I know of.
Comment: If you want to reduce noise transmission, then there are special products for that which work a lot better than just fiberglass insulation.
Comment: @Steven: Last I looked I couldn't find any that can compare with 10-12" of fiberglass when cost is a factor, and when the subfloor isn't being replaced.  But I would be interested in hearing of anything new on the market.
Comment: That stuff is like three times the cost and has mixed reviews.  I have pondered it, but decided against it personally.
Answer: When I started working chief engineer on one site told me something that describes this situation the best: "When you are cold do you eat your coat or do you wear it?" To put it differently every type of insulation, thermal included should be placed on the outer side of the building. From how you described I realized that you are planning to do it from the inside. Or did I have it wrong? Anyway, you can isolate basement, best to use Styrofoam or something like that, but it is highly recommended that you do it from the outside, which in a case of basement, sadly can be a problem, since most of it is under ground.
EDIT: Plus I forgot to mention that partial installing insolation partially (just ceiling or one wall etc.) doesn't make much sense, and could cause even more problems. If you want to do it you should do it completely.
Comment: The analogy makes sense if one is concerned about a cold basement, but often a cold basement is acceptable (if not preferred).
Comment: @DA01 yes but in this case insulation should be placed like there is no basement, meaning it should be under basement celling and around the walls continuously. Also insulation keeps cold things cold and warm things-warm. And since heat is going up I think this is applicable for this situation too.


Harmonica help please

Question: I am unsure of what harmonica key is played, I think I am playing the right harmonica and I can get the first note and some others but I can't seem to get all. Maybe I'm using the wrong one?
The harmonica is used on the intro but. The guitar is standard tuning, with capo on 2. The intro is G, B7, Em, - C, B7, Em.
Answer: Song starts with an open G chord on guitar, 2nd fret capo. So it's a concert A major. On standard, you'd use a harp in that same key - A. But here, it's played cross-harp, so a harp a P4th higher is used. That makes it a harp in D major.
There are minor harps, but I think that will do the job.

Harmonica help please


What does John 6: 57 mean?

Question: What does John 6: 57 mean?

Just as the living father sent me and I live because of the father, so the one who feeds on me will live because of me.
Answer: If one answers this question without getting caught up the the discussion about whether communion is the literal body and blood of Christ, but focus on what those listening to Jesus thought, Eli Lizorkin-Eyzenberg gives one of the best answers when commenting on John 6:52-60.

Animal blood was symbolically poured on the altar of the Jerusalem Temple to make atonement for the Israelites. It was meant for God. It was meant to be consumed by Him and by Him alone. This may sound strange to modern ears, but this is exactly how the ancients thought of sacrifice. The ancient Israelites were not exceptional in this understanding of sacrifice. They offered God food for holy consumption.... But in the ancient mind, the slaughtered sacrifice was meant to symbolize a fully dedicated life offered to the deity worshipped. No questions asked.

So, what is happening here? I think it is something like this – Jesus says: "Now the tables will be turned. It is God's turn to offer you all that He is. Just as you offer him the sacrifices symbolizing the whole life, so is he offering you Himself in the person of his Son." ...

Therefore, when Jesus referred to his body and blood, he meant the bread and wine should become, in the minds and hearts of his followers, fully associated with him in the entire spectrum of his life – his person, his teachings and his works. In other words, Jesus expected to be fully understood and received through active participation by faith. By faith in Him, the believer would partake of salvation, which is found in Jesus alone and is offered freely to all.

So let me summarize. Jesus' statement about his body and blood is true and no other picture could have made it clearer. His flesh and his blood, meaning Jesus Himself – the whole Jesus – is the only thing that can sustain a human being to life everlasting. (Jn. 1: 1, 14) --
Lizorkin-Eyzenberg, Eli. The Jewish Gospel of John: Discovering Jesus, King of All Israel (pp. 105-106). Jewish Studies for Christians. Kindle Edition.

St. Augustine also answered:

The hard saying cannot be taken literally, says Augustine, since it would seem to be enjoining a crime or a vice: "it is therefore a figure, bidding us communicate in the sufferings of our Lord, and secretly and profitably treasure in our hearts the fact that his flesh was crucified and pierced for us." Elsewhere he sums the matter up in an epigram: Crede et manducasti, "Believe, and thou hast eaten."
--
Kaiser, W. C., Jr., Davids, P. H., Bruce, F. F., & Brauch, M. T. (1996). Hard sayings of the Bible (p. 500). Downers Grove, IL: InterVarsity.

Here is a summary related to communion:

In the discourse of John 6 Jesus is not making a direct reference to Holy Communion, but this discourse conveys the same truth in words as Holy Communion conveys in action. This truth is summed up in the invitation extended to the communicant in the Book of Common Prayer: "Take and eat this in remembrance that Christ died for thee, and feed on him in thy heart by faith with thanksgiving." To feed on Christ in one's heart by faith with thanksgiving is to "eat the flesh of the Son of Man and drink his blood" and so have eternal life.
--
Kaiser, W. C., Jr., Davids, P. H., Bruce, F. F., & Brauch, M. T. (1996). Hard sayings of the Bible (p. 500). Downers Grove, IL: InterVarsity.
Answer:
Just as the living father sent me and I live because of the father, so the one who feeds on me will live because of me. John 6:57

There are 3 main components to this verse.

God the 'Living' Father 'sent' Jesus
Jesus 'lives' because of the Father
Those who 'feed' on Jesus will similarly live.

ONE
The term 'living Father' signifies the immortality of God - He isn't just God, but the LIVING God - He IS life. True life is only His to give.

He (God) alone is immortal and dwells in unapproachable light. No one has ever seen Him, nor can anyone see Him. To Him be honour and eternal dominion! Amen. 1 Tim 6:16

For as the Father has life in Himself, so also He gave to the son to have life in himself. John 6:26

Having life in Himself is part of God's aseity - the state or quality of existing in and of oneself, without external cause or dependence. While other creatures have eternal spirit life (as far as we can know), they are dependant on the God who provides this life - having originated from Him. The "living Father" originated form no thing on no one, having no beginning.

1 Corinthians 8:6 for us there is but one God, the Father, from whom all things came and for whom we exist. And there is but one Lord, Jesus Christ...

1 Timothy 6:13 I charge you in the presence of God, who gives life to all things, and of Christ Jesus, who made the good confession...

In this the love of God has been revealed among us, that God has sent His only begotten son into the world, so that we might live through him. 1 John 4:9

Only the Father has true eternal life. He has done all things for and through His son - giving Jesus authority for all that needs to be done - including granting life to those who believe in him.

because of Him (God), and through Him, and to Him are all things; to Him is the glory Rom 11:36, 1 Cor 8:6

Paul is careful to not understate the significance, the centrality, of Jesus to all God has done, but not to carelessly give Jesus credit for what only God has done as Creator. He is equally careful to ensure the reader understands that Jesus is the one who depends on God for life and that only God has this life - not Jesus. Paul is not alone in this important detail - all other NT writers teach the same truth.

Peace to you. As the Father has sent me forth, I also send you." John 20:21

"As You sent me into the world, I also have sent them into the world. John 17:18

TWO
When Jesus was born to Mary, it was possible by the purposeful act of God, granting life where no life should be possible - through a virgin. This was necessary to have a man without the sin inherited from Adam - which is passed through each father to every generation.
When Jesus is raised from the dead by God his Father, after having died in the flesh as a mortal man, the Father raised him to a new life in the spirit. Jesus gaining eternal life from then - as the first born of a new creation of many brethren.

Acts 2:32 God has raised this Jesus to life, to which we are all witnesses.

Christ... put to death in the flesh, but made alive in the spirit 1 Pet 3:18

Rom 8:29 For those whom He foreknew, He also predestined to become conformed to the image of His Son, so that he would be the firstborn among many brethren

John 5:26 For as the Father has life in Himself, so also He has granted the son to have life in himself.

John 5:21 For just as the Father raises the dead and gives them life, so also the son gives life to whom he wishes.

This life the Father initially gave Jesus (from the logos 'which' became flesh) was unique. Only Jesus (since Adam), while in the flesh, had a life which was without corruption. And now, only in the exalted Jesus, is this new spirit, eternal life, available to others. Life as we know it is simply a temporary existence; God offers true life and only through Jesus. Yet Jesus had to die. It was only once he was raised, exalted to the Father's side that he gained the true life from the Father - a life of spirit.

knowing that Christ, having been raised from the dead, is never to die again; death no longer is master over him. 10For the death that he died, he died to sin once for all; but the life that he lives, he lives to God. 11Even so consider yourselves to be dead to sin, but alive to God in Christ Jesus. Rom 6:9

Notice this aspect Jesus raises about life.

You gave him authority over all flesh, that to all whom You have given him, he may give eternal life. "This is eternal life, that they may know You, the only true God, and Jesus Christ whom You have sent John 17:2-3

Living forever is not the point - the angels (seem to) have that, and for the wicked ones that is a bad scenario. True life, eternal life, is from the Father, with the Father and knowing the Father - and His son!
THREE
So we have this model Jesus provided - a way to partake of this life through him - his blood and his flesh. Except we eat of him - take into ourselves the deposit of true life of the Father symbolised by these elements of His son and the death necessary, there can be no life for us. Jesus is the only way to the Father - this is another way of expressing that reality.
At the beginning of this process to receive this new and true life, we are given God's spirit as a deposit. A down-payment or pledge of the full spirit life given finally at Jesus return for those that are his. Just as Jesus was raised in the spirit, so too will those who partake of his body and blood.

So will it be with the resurrection of the dead: What is sown is perishable; it is raised imperishable. 43 It is sown in dishonour; it is raised in glory. It is sown in weakness; it is raised in power. 44 It is sown a natural body; it is raised a spiritual body. 1 Cor 15:42

placed His seal on us, and put His Spirit in our hearts as a pledge of what is to come 2 Cor 1:22

v49 And just as we have borne the likeness of the earthly man, so also shall we bear the likeness of the heavenly man.

It can be easy to read John and become confused when we don't understand the now, but not yet reality John writes with. Jesus is 'granted' many things - John writes as if they are already done and they are in the plan God has laid out - but they are yet to be fully realised by Jesus.
To say Jesus has the life of the Father before his crucifixion is an error. IF he had true life as only the Father has, then he could not possibly die. No, he died in the flesh - just as all men do - but was raised IN the spirit. Not BY the spirit - because no verse says that, nor do any say he raised himself. If we are careful to read what the bible provides without imposed contradictions, the reality of God and His son will become apparent.
Comment: John 5:26-27  The Father **has given**  to the Son to **have life in himself** (the same sourceless life the Father has) and authority to judge (mankind)  because he is the son of man.  All before death, burial, and resurrection.
Comment: You need to provide evidence for your pivotal assertion, "The term 'living Father' signifies the immortality of God" because I disagree and can see no evidence for this in the Bible.
Comment: @Mike out of curiosity, what do you base 'the same sourceless life' on? As Jesus died and was raised from the DEAD, his life is quite unlike the Father.
Comment: The Father has **life in Himself**...He does not draw this life from any outside source.  He has given the Son to have life in Himself **just as** He has.  Just as.  Exactly like.  The Son does not draw his life from any other.  **Just as** the Father, the Son sources his own life.
Comment: Wow, God gave His *only* son, who died, so  he didn't have such life *before* his death then did he? You just made up your own truth based on nothing biblical.

What does John 6: 57 mean?


Best UI pattern for letting a user assign items to groups

Question: Problem: the user has a list of about 5-20 uncategorised items and needs to categorize them into 2-4 groups. The tricky part is that the same item can be placed into more than one group (this is an edge case but needs to be supported).
From what I can see there are two design patterns that apply:
Drag-and-drop:
Basically user is provided with a list of drag-able items which he/she can then bucket inot groups
The main issue with this pattern is that because the same item can be placed into more than one group it means that it's not really a 'move' interaction, the item has to stay in the uncategorised list in order for the user to be able to also place it into another category. Another consequence of this is that the uncategorised list never shrinks so it's not immediately clear which of the items in it have been grouped and which remain unassigned
Here is a possible design that tries to handle the above issues. Items which have been assigned to groups appear darker. Also I use color (coloured dot corresponding to the group label color) to help the user see which group(s) the item has been put under.

Checkbox table:
A table-style UI where each item can be assigned to a group by checking the checkbox for that group's column. Checkboxes rather than radio buttons are used because of the multiple group assignment per item requirement. Here is an example:

The main disadvantage I see with this UI is that it's not immediately easy to see what items belong to a given group. Also it's a bit more clumsy to move items between groups once assigned (2 step action: user has to uncheck one checkbox and check another one). This can be remedied by providing a separate listing of the items in each group beside the assignment table UI. This list can either be non-interactive or support drag-n-drop for moving items between groups. Example:

To be honest I'm not completely satisfied with either solution. I'm wondering if anyone has any better ideas or improvements to this design?
Comment: +1 for putting the effort into showing your previous work on this.  A well presented question on a complexed topic.
Comment: [A related question and answer.](http://ux.stackexchange.com/questions/28995/moving-elements-between-lists)
Comment: I'm not prepared to make an answer of this, but it depends on what device you'll be targeting. On a PC, I'd say checkboxes are fantastic. Simply using SPACE and TAB I can do an awful lot in quite a short time. If this is a mobile device where the interaction is more 'physical' then dragging and dropping is most likely the way to go. Also, yes, just to reiterate what @JohnGB said, +1 from me as well for a well constructed question - very nice!
Answer: It's more a question of whether you need to see the entire mapping or not.
If you don't have to see the whole mapping at once, there is another possibility.

download bmml source – Wireframes created with Balsamiq Mockups
If the entire mapping is essential then your best approach is to use a matrix that will allow people to view the entire mapping.
Keep in mind that using Drag and Drop UI is nice but can be tiresome if there is a repetitive action that needs to be done by the users - checkboxes can make repetitive tasks much easier.
Answer: A lot depends on how many items and groups you expect there to be, as well as how many you expect someone to be actively working with at a time.
If working with large numbers of groups and items, the first option would become unusable.  Although, I would tend away from it even if the numbers were small.
The second option may not look fancy, but is both simple to use and understand, while also being able to adjust well to larger number of items and groups.  I don't see any major weakness of it other than the fact that it isn't a new way of doing it.  But that is its strength.
The third option is a nice improvement on the second, but only with low numbers of both groups and items.
I would suggest option 2 with a few changes.  Add the ability to sort by any of the columns (groups) and have a summary panel on the right that shows what groups an item is in when that item is selected.
Comment: @kontur the sorting buttons should take on the fairly standard table column sorting options of sequentially sorting in one direction on first click, then the other direction on second click, then the original order (unsorted) on third click, then repeating.
Comment: +1 The idea of making the group-heading a sort-button sounds interesting. This only would need some solution for returning to original sorting, i.e. item's order. Imagine you sort to have group1 checked items on top, and then want to return to the original order of the items. Having a summary panel on the right only adds information a second time and might be confusing as to where you actually perform the assigning of items to groups.
Answer: Why not combine the two?  Use the initial display of the second, and allow users to select checkboxes.  (Selecting checkboxes is far faster and easier than dragging and dropping, which makes this superior to Option 1.)  So that the user can easily tell what items are in a given group by glancing down the column, have each checkbox turn into a button as soon as it's checked.  (This button can look like those you show on the far right side of Option 2b with an x on it than can be clicked to remove the item from the group and turn the button back into an unchecked checkbox.)  You could even make it so that a user is able to click and drag the button to move it between groups in one fluid motion, while they would still have the intuitive but slightly slower option of unselecting it one column and reselecting in another using checkboxes.

Edit: Here's a quick mockup of what I mean.
Comment: I'm a bit confused by this mockup. Why is "Item 1" in blue lined up with Item 1 list on the left and then "Item 1" in blue and purple lined up with Item 2 list on the left? Was that just a typo? Should that second row read "Item 2" in blue and purple?
Comment: This was going to be what I suggested.  I think if you had a dual drag/drop and checkbox option it could be both intuitive and speedy.  E.G. When clicking on an item it would display a small checkbox showing the 2-4 groups very close by.  This would combine with the (in my opinion) excellent drag and drop layout.
Comment: @Muers Thanks for pointing that out.  Yes, it was a typo.  I've fixed it now.
Answer: I think that both paradigms make sense but not when presented at once.
As a follow-up question: Do you need to accomplish this activity on a single page? (e.g., is it part of a form?)
If this task is part of an item management experience that is core to the product I would reccomend a two page approach as is used in iTunes for playlist and Google+ for circles.
On the "list of items" page the user can see a list of all the existing groups and can drag and drop items into these groups. Each group might diaplay the number of items that have been added. You then might label each item with the number of groups it has been added to, when an item is selected the group(s) that it belongs to can be highlighted.
When a group is selected the structure of the page would change to clearly differntiate the items that were in and out of the selected group. Item that are out of the group could then be dragged in or multi-selected to move them into the selected group.
Answer: How about showing groups with an "auto-suggest" capable selection list. These groups could be further put in a responsive grid (organized according to your layout rules).
You can additionally show selected items in a tag-cloud-like component like Group #3
Comment: I found this very helpful when you have a lot of items
Answer: I would suggest a variation of your second option, but only show one group at at a time to minimize the user's confusion. In many cases, drag-and-drop just adds more work for the user when a simpler method exists.

download bmml source – Wireframes created with Balsamiq Mockups
In the mockup above, the group is selected from the dropdown box list and the checkboxes change dynamically depending on the selected group. Notice that the save button is above the group select to indicate that it will save all groups rather than just one. Having the group selection in a dropdown also makes this pattern a great deal more scalable, no matter the number of groups.
If you are doing this for a web interface, you could use this as a progressively enhanced solution, with the fallback being all groups being displayed at the same time, one on top of the other.
Answer: What is the primary task?

Assigning items to a group
Comparing groups
Moving items between groups
Something else?

I think that #1 is best supported with drag and drop. A good example of this in practice is google+  circles. #2 and #3 are probably best supported with the check box grid shown above or some variation on that concept although I think there could be issues with information overload with large numbers of items or groups. That could be more or less of an issue depending on the frequency of use for the target user group. As others have stated, I would avoid combining patterns and just stick with the one that best supports the primary task.
Answer: Some consideration needs to be given to the physical size of the work you will be using. If this task is spread across the whole screen then drag and drop becomes an issue. A couple of systems I have worked on the feedback has been holding down mouse buttons while dragging long, (the feedback did say long), distances led to many errors as fingers came up before they should have. If the drag and drop is click, slight turn of wrist, drop then most people will handle it with ease, even older folks with some movement problems.
The checkbox is a great idea for nearly any size grid and is better suited to those users who want to use keyboards rather than mice.
As usual the suggestion of a combination of both methods would win my vote as it provides a solution to most users. Development becomes somewhat longer but that is not your User's concern.
The answers all appear to be based on taking an item and assigning it to a group. I don't understand the relative importance of item and group but does it make any sense to use the group as the primary source and "pull" items from the list into the group and then move on to the next group.


RDP Dual Monitors treated as one

Question: The Windows Remote Desktop Connection tool allows use of dual monitors by leveraging the /span option.  The problem with that option is that it treates the remote dual monitors as one large desktop instead of two distinct desktops for each of the left and right monitors.  This is a pain because maximizing a Window or application will span both monitors and consume the entire screen unless manually stretching it into position of one monitor.  Another problem is that dialog boxes that are suppose to pop up in the middle of the desktop now are split dead-evenly in half by the two monitors.  Is there another option that I could be using so taht the remote monitors map exactly to my monitors instead of one giant spanned desktop?
Answer: You want the /multimon option instead of /span, but it's only supported by newer versions of Windows. I'm not sure which versions exactly; I'll leave that to you to research.
Comment: The feature is available since Windows 7, originally only in the Enterprise and Ultimate edition. Later the option was added to the GUI connection dialog.
Answer: You can install Ultramon or Splitview on the RDP server which will give the users the option controlling windows using controls and presets.

RDP Dual Monitors treated as one


Is a transit visa required in Tehran for only flight transfer?

Question: I am travelling from Dusseldorf to Delhi and vice versa via Tehran. Airlines is same (Mahan airlines). I will not get out of the airport in Tehran. Do I need a transit visa in Tehran? I am an Indian citizen.
Comment: What citizenship are you?
Comment: In an answer that has since been deleted, they indicated that they are an Indian citizen. I have added this information to the question and updated the tags, so it should now be answerable.
Comment: Best is to ask your airliner as conditions in those regions constantly changes.
Answer: Tehran allow citizens of India to transit airside through the airport without obtaining a visa, as long as the stay is less than 24 hours.  Using a Transit-without-visa (TWOV) you will not be allow leave the airside area of the airport.
Interestingly, if you are connecting on a different airline and require bags to be re-checked (something that would normally require passing through immigration), Tehran airport has a free service where they will handle that for you so that you do not need to pass through immigration.
It is also possible to apply for a transit visa on arrival, which allows staying up to 48 hours.
Not directly related to your question, however if you ever intend to visit the US, I would recommend against getting a visa and entering Iran if possible.  For citizens of countries that are eligible to use the US Visa Waiver Program, entering Iran will invalidate that eligibility.  For an Indian citizen a US visa would be required anyway, but having to list that you have visited Iran may make the process of obtaining that visa more difficult.
Simply transiting through the country should not be an issue, as that is generally not regard as having visited the country.
Comment: The 48-hour visa isn't mentioned in Timatic, so airlines will not board an Indian with separate tickets without a visa
Comment: @Coke They will, because a visa is NOT required, even when travelling with separate tickets, even with checks bags.  Getting an airline to agree may require some effort, but I suspect most airlines that fly to Tehran are aware of this arrangement. (Google will find you further details on this process, but it's not relevant to this question)
Comment: IME, they aren't aware about this for any country. I've seen Europeans at ZRH, FMM and ARN being summarily and clearly denied boarding on flights to Russia and China for pure transit, only because their tickets were separate. So while you're technically correct, convincing ground personnel will be hard *if you're lucky*. And as for "I suspect most airlines that fly to Tehran are aware of this arrangement", note that it's usually not airline staff that checks you in, but outsourced ground staff
Comment: @Coke And yet, Google will find you countless reports of people doing this without any problems.  Go figure.
Comment: Edited my answer
Answer: As stated in Timatic, the database used by airlines:

TWOV (Transit Without Visa): Passengers with a confirmed onward ticket for a flight to a
    third country within 24 hours

So if the trip is in a single booking, you do not need a visa.
If it's on separate tickets, it is also possible if the transit airport has facilities to transfer your luggage, but the check-in staff at the departure airport may well not be aware of this, and consequently deny you boarding.
If you're on separate tickets, contact the ground handling agent at your departure airport responsible for Mahan airlines and ask for their interpretation of the rules


How can I mass update my favorites in Codeplex Terminals?

Question: I'm on a laptop and often move back and forth between having monitors and having my built-in monitor, which are obviously at different resolutions. This is a problem for my Codeplex Terminals which stretches the window by default. I have about 50 links that I don't want to go change manually. How can I mass update these to a set resolution? I would assume this is stored in a text file somewhere, but I can't seem to find one.
Answer: Using Process Monitor from SysInternals, I was able to find a handle to a folder called %appdata%\..\Local\Robert_Chartier\Terminals\Data. (A quick google search reveals Robert Chartier to be a developer of Terminals.)
From there I opened Favorites.xml and changed all lines of <DesktopSize>AutoScale</DesktopSize> to <DesktopSize>x1024</DesktopSize> (which was what I found when I did the one manually).
Opening terminals now, I find the size to be appropriate and functioning properly.
Answer: Powershell is nice for stuff like this.
Back up the file first!
If you want a powershell one-liners:
This requires Powershell v3 or greater:
(gc 'C:\Path\to\your\file\favorites.xml').Replace("AutoSize","x1024") | Set-Content 'C:\Path\to\your\file\favorites.xml'

This only requires Powershell v2 which you almost certainly have:
(gc 'C:\Path\to\your\file\favorites.xml') -Replace "AutoSize","x1024" | Set-Content 'C:\Path\to\your\file\favorites.xml'

Comment: That is great to keep in my back pocket. The real problem was figuring out where the stupid file is in the first place. Ironically, I posted the question and said dammit, what would I do if someone posted this question and I tried to solve it, which led me to open proc mon, follow the file handles, and go from there :)


sum of Problem from Olympiad from book

Question:
This following problem from book,I don't understand this part. The book never explains how to get from a word to a point.
  $$\sum_{\xi_{1},\xi_{2},\cdots,\xi_{n}\in\{-1,1\}}\left(\sum_{i=1}^{n}\xi_{i}x_{i}\right)^2=2^n\sum_{i=1}^{n}x^2_{i}$$
  Thanks
Answer: Fix $\xi_1, \xi_2, \dots, \xi_n$
If $\xi_i$ and $\xi_j$ have the same sign, then in
$$
\left(\displaystyle\sum_{i=1}^{n} \xi_i x_i\right)^2
$$
we have a term $2x_ix_j$
If $\xi_i$ and $\xi_j$ have opposite signs, we get a term $-2x_ix_j$
But $\xi_i$ and $\xi_j$ have opposite signs half the time and the same sign half the time, so when we sum over all values of $\xi_1, \xi_2, \dots, \xi_n$, these cross-terms all cancel out.
So what we are left with are only the terms involving $x_i^2$, and there are exactly $2^n$ of these, giving the result.
Answer: Here is a probabilistic proof. Let $\kappa_1,\dots,\kappa_n$ be independent symmetric Bernoulli variables (i.e. $P(\kappa_i = 1) = P(\kappa_i = -1)= 1/2$). Then
$$
\mathrm{E}\left(\sum_{k=1}^n x_k\kappa_k\right)^2 = \mathrm{Var}\left(\sum_{k=1}^n x_k\kappa_k\right) = \sum_{k=1}^n \mathrm{Var}(x_k\kappa_k) = \sum_{k=1}^n x_k^2,
$$
where in the first equality we have used that $\mathrm{E}\kappa_k = 0$, $k=1,\dots,n$.
Rewriting the expectation in terms of joint distribution,
$$
\sum_{k=1}^n x_k^2 = \mathrm{E}\left(\sum_{k=1}^n x_k\kappa_k\right)^2 = \sum_{\xi_{1},\xi_{2},\cdots,\xi_{n}\in\{-1,1\}}\left(\sum_{i=1}^{n}\xi_{i}x_{i}\right)^2\mathrm{P}\left(\kappa_1=\xi_1,\dots,\kappa_n = \xi_n\right) \\
= 2^{-n} \left(\sum_{i=1}^{n}\xi_{i}x_{i}\right)^2,
$$
as required.
Answer: For example, for $n=3$, the sum is $$(x+y+z)^2+(x+y-z)^2+(x-y+z)^2+(x-y-z)^2\\+(-x+y+z)^2+(-x+y-z)^2+(-x-y+z)^2+(-x-y-z)^2\\=8(x^2+y^2+z^2)$$
Answer: It is clear to understand that the coefficient of the $x_i^2$ terms since the $\xi_i^2 = 1$ all the time. So the point is to understand why the $x_ix_j$ terms go off.
Fix a pair $i \neq j$, lets find out the exact coefficient of each time that the term $x_i x_j$ that appears in the sum. Since all the other indices $\xi_k,\,\,k \neq i ,j $ can be $-1$ or $1$, so each of the 4 possible choice of $(\xi_i, \xi_j)$ appears $2^{n-2}$ times.
So there are $2^{n-2}$ terms with $\xi_i = 1, \xi_j = 1$,  $2^{n-2}$ terms with $\xi_i = 1, \xi_j = -1$,  $2^{n-2}$ terms with $\xi_i = -1, \xi_j = 1$ and  $2^{n-2}$ terms with $\xi_i = -1, \xi_j = -1$, so in the total sum the coefficient of the term $x_i x_j$ is :
$$ \begin{align}
& 1 \times 1 \times 2^{n-2} + 1 \times (-1) \times 2^{n-2} + (-1) \times 1 \times 2^{n-2} + (-1) \times (-1) \times 2^{n-2} \\
&= 2^{n-2}  \times (1- 1 - 1 + 1) \\
&= 0.
\end{align}$$
That is why $\forall \,i \neq j$, the $ x_i x_j$ term disappears in the total sum.

sum of Problem from Olympiad from book


Christmas Lights on Vinyl fences

Question: My question is... How do I install Christmas lights (C7 or C9) in a nice uniform row atop all of my vinyl fence ? I don't want to glue, screw or tape
them on.
Comment: have you tried searching google for 'christmas light fence clips'?  In the image results, found 2 good candidates in the top 25.
Answer: Zipties (aka cable ties). Be sure to use ones that are UV-resistant.

Cost pennies each, strong enough for the application you're talking about, non-damaging and non-permanent, and easy to remove when done.
Comment: And the zip ties are available in a range of colors so they can be matched to the vinyl fence so as to be less noticeable. A natural color nylon zip tie would work out with a white vinyl fence.

Christmas Lights on Vinyl fences


Call c function from Java

Question: How to call c function from Java.
Seems c is compiler based.
I would like to call C  function in Windows from Java, and
GCC function fron Java too.
Any reference?
Comment: asked May 11 '11 at 11:11 :-)
Comment: You may like to look at JNI(Java Native Interface).
Answer: Have a look at Java Native Interface: Getting Started.

2.1 Overview
[...] write a simple Java application that calls a C function to print
  "Hello World!". The process consists of the following steps:
Create a class (HelloWorld.java) that declares the native method. Use
  javac to compile the HelloWorld source file, resulting in the class
  file HelloWorld.class. The javac compiler is supplied with JDK or Java
  2 SDK releases. Use javah -jni to generate a C header file
  (HelloWorld.h) containing the function prototype for the native method
  implementation. The javah tool is provided with JDK or Java 2 SDK
  releases. Write the C implementation (HelloWorld.c) of the native
  method. Compile the C implementation into a native library, creating
  Hello-World.dll or libHello-World.so. Use the C compiler and linker
  available on the host environment. Run the HelloWorld program using
  the java runtime interpreter. Both the class file (HelloWorld.class)
  and the native library (HelloWorld.dll or libHelloWorld.so) are loaded
  at runtime. The remainder of this chapter explains these steps in
  detail.
2.2 Declare the Native Method
You begin by writing the following program in the Java programming
  language. The program defines a class named HelloWorld that contains a
  native method, print.
class HelloWorld {
    private native void print();

    public static void main(String[] args) {
        new HelloWorld().print();
    }

    static {
        System.loadLibrary("HelloWorld");
    }
}

The HelloWorld class definition begins with the declaration of the print native method. This is followed by a main method that
  instantiates the Hello-World class and invokes the print native method
  for this instance. The last part of the class definition is a static
  initializer that loads the native library containing the
  implementation of the print native method.
There are two differences between the declaration of a native method
  such as print and the declaration of regular methods in the Java
  programming language. A native method declaration must contain the
  native modifier. The native modifier indicates that this method is
  implemented in another language. Also, the native method declaration
  is terminated with a semicolon, the statement terminator symbol,
  because there is no implementation for native methods in the class
  itself. We will implement the print method in a separate C file.
Before the native method print can be called, the native library that
  implements print must be loaded. In this case, we load the native
  library in the static initializer of the HelloWorld class. The Java
  virtual machine automatically runs the static initializer before
  invoking any methods in the HelloWorld class, thus ensuring that the
  native library is loaded before the print native method is called.
We define a main method to be able to run the HelloWorld class.
  Hello-World.main calls the native method print in the same manner as
  it would call a regular method.
System.loadLibrary takes a library name, locates a native library that
  corresponds to that name, and loads the native library into the
  application. We will discuss the exact loading process later in the
  book. For now simply remember that in order for
  System.loadLibrary("HelloWorld") to succeed, we need to create a
  native library called HelloWorld.dll on Win32, or libHelloWorld.so on
  Solaris.
2.3 Compile the HelloWorld Class
After you have defined the HelloWorld class, save the source code in a
  file called HelloWorld.java. Then compile the source file using the
  javac compiler that comes with the JDK or Java 2 SDK release:
 javac HelloWorld.java

This command will generate a HelloWorld.class
  file in the current directory.
2.4 Create the Native Method Header File
Next we will use the javah tool to generate a JNI-style header file
  that is useful when implementing the native method in C. You can run
  javah on the Hello-World class as follows:
  javah -jni HelloWorld

The name of the header file is the class name
  with a ".h" appended to the end of it. The command shown above
  generates a file named HelloWorld.h. We will not list the generated
  header file in its entirety here. The most important part of the
  header file is the function prototype for Java_HelloWorld_print, which
  is the C function that implements the HelloWorld.print method:
 JNIEXPORT void JNICALL   Java_HelloWorld_print (JNIEnv *, jobject);

Ignore the JNIEXPORT and JNICALL macros for now. You may have noticed
  that the C implementation of the native method accepts two arguments
  even though the corresponding declaration of the native method accepts
  no arguments. The first argument for every native method
  implementation is a JNIEnv interface pointer. The second argument is a
  reference to the HelloWorld object itself (sort of like the "this"
  pointer in C++). We will discuss how to use the JNIEnv interface
  pointer and the jobject arguments later in this book, but this simple
  example ignores both arguments.
2.5 Write the Native Method Implementation
The JNI-style header file generated by javah helps you to write C or
  C++ implementations for the native method. The function that you write
  must follow the -prototype specified in the generated header file. You
  can implement the Hello-World.print method in a C file HelloWorld.c as
  follows:
#include <jni.h>
#include <stdio.h>
#include "HelloWorld.h"

JNIEXPORT void JNICALL   Java_HelloWorld_print(JNIEnv *env, jobject obj)  {
     printf("Hello World!\n");
     return;
}

The implementation of this native method is straightforward. It uses the printf function to display the string "Hello World!" and then returns. As mentioned before, both arguments, the JNIEnv pointer and the reference to the object, are ignored.
The C program includes three header files:
jni.h -- This header file provides information the native code needs
  to call JNI functions. When writing native methods, you must always
  include this file in your C or C++ source files.
  stdio.h -- The code
  snippet above also includes stdio.h because it uses the printf
  function.
  HelloWorld.h -- The header file that you generated using
  javah. It includes the C/C++ prototype for the Java_HelloWorld_print
  function.
  2.6 Compile the C Source and Create a Native Library
Remember that when you created the HelloWorld class in the
  HelloWorld.java file, you included a line of code that loaded a native
  library into the program:
 System.loadLibrary("HelloWorld");

Now that all the necessary C code
  is written, you need to compile Hello-World.c and build this native
  library.
Different operating systems support different ways to build native
  libraries. On Solaris, the following command builds a shared library
  called libHello-World.so:
 cc -G -I/java/include -I/java/include/solaris HelloWorld.c -o libHelloWorld.so

The -G option instructs the C compiler to generate a shared library instead of a regular Solaris
  executable file. Because of the limitation of page width in this book,
  we break the command line into two lines. You need to type the command
  in a single line, or place the command in a script file. On Win32, the
  following command builds a dynamic link library (DLL) HelloWorld.dll
  using the Microsoft Visual C++ compiler:
 cl -Ic:\java\include -Ic:\java\include\win32 -MD -LD HelloWorld.c -FeHelloWorld.dll

The -MD option ensures that HelloWorld.dll is linked with the Win32 multithreaded C library.
  The -LD option instructs the C compiler to generate a DLL instead of a
  regular Win32 executable. Of course, on both Solaris and Win32 you
  need to put in the include paths that reflect the setup on your own
  machine.
2.7 Run the Program
At this point, you have the two components ready to run the program.
  The class file (HelloWorld.class) calls a native method, and the
  native library (Hello-World.dll) implements the native method.
Because the HelloWorld class contains its own main method, you can run
  the program on Solaris or Win32 as follows:
 java HelloWorld

You should see the following output:
   Hello World!

It is important to set your native library path
  correctly for your program to run. The native library path is a list
  of directories that the Java virtual machine searches when loading
  native libraries. If you do not have a native library path set up
  correctly, then you see an error similar to the following:
 java.lang.UnsatisfiedLinkError: no HelloWorld in library path
         at java.lang.Runtime.loadLibrary(Runtime.java)
         at java.lang.System.loadLibrary(System.java)
         at HelloWorld.main(HelloWorld.java)

Make sure that the native library resides in one of the directories in the native library path.
  If you are running on a Solaris system, the LD_LIBRARY_PATH
  environment variable is used to define the native library path. Make
  sure that it includes the name of the directory that contains the
  libHelloWorld.so file. If the libHelloWorld.so file is in the current
  directory, you can issue the following two commands in the standard
  shell (sh) or KornShell (ksh) to set up the LD_LIBRARY_PATH
  environment variable properly:
 LD_LIBRARY_PATH=.
 export LD_LIBRARY_PATH

The equivalent command in
  the C shell (csh or tcsh) is as follows:
 setenv LD_LIBRARY_PATH .

If you are running on a Windows 95 or
  Windows NT machine, make sure that HelloWorld.dll is in the current
  directory, or in a directory that is listed in the PATH environment
  variable.
In Java 2 SDK 1.2 release, you can also specify the native library
  path on the java command line as a system property as follows:
 java -Djava.library.path=. HelloWorld

The "-D" command-line option
  sets a Java platform system property. Setting the java.library.path
  property to "." instructs the Java virtual machine to search for
  native libraries in the current directory.
Comment: For Java >= 9 javah is deprecated so use ```javac -h . HelloWorld.java```. This is answered all over the place but ill add it here just for tl;dr.
Comment: Mac users can disregard solaris commands. This blog helped me finish what this answer helped start: http://nerdposts.blogspot.com/2010/10/jni-mac-os-x-simple-sample.html
Comment: People this would also come handy while reading this and frustrating why javah is not working and telling you `Error: Could not find class file for 'YourFileName.class'.` https://stackoverflow.com/questions/19137201/javah-tool-error-could-not-find-class-file-for-hellojni
Answer: In simple terms, just make sure you load the relevant library which contains the function definition, load the library which follows the JNI specification and wraps the target function from the first library, expose native methods from your Java class and you should be good to go.
I'd recommend against raw JNI since it contains a lot of boilerplate code and you would end up cursing yourself if you start wrapping a big C library. By all means do feel free to dabble in JNI when starting out but use something like JNA when it comes to real work.
Comment: Is JNA as fast as JNI?
Answer: You options include:
Java Native Interface
see: https://en.wikipedia.org/wiki/Java_Native_Interface
quote:

JNI enables programmers to write native methods to handle situations when an application cannot be written entirely in the Java programming language, e.g. when the standard Java class library does not support the platform-specific features or program library

Java Native Access
see: https://en.wikipedia.org/wiki/Java_Native_Access
quote:

Java Native Access is a community-developed library that provides Java programs easy access to native shared libraries without using the Java Native Interface.

JNR-FFI
see: https://github.com/jnr/jnr-ffi
quote:

jnr-ffi is a java library for loading native libraries without writing JNI code by hand, or using tools such as SWIG.
Comment: So JNR diff JNA is?
Answer: In the "exotic" category, see NestedVM, which compiles the C to Mips, and runs a Mips
VM inside JVM.
http://nestedvm.ibex.org/
Answer: Checkout  JNAerator.
https://code.google.com/p/jnaerator/
You need to provide the source code and preprocessor definitions etc.
Answer: If you are using Windows and MinGW gcc you may need additional flag if you are getting UnsatisfiedLinkError for specific method in lib:
gcc -D_JNI_IMPLEMENTATION_ -Wl,--kill-at -I"%JAVA_HOME%"\include -I"%JAVA_HOME%"\include\win32 BestCode.c -shared -o BestCode.dll

Answer: @Jonas gave a very elaborated answer, but I think its also  really worth checking this website and you will get all your essential answers there :
http://www.ntu.edu.sg/home/ehchua/programming/java/javanativeinterface.html
It explains how to call a program using JNI  :

For languages C and C++ or a mixture of both
JNI without any parameters, primitives, strings or Array of primitives
Accessing object variables, callback instances methods and much more.
Comment: the web page is down , the new link is https://personal.ntu.edu.sg/ehchua/programming/java/javanativeinterface.html
Answer: For making 64-bit compatible dll Remove "-MD" option from statement below
cl -Ic:\java\include -Ic:\java\include\win32 -MD -LD HelloWorld.c -FeHelloWorld.dll

Answer: I got a solution for this problem.  What you need to ensure is you're compiling the code using 64-bit c++ compiler for calling java function running on 64-bit JRE. Along with it we need to save the path of created dll file in "Path" under "Environment variable".
Answer: First make ensure to load your native library or .dll file in class path by setting path at property java.library.path
Then use System.loadLibrary()
Do not use .dll extension at the end.

Call c function from Java