Copying files: Do any of the mainstream operating systems (excluding e.g. BSD/Linux with ZFS) hash files when moving them?

Question: What I tend to do to go about making sure I don't lose my data is I pick and choose what files I want to keep, and once I have my large (in bytes, not in heft) external hard disk attached (usually 2TB, and usually USB3 these days), I use the usual drag-and-drop method to move the files to the backup drive.
Then, later on I may go as far as to copy the contents again to a third hard drive.
It's all very ad-hoc.
I know about all the ways to do it "better", but I care a bit more about that which is practical. For example, with a single external hard disk, it means I have one single 2.5" external USB3 drive that I put in the bag along with my MacBook Pro so that I have a total of 2TB external + 256GB local storage.
Anything with more redundancy will necessarily add more bulk to the setup. 2.5" has always been the sweet spot on transfer speed and capacity vs. physical bulk vs USB flash. For proper redundancy I now need to lug around two external drives. I just know I will not end up doing it properly, plugging both in.
Other ways to do it "better" are various programs that invariably cost exorbitant sums of real money that force a certain workflow on you or help you back up entire drives. I usually find that I do not want any of this. However, I am still open to suggestions, in particular something that helps check files after transfer/backup by hashing.
Back to the question at hand. In either Windows (7, 8, 8.1) or OS X (10.8, 10.9) when I tell Explorer (or Finder) to move an enormous directory from local disk to external mounted disk, does the OS hash the files after copying, before erasing the original contents?
In anticipation of some answers, Yes, I know about rsync. Yes I use Time Machine with this external hard disk I just mentioned (it is a 500GB partition on the 2TB disk). I know Time Machine uses rsync under the hood. The problem is that Time Machine will start to lose your stuff, and you have to allocate an enormously larger amount of space to reasonably expect everything to be retrievable. If you have a 4GB file and edit 2 bytes in it, Time Machine will consume an additional 4GB (and take the requisite amount of time copying all of it) at the next backup. These are just a few of the qualities I am aware of that make Time Machine fall well short of being perfect. I am quite happy to let it play around with a 500GB partition, though.
The flow of important files (ignoring all the source code which is already in Git servers) goes as such: First it's on the local disk only and every few days makes its way onto the Time Machine partition. Eventually it may disappear from the Time Machine partition as it fills and past images' granularity becomes decreased. Every few weeks I manually pick out files which take up lots of local space but that I don't see myself using, and I move it to a partition on the external drive. Now it exists as one copy and only lives on the external drive. If I really might need this data I store the data in one more location as well.
If indeed it is the case that telling the OS to move a file does not cause it to verify contents upon delivery, then I have to completely change my protocol. This is because if the target media is faulty then the data will be certain to get corrupted.
During the course of writing this question I am starting to think that I asked the wrong question. Perhaps it is just much smarter to simply always use two backup targets and change the protocol from 1 move, 1 copy to 2 copies and one delete. This produces an arguably higher assurance of full data retention.
However, performing hashing prior to delete/move is also quite important, because it is the only way to know that the target media is not faulty!
Perhaps what I want is an rsync GUI, or better yet, shell extensions/plugins that lets me perform an action like "Copy and Hash" and "Move and Hash" as I do my usual copy/move with my directories in Explorer/Finder.
There are some variations on this as well: With two external disks plugged in, I would like to issue a "Copy to 2 destinations and Hash". This will prevent the source data from being unnecessarily hashed twice as would happen with two consecutive copies.
Comment: You could write a script that does a md5sum of the files before the move, does the move, does a md5sum of the files after the move, compares it to make sure they're the same, then copys the md5sums onto the hard drive too. I don't know how that could integrate into the OSX Gui as I'm a Linux user, but that's an option.
Comment: Theres probably some applescript way to do this that's dead simple. Anyone know applescript?
Comment: I found [this](http://superuser.com/a/596271/98199) which is a start.
Comment: Half way there already !
Answer: I can confirm that Windows 7 does not verify the correctness of a copy/move operation as I've just experienced a case of corruption on copying a file to an external drive.
In terms of workarounds, as far as Windows is concerned, you can use Teracopy--I've just started using it and it seems to work well (just enable "Always check after copy" in preferences first). It also does shell integration, and although I haven't found a way to specify multiple copy destinations, you can manually select another destination to copy to after the first copy finishes, in which case it remembers the hash of the source file. Perhaps you could contact the authors and request the feature if you find it important.


When kernels are not useful in SVM?

Question: In SVM using kernels we map the original features to the higher, transformer space (feature mapping) and then perform linear SVM in this higher space. But when kernels are not useful? I could not find any limitations of it. Any help would be appreciated.
Thanks in advance.
Answer: The key idea behind using kernels is to map the data into a higher dimensions such that it becomes more linearly separable. If the data is already linearly separable, most real world data isn't but, at least close to it, you don't need to resort to transformations. So, it's a matter of necessity. This is similar with using polynomial features in linear regression when necessary or not using when it's not necessary.
I'd also like to point out that evaluating your data's separability is easy in two or three dimensional data because we can easily plot it, however it's not a straightforward task in general. You should obtain statistically significant improvements to conclude that your applied kernel is better than the linear kernel.
Comment: Suppose for a given dataset, data points have dimension >= 4. So it's not possible to check linear separability.  So how to know whether to apply kernels or not?
Comment: I wouldn't say that it's not possible just because we can't visualize. Because if it's possible, you can fit your data with linear SVM and see if it's separable or not. If you get no errors, it's separable. But many datasets are not perfectly separable even if you apply kernels. They just become more separable, and evaluating the degree of separability is not straightforward as I've tried to point out in my second paragraph. If you're getting statistically significantly better results with let's say RBF kernel vs linear kernel, then it means you've succeeded to separate your data better.
Comment: @Satish if you think it answers your question, can you please accept and/or upvote it?

When kernels are not useful in SVM?


Price of PYRO on Uniswap doesn't match price on Coinbase. If I make a small trade on Uniswap, can I expect Uniswap price to update?

Question: I'm a noob to crypto trading. The price of PYRO on Uniswap is reflecting much, much lower than the price shown on Coinbase. If I make a small trade on Uniswap, should I expect the Uniswap price to update? I successfully swapped a very small amount of PYRO for ETH, but the price hadn't been updated at all when I immediately previewed a 2nd, similar swap (it was still reflecting much, much lower than the price shown on Coinbase). I was told that the price on uniswap is updated by trade operations, so I expected to see it update in Uniswap.
Answer: Yes, each trade changes the Uniswap pool balance (you input token A and take out token B), and therefore also the price.
Depending on the pool size (liquidity), small trades may not change the price by any noticeable amount. You can play around with the trade size in Uniswap web interface and it will tell you the price impact, in percentages.
Comment: There is no central authority for prices. If you find it cheaper somewhere, you can buy there and sell in Uniswap for profit. Repeat until the prices change to be too close to each other so there is no longer profit.
Comment: Thanks @Lauri Peltonen. The price didn't change to match the Coinbase price though. This is confusing me. Shouldn't there effectively be a central exchange rate that's referenced by all exchanges? A naive question I'm sure, but anything you can do to point me in the direction of how this works is greatly appreciated!


TLS - How to know a CRL URL is not changed

Question: If a hacker would manage to sign a certificate with a stolen (private) key of a CA and would remove or change the URL in the CRL Distribution Points extension, and later the certificate would be revoked by the CA, then how would a browser know the certificate has been revoked if the URL to the CRL is changed so that it links to an old or by the hacker generated CRL?
Comment: For that, you need to not only break (learn the private key) of the CA certificate, but also that of the authority which vouched for the CA.  The two are the same only for self-signed (root) certificates, which are not what CAs actually use in day-to-day business.
Comment: At some point, the bad guy wins. No system is perfect. Once the breach is discovered, trust stores will be updated to exclude the exposed cert. That might take a day or two and people would be a little nervous using the internet until the patches come. This happened after Shellshock was exposed.
Comment: @NeilSmithline So, if I understand it correctly, the _CRL Distribution Points_ extension on a certificate only really works when the certificate is obtained without the private key being compomised by the hacker, and otherwise a browser should make sure to update his root certificate list?
Comment: I'm not an X.509 expert so I'm not 100% certain. That's why this is a comment and not an answer. If the attacker can forge a valid cert, they can set the CRL information to whatever they want so that they stay in control of it. I think that most, maybe all, popular browsers do not fail if they can't get a CRL. That is, they pass. And I'm pretty sure that Chrome totally ignores CRLs and OCSP. They have their own, IMO braindead, solution for cert revocations.
Answer: The location of the CRL for a specific certificate is embedded into the certificate itself and is visible for all which have access to the certificate, which is at least any client connecting to a server using this certificate. The location is put their by the issuer of the certificate (the CA), i.e. it is not included in the CSR (or gets replaced).
To have a different CRL in the certificate than the usual one the attacker needs to compromise the CA, i.e. the issuer of the certificate. It is true that the CA can not revoke the issued certificate then as long it has no access to the CRL location published in the certificate.
But again, making such a change to the certificate means that the attacker has compromised the CA. After such a compromise the CA itself must be revoked (or removed from the trust store in case of a root CA) which in effect invalidates all certificates issued by the CA, including the one certificate with the bad CRL location.
That's at least the theory. In practice some CA's are too big to fail and in this case fraudulent certificates actually gets inserted into the browsers trust store and explicitly marked as untrusted there. This process is outside the CRL/OCSP revocation checks.
Comment: @SWdV: A CA might decide to have multiple different CRL to limit the size of each CRL. Thus it might switch to a new CRL location after some number of issued certificates.
Comment: Thanks for your answer! One question: why isn't the _CRL Distribution Points_ extension on the certificate of the CA itself? Maybe a CA would be able to split op it's CRL? (I don't think this is done, though)


Comparing polygons in two layers based on their location in QGIS

Question: I'm trying to compare two layers representing the cycleways of my hometown. I've exported one layer from OpenStreetMap and the other from a regional web site.
Now I want to compare the two layer and if they intersect or are very near one another, I want to keep just the data from the regional website.
The data from OSM are lines while the other data are polygons, so I created a buffer around the OSM data and used the function Intersection. Then I used the function Symmetrical difference once with the buffer and the intersection (case1), then with the regional polygon and the intersection (case 2) but this doesn't work correctly.
As you can see in the picture the green polygon represents the intersection, the red one represents case 1 and the orange case 2. The problem is that all areas belong to the same attribute so in this case I want to keep just the green one.
Answer: Use "Clip" instead of "Intersection".


Whats wrong with my Aloe Vera plant how do I fix it?

Question: I'm super new to this planting thing and really dont want my aloe to die! I got my Aloe Vera about a week ago and put it in the pot watered it and put it in my window it's now starting to turn brownish yellow at the tips. Before I wrote this it had some fake hey stuff around it that it came with and I watered through that know Im watering it with out it on. Was that the problem can someone please help me-jadyn a very new planter.
Answer: Your aloe might be "sunburned". My aloe plants seem very intolerant of strong light and are happy getting little to no direct sunlight each day. Sometimes I've put them in an eastern or southern window, and they start losing their healthy green color like yours. But if I move them to a spot with plenty of indirect light, they green right up within a week or so.
Here's more discussion on aloe turning red due to excessive light: https://www.quora.com/Why-do-Aloe-vera-plants-turn-red
Good luck!


Any special requirements in driving from Spain to France?

Question: I'm renting a car in Barcelona. And i would like to make a trip at the Pyrenees, both the Spanish and French sides. Are there any special requirements needed for the rented car?
Answer: You have to confirm with your rental agency that you're allowed to do that. In Europe most agencies allow you to travel in all countries of central and western Europe, but forbid you to visit countries in the East, like for example Belarus, Poland, Croatia, etc.
However, it will be likely that your rental agency will bill you an extra fee if you want to cross the border. Normally it is around 100 Euros.
Then a personal hint from me which you have to be careful about: There is no real border between Spain and France, so the chances are high that you're rental agency will not notice if you drive to France. However be aware if you have an accident in France and didn't tell the agency that you will cross the border, you will have big trouble.
Btw if we are talking about the Pyrenees: When planning your trip you should keep in mind that the roads there are really hilly and you will need much time to get from one place to another, even if it looks close on the map. And there are only a few passes between France and Spain which you can pass by car.
However I can really recommend the region. Was there this summer with my own car, and it is really nice there and worth the trip!
Comment: No. In France you pay a fee if you're using the highways. But this fee you pay at stations every x kilometers. And in the Pyrenees there are no highways ;) But maybe if you're using a big tunnel or something like that, it could be that you have to pay a small fee there. I personally drove from Barcelona to Andorra and then to France. From Andorra to France I used a tunnel to pass the mountains and this costs some euros. But you could also avoid the tunnel and drive over the mountains.
Comment: Thanks Roflcoptr! So beside the permission of the rental company, there is no need of a regional car sticker or things alike?
Comment: If you're a country counter Like Mark Mayo you can go via Andorra.
Answer: I have no administrative advices, but just some suggestions for great sightseeings along the road:

avoid the highway between Barcelona and Perpignan: prefer the coastal route where the Pyrénées meet the sea. Landscapes are wonderful and you can stop at Figueres and Cadaqués, the home region of Salvador Dalí, then at Banyuls and Collioure for wine and anchovies.
Don't forget Andorra and Cerdagne, a region where the borders are more blurry than what is depicted on maps - people soul is more catalan than french or spanish. Odeillo and Mont-Louis are worth visiting.
The whole region is full of cathar castles worth visiting. The most famous is Montségur. If you don't mind going north, make a stop at Carcassonne.
Comment: With my family we drove from France to Spain. On the border, there was a sign: "France" this way; "España" that way. Someone had scribbled over it with spray paint: "Catalunya" both ways.
Comment: Thanks mouviciel, I was looking for this kind of advice! Defenatley will make the trip better.
Answer: If your vehicle has a European style licence plate (i.e. EU flag on the left hand side and country code, e.g. E for Spain), you can legally drive all over EU. Some countries (Ireland) always have an EU style plate, some countries (UK) do not always have this style.
Car insurance should cover you all over the EU (normal car insurance anyway, I don't know about hire cars)
Ask/Tell your car hire company.
The Pyreenes are very nice. Try to take some scenic roads, rather than the main motorway.


What is the difference between "could've" and "could of"?

Question: I have seen people using could of instead of could have. Are both of them correct?  Is there a difference in meaning between them?
Comment: "Could of" is a misrepresentation of "could've", which is a contraction of "could have", which is where you started. "Could of" is not yet acceptable (and drives some people mad when they see it).
Comment: @michael_timofeev u could of seen it alot by now if u r on Facebook n read the comments their.
Comment: I hope could of never gets a foothold in English...not even informal...has it already?
Comment: This is a spelling issue, of approximately the same importance for the future of mankind as the correct spelling of _theatre_ or _emphasize_. In the real language there is no difference between _could've_ and _could of_ and _could have_; they're all pronounced the same and understood the same. It's only folks whose sensitivities to spelling were permanently overstimulated in grade school who worry about this. To an English learner, it's irrelevant because it doesn't affect speech.
Comment: (man, was that painful to write.)
Comment: Lol...I can't bear to see some of the English used there.
Comment: "could of" is usually used by uneducated American teenagers.
Answer: "Could of" is always wrong.
It's just that the contracted "have" in "could've" sounds like "of", so uneducated people started writing it as "of" too.
(For the record, "should of", "would of", "might of", and the like are also always wrong.)
Comment: @Hellion, sorry to say that a lot of *educated* people write "could of" as well.  And I've heard people *saying* it ... "I ate the last of the pie" / "Well you shouldn't of" ... with the "of" fully pronounced.
Comment: @Geobits So you're saying *shouldn't've'sn't* a problem. I agree!
Comment: I'd be wary of saying it's "wrong". Language is a societal construct, after all, so if "could of" is mutually intelligible by the parties in the conversation then there's no "wrong" to it. Pedantry on the subject is foolish, as English (like any other language) will evolve no matter how pundits "feel" about the new constructs.
Comment: @Hellion, "Could one do X at all?" - "One could of one's own will, but not by force."
Comment: I'd add the hedge that the words _could_ and _of_ can legitimately end up together, though not in that meaning; the _of_ can be part of a phrase like "of course" or "of one's own free will".
Comment: @hemflit I could, of course, write *could* and *of* together like that, but I could not come up with a case that did not call for a comma between them.  :-)
Comment: @DavidGarner Normally when I hear people *say* it, I assume they're saying the double contraction *shouldn't've* instead, which makes more sense and sounds identical in some dialects.
Comment: @Geobits It seems *shouldn't've's* got a lot of apostrophes.
Comment: @talrnu Sure, I wouldn't've written it that way except to illustrate the point, but people say it like that all the time (at least in the US).
Comment: I write "shouldn't've, and I think it works as a natural extension of "shouldn't" and "should've".
Comment: My only regret is that I have but one +1 to give for this answer.
Comment: @DavidGarner "*I've heard people saying it ... "I ate the last of the pie" / "Well you shouldn't of" ... with the "of" fully pronounced.*" Yes, exactly so! I was just talking about that [here](http://english.stackexchange.com/questions/383911/how-many-legitimate-uses-of-could-of-would-of-should-of-are-there/383927#383927) !
Answer: Technically speaking, the phrase "could of" (in this context) arose from a mishearing of the contraction "could've" (as Hellion points out) and the literal definition of the words does not convey the intended meaning behind the phrase "could have". This is called a malapropism: "the mistaken use of a word in place of a similar-sounding one" (from Wikipedia).
With that said, language is not a set of "right" and "wrong". It evolves as our habits do, and things that were once considered "wrong" can become the accepted way of speaking and writing, even in the most formal settings. For example, the word "apron" used to be spelled "napron" -- but because the phrase "mine napron" was so common, the word was misheard so frequently that it eventually changed. That and several other examples of malapropisms that entered the English language are written about in this guardian article.
Recent printed usage of "could of" is nothing compared to "could have". In professional and formal settings, using the phrase "could have" is definitely preferable.
Comment: I don't think _mine napron_ in particular was ever all that much more common than it is now. Rather, it is the relative _non_-commonness of the word _apron_ in general, combined mostly with the indefinite article _a(n)_ (but yes, also with the possessive determiners) that bungled things up. When the final /n/ was lost in _an_ as well as _mine/thine_, things like _anapron_ became ambiguous: is it _a napron_ or _an apron_?
Comment: @JanusBahsJacquet i agree that your speculation seems very likely, but i think that i will leave the answer as written since that example comes directly from the article i cited in the following sentence.
Comment: @WoodrowBarlow: A fellow descriptivist! Oh frabjous day! Callooh! Callay! The English language loses a tiny bit of poetry every time someone corrects a mutually intelligible shift in an utterance.
Comment: @WoodrowBarlow ,  EL&U is a site for language lawyers to discuss such distinctions and to come up with the currently acceptable usage.  "It's a malaprop" could be the answer to nearly every question on the site, but that's generally not the answer the questioners are seeking.


High resolution screen on ArcMap?

Question: I have an Asus ZenBook Laptop with a 3200 x 1800 touchscreen, i tried enlarge icons but the ArcToolBox and other icons not fit on a 13.3 inches display.
Other "more common" apps that do not have much problem.
How to get the best configuration?
Sorry for my english.
Comment: There have been several threads on the ESRI Forums on this.  This one refers to the other threads: https://geonet.esri.com/thread/170386.  There are several suggestions in these threads that you might try, but there is no generally accepted solution as noted in MaryBeth's answer.  ArcGIS Pro scales better than ArcMap.
Comment: struggling with the same issue :(
Answer: There is now a solution to using ArcMap with high dpi screens at least on Windows 10. Install the Windows 10 Creators Update then change the settings on the ArcMap executable as shown below.
Answer: Per ESRI Troubleshooting page this has been reported as an issue and still in effect as of November. It appears contacting ESRI support is your best bet.

Donald, this issue appears to be most likely related to an Enhancement
which we have already reported to our developers.  The Enhancement is
related to laptops that use a display adaptor that supports a 3200 X
1800 resolution or higher, and has been reported for several different
laptops which have this adaptor.
The Enhancement is currently listed
as the following...
NIM100282 -The Lenovo Yoga 2 has a display
adapter which supports a 3200 x 1800 resolution, and ArcGIS for
Desktop's icon's and text are skewed in this resolution.
I
understand that this is not your exact laptop, however, there are
several cases in which different laptops with comparable resolution
have been added.
I would recommend contacting Esri Support so that
we can create a case for you and add it to the existing Enhancement.
Answer: Hi I found a solution to this problem with an older version of windows 10 (can't upgrade to Creator)
1) First follow the instructions here but apply to ArcMap.exe
https://www.danantonielli.com/adobe-app-scaling-on-high-dpi-displays-fix/
2) Then change the settings on the ArcMap executable so that none of the options are selected

Now ArcMap will appear normal!

High resolution screen on ArcMap?


Can a man sleep in the same room of her sister or mother in Islam?

Question: Me and my family are shifting to a new place in 2 weeks Inshallah. But unfortunately that apartment has only 2 bedrooms. I only have 1 sister and we have love for each other. I and 15 and she is 17. We used to sleep together in same bed till I was 12 but then our parents transferred me to the 3rd bedroom. We both have our own single bed but my question is that can we sleep in the same room?
Comment: Ummm, you are Mahram for her! You can sleep in the same room, why are you concerned? What makes you think you can't?
Comment: Because I use to thought that Brother sister shouldn't sleep together after puberty. I thought it's Haram. I don't know the full reason why our parents separated us right when I hit puberty. Thank you for your answer. It was really helpful
Comment: @Rameez a comment asking for clarification is not necessary an answer. Answers should be posted in the answer section!
Answer: salaam,
I think it is totally fine as long as it is a halal sister and brother relationship, which is totally different than the relationship one has for a wife or husband. :)
Best,
Michelle
Answer: Islam permits "khalwah" (seclusion of a man and woman without a third present) between mahrams. An adult male does not incur sin upon himself if he sleeps in the same room as his adult sister out of necessity, and shares closet, bathroom, dressing table and other items of the room with her.
It is permissible for a man to sleep with his sister on the same bed as long as the bed is big enough for two persons, their awrah (which are private parts in case of siblings) are covered, and have separate blankets.
The Prophet (pbuh) said: "Command your children to pray when they are seven years old, and beat them for (not offering) it when they are ten, and put separation between them in bed."
Putting separation between them means not letting them sleep naked in one bed (like they used to do in the childhood), sleeping in their clothes without touching one another, and having separate blankets for each.
Ibn Muflih said: A boy who reaches the age of ten should be prevented from sleeping naked with his sister or any other mahram. This was mentioned in al-Mustaw'ab and al-Ri'aayah.
References:
https://www.islamweb.org/en/fatwa/422176/adult-brother-and-sister-sleeping-together
https://www.islamweb.net/en/fatwa/249073/adult-brothers-and-sisters-sharing-the-same-room
https://islamqa.info/en/answers/78833/can-a-man-sleep-in-the-same-room-as-his-sister


Can you cast healing word with charisma as a paladin cleric multiclass if healing word is prepared as cleric?

Question: I am going to play a life domain cleric paladin multiclass with high charisma. Since life domain cleric already has healing word as a prepared spell, can I cast it with my charisma or do I need to prepare healing word again with paladin to cast it with charisma?
Comment: Welcome to RPG.SE! Take the [tour] if you haven't already, and check out the [help] for more guidance. Please review the linked question and see whether it matches yours; if not, please edit your question to clarify what you're asking that's not already addressed there.
Answer: You cast healing word with Wisdom as the spell casting ability
A spell prepared by a particular class is only cast with the casting modifier of that class. Since the healing word spell is prepared as part of the cleric class then you must use your wisdom modifier to cast it.

Each spell you know and prepare is associated with one of your
  classes, and you use the spellcasting ability of that class when you
  cast the spell.  Similarly, a spellcasting focus, such as a holy
  symbol, can be used only for the spells from the class associated with
  that focus.

You can't prepare healing word as a paladin. It isn't on their spell list.  You must prepare it as a cleric, and cast it using Wisdom.


Run A Cron Job Task Every 30 Seconds

Question:
It's possible to set the cron job tool in my website cpanel 'VPS Hosting' to execute php file every 30 second
I am using it to execute php file once at a minute *,*,*,*,* but I need to set it to run twice  in minute
I have tried 1/2,*,*,*,* but it's not working.
Comment: To keep it precisely, not a dublicate; it's 30 seconds not 15 ;-) ^^
Comment: i provide a different answer than given here or at the every-15-second question. See http://unix.stackexchange.com/a/205717/105631
Answer: You can't exec cron with increment less than minute. You can search for other schedulers. Or consider to create daemon which will have internal scheduler for such interval
Answer: Why don't you run a shell script which runs your command, like:
#!/bin/tcsh -f
start:
mycommand >> /tmp/output
sleep 30
goto start

As someone else said, cron has a granularity of 1 minute.
Comment: Ned64, IMHO will be good to create your script proof from more than one run. Otherwise will become very interesting DoS tool :)
Comment: Romeo, Yes, that would be a nice feature.  If the command is executed manually, though, and not called by `cron`, it could be OK.  Let's see what Ashraf thinks.
Comment: If you want an easy way to proof the script from running with multiple instances, you can use flock as is demonstrated [here](http://jdimpson.livejournal.com/5685.html). This is Bash of course.

Run A Cron Job Task Every 30 Seconds


Far field spherical waves plane waves

Question: All em radiation propagates spherically and at a far off place a small enough distance, when observed appears like a plane like our experience on the earth.  So I tend to think that whether a wave on an aperture can be considered plane or not depends on how far the aperture is from the origin and how much is the aperture.  So it should be only dependent on the angle made at the centre by the aperture i.e. apertures making more than a certain angle at the centre can be considered spherical, and otherwise can be considered plane.  This is my wrong understanding.    But in radar theory, this is not the criterion for considering plane and far field.  A 2D^2/lambda formula is used.  How is this formula relevant?  How lambda is entering into the formula?
Comment: The distinction near/far field is not identical to the approximation spherical/planar wave! I think you should look up the definition of the near field of a dipole or even multipole oscillator.
Answer: Rajeev Bansal in the appendix to this article explains the $2D/\lambda$ rule:

How does one arrive at the various criteria for the far-field zone?
Basically, the criteria are guidelines to the boundaries where the
fields start to approximate the "ideal" assumed characteristics. First
of all, only the radiation ($1/r$) terms remain significant; higher
order terms fade away. Second, in the far-field zone, the angular
field distribution becomes independent of the distance [5]. Third,
only transverse field components remain, and the ratio of the electric
and magnetic field components approaches the free-space impedance, 377
ohms [6 ,7]. Finally, for a receiving antenna, the incoming wave-front
is nearly planar across the aperture. In fact, the $r = 2 D^2/\lambda$
formula corresponds to a phase error (due to the curvature of the
actual spherical wave-front) of no more than $\pm 22.5$ degrees across the
aperture, as compared with the ideal plane wave-front [6, 8].
References:

IEEE Standard Dictionary of Electrical and Electronics Terms, IEEE standard 100-1984, 1984.

C. Paul, K. Whites, and S. Nasar, Introduction to Electromagnetic Fields, 3rd ed., McGraw-Hill, 1998.

Reference Data for Radio Engineers, 6th ed., SAMS, 1981.

G. Smith, An Introduction to Classical Electromagnetic Radiation, Cambridge, 1997.
Comment: Obviously I am blind to some point even after reading the article.  I am solely thinking of about the final point in your answer - geometric point.  When can an arc of a circle be considered straight?  When the arc makes a very small angle at the centre.  If you consider only this geometric point, the criterion should be independent of the wavelength.  It looks like the far field criterion is more coming from radiation field dominance over other terms than the pure geometric requirement of approximation of an arc as straight.  Can you confirm this?
Comment: The condition is that the phase error, due to a spherical wave-front rather than a plane wave, across the aperture being "small", The phase error is wavelength dependent.
Comment: How can I accept this answer?  That option, I am not able to see.
Comment: @SeethaRamaRaju There should be a greyed-out tick mark just below the up and down voting arrows for you, the originator of the question.

Far field spherical waves plane waves


Class diagram from a java code

Question: I am trying to create a class diagram using existing Java code, when I drag drop the class files to class diagram window in Jdev, it just shows empty classes ( no attributes / methods) also does not show the relationship of classes!!,,,
Please advise what could be wrong?
i did following steps -
created modelling java project with class diagram option, and then added project src files to the modelling project
Answer: Does it work if you create the class diagram in the same project that your source is in?
Does it work if you go into your UML project properties and under content add the directory where the Java source is?

Class diagram from a java code


Is it idiomatic to write: "He rides to the farm by bike."?

Question: Is it idiomatic to write: "He rides to the farm by bike."?  In my opinion, you'd rather write "He goes to the farm by bike" or "He rides his bike to the farm".
Comment: He bikes to the farm. He walks to the farm.
Answer: No, it is not idiomatic to say "ride by bike".  Riding is how one travels on a bike, so ride by bike sounds strangely redundant.
Google Ngrams shows how much less common "ride by bike" is than other "verb by bike" phrasings.
I suspect that some of the "ride by bike" examples that it has found are actually from sentences like "It is two hours' ride by bike", where ride is actually a noun.
Comment: I find the sentence to be idiomatic. Yes, it might be redundant, but not if we assume that there are other ways to ride to the farm. (Perhaps there are a horse and a tractor nearby.) (This is along the lines of what @Joachim is saying.)
Comment: Unless it's a reaction to the statement that "he" is "riding to the farm", perhaps? To emphasize *how* he is riding?
Comment: Thank you very much indeed for your answer.
Comment: There is no special emphasis intended in this sentence. It is just a statement that the person doesn't use public transport to go to the inner city farm he works for, unlike some colleagues who go there by bus.
Comment: I agree with you that _He rides his bike to the farm_ is much more idiomatic - or _He goes to the farm on his bike_.
Answer: This is pretty interesting actually.
If you said, "He travels to the farm by train" that would be 100% correct. When you travel on a train, you travel by train. You might travel on a train, but in the context of how you got to a place, if you got there via a train, you would say you got there "by train."
But that's not the case with a bicycle. You would simply say, "He bicycles to the farm."
English has a very strange habit of creating verbs from nouns. Bicycle is a noun. "He has a bicycle. It is red." The word was created to describe the thing.
Bicycle is also a verb. "He bicycles all over town. He doesn't like cars." We sort of made that up after the fact to describe people doing bicycle things.
So logically, you'd think a sentence like, "He bicycles his bicycle all over town" would work, but it doesn't. Instead you would say, "He rides his bicycle all over town."
"Ride" is of course the proper verb for this sort of activity and "He rides his bike to the farm" would be perfectly correct. You can replace "bike" in that sentence with any rideable thing: horse, motorcycle, hamster...And it will still make sense (might be a big hamster).
But, because bicycle is a "verbed noun", you can also say, absolutely correctly, "He bicycled to the farm" where you couldn't say "He horsed to the farm" or "He hamstered to the farm" (you could say "He motorcycled to the farm", though that's less common).
Just English being weird.
Comment: Is "he bicycles to the farm" idiomatic? More importantly, is "he rides to the farm by bike" idiomatic? The latter is the question here, and you don't seem to answer it :)
Comment: He **cycles** to work. The most common verb is "cycle".


How can I fix these floorboards?

Question: Two of the pieces of my floorboard are damaged and I'm looking for a way to fix them. I'm kind of lost so what process/steps should I take to repair this?
Answer: Vinyl planks interlock with each other, so unlike wood floors, there's no easy way to remove the broken one and insert a new one (real wood floors are also interlocked, but there are tricks one can use to replace a single board.)
If this is near a wall, you could remove the trim (baseboards), remove that section of the floor, and re-do it replacing the two broken planks with new ones.
You could also cut the planks in two using an oscilating multi-tool, remove them. With a utility knife, remove the interlocking lip on the new and surrounding planks. Glue the new one from the top. This will not look pretty, but just a tad better than the broken planks.
Comment: (Those look more like laminate than LVP.)  OP could also disassemble the floor and hopefully relocate the bad boards to a location under a rug or furniture.
Comment: @Huesmann Agreed. With some luck, they still have some planks saved from the original installation.
Answer: What you have appears to be laminate flooring.
It is not real wood, so it cannot be filled and sanded and restained.
Outside of replacing the damaged pieces, the only possible solution may be filling the damaged areas with an epoxy as smoothly as possible and trying to paint some grain onto it to blend.  This may be unacceptable to you, however the  only other option is replacement.
Comment: A disturbing number of homeowners also often choose a 3rd (bad) option: leaving it in place and putting a new cheap floor over it.

How can I fix these floorboards?


All Caps in International Design

Question: I have my own opinions on this but need some arguments when talking with designers. What are the advantages/disadvantages of using caps for all words in mobile application design?
Comment: What do you mean by "International Design"?   Will this be a multi-lingual design with text in different scripts?
Comment: THIS TEXT LOOKS LIKE A RECTANGLE BECAUSE IT IS ALL IN  CAPS.
Answer: There are very few advantages to using all caps, and that is why we usually don't.
When we read text, largely what our brains are doing is recognizing the overall shape of words, rather than the individual letters.  Lowercase letters have different sizes and visual densities; some have ascenders sticking up, or descenders sticking down.  This means that looking at the visual silhouette of a lowercase word, and identifying at the first and last letters, is almost always enough to identify the word.
For all-uppercase words this is much less true, and reading a word requires looking at each letter.  Words take fractionally longer to identify, and are misread more often, which reduces reading speed and requires more concentration.  For the same reason it is also hard to find your place if you glance away from a large block of uppercase text.  These problems are much worse for anyone with dyslexia or any kind of visual impairment, to the extent that using all caps for informational text may actually be illegal under accessibility statutes.
For what it's worth, some reasons you might use all caps:

for emphasis (but bold or italic or larger type are all preferable)
for graphical reasons – as sergiol says, capitalised words are basically rectangles and if it's just one or two words, the greater visual simplicity may be worth it.
for ancient Latin text (before lowercase was invented, carved inscriptions on Roman monuments used only capital letters)
to discourage people from reading a block of text – this is allegedly why some warnings on cigarette packaging use all caps, and also why the text is surrounded by a tight black border.

I gather that it is more common for Greek text to be set in all caps; I don't know why this is, and it may be for related historical reasons (the distinction between small and capital letters originates from the distinction between handwritten and carved text).  I would assume the same arguments apply in Greek or Cyrillic but I don't know if there are other considerations there.
Answer:
"What are the advantages/disadvantages of using caps for all words in mobile application design?"

Do you mean ALL CAPS ALL THE TIME? Or Capital Case Only For The First Letter?
Disadvantages

ALL CAPS looks like you're SHOUTING! Bad if there's no semantic reason for this.
Can feel like it crowds other elements, especially on mobile where space is at a premium
Less legible if longer than a few words - the rhythm & end points of words are obscured
Not possible with many written languages
In some languages, capitalization changes meaning or pronunciation
Doesn't achieve the desired effect as well as alternatives that render it unnecessary

Advantages?

It does appear larger/more important or emphatic.
For stylistic appeal & uniformity in a headline or logo
It would make Latin-text designs more similar to Asian text that has a uniform height.

Standing out visually can (and should) generally be achieved through other means: Use a larger font size, a heavier weight, or a darker/more saturated color. No need for capitalization unless it's semantically appropriate.
You might often see all caps in a logo precisely because it creates a more uniform shape or can be more stylized - but you asked about "all words." This definitely wouldn't apply in a general sense.
With many languages (E. Asian especially) you will wind up with the same "rectangle" of text as you would with ALL CAPS, because their characters have a uniform height/width:
比方說中文的繁體字都有差不多一樣的尺寸。
Readers of those languages are used to that though - it would not be appropriate (or a good user experience) to force this uniformity on other languages that have variable heights/widths (most European & Middle Eastern languages). While Latin text has capital letters, Arabic and Persian scripts do not. Creating a uniform height even if you want to in those scripts is a matter of stylistic font selection.
Capitalizing Across a Headline, Etc.
Doesn't make a difference in English at least, as long as you're consistent. People are used to this approach in news headlines, but in other circumstances it's likely awkward.
Depending on the rules of the language, capitalization has a specific grammatical purpose for identifying nouns, proper nouns, etc. It's not just an aesthetic choice, but a semantic & linguistic one.
In German for example, if you write "essen" it's a verb (to eat), but "Essen" is a noun (food/meal). In English, "Bob" is a proper name, but "bob" could be a noun or a verb. In Arabic, which doesn't have "capital letters," a 'D' vs 'd' or 'T' vs 't' when romanized indicates a distinct pronunciation and different letter & sound entirely.
Point being: you shouldn't just change how words are spelled for aesthetic reasons.
Last thought ... if you really want to be sure what's right for your situation, you could adjust the case programmatically & test with your prospective audience. You can apply all-caps, first-caps, and small-caps to normal-case strings without having to actually change the underlying string data. See which one people prefer.
Answer: This is more of an algorithmic problem, but it is worth keeping in mind that some languages do not have the distinction of upper- and lowercase. E.g. Japanese (they also don't have the concept of bold text).
And some letters do not exist in an uppercase variant, e.g. the German "ß" ('sharp S') is a strictly lowercase letter1 as there are no words that start with it, and in all-caps is usually reduced to the (sometimes ambiguous) letters "SS" instead.
1) There have been designs for an uppercase letter in modern times, "ẞ", but it only recently got added to Unicode, is usually only found in the system fallback font, isn't easily typed on any German keyboard and isn't taught at schools, so in practice it might as well not exist.
Comment: Essentially the concept of upper and lower cases (or majuscules and minuscules) is limited to Western scripts: Latin (what we're using now), Greek and Cyrilic (what is used in Russian and some other Eastern European and Central Asian languages). The rest of the world's major scripts (Chinese/Sinitic, Arabic, Devanagari, Japanese, Thai, Hebrew, etc. don't have cases.
Answer: A thing to consider is that "design", when use as a form of communication, should ease the process rather than hider it. For that reason I avoid using all caps from a typographical perspective. As Bobtato mentioned, our brains read by recognizing the overall shape of words. Not necessarily the individual letters. One of the biggest challenges that all caps present is to people with dyslexia (15% of the US population). Reading individual letters is difficult and frustrating. Many cannot see the shape of the intended word. If it's just a few letters they will work it out if they feel it might be essential to the overall meaning. If it is decorative, "seem" unimportant, or long it might as well not exist.

All Caps in International Design


Is the attack surface of Docker vs. LXC/systemd-nspawn significantly different?

Question: One decision point in choosing between and application container solution versus an OS container solution is security. I'm not knowledgeable enough to be able to compare and contrast the two. I assume they're different, but is one significantly more open than the other?
Answer: From a security standpoint, and in my opinion, rkt is worth considering too.
See for example CoreOS's  somewhat opinionated comparison of rkt to alternative container systems.
As they point out, docker is now using containerd under the hood, and provides a whole bunch of 'stuff' around the running of containers - I would tend to think the extras are likely to introduce more attack surface than more barebones systems (like containerd).
You should also keep in mind that the security of lots (if not all) the solutions you list is enhanced by a suitably hardened kernel (e.g. PaX), and system (e.g. seLinux).


Training Image classifier on tiny dataset

Question: If we have a tiny dataset in terms of images per class where we only have one image available for a given class e.g. a Flag, will data augmentation strategy work or what should be the strategy of training in this case?
Answer: CNNs require a large number of images to be trained properly. The most common workaround when having a small training set is to use a pre-trained model, which has been trained on a huge dataset (e.g. ImageNet). Through this you take a highly effective model, drop its final layers (which are used for classification) and keep all the previous (which are used for feature extraction). Then you add your own final layers and only train them. This allows you to train a model with much less parameters (because most of them have already been trained), which can be done on smaller datasets.
Another thing you can do is data augmentation. This usually consists of affine transformations (rotations, translations, scaling, shifting, etc.), flipping the image, brightness/contrast adjustments, noise induction, etc. The problem with this is that strong augmentations might ruin the image. This limits you in terms of how many and how strong augmentors you use.
That being said, in terms of image classification a tiny dataset could be considered one with a few hundred samples. If you have just one image per class, I'm not sure that you can ever effectively train a CNN without overfitting. My suggestion is, if possible, obtain more data.


How to hide sub fields in a field group and also the entire field group if the answer selected is "no"

Question: I have a field group (repeater field type) set up (titled "Units") with sub fields; sq footage, floor plans and availability (this is a yes/no selection). I have the availability sub field to display on the front end as "Yes" or "No" but I don't want the Units to show up on the front end that have the "No" availability selected. I am not sure what to do to get the "No" units to hide when that is selected as well as the whole field group to hide if there are no "Yes" units in the group.
Answer: In your loop, you can add
<code>$available = get_sub_field('available');
if($available == 'yes'){
   //your row rendering code
}
</code>
Switch 'available' with whatever you named that field.


How long did it take the Noldor to cross the Helcaraxë?

Question: The journey across the Helcaraxë was difficult and perilous, but how long did it take to reach Beleriand?
Comment: Fingolfin, you should know, surely?
Answer: Around twenty years.
In the earlier version of the Annals of Aman in History of Middle-Earth V, where it is noted that each Valian Year (VY) "is as ten years of the Sun now are", we have:

VY 2998-3000: Now Fingolfin [...] won their way at last with grievous losses and with minished might into the North of Middle-earth.

So it took two Valian years, or twenty years in the usual reckoning.
Comment: It seems like Fingolfin had very poor navigational skills. Then again, the Old Testament tribes of Israel wandered in the wilderness for forty years, so I suppose there are other precedents.
Comment: 20 years?! It certainly makes the Fellowship's journey seem like a nice, leisurely stroll
Comment: It probably wasn't a matter of everyone walking straightforward for 20 years. Given that any food you needed for the trip had to be carried from the eastern edge of Aman, imagine how long it would take to carry the necessary supplies out onto the ice so that once you *did* start moving forward, you didn't have to do all the way back to Aman for more. Something of a 2-miles-forward-1-1/2-miles-back kind of trip.
Comment: 1) You're looking at an older version of Tolkien's writings, written a good 15 years or so before the versions generally used in the Silmarillion. There are newer versions available with different dates. 2) I think you're misinterpreting the notation Tolkien is using. As I read it the entry is just discussing when the crossing finished, and the year picks up from right after the last entry ends. Note that ships were already burnt in VY2994. 3) When each Valian Year is 10 solar years, you should give some more error bounds. Even if it was 2998-3000 that could be anywhere from 10 to 30 years.
Comment: @RoyalCanadianBandit Israel did not wander forty years because they didn't know the way. They wandered forty years **after** having already reached the destination once but being unable to take the land.
Comment: Moving an entire nation takes a lot longer than a handful of people. It's less "make camp" and more "build town".
Answer: One hundred and forty-four years
Around 1959, Tolkien wrote a series of notes working out the final chronology of the First Age. These reflect a recent change that he had made regarding the length of a Valian year. Previously, in 1951 he had done it as 5VY, which was then equivalent to about 50 years. Now he had changed each Valian Year to the equivalent of 144 sun years, and felt the dates of the journey needed to be revised.

Note in the "Tale of Years" that 5 VY is allowed for the wanderings of the Exiles, 1495 to 1500, but that was reckoned on a scale of 1 VY = 10 SY, and so was insufficient, being only 50 Sun-years. It is now far too much, being 720 years! Adequate would be 1 Valian Year = 144 [SY]. Therefore the Crossing of the Ice should be in FA 1496.
The Nature of Middle-earth - "Difficulties in Chronology"

The Valian Year spent in reaching Beleriand via the ice aged all the Exiles about 2 years (it took 144 Sun-years) = 72 (but Feanor reached Beleriand in one half the time = Bel. 50 and so only aged 1 year). As soon as they reached Beleriand the rate quickened to 50 = 1.
The Nature of Middle-earth - "Difficulties in Chronology"

As soon as the Exiles left Valinor their ageing and growing rate
increased. Those who had to make way on foot and cross the Ice
spent a Valian year(= 144 [sun-years]) on the journey after the doom
of Mandos. This dreadful journey aged them all to an extent of about
2 [Valian] years (or 72: 1). As soon as they stepped on Middle-earth
the growth rate leapt to 10 : 1.
The Nature of Middle-earth - "Ageing of Elves"

The journey to Middle-earth [took] 144 [sun-]years but counted as 2 [life-]years ... We still have to alter the arrangement during the march from Aman in VY 1496. This occupied 144 sun-years; but it was so horrible that the mature aged at a double rate 2 [life-]years during that time.
The Nature of Middle-earth - "Ageing of Elves"

Note that this all reflect Tolkien's final view on the matter. In previous, now rejected, versions of the legendarium, the crossing had taken anywhere from about six years to about seventy years.
Comment: What were the other Noldor (or, given the time this was written, Ñoldor) doing in Middle-earth for those 144 years? This really seems too long to my eyes. I know this is really for another question, but ... wow. I can understand the Eldar taking so long to move west in the initial migration, given the exciting lands they were moving through, and growing crops and raising kids and all, but there's precious little to enjoy on the Helcaraxë.
Comment: @DavidRoberts - Not sure, but while this seems like a long time, it was the equivalent of just one year as Elves had been perceiving time in Aman (though due to the march it was now two years). Also, the initial Great March westwards was significantly longer than this.
Comment: I think I saw another excerpt (posted by you?) that says that Elves are just faster than Men at things. If this is true, then they will experience time as even longer than we do, rather than as shorter. Experiencing 144 years as just 2 years means they were moving really, really slowly... But maybe I just don't understand this notion of "experiencing" that Tolkien is writing about.
Comment: @DavidRoberts - It's complicated. I think Tolkien is saying that they age slower and are less motivated by everything going on in the present, but then clarifies that it doesn't mean they move slowly, but that they actually move much faster than Men.
Comment: Yeah, ageing slower is fine. Having faster cognition (and so "perception") than Men means 144 years would actually seem longer to them than for Men. But it's possible I'm attaching the wrong significance to the words, and I'm only reading your snippets, rather than the original :-)


K(F_1) = sphere spectrum?

Question: I repeatedly heard that K(F_1) is the sphere spectrum. Does anyone know about the proof and what that means?
Comment: Let's be serious. Anything may arise from the heuristics on the field with one element. It's numerology. I don't think anyone has real hope to prove the Riemann hypothesis from these heuristics.
Comment: In case you're not aware of this feature, you can change which answer you accepted, shall you decide to.
Answer: Yes, taking GL _n(F _1) to be Sigma _n one can make sense both of the Q- and the +-construction and both yield the same answer as shown by Deitmar in http://arxiv.org/abs/math/0605429.
GL _n(F _1)=Sigma _n is suggested by several observations.
One is that counting formulas for subspaces of n- dimensional vector spaces over F _q turn into counting formulas for subsets of n-element sets, if one sets q=1. So one could say that an n-dimensional vector space over F_1 is an n-element set and GL _n(F _1)=Aut(F _1^n)=Sigma _n. See Cohn's very nicely written http://arxiv.org/abs/math/0407093 for this.
One gets another hint by looking at the Tits building for GL _n(F _q) (that is a simplicial complex where the group acts). There is a natural limit for q going to one 1 - what then remains is the so-called chamber of the building and the symmetry group of that is Sigma _n.
Further hints that one should just drop addition (in comparison to the usual notion of module) come from arithmetic geometry, but that is maybe less convincing and a longer story...
Comment: I don't have a direct reference to this, but if you compare representation theory and the theory of group actions on finite sets, it seems to me that you can see more evidence that the correct way of thinking about F_1 involves forgetting about addition.
Comment: @harrison: Yes, burnside ring and representation ring, marks and characters, etc. behave very similarly. Even some proofs carry over, e.g. Steinberg adapted a proof of Frobenius about the irreducibility of some permutation representation to the linear representation analogon (I saw this in a lecture by C. Soule, Nashville 2009)
Comment: @Reid:What one usually does to count F1-points, when the number of points of a variety is given by a polynomial (which is not unusual), is to "multiply away" the zeros at q=1 and then insert 1. This then is consistent with the symmetry group of the chamber view point - for any Chevalley group not only GLn.
Comment: Is GLn(F1) = Sigma_n right? The cardinality doesn't work out when I take the q->1 limit of |GLn(Fq)| (off by a factor of (q-1)^n).
Answer: I understand that this is because GLn(F1) is supposed to be Sigman, the symmetric group on n letters. Thus K(F1) = K(finite sets) which is the sphere spectrum by the Barratt-Priddy-Quillen-Segal theorem.
But I have no idea why GLn(F1) should be Sigman...
Answer: Here is another heuristic, related to what Randal-Williams said above. The sphere spectrum is the unit object in nice categories of spectra. That is, ring spectra are algebras over the sphere spectrum. Now, to every scheme X you can associate a K-theory ring spectrum K(X), and this is contravariant. So, in the usual theory there is a morphism K(Z)->K(X) for all schemes X. So, finding F_1 also means finding something (its K-theory spectrum) that maps to the (homotopy) limit of all K-theory spectra. That this should be the unit object of the category of spectra doesn't seem very surprising.
Comment: Thanks. I just looked where the idea comes from: Manin mentions it in "Lectures on zeta functions and motives (according to Deninger and Kurokawa)" shortly and refers to Priddy "Transfer, symmetric groups, and stable homotopy theory", fitting to the first answer.

K(F_1) = sphere spectrum?


Gravitational force exerted by a rod on a point mass

Question: I have doubts with the solution of a certain problem. I will give the entire solution below and will lay out my doubts as well.
A point mass $m_1$ is separated by a distance $r$ from a long rod of mass $m_2$ and length $L$.The objective is to find the total gravitational force exerted by the rod on the point mass.This is how a particular author solved this question in a book.
The total mass of the rod was differentiated with respect to the total length of the rod, and each mass piece was called $dm$ and each length piece was called $dx$. Hence this equation was formulated:
$\large \frac{m_2}{L}\ =\ \frac{dm}{dx}$
Also, the distance between the point mass and each individual $dm$ piece was taken as $x$.
Then the gravitational force between the point mass and each mass piece is given by:
$F\ =\ \large \frac{Gm_1dm}{x^2}$
$dm$ was substituted using the first equation, now the new equation becomes:
$F\ =\ \large \frac{Gm_1m_2}{Lx^2}\small dx$
This is then integrated from $x\ =\ r$ to $x\ =\ r + L$.
My question is this: how can we integrate $x$ with respect to $dx$?
$dx$ represents the tiny length pieces of the rod, and $x$ represents the distance from the centre of the point mass to any point along the rod. How can we integrate $x$ with respect to $dx$, it does not make any physical sense to me? I am new to differentiation and integration, but I understand the basics well enough. If there is something wrong with this solution please tell me the right way to solve this problem, otherwise tell me how this solution makes sense.
Comment: You are right. One cannot integrate $x$ wit respect to $dx$. Maybe you are misinterpreting the author. A link to that solution would help.
Comment: @udiboy. It is not on a site, it is from one of the coaching center study materials. The final answer comes out to be $F\ =\ \frac{Gm_1m_2}{r(L + r)}$. Is this what you would get if you solved the problem the right way?
Answer: I don't think that you really understand integration. Let me clear this up for you.
In that question there is a rod of length l.
You know how to calculate gravitational force between two point masses but not in continuous mass bodies.
If you apply the formula to find the gravitational  force you don't know what to take the distance as because it is continuous body.
Let us apply the formula  $F\ =\ \large \frac{Gm_1m_2}{r^2}$ by taking r as the distance between the two bodies. Obviously we get a wrong answer. Now let us consider the rod to be made up of two bodies each of mass $m_2/2$ an length $l/2$ . Now we can define the force as
 $F\ =\ \large \frac{Gm_1m_2/2}{r^2} + \frac{Gm_1m_2/2}{(r+l/2)^2}$ .
Again we get a wrong answer. Now let us divide it into $N$ parts. Now the force can be represented as $F\ =\ \large \frac{Gm_1m_2/N}{r^2} + \frac{Gm_1m_2/N}{(r+l/N)^2} +\frac{Gm_1m_2/N}{(r+2l/N)^2}+......  \frac{Gm_1m_2/N}{(r+(N-1)l/N)^2}+\frac{Gm_1m_2/N}{(r+l)^2}$
Or $F\ =\ \large \frac{Gm_1m_2}{N}[\frac{1}{(r)^2} +\frac{1}{(r+l/N)^2} + \frac{1}{(r+2l/N)^2} + .....\frac{1}{(r+(N-1)l/N)^2}+\frac{1}{(r+l)^2}]$
Now if we increase the value of $N$ we get a more accurate answer as the divisions become more smaller and more like point masses.
Now if we make the value of $N$ very very high then we would get an accurate answer. This is where differentiation ad integration comes in. $\large \frac{m_2}{N}$ represents $dm$  and $\large \frac{l}{N}$ represents $dx$.
Now you know why $dm\ =\large \frac{m_2dx}{l}$ Let us now apply this in the above expression.
So now we have .. $F\ =\ \large \frac{Gm_1m_2dx}{l}[\frac{1}{(r)^2} +\frac{1}{(r+dx)^2} + \frac{1}{(r+2dx)^2} + \frac{1}{(r+3dx)^2} + .....+\frac{1}{(r+l)^2}]$
This is same as integrating $\ \large \frac{Gm_1m_2dx}{lx}$ from $x=r$ to $x=r+l$
$Note:$ Every dm mass is not at the same distance from the point mass. We can integrate $x$ with respect to $dx$ as $dx$ is a small change in $x$ . You add all the values and you add $dx$ to $x$ in every next value. Hope this helps


Issue provisioning IIS 7.5 server using Web Farm Framework 2

Question: We have WFF 2.5 installed, and have used it to successfully configure a farm and provision a secondary server in our test environment.
Our environment (controller, primary, secondary servers) is Windows 2008 Server Web Edition R2, running IIS 7.5, with WFF 2.5 installed.
We have ongoing issues with a .tmp file in an app pools related directory being locked. Process Monitor indicates that it is the worker process (w3wp.exe) locking the file.
The exact error message is  Failed to run operation "ProvisionApplications". Failed to run method "Microsoft.Web.Farm.SyncApplicationsRemoteMethod" on server "abc". Exception in response stream. An error was encountered when processing operation "Delete File" on "ABC85DA.tmp". The error code was 0x80070020. The process cannot access "C:\inetpub\temp\appPools\ABC85DA.tmp" because it is being used by another process
If I shut down the Windows Process Activation Service which AFAIK hosts the worker process, the error goes is solved.
Obviously, however , to bring the server online, we need to start the service, and as soon as we do, the automated provisioning step fails, and WFF marks the server as unhealthy, and takes it out of the farm.
I have tried to turn Application Provisioning off by unchecking "Enable Application Provisioning" under the Application Provisioning Module, but the operation still seems to fire every 30 seconds.
So - two problems really:

How to solve the file locking issue on the App pool temp file.

How to turn off automated application provisioning operation on secondary servers? (this is really a second prize workaround in case there is no solution to problem 1)
TIA
Answer: I managed to get around the issue by updating the ignore list in c:\windows\system32\inetsrv\conf\applicationHost.config on the web farm controller. I updated the web farm section to skip the provision of the appPool and logFiles folders, this seems to have fixed the issue for me.
<code><webFarm>
    <applicationProvision offlineWhileSync="true" syncWebServerFromPrimary="true" periodicSync="00:00:30">
        <clear />
        <skipDirectives>
            <skip name="appPools" skipDirective="objectName=dirPath,absolutePath=.*appPools.*" />
            <skip name="logFiles" skipDirective="objectName=dirPath,absolutePath=.*LogFiles.*" />
        </skipDirectives>
    </applicationProvision>
</webFarm>
</code>
Answer: Rebooting the ARR server caused the server to stop attempting to repeatedly provision the secondary servers (in other words applied the "Enable Application Provisioning" option, which I had turned off)
Otherwise, I think the locking issue would still occur. This may not be an issue, since you can turn off the Windows Process Activations Service while initially provisioning the service, and during any subsequent application provisioning intended to synch the servers.
Automated provisioning on a schedule will still be an issue, I suspect.
Answer: I can get it to successfully provision the secondary server by turning off Application Provisioning, but in my scenario I need the content to replicate, so it's not really a solution, just a flag of what part of the service is failing. Platform provisioning seems fine.
I'm getting the same error with locked tmp files - running on clean instances on Amazon's EC2.
Are you still geting the locked file issue? Did you manage to get a resolution to automated provisioning?
Comment: I am still getting the same error, if incremental application provisioning is turned on. We also have a content mirroring requirement, requirement. I am looking at robocopy and Vice Versa http://www.tgrmn.com/ as options. If you have Windows Standard Edition, you might consider DFS-R http://msdn.microsoft.com/en-us/library/windows/desktop/bb540025%28v=vs.85%29.aspx
Comment: That's too bad - shame this isn't working as it's so close to what we both require. I'll take a look at ViceVersa - looks ideal. Thanks.


How can iPhone see android emoji?

Question: My girlfriend has an Android phone and when she text me on my new iPhone, emoji like <code>;-)</code> appear as is and not as a winking smiley. Is there a way to change that?
Comment: You have to download emoji on both phones
Answer: The emojis sent by the iPhone are particular characters (cf Emoji on Wikipedia)
If you see a smiley, it means that the android phones is probably converting the smiley into images on the phone directly but it seends only the text corresponding to the smiley to the reciever.
Since the iPhone does not change the smileys into emojis (at least without jailbreak), you will not be able to see the emojis.
NB: You can also make a test by sending emoji between an iPhone and a Windows Phone. You'll see that each phone will display its own emojis, since it's the system who has a set of images corresponding to the emoji characters.
TLDR : Your girlfriend's phone doesn't seem to send emojis characters but simple smileys.
Comment: without a Jailbreak : no. With a jailbreak there are someapp that will do it.
Comment: NB: You don't want your iPhone to be automatically rendering smileys as icons. What if something cost 8p or you were sharing a password that involved the ;) sequence. Seeing those as icons would be the bummer...
Comment: I know that the iPhone uses special characters for emojis, but can it convert the smiley into icons instead of `:-)` for example? Because that is what standard android phones do.
Comment: actually, this problem never occurred to me. My brother uses an Android mobile phone but when he texted me it shows imojies without any problem. Now I wonder why is that?

How can iPhone see android emoji?


Automation Control Cabinet Isolation

Question: I`m designing a control cabinet with a 60A output demand for heaters. The on/off switching of the heater will be done through a 24V/80A contactor(relay). The customer wants the main switch on the door. That requires 2x5x10mm2 wires to and from the door switch. Unfortunately, there is no space for the switch on the DIN rail with a long stick to the door.
I offered 2 solutions:
1. Place the main switch on the side, not on the door.
2. The main switch operates only L1 for the control electronics and L2, L3 going strait to the MCB, and then to the contactor(relay), so I do not need to switch the 60A on the door, only the small current for the control electronics. Is this legal to do this way?
My question is, which solution is the right one? Or if none, then how would you do it?
Thanks!
Comment: "Is this legal" very much depends on where this is going and the application, so we can't answer that. You could also use a smaller relay to control the bigger one so that you only have to run enough current to drive the coil through the switch in the door.
Comment: Hi Ron, thank you for your reply! My concern is mainly the following in case 2.: The door switch operates as an isolator, however, it is not switching all the incoming 3 phases. It switches L1, that gives power to the 24V PSU and that powers all the control electronics, which can operate the 80A contactor, when it is needed. L2 and L3 goes directly to the MCB and from there they are going to the contactor. The customer seeing this as a product, so it could go anywhere. Thanks!
Answer: From the safety perspective, it would be logical to disconnect all three phases with the main switch. Maintenance personnel would also expect/assume that it would be so.
Door-mounting of the main switch would only be an alternative to side-mounting without any added benefits. In fact, door-mounting would be more unsafe than side-mounting, considering the routing of the 10mm² cables with sufficient slack and the chances of exposure of personnel to live points.
A door-interlocked main switch would render the cabinet inherently safe and would also conform to safety norms worldwide (considering it as a product and not a one-off).
In my opinion, a door-interlocked main switch, to disconnect all three phases, would be the right choice.
It would be worth your while to redo the layout.
Comment: Agreed. The main isolator must remove all power to the panel.
Comment: Thank you for you all! The door-interlocked mains-switch will be then... Thanks and have a good day!
Comment: I would be glad if you would accept my answer.
Comment: Anytime, TheSaint!

Automation Control Cabinet Isolation


lsof - restrict output to physical files only - how?

Question: How do I tell lsof I need to list only physical files (not sockets, not TCP/IP connections, only physical files)?
Comment: First you need to determine what you need it for. To say "physical files" is too general. lsof will give you files that have been opened with a file descriptor. it will give you files that have been opened as memory-mapped files by threads. it will give you library files that have been opened by proceses. all of these are physical files, but the way they are being used is different.
Answer: Just looked through some man pages, it appears you use the command:
sudo lsof /

This will list all open files in the / directory, which is everything on a Linux filesystem. Just tested and it shows only REG and DIR.
More examples:
lsof -a -d 0-999 -c <command name> /
lsof -a -d 0-999 -p <pid> /

0-999 limits it to files with a file descriptor number.
Comment: lsof / only includes files on the root filesystem. If you have multiple filesystems mounted, they won't appear in the output. I find the best way is to just use grep.
Comment: Will include FIFOs as well.
Comment: Nice and simple. If you need just the last column you could append

| awk {'print $9'}

Interesting. I don't get fifo in my output either. Fedora 12 and CentOS 5.3
Comment: CentOS 5.2 and Ubuntu 9.04 return the fifo's for me, could be a change, but are you sure there are fifos?  I would grep for it first and make sure it is there, than try the `/`
Comment: Also, I was just nitpicking, it sounds like he just doesn't want the noise, and there probably won't be very many fifos.
Comment: @James , thanks for the comment, that helped. I was trying to see what files were opened by a bit-torrent client without waiting for the inet entries. With your comment, I did `cat /etc/mtab |awk '{print$2}' | xargs lsof -a -p `
Comment: This doesn't work on FreeBSD.
Comment: it worked very well also to show only files for specified mounted device
Comment: Shouldn't be considered as the answer to question asked. It displays even unix sockets, for e. g.
Answer: There might be a switch, but if you don't mind filtering it through grep, you could do sudo lsof | egrep 'REG|DIR' , assuming by "physical files" you mean regular files and directories.
See the OUTPUT :: TYPE section of the man page man lsof for all the types that might be in that column.
Comment: There might be a switch, but the manpage reads like someone's phd thesis... :)
Comment: Yea... lsof man is extremly hard to read... ;p)
Comment: on a vpn server with enough clients , lsof won't return, so greping is not an option for me
Comment: @OhadCohen lsof will return if you restrict what it's looking for. See "FD" in the manpage (mem, cwd, pd, etc)
Answer: This is what I did which worked perfectly for me:
lsof -F n -p 12501 | grep ^n/ | cut -c2- | sort -u

The -F n option to lsof will cause it to only print out the names of the open files. Each output line that has the name of an open file will start with the single character n followed immediately by the name. Regular files will always be the absolute, fully-qualified name of the file. The grep ^n/ will select only those lines with a name starting with a / (meaning an absolute, fully-qualified file name); thus eliminating things like open ports, sockets, pipe (like FIFOs), etc. The cut -c2- will eliminate the first character, the n, leaving only the file name. Then finally, the sort -u will eliminate any duplicate entries.
One caveat, this will include files that are not regular as long as their name starts with a /. For example, all files starting with the following would be included:

/dev
/proc
/sys

And there may be others depending on your OS.
Answer: this works fine on mac os:
$ lsof /

i like it like this 'cause it's fast. it's faster if you specify -p
$ lsof -a -p <comma,sep,pids> /

Answer: If you use lsof / it will just list open files on filesystems mounted DIRECTLY under / - that is, if you have /home mounted under /, its contents will be ignored. I tried various combination of options for lsof, but all had problems. The best I could come up is this:
lsof `readlink -f /dev/block/*`

This uses readlink -f to get all block devices and feed them as a list to search. lsof ignores the ones that are not mounted.
If you have any other options to limit the search, for instance a pid, remember to end the lsof command with an -a to AND them with the list of block devices:
lsof -p 982482 -a `readlink -f /dev/block/*`


How can I detect when football passes through a hula hoop?

Question: How can I measure whether a football passes through a hula hoop? The main challenge is the need for outdoor use, which presents difficulties due to the presence of ambient light (sunlight).
It might be possible to install a sensor module on top of the hula hoop, which comprises a Class 1 laser emitter and a receiver. The emitter emits invisible laser pulses that bounce off any objects in the sensor's field of view, and the receiver detects the returning pulses. When a fast-moving object such as a football passes through the hoop, it will interrupt the laser beam, causing the sensor to detect the change in signal and register the event.
I also explored the possibility of using infrared (IR) technology to detect the passage of a football through the hula hoop.
Comment: BTW, there are lots of questions of this kind on EE.SE, asking for alternative possible solutions giving some constraints, and they were not closed. Just an example [here](https://electronics.stackexchange.com/questions/651393/detecting-stalled-ac-fan-in-high-temperature-system/651701).
Comment: I don't think this answer is opinion-based. Asking for possible solutions for a design problem is not mere "opinion". And it is not a shopping question, unless one specifically asks for specific parts or modules. Voting to reopen.
Comment: "*The emitter emits invisible laser pulses that bounce off any objects in the sensor's field of view, and the receiver detects the returning pulses.*" The most reliable method for detection of a solid object is through-beam sensing. The receiver normally detects the transmitted light and **loss** of light (breaking of the beam) means an object is present. Detecting of "returning pulses" is much more difficult.
Comment: Does that meet your requirement of cheap?
Comment: @SolarMike While it may not be the most affordable choice, there is of course a trade-off between accuracy and cost. While I am actively seeking more cost-effective alternatives, I have yet to find a suitable cheaper option that meets my requirements.
Comment: This question is likely to be answered with opinions rather than facts and citations. It should be updated so it will lead to fact-based answers. Also requests for alternative sensor options is basically a shopping question. You should read the rules about what sort of questions might be seen as invalid for this site. [What types of questions should I avoid asking?](https://electronics.stackexchange.com/help/dont-ask) and [What topics can I ask about here?](https://electronics.stackexchange.com/help/on-topic).
Comment: @LorenzoDonatisupportUkraine we should stick with what the community has decided is on or off topic in the meta. We usually answer specific questions that are related to electronic design. Broad questions are not encouraged
Comment: A stock LiDAR sensor from Pololu will do the trick. They are designed to deal with ambient light. Choose one that has a wide field of view and a fast sampling rate. They got exactly one - it's a D-shaped black PCB module that uses OPT3101. Done. That was easy, right? :)
Comment: There are DIY articles on the Internet for chronographs for measuring bullet and arrow velocity. Perhaps a subset of this technique can be used for the football sensor.
Comment: @VoltageSpike So why the question I linked to wasn't closed? I don't think they are so different, except for the fact that in that case the OP was an high rep user and the problem was apparently related to some industrial context.
Comment: @VoltageSpike, BTW, I'm sure I have seen other questions here that had the same structure (alternative approaches for an applications) and weren't closed. The one I linked to is just the one I remembered off the top of my head.
Comment: @LorenzoDonatisupportUkraine there are questions on both sides of the aisle. There are some questions that should be closed that remain open and then there are some questions that should be open but got closed. The goal is to keep both of those to a minimum, but we're dealing with a bunch of humans here so we try to do our best
Comment: @VoltageSpike Sorry if I wasn't clear, I didn't want to criticize you mods. What I was trying to say is that sometimes there are high rep users that are a bit too eager to close a question if they think a meaningful answer cannot be given, even if the facts prove them wrong. The site has always been about *electronic design* not simply *circuit design*, so exploring the alternatives (if the problem is stated reasonably clearly) I think is on-topic.
Answer: If you aim for absolute cheapness and an electromechanical solution fits your bill you could use microswitches.
Mount some microswitches on the hula-hoop and connect their levers to very light and rigid plastic strips that go from the microswitch to the center of the hula-hoop. When the football pass through the hoop it will momentarily displace one or more strips, that in turn would act on their corresponding microswitch.
The strips should be so light that the football is not impeded in its motion through the hoop, of course.
The number of strips depend on the relative size of the football wrt to the diameter of the hoop. Probably 4 or 5 will do. You may have to tinker a bit and think of a way to fasten the strips to the hula-hoop (the other end would be flapping around near the center of the hoop) and how to make them act on the switch.
All this requires a bit of mechanical thinking and skills, but probably is unbeatable from a cheapness POV. You could get 5 microswitches for a couple USD and the other materials could also be recycled or commonly available stuff (for the strips I can think of electrician's cable ties, for example; when fastened to the hoop the part you usually cut-off is fairly elastic; there are quite long ones that could fit your application).
Moreover sunlight won't interfere at all. And if you don't need a particularly professional job, you can easily waterproof it all (after you test the set-up) with generous application of silicone sealant (silastic) and/or hot-glue.
In addition, since you don't have delicate electronic components, you could use common silastic for hydraulic applications, which would corrode components in the long run due to the presence of acetic acid in its formulation. The only parts you should protect are the terminals of the microswitches, where you would solder the connection wires. That's easy to do with some heat shrinks.
It's not an elegant solution, and aesthetically would probably look not too good, but its dirty cheap, especially if you have the skills to build it up, otherwise you could spend a lot of time to get it right (YMMV).
Comment: While this is one way of doing it, modern sensors are quite amazing and a wide FoV LiDAR will do this admirably (among other things). About as plug and play as you can get.
Comment: @Kubahasn'tforgottenMonica I'm not up to date to newest technologies like LiDAR when it comes to actual implementations and parts (BTW if you can share a link, I'd appreciate it, I'm curious). Anyway, since the OP mentioned "cheap", "arduino" and "hula-hoop+football", those keywords screamed "hobby (or school) project" to me, so I went with the first most cheap-ass solution it came to my mind (remembering the days when I was a nerdy high-school student dabbling with electronics and salvaging any electronic component I could get my hands on!). :-)
Comment: An ultrasonic proximity detector and an Arduino might do the job for less than $10. https://www.makerguides.com/hc-sr04-arduino-tutorial/
Comment: Thank you for the responses. @LorenzoDonatisupportUkraine If I understand it correctly, using micro switches it is possible to detect when the football touches the strip, and it does not require a push to activate? The sensitivity of the micro switch allows it to respond to even slight movements of the strip. Is that correct?
Comment: @FPSXV Microwsitches are just extremely sensitive switches, so they are on/off. You didn't describe your application too well. If the only thing you want to detect is whether or not the ball went through without too much precision about the timing, the only thing that matters is that at least one of the strip (which must be hinged somehow to the hoop and must be able to press the switch when moved) activates the corresponding strip. ...
Comment: @FPSXV So the switch *does* require a push, but they are extremely sensitive, so they don't need much force. You have to solve the problem of how to make the strip end near the hoop to act on the switch. That's why I said you need some mechanical thinking to devise the right setup.
Answer: For this application, I would use a Time-of-Flight (ToF) sensor.
This kind of sensor does not require any reflector, enabling the entire system to be contained on one side of the hoop.
Integrated circuits exist that implement ToF sensing, with a I2C interface that is easy to communicate with a microcontroller (be it an Arduino or otherwise). They automatically compensate for ambient lighting and work outdoors. Typical resolution for the distance measurements are would be 1mm, and supporting sampling rates of 25-90 Hz.
One alternative would be VL53L5CX, which gives a 8x8 array of distances.
It has a 45x45 degree square FOV (65 degree on diagonal). It could be mounted either looking straight across the hoop, or slightly up or down. The processing would be able to look at the distance to the ball, as well as the shape.
Official break-out boards are available for 20 USD. Or 10 USD for the cheapest from China. The chip costs 7 USD @ 100 pcs, and 5.5 USD @ 10k.
Other array alternatives could be TMF8820/TMF8821 with 4x4 and 30 Hz sample rate. It is as low as 4.5 USD @ 10k units.
It may also be possible to use a single-channel ToF distance sensor. Those are down to 2 USD @ 10k. But due to the more narrow FOV, the sensor would have to be further away and look up/down into the hoop. This might increase total system costs by more than the available savings. Reliability might also be lower due to the inability to look at the shape of the object.


NumPy, PIL adding an image

Question: I'm trying to add two images together using NumPy and PIL. The way I would do this in MATLAB would be something like:
>> M1 = imread('_1.jpg');
>> M2 = imread('_2.jpg');
>> resM = M1 + M2;
>> imwrite(resM, 'res.jpg');

I get something like this:
alt text http://www.deadlink.cc/matlab.jpg
Using a compositing program and adding the images the MATLAB result seems to be right.
In Python I'm trying to do the same thing like this:
from PIL import Image
from numpy import *

im1 = Image.open('/Users/rem7/Desktop/_1.jpg')
im2 = Image.open('/Users/rem7/Desktop/_2.jpg')

im1arr = asarray(im1)
im2arr = asarray(im2)

addition = im1arr + im2arr

resultImage = Image.fromarray(addition)
resultImage.save('/Users/rem7/Desktop/a.jpg')

and I get something like this:
alt text http://www.deadlink.cc/python.jpg
Why am I getting all those funky colors? I also tried using ImageMath.eval("a+b", a=im1, b=im2), but I get an error about RGB unsupported.
I also saw that there is an Image.blend() but that requires an alpha.
What's the best way to achieve what I'm looking for?
Source Images (images have been removed):
alt text http://www.deadlink.cc/_1.jpg
alt text http://www.deadlink.cc/_2.jpg
Humm, OK, well I added the source images using the add image icon and they show up when I'm editing the post, but for some reason the images don't show up in the post.
(images have been removed) 2013 05 09
Answer: As everyone suggested already, the weird colors you're observing are overflow. And as you point out in the comment of schnaader's answer you still get overflow if you add your images like this:
addition=(im1arr+im2arr)/2

The reason for this overflow is that your NumPy arrays (im1arr im2arr) are of the uint8 type (i.e. 8-bit). This means each element of the array can only hold values up to 255, so when your sum exceeds 255, it loops back around 0:
>>>array([255,10,100],dtype='uint8') +  array([1,10,160],dtype='uint8')
array([ 0, 20,  4], dtype=uint8)

To avoid overflow, your arrays should be able to contain values beyond 255. You need to convert them to floats for instance, perform the blending operation and convert the result back to uint8:
im1arrF = im1arr.astype('float')
im2arrF = im2arr.astype('float')
additionF = (im1arrF+im2arrF)/2
addition = additionF.astype('uint8')

You should not do this:
addition = im1arr/2 + im2arr/2

as you lose information, by squashing the dynamic of the image (you effectively make the images 7-bit) before you perform the blending information.
MATLAB note: the reason you don't see this problem in MATLAB, is probably because MATLAB takes care of the overflow implicitly in one of its functions.
Comment: Why 'float'? A 'uint16' would be sufficient.
Comment: There was no rational reason for choosing float, uint16 would have been enough indeed.
Answer: Using PIL's blend() with an alpha value of 0.5 would be equivalent to (im1arr + im2arr)/2.   Blend does not require that the images have alpha layers.
Try this:
from PIL import Image
im1 = Image.open('/Users/rem7/Desktop/_1.jpg')
im2 = Image.open('/Users/rem7/Desktop/_2.jpg')
Image.blend(im1,im2,0.5).save('/Users/rem7/Desktop/a.jpg')

Comment: this is especially nice for getting the job done without dragging in numpy.
Answer: It seems the code you posted just sums up the values and values bigger than 256 are overflowing. You want something like "(a + b) / 2" or "min(a + b, 256)". The latter seems to be the way that your Matlab example does it.
Comment: Don't you actually want `min(a + b, 256)` because if you get a value over 256 you want to clamp the value at 256 (you don't want to take a value over 256). In any case, to fix the error @rem7 pointed out, you can do `additionF = np.minimum(im1arrF + im2arrF, 256)`
Comment: Yes, matlab clamps values when doing arithmetic on uint8 values (e.g. it implicitly does the equivalent to max(double(a)+double(b),256) )"
Comment: When I try to do max(im1arr+im2arr,256) I get the error:
"ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"

I do (im1arr+im2arr)/2 I get funky colors, only dimmer, max value 127 so I did:
addition=(im1arr/2)+(im2arr/2) and that seems to work.
Answer: To clamp numpy array values:
>>> c = a + b
>>> c[c > 256] = 256

Comment: It assumes that type of elements is larger than uint8.
Answer: Your sample images are not showing up form me so I am going to do a bit of guessing.
I can't remember exactly how the numpy to pil conversion works but there are two likely cases. I am 95% sure it is 1 but am giving 2 just in case I am wrong.
 1) 1 im1Arr is a MxN array of integers (ARGB) and when you add im1arr and im2arr together you are overflowing from one channel into the next if the components b1+b2>255. I am guessing matlab represents their images as MxNx3 arrays so each color channel is separate. You can solve this by splitting the PIL image channels and then making numpy arrays
2) 1 im1Arr is a MxNx3 array of bytes and when you add im1arr and im2arr together you are wrapping the component around.
You are also going to have to rescale the range back to between 0-255 before displaying. Your choices are divide by 2, scale by 255/array.max() or do a clip. I don't know what matlab does
Comment: Are the images still not showing? I edited the question and after that, it works here.
Comment: works for me now. It definitely looks like a wrapping/saturation issue. It would also be nice if you posted your source images.
Comment: I think the pil conversion does make it a MxNx3 since im1arr.shape prints this: (2477, 3700, 3). Option two seems to be correct.
Comment: It seems that I had to divide both images first before I can add them, even if I do a clip(min=0, max=255) on the result, the overflow already happened so the funky colors are still there.
Comment: The alternative to dividing first is to cast from a byte array over to an int (or short) array and then do your math.

NumPy, PIL adding an image


What is a PID as is related to quadcopters

Question: I'm trying to make a Quadcopter from scratch, I have a fair amount of experience with adruinos, and I'm trying to understand how to necessary systems work, and I can't seem to figure out what PID means, is it a method of regulating pitch and roll? like a stabilizer? I think from what I've read that its a system that detects orientation of the craft and tries to correct it
Answer: The term PID itself refers to Proportional plus Integral plus Derivative control, which is a very common control technique. The IMU (inertial measurement unit) measures the orientation of the quadrotor, and the roll/pitch/yaw values are used in the PID controller to calculate motor commands.
Comment: So the pid takes the output of the imu and sends the appropriate command to the motors?
Comment: Basically, yes. There are also some user-defined tuning variables to adjust how strong the motor command is relative to the error.


Recover files of encrypted SD card after factory reset without decrypting the card

Question: I own a Samsung ON 7 phone and I was using a class 10 Sandisk memory card which was encrypted by the device in the lock screen and security menu and with no other third party software. Now I have done factory reset on my phone and accidentally forgot to decrypt the SD card, now SD card is detectable and all the files are there and visible as well. but i can't open any file. What to do, please help !
Answer: Before you start anything: Did you use the offer of Google Account for storing all your passwords,etc?
If not:
Are you a beginner or an Android Crack? If you are a beginner, then it is very, very complicated - get asap to a data recovery firm (very expensive) or get to the National Security Agency :)). As Android Crack I would try ASAP (hope you've rooted the device by a Custom-Bootloader) mirror the whole smartphone (on a phone shell apk with sudo/su then dd if=/dev/mmcblk0 of=/ disk with same mem size of smartphone mem) as well as the SD disk to a PC disk, then try to use a Linux recovery disk with gpart, disktype, testdisk, and e.g. aeskeyfind etc. to recover the data. So far I know the keys are in a certain folder (look on the web/stackoverflow) in the system partition, but if you overwrote the phone with Odin/Heimdall (DO NEVER THAT NOW) then you can forget all data.
The next time after you've rooted/ made a firmware reset and new encryption the first thing you should do is to backup the key stuff on a new Memory card and duplicate the keyfiles as much as you can!
Afterwards everything is hell :)) (Even there are APK which are offering a recovery/decrypting of private encrypted files, I would be very cautious of that - they're mostly fakes/adware and maybe trojans)
Comment: thanks @aprogrammer that's very kind of you to reply. However, I had so much of data in that memory card but now I have lost all the hope to recover and moved on !