Conceptual Question: Best Way to Map Multiple Layers

Question: I'm familiar with using QGIS, so this is not a technical question; it's more of a conceptual question. I'm mapping attendance of households at different meetings, and I specifically want to show which meeting or meetings households have attended. I've tried to show this using points, but the map is so large, it makes it look like the meetings haven't had many attendees. (We want to show that the meetings have been well attended.) Instead, I've been using polygons over each house parcel. The issue is that there are households that have been to multiple meetings but the map only shows whatever layer is on the top. I've also tried having the polygons with a line fill, but that didn't work too well. Does anyone have any suggestions for improving this?
Answer: A choropleth map would be suitable in this case.
Per Wikipedia:

A choropleth map... is a thematic map in which areas are shaded or patterned in proportion to the measurement of the statistical variable being displayed on the map.

Choropleth maps show areas filled with a colour where the colour varies with the attribute value being displayed.
That said, if your meeting attendance data is stored in different layers, you will probably want to combine them into a single layer first. The combined land parcel polygons would then have some attribute like "total_meetings_attended". This will be much easier to map than multiple layers.
One thing to keep in mind when preparing a choropleth map (or any map) is the importance of selecting a suitable colour palette. White, Slocum, and McDermott refer to a "logical progression of colors". Essentially, you want the colour palette to make sense in the context of the data you are presenting. You have unipolar data (values range from small to large), so a scheme such as the following could be suitable:

no meetings = white (i.e., absence of meetings = absence of colour)
some meetings = light blue
many meetings = dark blue (i.e., most meetings = darkest colour)

It would be different if you wanted to display bipolar data, such as temperature or income relative to median value (values can be low or high positive or high negative). In that case you would want deep colours on both ends of the palette and a neutral or light colour in the centre.
An example from White, Slocum, and McDermott showing palettes used to indicate % home ownership rate:

On the left they show an example of a logical palette for unipolar data. On the right are three palettes that lack a logical connection to % home ownership data.
Another thing to watch out for with choropleth maps is that large regions can dominate the map and have more visual impact than small regions. I would imagine residential land parcels are similar enough in size that this would not be of concern in your case.
Comment: Great, this is extremely helpful! Thank you for your help!
Comment: You are very welcome. If you feel this answers your question, please mark it as an answer. See [https://gis.stackexchange.com/help/someone-answers](https://gis.stackexchange.com/help/someone-answers) for more details.


Performance of programming languages and frameworks

Question: I want to program an online 2D MMORPG with graphics like in this game. Since I develop in javascript and python mainly I chose python for my first games and the game library pygame which is pretty straightforward and awesome. But since many people go for c++, c# etc. I wonder if I still could achieve what I want to with python. Is anybody experienced with performance with python and pygame in cases like this? should I rather go for c++? Should I use a combination of python and C, or maybe even python and c++?
Comment: @IbrahimApachi Yes, I think you should use C++. Since you're not used to c++ you will have a hard time figuring out how to create an MMO. Only learning c++ is nothing, getting your networking to work is such a massive task. Try making a simple multiplayer game (1v1) in c++ and then reconsider creating an MMO. Good luck :)
Comment: @IbrahimApachi I guess you can. Search for some networking libraries in python. Still, building the whole architecture for your game will be very hard. I would definitely NOT recommend doing this when you're a beginner.
Comment: I couldn't agree more with @Dries. I am curious of how many of those people who post everyday about "How can I make a 3D FPS/MMORPG" actually ends up doing anything remotely close in difficulty. Makes achievable goals first. Multiplayer aspect in the make makes it a lot more complicated. Try making a tic tac toe online game see if you can do that, then aim higher.
Comment: I don't think that the language really matters as long as your game framework is good enough for what you are doing. You didn't mention which platform you are targeting. You should just pick the language you know or the one you want to practice. After compiling all the languages are the same set of commands, it doesn't matter, language is just for the programmer
Comment: @Shiro At first I target Windows Computers. I just thought that I might have performance problems if I would go for python and pygame
Comment: Since you seem like a beginner, I doubt you will build something more than 500 people will play at the same time. In that case it doesn't really matter what you use. When a lot of people at the same time are playing though, you will run into some performance issues which would need to be solved more low level. That's why most people that create MMO's use C++, it's one of the most low level languages there are, while python is a very high level language
Comment: @Dries I dream big so I expect even more than 500 people :P So I definitely should go for c++?
Comment: @Dries sounds like it's uber difficult :D So there is no chance in going with python and pygame :P ?
Comment: I just build a basic game in pygame with collision detection and pacman in java in school. What would you recommend doing as a beginner then :D ? I would love to just try things out
Answer: As an answer to this question and to most of the comments.
Try making some other games first. Since you are a beginner, creating a multiplayer tic-tac-toe (as Shiro suggested) will be hard enough. Even if you can manage to create that creating an MMO is a massive task that most of us, and definitely the beginners, will underestimate.
For example: how will you track player movement on other clients, if you're going to do PVP how are you going to send messages so that the other player knows he's been hit. What about, connecting and disconnecting to servers. Will you be creating a Peer-to-peer game, will it be a server-client architecture (with a dedicated server). How will you manage lag and hackers? This and many other questions will arise, which you will probably not think of when you start this.
If you want to continue doing this, create a simple chat system using python first. (you can do this with telnet, which is included in the basic installation of python). If you can manage that, create a VERY simple 2-player game. If you can manage that, go on to creating a game where people can connect to a main pc (p2p host or dedicated server) and see if you can make the players move and make the server send that information to all other connected clients.
TL;DR: It's great that you want to try this but slow down, think about it, realise that this is not just "connecting pc's and I'm done".
Comment: It is really awesome that you mentioned some milestones which I have to achieve. I will try all that stuff out :D thank you very much :)


Drarry Harry Potter fan fiction where Draco has to be Harry's familiar

Question: Draco has to pretend to be Harry's familiar so he doesn't get caught by Voldemort. I think it was Snape that got him to do it. He's an Animagus which is a silver fox and no one else knows that it's actually Draco but eventually Hermione, Ron and Ginny find out when they see Draco and Harry together and Draco has the foxes collar on.
Answer: Familiar (2018) by larrysmeanttobe
"Draco has to pretend to be Harry's familiar so he doesn't get caught by Voldemort. I think it was Snape that got him to do it."

"You'll stay a fox Draco, Potter will take you to McGonagall and say that he found you and you two bonded. You will pretend to have Draco as your familiar while I handle everything else, do not tell a soul who he is and that he's actually an animagus. Now I do not need either of you sobbing about how much you hate one another because both of you will be dead in no time unless you do as said."

"He's an Animagus which is a silver fox and no one else knows that it's actually Draco"

If anyone would ask Harry he'd say that he was actually intelligent enough to agree and do what was the best for him but in reality he did not move because he wasn't able to. He wanted to do many things when Death Eaters appeared but he felt stunned, frozen to the spot after watching Draco lose his form and shrunk down, leaving a beautiful fox behind. The fox.
That's when Harry understood why the, he-thought-to-be-familiar, was so mean to him, it was Draco all along. His jaw was probably permanently lost, quite amazed that he was able to perform such complicated magic. He was an animagus.

"eventually Hermione, Ron and Ginny find out when they see Draco and Harry together and Draco has the foxes collar on."

"Ron, I think Dragon was Malfoy. He must be an animagus, that's literally the only way this makes sense. I'm so dumb, I should have known from the first second when Harry was rude to his familiar, a bonded wizard would not do that. It just...it doesn't make any sense, that must be why I never figured it out. Harry and Malfoy make no sense."
Comment: It's not that one but thanks for trying
Answer: I found it!! I knew I remembered what you were looking for. So the story starts off during the summer with draco as a ferret and Harry rescues him, and to help him stay under cover when they return to school draco pretends to be Harry's pet fox.
Ferret in My Shoe by MikoGoddess
It's on fanfiction.net
Summary:
Harry finds Malfoy in a petshop and brings him home, wanting to know why he was there, and why he was a ferret again. What ensues is a bit of this, a bit of that, and a dash of slash. HPDM, after 6th year, no DH. Now with more plot!
Harry Potter, T, English, Romance, chapters: 13, words: 112k+, favs: 1k+, follows: 571, updated: Mar 20, 2008 published: Nov 11, 2007, Draco M., Harry P.
Expert from chapter 6
"  They received many stares, and people whispered as they passed, wondering why Harry Potter had a silver fox following him around now, and where he had gotten it. He ignored most, and smiled at some when he knew them, but mostly he just walked quickly past everybody and onto the train. When he finally did find one of the further-most compartments, Harry put his suitcases onto the rack, and flopped down in one of the window seats. Draco hopped up onto the seat next to him, and laid his head across Harry's lap.
Harry looked down in surprise, and smiled as the fox appeared to be drifting off to sleep. "Tired, Draco?"
A slight huff was his only response, and Harry chuckled. "I told you not to stay up too late." Draco opened one eye and glared. "
Hope this helped.

Drarry Harry Potter fan fiction where Draco has to be Harry’s familiar


Clarification Needed: Power Spectral Density of Real Signal

Question: For a real signal, the power spectrum will have Hermitian symmetry. If I consider the one-sided spectrum (as negative frequencies, or anything above the Nyquist frequency are redundant) must I then multiply my power spectrum by a factor of 2? I have seen this done but I can't understand why the "redundant", symmetrical portion of the spectrum should factor into the power density? Maybe this is a matter of convention? Please correct my assumptions if necessary.
Comment: The power spectrum of a real-valued signal must be a real-valued nonnegative even function of $f$. Yes it has Hermitian symmetry but in a trivial sense since there are no imaginary components to worry about and the real components are even functions of $f$.
Answer: This stems from Parseval's theorem. For any signal, $\int_{-\infty}^{+\infty}|x(t)|^{2}\mathrm dt = \int_{-\infty}^{+\infty}|X(f)|^{2}\mathrm df$ and hence for a real signal, the one sided PSD must be multiplied by a factor of 2 because of Symmetry. Intuitively, the Fourier Analysis of any signal provides us with a spectrum which has Negative frequencies too because of the fact that Sines and Cosines can be constructed using Euler's theorem of using Complex Exponentials of positive and negative frequencies; and it so happens for any real signal that all you need are complex exponentials which are conjugates of each other to construct them.
The negative portion is not exactly "redundant". The signal still owns those "negative" frequencies and hence anything present there accounts to its energy.
Answer: I've found this paper on Spectrum and spectral density estimation to be a great resource in understanding some of these subtle points when dealing with the spectrum, windowing, and overlap. Refer to section 9 for a discussion on the scaling.
Long story short, efficient FFT routines don't compute the redundant frequencies, so in order to properly represent the spectrum for the first half you must multiply by a factor of 2 to make up for that energy. Also, depending on if you want the power spectrum or power spectral density there are other scaling factors required.


What will happen when lightning strikes a zeppelin?

Question: I know airplanes have an aluminium outer body that lets lightning just slide through the outer surface and not causing much damage. But what will happen in the case of a zepplin?
Comment: Do zeppelins even exist anymore? And if they did they wouldn't be using hydrogen
Comment: They don't exist anymore, and even if they did they would be using helium as it's not inflammable. This was just a theoritical question out of curiosity.
Answer: Firstly, Zeppelins usually use a conducting shell. Secondly, inside the hydrogen-filled shell there exists "no" oxygen. Hence, it is not possible to ignite a fire inside the shell.
Nevertheless, Zeppelins fires have been observed during lightning strikes. However, this was during the landing procedure, when hydrogen is vented to increase the ballast.  The vented hydrogen mixes with the oxygen in the atmosphere, creating a combustible mixture.
Sidemark: One hypothesis for the famous German Zeppelin "Hindenburg" disaster is a lightning strike during the landing process.


What was the backstory to Shepherd Book on Firefly?

Question: Firefly was cancelled before it ever was able to expand on the back stories of most of the characters, and the follow-up movie, Serenity, simply didn't have the time.  Did Joss Whedon ever reveal the history to Shepherd Book?
Comment: Same question over on [Scifi.SE](http://scifi.stackexchange.com/q/166/1027).
Answer: From Wikipedia:

His background is explored further in the comic book Serenity: The Shepherd's Tale. Book was born Henry Evans, a boy who was raised by an abusive father. He ran away from home and began life as a petty criminal before being recruited by the Independence movement and moving out to the Border Worlds. Long before the Alliance begins the Unification War, forward-thinking Browncoats assign Evans to be a long-term mole. He sheds his old identity by killing a random passerby and stealing his identification card, becoming Derrial Book. His Browncoat superiors keep tabs on him by surgically removing one of his eyes and replacing it with a camera. He joins the Alliance military and quickly moves up in rank. Becoming an officer, Book intentionally leads a risky operation that results in a humiliating defeat for the Alliance. He is forced to retire from the Alliance military. It is implied that the Alliance covers up the loss, therefore not officially punishing Book. Homeless, he visits a soup kitchen and finds God while contemplating a bowl of soup. He takes refuge at an abbey where he becomes a shepherd before leaving on Serenity to become a missionary.

More on the comic can be found on the Firefly Wikia.
Comment: Thanks, this is great. If I could have marked the comment from Keen above as the answer I would too :)
Comment: This could explain Jubal Early's statement in Objects in Space, "That ain't a Shepherd". Maybe Early had had prior interactions with Shepherd?


How to batch copy transforms from one object to another by name

Question: in order to speed up the process of configuring a ragdoll humanoid with Blender, i use an addon that creates empties on the head of each bone aligned to the bone (Bonera), and other that creates meshes on the same location but with already configured rigid bodies and rigid body constraints (Rigid Body Gen). Then i manually copy the transforms from the empties to the meshes so they line up one by one. How could i do this for all selected  meshes at once with a script?
Like for the selected meshes, copy loc and rot from the empties using their name as reference (copy loc/rot from bone_[name] to joint_[name])
Answer: From the information you've given, only this simple script can be derived. Hope it helps. If it's not working, please provide more precise information about your scene setup.
<code>import bpy

# get all selected objects
for selected_obj in bpy.context.selected_objects:

    # only consume meshes
    if selected_obj.type == 'MESH':

        # get bone and joint object with mesh name
        bone_obj = bpy.data.objects['bone_' + selected_obj.name]
        joint_obj = bpy.data.objects['joint_' + selected_obj.name]

        # copy loc and rot
        joint_obj.location = bone_obj.location
        joint_obj.rotation_euler = bone_obj.rotation_euler
</code>
Comment: Thanks @taiyo, it was almost there, i just had to remove the "joint_" string from the obj name before assigning the bone, the way you did it become "bone_joint_name", the end script is even simpler, your answer helped me to figure it out:
`bone_obj = bpy.data.objects['bone_' + obj.name.replace("joint_", '')]`
Comment: I just noticed that if the empties are parented to something, the copy loc and rot does not work properly, is there any code for copying the transform data if the "bone_" object is a children of another obj?
Comment: @Jh0nny loc and rot are local values (relative to the parent), if you have a hierarchy its gets more complicated. You can get the global values with decomposing the `obj.matrix_world` attribute, see this answer https://blender.stackexchange.com/questions/209398/how-to-copy-rotation-from-active-to-selected-in-python.
Comment: Thanks, it works now!


How can I make my keyboard's media keys work when an elevated program has focus?

Question: When I hit my media keys when using Visual Studio 2010 normally, they control Media Player Classic just fine. When I launch VS2010 with elevated privileges, I have to select another program in order for the keys to work. How can I make the media keys work even when I have a program with elevated permissions with focus?
Answer: Depending on what type of keyboard you have there are different supporting applications enabling special features like the media buttons.
Microsoft mice and keyboards use the IPoint and IType applications for this. I have solved the issue with special functions provided by these applications by setting the "Run with highest privilege" on the Windows Task Scheduler activities that are responsible for starting the IPoint and IType applications when a user log in. This way the special features will also be available in admin sessions in Visual Studio.
If your keyboard is from another manufacturer you could probably find the software installed to support your keyboard and try running it with elevated privileges (run as admin) to test it.
Comment: Sorry, but I do not know if or how to solve that situation with the generic driver. The possibility to solve it for the IPoint and IType apps was based on the fact that they were separate apps.
Comment: My keyboard is using the Windows generic drivers. I have the same problem with the media keys not working when elevated programs are in focus. Is there a way to elevate the generic keyboard driver?


Exact structure of a file

Question: My question may seem really basic but I struggled to find satisfactory answer. I have started to wonder what is the exact structure of a file in Linux. There are some commands like file or ls that can be used to get some information about the file but I would like to check values of all attributes that file is comprised of. I mean each file has its creator, different important dates, modes, type, encoding, size, actual data etc. Address that informs where the file is located on the hard drive also got to be stored somewhere. Are all of these information stored in the header of the file, ahead actual data or are they in different memory locations? Is there any magic way to get all possible information about the file using bash?
Comment: There's no "magic" way. But there are commands such as `stat`(1) to help obtain some of it.
Answer: If file/ls is not enough for you, then use stat (man stat).

Exact structure of a file


MacBook pro 16 inch 2019 keeps forgetting KVM settings

Question: I have a KVM setup that connects several computers to the same Keyboard (Kul ES-87) and Mouse (wireless logitech M525). My monitors are 24 inch, 1920x1200 resolution Dell (2412M and 2415). I connect an Ubuntu machine, one Late 2013 Macbook Pro and a brand new 2019 Macbook Pro 16 inch purchased last week (henceforth, just "MBP 16") for work to this KVM setup (IOGear GCS24U). The MBP16 has AMD Radeon Pro 5300M 4 GB
& Intel UHD Graphics 630 1536 MB and has the latest, updated software.
The Ubuntu and the Late 2013 MBP machines connect just fine to my KVM, and have had for years now, but the MBP16 has been extremely flaky with the KVM. The result of the flakiness: it doesn't recognize the VGA monitor (Dell U2412Mb) and after it fails, requires heavy-handed approaches (see below) to fix. I am not sure if these approaches are sustainable.
I connect the two external monitors to the MBP16 in the following way using two separate USB-C ports on the MBP16:

MBP16 port 1 -> Benfei USB-C 2 VGA -> KVM (VGA) -> (VGA) Dell 2412Mb // Mostly flaky

MBP16 port 3 -> Anker USB-C 2 DisplayPort -> (DisplayPort) Dell 2415 // Always works

(MBP16 port 2 is used for a USB 2.0 hub for ethernet, mic, KVM mouse and keyboard; MBP16 port 4 is used for power.)
I see that the MBP16 connects to the U2415, no problems ever noted. The VGA connection through the Benfei adapter and U2412Mb frequently is flaky (see definition of flaky below). It requires a combination of me switching the KVM port for the MBP16 or reconnecting the VGA on the KVM switch itself that makes the MBP16 recognize the U2412Mb again.
What do I mean by flaky? It works fine so long as it was recognized: wakes up from sleep and re-recognizes the VGA display; after switching to another KVM port, re-recognizes the VGA display. However, if I remove the MBP16 and take it outside of the KVM world (e.g., work on sofa) and get it back, it forgets the VGA. And then it requires all kinds of heavy-handedness to re-recognize the VGA.

I am not daisy chaining monitors through a hub (see connection description above).

I am running the latest OS on my MBP16 (11.3.1).

I have tried, instead of the Benfei USB-C adapter, (1) An apple-store purchased Belkin VGA to USB-C adapter (which did not work at all) (2) an Apple adapter to thunderbolt and then a thunderbolt to USB-C (didn't work at all); (3) a CableCreation multiadapter with Ethernet and VGA to USB-C (worked for 20 minutes). That said, I didn't try using a different KVM port when I tried approaches (1)--(3) above.  Also note, a direct connection from Benfei USB-C 2 VGA to the Dell 2412Mb works fine.

Last, but not the least, I tried both NVRAM and SMC reset multiple times, didn't do anything.

What is the secret to appeasing the "it just works" Apple gods? Any insight is appreciated.
PS: Post question rant: FWIW, I have noticed it never "it just works" with Apple gear. NFS, CIFS, Guest access, USB connections, USB-based Ethernet, iMessage forwarding, call forwarding to other Apple products, all of which, in my over-a decade experience, has never "it just works" and it always breaks from one release to another.
Comment: My Apple 27" display always works with my 3 macbook pro machines and two need an adaptor to get to usb-c "it just works" especially with Apple gear...
Comment: I am wondering if the issue may be that the monitor and KVM are both *analog* signals via VGA. Does the VGA monitor work **directly** to the MBP?
Comment: My VGA monitor did *directly* connect to the MBP, but that connection is also flaky.
Answer: The type-C-to-VGA converter cable did not pass the EDID feeding timing correctly to the VGA KVM switch or the VGA KVM switch did not pass or have VGA EDID emulation feeding to the shared monitor.
Please make sure your IO Gear VGA monitor provide Bi-directional EDID emulation and feeding fuction first. If IOgear did not support the EDID emulation, then you may need add an external VGA EDID emulator between the converter cable and the KVM switch.


Photographing baby turtles/turtles at night

Question: Is anyone able to give suggestions on what camera settings would be suitable for night photography of baby turtles? I'm currently using a Canon 1300D with a Tamron 16-300mm lens.
Comment: Some details would help: 1) can you use flash? 2) can you use continuous light (LED)? 3) are turtles under water or on the surface? 4) what is special about baby turtles compared to adults? 5) how close can you get to the turtles?
Comment: @aaaaaa In almost all locations, **you cannot use flash**. Most sea turtles are endangered or protected. And even if it's not illegal to use flash, it is largely considered unethical. It can disorient the hatchlings (or nesting turtle, at the start of the season), and cause them to not find their way to the water.
Answer: From a camera standpoint, the best thing you'll need to do is shoot on manual and making sure that you're using the best aperture that is possible for the lens. You should bring a Tripod with you too so that you're able to shoot at a rather low shutter speed, ideally no more than 1/30th of a second. Without a tripod, you'll never get a clear photo. Lastly make sure to crank up your ISO, a lot of people fear to do this due to making a photo more "grainy" or "noisy" however you're somewhat limited here, 1600, 3200 or 6400 if you're struggling - this will help you get some lighting too.
In regards to the tripod, I'm sure you'll be shooting on a beach if that's the case try to bring something like cup mats to put your tripod on. it's possible it'll sink very very slowly into the sand so it's a good way to avoid that and if you decided to try long exposure shots it's pretty much a must.
Comment: Depending on how much work @Warwick wanted to put in, image averaging and a bit of photoshop could get rid of the background noise.

Though to be frank, if this is a shot on the beach, I think the noise would be less noticeable.

Wide aperture definitely helps on low light, so not sure how wide that Tamron goes.
Answer: At the risk of stating the obvious you will want to photograph on a stable tripod and use the highest ISO possible in order to minimize exposure times. Even at 6400 ISO the exposure could be too long to "freeze" the subject. Don't be afraid to underexpose by a stop or two if you are shooting Raw images. It is easier to recover exposure and remove noise than it is to artificially remove motion blur. Consider bracketing your exposure times so that you can later choose the longest exposure with no apparent motion blur. This will allow you to compromise blur and noise effectively. you may also bracket ISO in a similar manner by determining the longest "stop-action" exposure and then varying ISO (and therefore exposure / noise.)
You will likely need to utilize the widest aperture your lens offers. However, if it is possible to "stop down" I recommend you do so. This will help to mitigate any mistakes you've made in focusing.
An often overlooked aspect of nighttime nature photography is lighting. Between a normal new moon and full moon illumination varies from 0.002 to 0.25 or about 7 stops! If you happen to photograph your subject during a super moon illumination could be 0.36, up to and additional 3 stops (note that there is some discrepency in Wikipedia as to whether full moon illuminance is up to 0.25 or up to 0.1 lux.)
Finally, consider color balance. If you are shooting Raw this is not a big issue since it can be determined experimentally later. Color balance will be trickier than with daylight photography since color cast from earthshine and atmospheric glow will be up to three orders of magnitude greater than during the day. Raw or not it is often useful to include a graycard in your test shots and one is especially beneficial in static lighting conditions such as a clear night since you can not only obtain a gray-balance reference point but also calibrate your manual exposure before engaging a tricky target.
Final thoughts: having worked with nighttime nature photography before, I've found it helpful to have an extremely stable platform. I've done so by attaching a tripod head to a 2x4 attached to a plywood plate.
Answer: Note: This answer doesn't address the photographic aspect of shooting sea turtle hatchlings at night. Rather, it addresses how to minimize your impact on turtles while shooting.
In the U.S., marine turtles are protected under the U.S. Endangered Species Act of 1973. It is a violation of the act to harass, harm, pursue (in addition to other actions such as hunt, shoot, take, etc.) them. Violations can be severe, and Fish & Wildlife wardens/officers often have broad leeway to cite individuals for harassment of turtles. Additionally, states such as Florida have additional protections for marine turtles, and have more officers able to identify and fine individuals deemed to be harassing turtles.
In order to minimize the impact on both nesting turtles and hatching turtles, and minimize any risk of being deemed to harassing them (and subsequently, fined), make sure to:

Keep your distance from them. From a photography standpoint, this means opting for longer focal length lenses, rather than shorter (wider angle) lens. Of course, this is a tradeoff with the desire to collect as much light as possible with minimal movement in the scene, but... photography is all about tradeoffs.
Minimize artificial lighting. Bright smartphone screens and camera LCD displays can be quite bright, especially if there is little spillover artificial lighting in the area. Nesting turtles can be startled by sudden bright lights, to the point they abandon their attempt to build a nest. Hatchlings can become disoriented and not find their way to the water. Do everything you can to minimize the artificial lighting you bring:

Use "night mode" on the devices that support it. Especially if night mode is red-lit.
Reduce the brightness of your screens as low as it will go. This is still usually more than bright enough at night, often times too bright to preserve your night vision.
Disable automatic preview after taking a picture, if your camera supports it. If not, consider keeping the LCD covered with a cloth or gaffers tape.
Try to keep your camera's LCD display (and smartphone) covered or shielded to minimize its ability to be seen by turtles.

Use amber or red lighting, at low power, for lighting. Turtles cannot see longer wavelengths of light, such as red and amber.
Try to minimize your movements. The more you act like a professional wildlife photographer (moving slowly, keeping your distance), the less chance you will startle the turtle. And the less chance a Fish & Wildlife officer will think you're harassing the animals, and give you the benefit of the doubt about your intentions.
Contact your local sea turtle preservation society. They often conduct turtle walks, educating the public about the threat to turtles, showing people how to safely observe them, and informing people about the laws and ordinances protecting the turtles.

And if it wasn't obvious from the previous points, above all: No flash photography.
See also:

NOAA National Marine & Fisheries Service, Southeast Region Marine Mammal & Sea Turtle Viewing Guidelines (nmfs.noaa.gov)
Marine Turtle Protection Laws (FL Wildlife Commission)
Nesting sea turtles, flashing cell phone photos a bad mix (FL Wildlife Commission)
10 Do's And Don'ts for Nesting Turtle Season (SeaWorld)


VS2010 Professional using Moles...receive error "System.InvalidOperationException : Could not start Moles host."

Question: My situation is similar to user2768132's question (VS2010 pro not able to start Moles host), however, I have a couple differences.  I also attempted the suggestion by SouthShoreAK but it didn't resolve my problem.  Pardon the similar post.
I'm new to this project at work as well as Moles so I might be missing something simple/obvious.  We are also using Moles framework to write unit test cases but are not able to either debug or run a unit test that involves Moling a public static class.
System - Win-7 Professional SP1
.NET - .NET v4.0.30319 SP1 Rel
VS - VS2010 Professional v10.0.40219.1
Moles - v0.94.51023.0
The solution builds successfully.  The 6 simple unit tests (i.e. not Moling static classes) pass but the one unit test that requires Moles to deal with a static class aborts.
Error for the aborted test:
<code>Error   3/26/2014 2:26:06 PM    System.InvalidOperationException: Could not start Moles host. Please review the Test Run Errors for more information.
   at Microsoft.Moles.VsHost.Agent.HostTestAdapterDriver.EnsureHostAdapter()
   at Microsoft.Moles.VsHost.Agent.HostTestAdapterDriver.Microsoft.VisualStudio.TestTools.Execution.IBaseAdapter.Run(ITestElement testElement, ITestContext testContext)
   at Microsoft.Moles.VsHost.Agent.MolesAgentAdapter.Run(ITestElement testElement, ITestContext testContext)
</code>
My fuslogvw was empty and did not identify any errors during assembly loading.
I found the same blog as user2768132 that mentioned removing the .exe.config file from privateassemblies folder under VS2010 IDE folder.  I did that and it didn't fix my problem either.
I believe the tests are 32 bit.  With that said, I attempted SouthShoreAK's suggestion of editing the test settings to 64 bit and adding the bitness line to the bottom of the AssemblyInfo.cs file.  Unfortunately, that didn't solve my problem either.  The simple tests that originally passed would fail and the unit test requiring Moles would error saying that Moles cannot be loaded because the key 'Moles' cannot be found.  I undid these changes and I'm back to my starting point.
Anyone have any ideas/suggestions?
Thanks,
Steve
Answer: Answer was to make sure the "Platform target" parameter was set to x86 in the Build tab of the test project's Properties.


Vectors and Matrices

Question: Mathematica makes no distinction between columns and rows. Yet, that is a BIG deal in the classroom. Does anyone have a source that explains how Mathematica manages to make every vector a list and every list a vector regardless of whether they are columns or rows? I have searched for this a lot with no success.
Comment: Maybe the following [answer](https://mathematica.stackexchange.com/a/197960/45431) by @Szabolcs suffices?
Comment: Very helpful. I see I need to brush up on Tensors. Thanks.
Comment: I just write my vectors as `1 x n` Or `n x 1` matrices as appropriate, to enforce expected behavior. The only real burp comes when you take the inner product of a row and column. The result is a `1 x 1` matrix rather than a hoped for scalar.
Answer: When you're teaching I recommend connecting vector representations explicitly to the underlying linear-algebra concepts.
A vector is an abstract concept: it is an element of a vector space. To represent it in a computer, we must define a basis set and express the vector as a linear combination of the basis-set elements. The list of coefficients in this linear combination is what Mathematica uses to represent the vector. The vector itself cannot be represented directly in a computer (except for some symbolic tensors).
Such a linear-combination expression in terms of a basis set can be done for any vector in any finite-dimensional vector space (FDVS). In this sense, vectors of any FDVS as well as vectors of its dual space (which is a FDVS as well) can all be represented as linear combinations of basis vectors. There is no intrinsic difference between how vectors of a FDVS and those of its dual space are represented.
Mathematica represents both FDVS elements and dual-space elements as lists of coefficients for the corresponding basis set.
In other circumstances, vectors and dual-space vectors are written distinctly:

MATLAB writes vectors as columns ($n\times1$ matrices) and dual-space vectors as rows ($1\times n$ matrices). This helps to distinguish them and to calculate their scalar products as matrix multiplications.
The Dirac notation of quantum physics writes vectors as kets $\lvert\psi\rangle$ and dual-space vectors as bras $\langle\psi\rvert$. This helps to recognize their identities and scalar products more easily.

Further reading: chapter 2 of my book Using Mathematica for Quantum Mechanics: A Student's Manual
Comment: I think this may be obfuscating the issue here. For a given positive integer *n*, the set of all *n*-tuples of real numbers *is* a vector space (with respect to the usual operations), and each element of this set may be represented in *Mathematica* as a simple (unnested) list.
Comment: @murray In your comment you choose a particularly simple example where the tacitly assumed basis is the set of Kronecker $n$-tuples $\{\{1,0,0,\ldots,0\}, \{0,1,0,\ldots,0\}, \ldots, \{0,0,0,\ldots,1\}\}$, and so the correspondence between an $n$-tuple and an $n$-list-of-coefficients looks trivial. I agree that in this simple case what I say borders on obfuscation. Yet in only slightly more complex cases it's crucial to remember the linear-algebra underpinning, and to remember that objects (vectors) and representations (lists) are in different categories.
Comment: By definition, a vector space consists of a set provided with an internal operation and an external operation satisfying the usual axioms. I made no assumption whatsoever about a basis! I just stated the simple, trivial-to-prove, fact that, with respect to the usual operations of addition and multiplication by scalars, the set of all *n*-tuples of reals *is* a vector space.  One immediately deduces that the *n*-tuples you list do form a basis of this vector space. (I do, though, understand the distinctions needed  in geometry among points, vectors, and covectors.)
Comment: @murray I think we agree in practice and are splitting hairs over a quasi-religious difference: is an $n$-tuple the *same thing* as its representation in a list of numbers inside the computer, or is there a trivial bijection involved? I don't mean the hair-splitting over double-precision representations vs. true real numbers; but rather the distinction between the abstract and the concrete. I am not versed enough in modern math and philosophy to stake any claims here, please take all I said with a grain of salt.
Answer: Presumably "column vector" means a matrix having 1 column.
But what is meant by "row vector" ? If it means a matrix having 1 row, then it's easy to make the distinction between row vectors and column vectors in Mathematica:
    lis = {5, -9, 7/3};

    rowvec = {lis}
(*  {{5, -9, 7/3}}  *)

    colvec = Partition[lis, 1]
(*  {{5}, {-9}, {7/3}}  *)

    Dimensions[lis]
(*  {3}  *)

    Dimensions[rowvec]
(*  {1, 3}  *)

    Dimensions[colvec]
(*  {3, 1}  *)

Note that a "row vector" such as rowvec, above, is not considered as a "vector" by Mathematica!
    VectorQ[rowvec]
(*  False  *)
    VectorQ[lis]
(*  True  *)

A trouble with many linear algebra textbooks is the failure to make a clear distinction between a simple list, on the one hand, and a row vector (as a 1-row matrix), on the other hand.

Vectors and Matrices


How much weight can a 2 inch screw in a wood stud hold?

Question: I am building some industrial style shelving for my office. Basically I need to know how much weight can one 2 inch screw in a stud hold? This will answer my question. Thanks.
Comment: You'll need to give more details on the design of your shelf and the use of the screws to determine what kind of loads the screw will be under. Load capacity caries with shear loads (i.e. like with hanging a picture), and pulling loads (i.e. leverage action of a shelf pulling the screw out of the wall). Most shelves will have both types of loads, but the design of the shelf will help determine the type of load. Also, how much of the 2" screw will be into the stud?
Comment: Two more important questions that need to be asked. What is the diameter of the screw? Is the screw installed in a correctly sized pilot hole or is it simply jam screwed into the stud. Both of these also greatly impact the answer to this question.
Comment: Another thing to consider is that you should never design a support system for a load that is calculated right up to the capability to the last screw. You should always go for 3 to 4X the rated capability of fasteners to assure the biggest safety margin. The last thing you need is for the industrial style shelving to come down on top of someone.
Comment: The other factors not being mentioned is the fact that the screw will have a piece of drywall in between it and the stud.  This will have more impact on the screw than almost any other factor.   With (less) weight now the screw has ample room to deflect down.  Conceivable the screw will be 5/8" out of stud which will have a really big bearing on how much it would hold.
Comment: Also to be taken into consideration is the quality of the screw alloy and proper tempering thereof. I've seen cheap stuff that snaps off just in the act of tightening 2" of threads into Douglas Fir and I've seen structural screws that have guaranteed published tensile and shear strength and tables that delineate the type of wood and the expected holding power.
Comment: If you use a 2 1/2 course thread in wood it will hold over 150 lbs. No problem.
Comment: Voting to close as too broad/unclear. There are several factors which can dramatically alter the answer (exponentially). Instead, the question should've involved the actual project being undertaken.
Answer: How much load a screw can hold does not depend on its length, assuming it is long enough.  Instead, the load is a function of its cross-sectional area.  A typical range for proof strength for steel is 50 to 100 kpsi (i.e., a screw with a 1 square inch cross-sectional area of steel can hold up to 50,000 to 100,000 pounds).
See here and here.
Of course, as the diameter of your screw increases, the stud is likely to fail first.
Comment: @wsw I see what you are getting at. Yes there is a limit to the screw strength. But that usually exceeds that of the pull out strength in shelving situations given the number of screws used. So typically the load it can hold is more dependent on threads and length.
Comment: Withdrawal loads are a function of screw diameter, penetration depth, and wood species. In addition the 50 kpsi etc. are ultimate strengths at which the steel undergoes non-elastic deformation. Working loads are a fraction of ultimate strength based on an appropriate factor of safety using sound engineering practice.
Comment: Ben: Hence I mentioned the proof strength to avoid going beyond the yield point.  My main point is to point out to the OP that the length of the screw does not really matter, as long as it's long enough.  Look at the other answer -- "So now we have a whole one inch actually used for support. Enough to keep things tipping over but not enough to hold anything heavier than a picture up."  As if doubling the length to 2 inches will increase the load the screw can hold.
Comment: @wsw the length of the screw *does* matter as there is typically going to be a 'pull' load in many case (if we're talking shelves supported by the wall, for instance) it's a load shared with the stud, of course.
Comment: @DA01: I disagree and I don't follow your example. If we can agree that when a screw is tightened, it is stretched under tension. However, note that the threaded part is not stretched; hence doubling the length of the threaded part will not help increase the strength of the screw.
Answer: Assuming you mean a standard #8 wood screw, and a standard office, not much. A 2 inch drywall screw will hold even less.
The first half inch of most screws are tapered and thus don't add much to it's strength. Then you need to subtract the thickness of the bracket and the drywall. So now we have a whole one inch actually used for support. Enough to keep things tipping over but not enough to hold anything heavier than a picture up. And if you overtighten it into the wood it's more of a pin than a screw.
Offices often have commercial steel-stud walls. Bad news for you as steel studs are designed to hold up drywall and nothing else. They are thin sheet metal.
"Industrial-style shelving" implies industrial-style loads. Get a self-standing model from any shipping or warehouse supplier.
And the reason drywall screws hold less weight is because they are intended for one (and only one) purpose - holding drywall to steel studs. They are hard, thin, brittle and will snap off if overloaded.
Comment: Its a #12 wood screw 2in long. I drilled a pilot hole slightly smaller. I used 3/4 galvanized floor flanges to secure my galvanized pipe which is holding the shelf. There are two screws in each flange. Into wooden studs. 3 supports per shelf, so thats 6 screws. It doesn't need to hold much. Id say 50 to 100lbs would be more than enough
Comment: Back them out and get some 4 inch #12 screws. Predrill deeper and set them properly (don't overtighten with a big drill) and you should be fine. (you are quite sure you hit the middle of the stud? 1/4 inch from the edge won't hold much)


Why is it valid to always use the particle in a box model in density of states calculations?

Question: Suppose we would like to calculate the density of states of some 3-D system given the dispersion relation $\omega = f(k)$. In every such example I have come across (for instance, with phonon dispersion), we use the fact that the k-space density of states is $D(k) = \frac{\pi^3}{V}$, where V is the volume of the system. From this, we can find $D(\omega)$ as usual. My question is why the expression $D(k) = \frac{\pi^3}{V}$ is always valid, since this expression comes from assuming that the system behaves like a particle in a box with hard wall boundary conditions and applying the associated quantisation on $k$. I have read that the density of states does not depend on the shape of the system and so such an assumption is valid, but I do not see why this is true, or why the constant $k$-space DOS should hold for more complicated systems.
Answer: The density of states does depend on the situation. There are two issues: potential energy, and averaging.
The particle in a hard-wall box model is suitable for cases where the particles move freely, without any potential energy function except at the walls. This is accurate in free space and a good approximation for phonons in solids. For some of the states of electrons in crystalline solids it is quite accurate under certain approximations. However for a cloud of particles in another type of potential well, such as a harmonic potential for example, the density of states function will be different. It will depend on the potential.
Next, on averaging. The statement $D(k) = \pi^3 / V$ is a statement about the average density (in the hard wall box model) after averaging over a region in $k$ space large enough to contain many states. Really the density of states is sharply peaked at certain $k$ values, and zero in between. The details of exactly where the states lie does depend on the shape of the box. But if the box is large and one is averaging over many states, then these details do not affect the average.
For a cavity of finite size, on the other hand, things go differently. This may or may not be important, depending on the temperature. For example, the spectral energy density of cavity radiation does differ from the Planck form, when the wavelength becomes comparable to the dimensions of the cavity. Indeed, for flat cavities at low temperature you can treat the cavity as two-dimensional instead of three-dimensional, on the argument that the modes in the small dimension are not excited. This argument requires that one brings in the discreteness of the modes.


Download all JAVA updates per version

Question: Gentlemen, I need to download all updates of a specific version of Java Runtime Environment (ie, I need to download, jre6u1, jre6u2.....jre6u37, etc), I order to test different versions on a deployment.  Any suggestions on how to do a batch download of these?
Answer: I think you have no choice but to go the Java Archive and download them manually.
You could try to use a plugin like Metalink Downloader for Google Chrome or DownloadThemAll for Firefox.

Download all JAVA updates per version


How to design an optocoupler circuit for raspberry pi

Question: I want to give sensor pulse to raspberry pi. The sensor signal comes from a running conveyor . The sensor gives 24v signal hence I used a optocoupler to convert the 24v to 3.3v . How should I design a best optocoupler suitable for PI.
Comment: 1. It sounds like what you did should work.  2. There is a stackexchange raspberry pi web site. 3. Unless there is a reason to use the existing signal, I would have used a magnetic pick up for several reasons.
Comment: Are you looking for a specific optocoupler to use or a circuit design that would do what you're after? Showing what you already have so far is a good start to getting a good answer
Answer: It seems your problem is that you have a 24 V signal that you want to get into a 3.3 V digital input.
Since the signal is coming from some industrial equipment, I agree that opto-isolating it is a good idea.  So here is what you do:
Pick a opto-coupler.  Just about any will do since you seem to have plenty of input voltage and presumably current available.  Use whatever your company already has in stock.  If you don't already have something available, check out the FOD817 family.  They are cheap, widely available, and have good CTR.  They aren't for high speed applications, but should be instantaneous for a signal from a conveyor belt.
Read the datasheet.
Look at what kind of digital input is available.  The best would be one that has a internal pullup, because then you need not other parts than the opto itself on the digital side.  If all you have is a regular digital input, then you have to supply your own pullup resistor.  10 kΩ is usually a good value for such things.
Either way, find how much current the opto has to sink to pull the digital input low.
Divide the minimum required pulldown current by the minimum guaranteed CTR (current transfer ratio).  Now at least double that.  This is current you want to drive the input of the opto with.
Check the specs for the 24 V signal and verify it can source the current computed in the previous step, with some margin.  I'll assume it can.  If it can't, you'll have to get more clever and the solution isn't as simple as hooking up a opto-isolator.
Look at the minimum guaranteed signal voltage (24 V nominal might only be 22 V min guaranteed, for example), and subtract off the maximum LED voltage from the opto datasheet.  This is the minimum voltage that will be across the resistor.
Use Ohm's law to calculate the maximum allowed resistor in series with the LED on the opto's input side.  Go one or two standard values down from that, or some value you already stock that is a bit lower than the calculated value.
Connect everything up.  Put the opto physically close to the digital input it drives.  In other words, the long pair of wires should be between the conveyor and the opto, not the opto and the digital board.
Answer: Does your sensor toggle between 0V and 24V with each impulse? Are the GNDs connected? You don't need an optocoupler then but can use a much simpler circuit:

simulate this circuit – Schematic created using CircuitLab
How does this work? Easy, the +24V from the input don't ever reach the Raspberry Pi GPIO port. Only the 0V do. Your impulses toggle between 0V and 24V, remember? When the sensor outputs 24V, the diode is non-conducting and thus, the GPIO is pulled to 3.3V by the resistor. When the sensor outputs 0V, the diode is conducting and the GPIO is pulled to 0.4V by the sensor.
Depending on your Raspberry Pi GPIO pullup setup, you may even leave out R1.
Comment: I like the simplicity. What possible drawbacks are there with using this setup? (Safety/stability, etc). Perhaps a cap should be used as a filter?
Comment: The biggest drawback is you need connected GNDs. When your sensor is on a thin 10m+ cable and/or draws a lot of power through a combined sensor/power cable, you may have a noticeable ground shift which makes it impossible to pull the input to 0V. You have to check this. You have to make sure GND isn't connected to PE at the sensor (not even as noise filter caps) as this will create a ground loop. A 1nF..10nF filter cap may be applied from GPIO to GND. Lower caps aren't useful, higher may irritate the GPIO because of the slope. You need an additional Schmitt trigger then.
Answer: if the sensor generate high speed pulses use high speed optocouplers 6N137


$\int_{0}^{\frac{\pi}{4}}\frac{\tan^2 x}{1+x^2}\text{d}x$ on 2015 MIT Integration Bee

Question: So one of the question on the MIT Integration Bee has baffled me all day today $$\int_{0}^{\frac{\pi}{4}}\frac{\tan^2 x}{1+x^2}\text{d}x$$ I have tried a variety of things to do this, starting with
Integration By Parts Part 1
$$\frac{\tan x-x}{1+x^2}\bigg\rvert_{0}^{\frac{\pi}{4}}-\int_{0}^{\frac{\pi}{4}}\frac{-2x(\tan x -x)}{\left (1+x^2 \right )^2}\text{d}x$$ which that second integral is not promising, so then we try
Integration By Parts Part 2
$$\tan^{-1} x\tan^2 x\bigg\rvert_{0}^{\frac{\pi}{4}}-\int_{0}^{\frac{\pi}{4}}2\tan^{-1} x\tan x\sec^2 x\text{d}x$$ which also does not seem promising
Trig Substitution
$x=\tan\theta$ which results $$\int_{0}^{\tan^{-1}\frac{\pi}{4}}\tan^2 \left (\tan\theta\right )\text{d}\theta$$ which I think too simple to do anything with (which may or may not be a valid reason for stopping here) I had some ideas following this like power reducing $\tan^2 x=\frac{1-\cos 2x}{1+\cos 2x}$ which didn't spawn any new ideas. Then I thought maybe something could be done with differentiation under the integral but I could not figure out how to incorporate that. I also considered something with symmetry somehow which availed no results. I'm also fairly certain no indefinite integral exists. Now the answer MIT gave was $\frac{1}{3}$ but wolfram alpha gave $\approx$ .156503. Note
The integral I gave was a simplified version of the original here is the original in case someone can do something with it $$\int_{0}^{\frac{\pi}{4}}\frac{1-x^2+x^4-x^6...}{\cos^2 x+\cos^4 x+\cos^6 x...}\text{d}x$$ My simplification is verifiably correct, I'd prefer no complex analysis and this is from this Youtube Video close to the end.
Comment: Your bounds on the integral with trig sub should be $[0,\arctan(\frac{\pi}{4})]$. It is true $\tan (\frac{\pi}{4})=1$ but $\arctan(\frac{\pi}{4}) \neq 1$.
Comment: That is true, but at this point it doesn't matter lol @AhmedS.Attaalla
Comment: I cannot find the link now, but I'm pretty sure this integral was discussed here on Math.SE last Autumn. I don't remember the outcome of that discussion, though.
Answer: There must be some problem here.  Note that on $[0, \pi/4]$, $$\frac{\tan^2 x}{1+x^2} \le \frac{\tan^2 x}{1 + 0^2} = \tan^2 x,$$ therefore the definite integral is bounded above as follows:  $$0 \le \int_{x=0}^{\pi/4} \frac{\tan^2 x}{1+x^2} \, dx < \int_{x=0}^{\pi/4} \tan^2 x \, dx = 1 - \frac{\pi}{4} < \frac{1}{3}.$$  Mathematica is correct; the definite integral cannot be $1/3$.  I also watched the YouTube video (see time stamp 1:34:34), and you have transcribed the question correctly and performed the correct algebraic transformations.
Okay so at 1:39:04 they reveal the answer as $1/3$.  This is very, very obviously wrong.  The very first thought to enter my mind was to check the reasonableness of the result by choosing an appropriate bound.
Interestingly, one contestant at 1:38:42 answers with $\pi/16 \approx 0.19635$ which is remarkably accurate for a last-moment guess, certainly much closer to the mark than the official answer!
Comment: Incidentally, $\frac13$ is a factor in the symbolic value of the modified integral where we replaced $\tan$ with $\arctan$: $$\int\limits_0^{\frac\pi4}\frac{\arctan^2 x}{1+x^2}=\frac13\arctan^3\frac\pi4.$$
Comment: For what it's worth, I attended a different "Institute of Technology," at which, I should imagine, mistakes like this are not so easily made....
Comment: If it exists, *Mathematica* is not able to find a symbolic expression for its value.  And I can count on one hand the number of definite integrals that I can evaluate that it cannot.
Comment: @JamalS A very simple example is $$\int_{x=0}^{\pi/2} \frac{dx}{1+\tan^{\sqrt{2}} x} = \frac{\pi}{4}.$$
Comment: Your comments have a good amount of humor. +1 for the answer and some of your comments.
Comment: I personally think that the top tangent should've been an arctan which would make this significantly easier
Comment: @TehRod Yes, but given the **original** integral as shown in the video, there is no subtle modification of that integrand that would lead to it simplifying into $\tan^{-1} x/(1+x^2)$ or something of that nature.  I can't think of any way to make a minor change to that integrand that would give you an answer of $1/3$.
Comment: haha, so this cannot be integrated at all correct?
Comment: @heropup Out of curiosity, what is an integral you can evaluate symbolically that *Mathematica* can't? :)
Comment: Spreadsheet approximation, midpoint rule, 100 slices, is about 0.2
Comment: @JPhy Many contour integrals and nasty real integrals here on MSE have been beyond the abilities of Mathematica
Answer: This is not the whole answer to this question but it is something new that wasn't mentioned here so I thought I would post it. Let us denote the unknown integral by $J$. Then substituting for $y= \tan(x)$ we get:
\begin{equation}
J = \int\limits_0^1 \frac{y^2}{1+\arctan(y)^2} \cdot \frac{1}{1+y^2} d y =
\int\limits_0^1 \frac{1}{1+\arctan(y)^2} d y - \int\limits_0^1 \frac{1}{1+\arctan(y)^2} \cdot \frac{dy}{1+y^2}=
\left(\sum\limits_{n=0}^\infty (-1)^n \int\limits_0^1 \arctan(y)^{2 n} d y\right) - \arctan(\frac{\pi}{4})
\end{equation}
Now, clearly the series converges which follows from the estimate $\arctan(y) < y$ for $y\in(0,1)$. Integrating by parts we have:
\begin{eqnarray}
\int\limits_0^1 \arctan(y)^2 d y &=& (\frac{\pi}{4})^2+ \frac{\pi}{4} \log(2) - G \\
\int\limits_0^1 \arctan(y)^{2 n} d y &=& \cdots
\end{eqnarray}
where $G$ is the Catalan constant. Now, of course the real challenge is to calculate the last integral above in closed form. This requires more work. However I have a feeling that this integral can be reduced to poly-logarithms for arbitrary values of $n$ and as such does have a "closed form".
We use the following identities:
\begin{eqnarray}
 [\arctan(y)]^2 &=& \frac{1}{2} \sum\limits_{n=0}^\infty (-1)^n \frac{(y^2)^{n+1}}{n+1} \cdot \left( \Psi(-1/2) + \Psi(n+3/2)\right) \\
&=& -\frac{1}{4} \log ^2\left(\frac{y+i}{y-i}\right)+\frac{1}{2} i \pi  \log \left(\frac{y+i}{y-i}\right)+\frac{\pi ^2}{4}
\end{eqnarray}
Now, raising the identity above to the $n$th power and integrating we readily see that the only non-trivial integral we are dealing is, is the following:
\begin{eqnarray}
{\mathcal A}_n &:=& \int\limits_0^1 [\log(\frac{x+\imath}{x-\imath})]^n dx \\
&=& (-2 \imath) \int\limits_{-1}^{\imath} \frac{ [\log(u)]^n}{(1-u)^2} d u \\
&=&(-\imath)(\imath \pi)^n + (1+\imath) (\imath \frac{\pi}{2})^n + \\
&&(-\imath)n! (-1)^n \left((\log(2)+\imath \frac{\pi}{2}) 1_{n=1} + 2(S_{1,n-1}(2) - S_{1,n-1}(1-\imath)) 1_{n > 1}\right)
\end{eqnarray}
where the path in middle integral is a quarter of a unit circle starting at $-1$ and ending at $\imath$. The quantities $S_{1,n-1}()$ in the bottom formula are the Nielsen generalized poly-logarithms. Here $n\ge 1$. Combining the two identities above we obtain the following identity :
\begin{eqnarray}
&&\int\limits_0^1 \arctan(y)^{2 n} dy = \\
&&
 \left(\frac{\pi^2}{16}\right)^n + \\
&&  Re\sum\limits_{0\le p_1 \le p_2 \le n}
\frac{n! (2(p_2-p_1)+n-p_2)!}{p_1! (p_2-p_1)!(n-p_2)!}
\left(\frac{\pi^2}{4}\right)^{p_1} \left(\frac{1}{4}\right)^{p_2-p_1} \left(\frac{\pi}{2}\right)^{n-p_2} \cdot \\
&&
\left(
0 \cdot 1_{n+p_2-2 p_1=0} +
(\log(2)) \cdot 1_{n+p_2-2 p_1=1} +
2 (-\imath)^{n+p_2-2 p_1+1}
(S_{1,n+p_2-2 p_1-1}(2) - S_{1,n+p_2-2 p_1-1}(1-\imath)) \cdot
1_{n+p_2-2 p_1>1}
\right)
\end{eqnarray}
valid for $n=1,2,\cdots$. This concludes the calculation.
Comment: $\int\limits_0^1 \arctan(y)^{2 n}\, dy$ are not too bad at all. Nice solution.
Answer: To avoid the use of complex analysis as done above by @Przemo, could one simply use taylor series expansions and Cauchy products to obtain:
\begin{array}{rcl}
\displaystyle{\int_0^{\frac{\pi}{4}}\!\!\frac{\tan^2\!x}{1+x^2}dx} & = & \displaystyle{\int_0^{\frac{\pi}{4}}\!\!\tan^2\!x\left(1-x^2+x^4-x^6+\cdots\right)dx} \\[5mm]
& = & \displaystyle{\int_0^{\frac{\pi}{4}}\!\!\tan^2\!x\left(\sum_{k=0}^{\infty}(-1)^kx^{2k}\right)dx} \\[5mm]
& = & \displaystyle{\int_0^{\frac{\pi}{4}}\!\!\left(\sum_{k=0}^{\infty}\frac{B_{2k+2}(-4)^{k+1}(1-4^{k+1})}{(2k+2)!}x^{2k+1}\right)^{\!\!2}\left(\sum_{k=0}^{\infty}(-1)^kx^{2k}\right)dx} \\[5mm]
& = & \displaystyle{\int_0^{\frac{\pi}{4}}\!\!\left(\sum_{k=0}^{\infty}\sum_{l=0}^k\frac{B_{2l+2}B_{2k-2l+2}(-4)^{k+2}(1-4^{l+1})(1-4^{k-l+1})}{(2l+2)!(2k-2l+2)!}x^{2k+2}\right)\left(\sum_{k=0}^{\infty}(-1)^kx^{2k}\right)dx} \\[5mm]
& = & \displaystyle{\int_0^{\frac{\pi}{4}}\!\!\sum_{k=0}^{\infty}\sum_{l=0}^k\sum_{m=0}^l\frac{B_{2m+2}B_{2l-2m+2}(-4)^{l+2}(1-4^{m+1})(1-4^{l-m+1})}{(2m+2)!(2l-2m+2)!}(-1)^{k-l}x^{2k+2}dx} \\[5mm]
& = & \displaystyle{\sum_{k=0}^{\infty}\sum_{l=0}^k\sum_{m=0}^l\frac{B_{2m+2}B_{2l-2m+2}(-4)^{l+2}(1-4^{m+1})(1-4^{l-m+1})}{(2m+2)!(2l-2m+2)!}(-1)^{k-l}\int_0^{\frac{\pi}{4}}x^{2k+2}dx} \\[5mm]
& = & \displaystyle{\sum_{k=0}^{\infty}\sum_{l=0}^k\sum_{m=0}^l\frac{B_{2m+2}B_{2l-2m+2}(-4)^{l+2}(1-4^{m+1})(1-4^{l-m+1})}{(2m+2)!(2l-2m+2)!}(-1)^{k-l}\frac{\frac{\pi}{4}^{2k+3}}{2k+3}} \\[5mm]
\end{array}
Answer: Six years too late but just for the fun of approximations
Knowing the series expansion of the integrate, it is simple to build $P_n$, the $[2n+2,2n]$ corresponding Padé approximant.
$$P_n=x^2\,\frac{1+\sum_{k=0}^n a_k\,x^{2k}}{ 1+\sum_{k=0}^n b_k\,x^{2k}}$$ which can in turn write
$$P_n=\frac{a_n}{b_n} x^2\frac{\prod_{k=0}^n (x^2-r_k) } {\prod_{k=0}^n (x^2-s_k) }$$ Now, partial fraction decomposition and integration for closed form approximations. For example
$$P_1=x^2\,\frac{1+\frac 95 x^2 } {1+\frac {32}{15} x^2 }$$
$$I_1=\frac{3}{8192}\left(50 \pi +12 \pi ^3-25 \sqrt{30} \tan ^{-1}\left(\pi\sqrt{\frac{2}{15}}    \right)\right)$$
Some decimal representation of results for
$$I_n=\int_0^{\frac \pi 4} P_n\,dx$$
$$\left(
\begin{array}{cc}
n & I_n \\
 0 & 0.1614910 \\
 1 & 0.1509670 \\
 2 & 0.1565241 \\
 3 & 0.1565032 \\
\end{array}
\right)$$
Answer: In terms of the derivatives of the digamma function $\psi$ and the incomplete beta function $B$ we have
$$
\int_0^{\pi/4}\frac{\tan^2x}{1+x^2}dx
=\int_0^{\pi/4}\frac{1}{1+x^2}\left[
\sum_{k=1}^{\infty}
\frac{2 \psi ^{(2 k+1)}\left(\frac{1}{2}\right)}{\pi^{2k+2}(2 k)!}x^{2 k}
\right]dx\\
=\sum_{k=1}^{\infty}
\frac{2 \psi ^{(2 k+1)}\left(\frac{1}{2}\right)}{\pi^{2k+2}(2 k)!}
\int_0^{\pi/4}\frac{x^{2k}}{1+x^2}dx\\
=\sum_{k=1}^{\infty}
\frac{2 \psi ^{(2 k+1)}\left(\frac{1}{2}\right)}{\pi^{2k+2}(2 k)!}
\left(-\frac{i}{2} (-1)^k B_{-\pi^2/16}(k+\frac{1}{2},0)\right)\\
=-i\sum_{k=1}^{\infty}
\frac{(-1)^k\psi ^{(2 k+1)}\left(\frac{1}{2}\right)}{\pi^{2k+2}(2 k)!}
B_{-\pi^2/16}(k+\frac{1}{2},0).
$$
This sum converges rapidly: for large $k$, each term is about $1/4$ of the preceding term.
Summing the first few terms, we see that the result is definitely not $\frac13$: in Mathematica (see also here),
<code>-I Sum[(-1)^k PolyGamma[2k+1, 1/2] Beta[-π^2/16, k+1/2, 0]/(π^(2k+2) (2k)!), {k, 30}] //N
(*    0.15650324569956275` - 3.530585719508859`*^-17 I    *)
</code>
Answer: Let $f(x)=\tan x-x=\sum_{n=2}^\infty a_nx^{2n-1}$ where $a_n=\frac{(-1)^{n-1}2^{2n}(2^{2n}-1)B_{2n}}{(2n)!}$ and $B_{2n}$ is the $2n$-th Bernoulli number. Then $f'(x)=\tan^2 x=\sum_{n=2}^\infty (2n-1)a_nx^{2n-2}$. Hence,
$$\int_0^{\pi/4}\frac{\tan^2x}{x^2+1}dx=\sum_{n=2}^\infty (2n-1)a_nb_n$$
where
$$b_n=\int_0^{\pi/4}\frac{x^{2n-2}}{x^2+1}dx.$$
Comment: Oh, hey Bob.  I wish you would spend a little more time getting the Xists to arrive and a little less time doing integrals on math.stackexchange!
Comment: @StevenGubkin What about MK-theory?
Comment: I don't know anything about MK-theory
Comment: Better not know. Less computation. More words.
Answer: I read that in the final of this competition only four minutes are given for one integral.
It is madness to try to calculate the given integral in that time.
Since the competition takes place at MIT then i suppose that simple approximations to get quick estimations of integrals is approved.
In given case let's use the very crude  but the simplest approximations to approximate the integrand.
$$\tan x \approx \frac{4x}{\pi}$$
$$\frac{1}{1+x^2}\approx 1-\frac{4\pi x}{16+\pi^2}$$
$$0\leqslant x \leqslant  \frac{\pi}{4} $$
They are chosen in such a way that the errors they cause are directed oppositely and partially these errors cancel one another out.
i.e.
$$\tan x < \frac{4x}{\pi}$$
$$\frac{1}{1+x^2} > 1-\frac{4\pi x}{16+\pi^2}$$
Then simple integration gives
$$I\approx \frac{\pi}{48} \frac{64+\pi^2}{16+\pi^2}=0.1868...$$
The exact value of the original integral is $I=0.1565...$ so that the deviation from the exact value is about $0.03$
So we avoided the complicated computations and still gain insight into the  value of the given integral.
There was a desire to use complex analysis to calculate this integral.
I think that if it is possible, then at the cost of very complicated calculations.


Identifying all unix commands from a file

Question: I need to scan through a file which has some unix shell commands and its output. I need to extract the list of unix commands mentioned throughout the file and list them down onto a different file. One way to achieve it to scan through the file for some specific list of commands and if present to redirect them to a different file. But this gets difficult as the list kept growing. Any other ideas in this line.
TIA
Comment: Can you give an example of the file's contents? Is it just the output of the `script` command? If each command is preceded by a prompt string, then it's fairly easy to extract the commands, although it won't be perfect.
Comment: Assuming that what you want is to determine which commands an arbitrary script can invoke during its execution, a correct implementation of this is provably impossible if you need it to cover all the corner cases (including `eval` usage). What are the real-world design constraints and requirements, so we can figure out if a good-enough implementation exists (and whether it will *actually* be good enough)?
Comment: ...if you could clarify the question enough that we don't need to make assumptions about what it is you are or are not asking for, that would be helpful.
Comment: An example file would be something like -
>pwd
/bin/dir1
>date

>echo "hi"
hi. In this case I want my script to scan through this file and identify that three unix commands are used in this file and save those commands onto a new file.
Comment: So whatever the file contents, ignoring the rest only the unix commands should be identified. and either copy the command alone onto a different file or simply copy the whole line onto a different file.
Answer: You can get a list of all commands available in bash with compgen. If you want to use a whitelist approach, you could store the output of compgen -ac (aliases and commands) in a file and then check each token in your input file against that list.
More details on usage of compgen can be found on this answer.
Comment: Hmm. The way I read it, the OP is trying to figure out which commands can possibly be invoked during a specific script's execution (as via textual/static analysis of that script), as opposed to which commands exist on the system -- but the question is indeed a bit ambiguous here.


Deleted answer to question 348196

Question: I'm wondering why my answer to
How do I enable Ubuntu (using full disk encryption) to call LUKSsupend before sleeping/suspending to RAM?
was deleted and if it could be considered for restoration. I thought that there was enough information there that at the very least it could be used as a framework for a Community answer. As it is there is currently no answer whatsoever.
Answer: Bold links in this post point to pages associated with the deleted answer: those pages won't be accessible to you if you're not the author of this question, a user with <=10k rep, or a moderator. I've written this answer with the intention of being clear even when those sources are inaccessible.
Originally, when posted on May 6, your answer looked like this:

You could try reaching out to the folks at https://unix.stackexchange.com/, since your trying to modify an arch script, someone there may have familiarity with both platforms or better yet, https://stackoverflow.com/

That is not an answer at all.
Subsequent content appears to have been added though editing, turning what was originally not a real answer into something that now is (but has other problems instead). You added it after the answer was deleted.
In your edits you added a large amount of text from this source. This raises a copyright problem, discussed in Oli's meta answer, and is sufficient reason not to undelete the answer in its current form.
But it couldn't have been deleted originally for that reason, because the copied content hadn't been added at that time. It was deleted because it was not actually an attempt to answer the question, even partially. See Why and how are some answers deleted? for more information.
Answer: It was copypasta. You took content that wasn't yours and posted it all. Our Terms and Conditions require you to grant copyright licenses on your content to SE in order for them to be able to republish it. In order to do that you need to own it (or have certain privileges over it). This is all covered in section 3 but the pointy bit is:

Subscriber (you) warrants, represents and agrees Subscriber has the right to grant Stack Exchange and the Network the rights set forth above.

As far as we can tell, you don't. The content isn't explicitly licensed in a way that suggests it's re-distributable under CC-BY-SA 3.0 and there's nothing to suggest it's yours.
And the cherry on top (though legally and topically irrelevant), you didn't reformat the code samples.
Comment: [Nope, other way around](http://www.templetons.com/brad/copymyths.html). Copyright is implicit since 1989, regardless of notice or registration. If somebody wants to relinquish rights over something, they have to do it explicitly.
Comment: Ahh. I did note the source and there was no copyright notice on the page. It appears that my assumption was that a lack of copyright indicated public domain. Is that incorrect?
Comment: I should have studied law... thanks

Deleted answer to question 348196


Is there such a thing as a work meter to measure work?

Question: I know there are devices to measure power (e.g., dynamometers) but I can't think of any example of a device that measures work directly. Is there such a thing?
Comment: https://commons.wikimedia.org/wiki/File:Joule_Apparatus.jpg
Answer: Several things that we don't normally think about as "work meters" effectively measure work.
For instance, if you marked a spring scale with energies instead of forces, you would have a device that measures work done to it.
Answer: An old method to measure mechanical work is the Prony brake. One measures with a spring balance the torque $T_p$ exerted by an immovable lever with an adjustable brake on a rotating axis (e.g. of a motor) and then counts the number of turns of the axis. The torque already has the dimension of work. The work performed by $n$ turns of the axis is given by $$W=2\pi n T_p$$ In this method, the mechanical work is transformed into heat generated by the friction of the brake.
Answer: If you've ever lifted an object on a pulley, the height of the object functions as a 'work meter'.
Another way to measure work is to convert the energy to heat and measure a temperature rise, which is the principle behind calorimeters.
A third method is to indirectly use chemistry. You can calculate the total energy released by a battery given the energy released in each individual reaction. Similarly, you can loosely estimate how much work a human is doing by seeing how much $\text{CO}_2$ they exhale.
Answer: I'm having trouble thinking of many things that measure "directly" in general.
The best examples I can think of would be length measurements; but even that is a convoluted physical process involving the comparison of light reflections that humans just happen to be really good at.
I'd say a dynamometer isn't very direct either.  They usually measure torque and RPM, or some other variables that can be converted to work.
Basically, measurement is giving mathematical value to something physical.  It's hard (impossible?) to make any measurement without a medium.
Answer: Note that to know work, you must measure a flow variable, an effort variable, and a time variable. I know of no measurement device that can capture all three "directly" i.e., in a single measurement.
But in the electrical realm, a work meter is called a watt-hour meter and there's one sitting on the outside of your house, which furnishes the basis for your monthly power bill.
And in the mechanical realm (specifically, steam power) there is a device called an indicator in which the stroke displacement of a piston in a steam engine is drawn onto the x-axis of a piece of chart paper while the steam pressure above the piston is drawn onto the y-axis. the area under the curve is an analog representation of the work done per stroke.


Trigonometric Substitution

Question: I am having some difficulty with a homework question and would like to ask for some help. The question that I do not understand reads: "Use the substitution $x=6\sin(t)$ to evaluate the integral $\sqrt{36-x^2}dx.$" I understand I need to substitute the $x^2$ with $(6sin(t))^2$, so that the integral is  $\sqrt{36-6\sin(t)^2}dx$ but I am not sure what to do from there.
Comment: Don't forget that you also have to express $dx$ as a function of $dt$.
Answer: If you let $x=6\sin(t)$, then $x^2$ becomes $36\sin^2(t)$ not $6\sin^2(t)$.  From here you will get $\sqrt{36-36\sin^2(t)}$
Answer: Note that $dx=6\cos tdt$ and so
$$\int \sqrt{36-36\sin^2t}\cdot 6\cos tdt
\\=36\int \cos^2tdt$$ then use the double angle rule. To go back to $x$ draw a right angle triangle with sides $x,6$ and angle $t$ satisfies  $x=6\sin t$
Answer: Take the integral:
 integral sqrt(36-x^2) dx
For the integrand sqrt(36-x^2), substitute x = 6 sin(u) and  dx = 6 cos(u)  du. Then sqrt(36-x^2) = sqrt(36-36 sin^2(u)) = 6 cos(u) and u = sin^(-1)(x/6):
  =  36 integral cos^2(u) du
Write cos^2(u) as 1/2 cos(2 u)+1/2:
  =  36 integral (1/2 cos(2 u)+1/2) du
Integrate the sum term by term and factor out constants:
  =  18 integral 1 du+18 integral cos(2 u) du
For the integrand cos(2 u), substitute s = 2 u and  ds = 2  du:
  =  9 integral cos(s) ds+18 integral 1 du
The integral of cos(s) is sin(s):
  =  9 sin(s)+18 integral 1 du
The integral of 1 is u:
  =  9 sin(s)+18 u+constant
Substitute back for s = 2 u:
  =  18 u+9 sin(2 u)+constant
Apply the double angle formula sin(2 u) = 2 cos(u) sin(u):
  =  18 u+18 sin(u) cos(u)+constant
Express cos(u) in terms of sin(u) using cos^2(u) = 1-sin^2(u):
  =  18 u+18 sin(u) sqrt(1-sin^2(u))+constant
Substitute back for u = sin^(-1)(x/6):
Answer:
 |   =  1/2 sqrt(36-x^2) x+18 sin^(-1)(x/6)+constant

Trigonometric Substitution


Is it possible to generate internal reset pulse in verilog with machxo3lf fpga?

Question: I have a board without Reset input for my design. But I need to reset at fpga startup.
Is there a verilog solution to generate this pulse ?
Comment: What does the FPGA's data sheet say about resets?  That's the first place you should look.
Answer: The datasheet on MachXO says that

The MachXO registers in PFU and sysI/O can be configured to be SET or
  RESET. After power up and deviceconfigured, the device enters into
  user mode with these registers SET/RESET according to the
  configuration set- ting, allowing device entering to a known state for
  predictable system function.

Therefore, the simplest thing you can do is to configure all regs that need to be initialized with initial verilog construct or the equivalent understood by the tools.
If you still need a 'traditional' reset pulse, you can do it like this:
reg [3:0] rst_cnt;

wire rst_n = rst_cnt[3];

initial rst_cnt=4'd0;

always @(posedge clk)
if( !rst_n )
    rst_cnt <= rst_cnt + 4'd1;

This code again relies on the ability to set initial (power-on) values for the flipflops of MachXO.
Comment: In fact, that does not work in fact : "WARNING - CG532 :[...] |Within an initial block, only Verilog force statements and memory $readmemh/$readmemb initialization statements are recognized, and all other content is ignored."
Answer: I finally found the solution thanks to lvd and tom-carpenter. Many FPGA can initialize there registers to 0 and nothing else. It's the case of machxo3.
Then doing that works for me:
reg [3:0] rst_cnt = 0;
wire rst_n = rst_cnt[3];

always @(posedge clk)
if( !rst_n )
    rst_cnt <= rst_cnt + 1;

Initial statement is ignored by lattice synthesis toolchain (even with synplify) if it's not a «force» or a memory initialization.


how to re-map a keyboard key/

Question: the shift key in my keyboard has stopped working.(mechanical problem)
so, is there a way so that I can make windows think like (caps-button) is new shift button.
I'll buy a new keyboard ASAP but I need to do some urgent work that's why.
Answer: You can use SharpKeys to do this on Windows. Remapping Caps Lock to Shift is even one of the examples.
Answer: Props to Darth Android for the quick and simple (and correct for your situation) solution, but for completeness sake, you can also modify the registry to include a scancode map.
Basically you'll add a Scan Code binary key to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout
Format for it is:
00000000 -Header (all zeros)
00000000 -more all zeros
0x000000 -Where x is the number of changes +1
xxxxyyyy -Where x is the scan code, and y is the key your remapping it to.
00000000 -Null entry to show the end

So for instance:
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,A0,00,5B,00,00,00,00,00

Would change your left shift (00A0) to map to your left windows key (005B)
There's a much deeper, in depth article on Experts Exchange if you need to go down that route for a more permanent-ish change, but I wanted to give the other option.  Still... go with Darth Android's solution for your quick fix.  :)
Comment: This actually is what SharpKeys does, IIRC. It's just a fancy GUI over building the scancode map for you and updating the registry! One of the reasons I like it so much. :)
Comment: Nice.  I may start using it myself then instead of my usual "Do I really want to have to look up the scan code and edit the registry or just ignore it?" internal monologue.  :)

how to re-map a keyboard key/


What controls the list of supported languages of an iPhone app in iTunes?

Question: What controls the languages shown as supported in an iPhone app's iTunes page (in the right side, below "Description", under "Languages")? From the iTunes Connect Developer's Guide it appears it's not something you choose during submission. I assume it's something in the bundle.
Comment: Yeah, I was wondering too why my English-only app apparently supports French, German, Spanish, and Northern Sami.
Answer: I used a technical support incident to ask this question of Apple directly. Here is the answer:
"The list of languages supported by the app, as shown in the iTunes store screenshot
you sent, is automatically determined by inspecting the submitted application bundle.
Typically, this comes from the .lproj folders in a bundle, as the process (and iOS)
use this to determine what languages the application can support.  However, it is
also possible to provide your own localization support system in the application
without using .lproj folders (although this is typically much more work) -- in
this scenario, the list of supported languages is specified in the application's plist
file, via the CFBundleLocalizations key.  See the following docs (and the guide linked
to in the docs) for more info on this:
http://developer.apple.com/library/ios/#documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html%23//apple_ref/doc/uid/TP40009249-109552-TPXREF111
"
Answer: You don't have to specify anything in iTunes Connect. They seem to scan the contents of the bundle and look at the localization subdirectories: I've got en.lproj, nl.lproj, and de.lproj in my app and iTunes lists "English, Dutch and German" as supported languages.
Comment: What if you don't do localization like that, can you just add empty directories? Do you know if there's any official spec that says this is how it works and there's no other way?
Comment: @crackers: Sorry, I don't know about that. I'm not sure if it is a good idea to do localization in a different way, since iPhone OS wouldn't let the user select his preferred language for the app then.
Comment: The problem is that the cost to experiment is high, with the whole store submission process. Maybe I could get more info by asking Apple directly (yeah, right). BTW, the app handles its own settings, so it's not a problem in this regard. Thanks for the help!
Comment: @NikolaiRuhe I know this was posted a long time ago, but I had to comment this. A good reason to do the localization in a different way is to write portable code (which makes it easier to port your app to Android and/or PC).


What do pomegranates of blue, purple and scarlet material look like?

Question: This is the 1st time I'm asking this website a question.. But what do the pomegranates in blue, purple and scarlet material look like? Are they actual pomegranates (which as far as I know, are red... Wrapped up in fabric?
Comment: Are you referring to the yarn designs in the pattern of a pomegranate, but wondering if real fruit wrapped in yarn was used instead? Exodus 39:24
They made pomegranates of blue, purple and scarlet yarn and finely twisted linen around the hem of the robe.
Answer: I believe the OP is referring to the pomegranates that form the hem of the me'il [robe] of the Kohen Gadhol [high priest]. See Exodus 28:33-34 and 39:24-26.
My understanding of these verses is the simplest, contextual meaning of what they looked like would be tassels: the blue, purple, and crimson threads that form the robe gathered and tied together. A tassel/knot with the loose ends hanging out visually resembles a pomegranate (crown pointing down).
You can actually see a reconstructed example at this website (scroll to the middle of the page) [warning: I am not endorsing this organization, their message, or their accuracy in anything except this particular example of the pomegranate tassels, which I found surprisingly well-done. The rest, not so much]:
http://www.mishkanministries.org/highpriest.php
Comment: +1 I like the replica of [Solomon's Temple](http://www.mishkanministries.org/kingsolomonstemple.php) from that site.


c# how to print AssemblyFileVersion

Question: How can I print in my log the version of the program that is running?
In other words, can I access AssemblyFileVersion using Console.WriteLine?
Thanks
Tony
Answer: It looks like something like this would work:
public static string Version
{
    get
    {
        Assembly asm = Assembly.GetExecutingAssembly();
        FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(asm.Location);
        return String.Format("{0}.{1}", fvi.ProductMajorPart, fvi.ProductMinorPart);
    }
}

From another post on SO.
Answer: // Get the version of the current application.
Assembly assem = Assembly.GetExecutingAssembly();
AssemblyName assemName = assem.GetName();
Version ver = assemName.Version;
Console.WriteLine("{0}, Version {1}", assemName.Name, ver.ToString());

More on MSDN:
Version Class
Answer: FileVersionInfo.GetVersionInfo(asm.Location) doesn't work for embedded assemblies (e.g. using Fody's Costura to ship a single EXE instead of the executable and all of it's dependent assemblies).  In which case, the following works as a fallback:
var assembly = Assembly.GetExecutingAssembly();
var fileVersionAttribute = assembly.CustomAttributes.FirstOrDefault(ca => ca.AttributeType == typeof(AssemblyFileVersionAttribute));
if (fileVersionAttribute != null && fileVersionAttribute.ConstructorArguments.Any())
    return fileVersionAttribute.ConstructorArguments[0].ToString().Replace("\"","");
return string.Empty;

c# how to print AssemblyFileVersion


Can't get border to go on all 4 sides of a screenshot in Word 2010

Question: I have inserted a screenshot, then went to Format Picture to add a border.
 It worked great for the first one, but the second one only shows the border on 3 sides.  It is not appearing on the bottom. I have tried everything but no luck.
Any thoughts?
Answer: Is the bottom of the image overflowing into the page margins? That might prevent formatting from appearing. Try to scale or crop the image down and then apply the border, if that works you will have to leave the image that way, or decrease your page margins.
Comment: Unfortunately, it is not impacted by margins, but that's a great thing to check.
Answer: I got mine to appear by right clicking on the picture, text wrap and select square.
Comment: Yes, this is an answer to the question. If you feel it's a wrong answer, downvote it, but do not recommend it to be deleted.
Answer: The missing border might just be invisible at your current display magnification but actually be there. Try zooming in and see if it appears -- or print it out and check the output.
Answer: I was able to solve this problem by making the border's line width 2pt.
For widths smaller than that (e.g., 1 or 1.5), the bottom line did not reliably appear.


Distribution of terrestrial impact craters

Question: Recently I was looking at a map of known impact structures and I noticed that they are concentrated between the tropical and arctic latitudes, but there is very little near the equator.  I can think of a couple reasons that describe some features of the map, like how the Canadian Shield is ancient, has a lot of water, and lacks dense vegetation, which makes craters easy to spot.  Perhaps the crust near the equator is younger and just doesn't hold as long a record, but I am not a geologist so I'm just speculating.  It could also be that some physical argument like the conservation of angular momentum (i.e. which might cause a bias in trajectory deflections) and/or the distribution of asteroid orbits and their relative alignment with Earth's equatorial plane would be sufficient to explain this, but I'm curious if anyone knows of a better theory?
Comment: this question might have an answer over at https://astronomy.stackexchange.com/
Comment: I agree, is there a way to cross-link questions across multiple stack exchange sites?
Comment: You might find this interesting: [*What explains the distribution of new impact craters on Mars?*](https://astronomy.stackexchange.com/questions/14304/what-explains-the-distribution-of-new-impact-craters-on-mars).
Answer: One thing to consider is, currently, there is very little above ocean land mass around the equator. The bulk of the land mass lies above the tropic of Cancer in the northern hemisphere.
The other thing to consider is plate tectonics. Apart from Antarctica, most of the land masses have moved over time, spending various amounts of time at various latitudes and the craters that do exist may not have been created where the land masses are currently located, they may been created when the land mass was elsewhere. With plate tectonics there is also the matter of crustal renewal & recycling.
Regarding the Sahara and Namib desserts there may be craters covered by deep sand.
The map you link to in your question is a very interesting map. It would be even more interesting to have a similar series of maps for the different geological ages of Earth with the craters created on each land mass during each of those ages to see where the land masses were when they were hit.
Comment: The movement of the landmasses is a good point, and a map with the continents backtracked to their rough positions in the past would probably show interesting correlations in the crater positions - maybe it would even help with positioning their ancient locations if mutliple craters were thought to have formed from the same event?


How to show the first x bytes using hexdump?

Question: I have two files and I want to see if the first 40 bytes are similar. How can I do this using hex dump?
Comment: 'Compare first N bytes' is different than 'Show first N bytes'.  Consider this NOT A DUPLICATE.
Answer: If you are using the BSD hexdump utility (which will also be installed as hd, with a different default output format) then you can supply the -n40 command line parameter to limit the dump to the first 40 bytes:
hexdump -n40 filename

If you are using the Posix standard od, you need a capital N. You might find the following invocation useful:
od -N40 -w40 -tx1 -Ax filename

(You can do that with hexdump, too, but the format string is more work to figure out :) ).
Answer: Try this:
head -c 40 myfile | hexdump

Answer: Not sure why you need hexdump here,
diff <(dd bs=1 count=40 if=file1) <(dd bs=1 count=40 if=file2)

with hexdump:
diff <(dd bs=1 count=40 if=file1|hexdump) <(dd bs=1 count=40 if=file2|hexdump)

Comment: Assuming that the files are not text files (in other words, they have various non-printing characters), then `diff` will only tell you whether the files are identical or not. Using `hd` (or `hexdump`, but `hd` is usually a friendlier format), you can tell if they are *similar*, as in the question. BTW, `dd bs=40 count=1` is more efficient, and you probably want to toss dd's byte count reports into the bitbucket (`2>>/dev/null`)
Comment: I would like to actually see them. Thanks.


Is it allowed to play a jetpack when buried?

Question: The rules state that if you are buried, you can take no other action until you dig yourself out. The jetpack card says "play at any time". Does playing a jetpack count as an action for the purposes of following the rules (albeit a free one), or do "play at any time" cards circumvent all action restrictions?
Answer: A rules faq on boardgamegeek here says you can.

Yes. While a buried player cannot take any action other than removing sand, using equipment doesn't take an action.
Answer: Since the card explicitly allows being played at any time, and cards trump general rules, I would say yes, you can play it when buried.
Thematically, buried obviously doesn't mean your entire body is covered in sand, it just means you can't move effectively due to the amount of sand.  A jetpack cancels out needing to worry about the amount of sand. =)


What is involved in taking a canoe through a lock on a major US River?

Question: Most of the locks on rivers in the United States are built for commercial traffic. like barges to navigate the river system. I know they exist and I have seen them on television, but that is all I know. Can and/or how does a person in a canoe navigate through locks on major rivers (like the Mississippi) in the US.
Comment: Not saying it's hard - it probably isn't - but that it may not be necessary. Here's an article (http://canoeacrosscanada.ca/paddle-down-the-trent-severn-waterway/) about a trip in Canada where people sometimes used the locks and sometimes portaged around them. If you set off planning to portage around them all, and then were able to go through a few, that would probably be a pleasant surprise. It's more the money/hassle that would keep me from doing it than any difficulty - going through a lock isn't difficult at all no matter how your boat is powered.
Comment: Not an expert but wouldn't you just carry your canoe around the lock?
Comment: probably your best bet is to portage around the lock. There is often a fee to use locks and you may have to wait for a large boat to come through before your turn etc.
Comment: A comment [here](http://outdoors.stackexchange.com/questions/6948/how-to-carry-a-bicycle-in-a-canoe#comment13714_6948) suggests that it is not as difficult as we imagine; leading to this question.
Comment: @Liam carrying your canoe around the lock may not be an option.  In my experience (1 lock) it is [14 miles between public access points near the lock.](http://outdoors.stackexchange.com/questions/7239)  The lock is on federal property and there is no provision for foot traffic.  Besides the legal barriers for miles on either side of the lock it physically impractical to portage, either serious risk of death, and/or trying to haul your canoe over fenced properties.
Answer: There is not a definitive guide for all locks, however most of the major locks in the US are run by the US Army Corps of Engineers, and they do not charge recreational boaters to pass through them. To my knowledge, all locks on the Upper Mississippi are accessible via paddling.
As for the Ohio river, you can try calling McAlpine lock and dam, and they'll be able to answer for sure what the situation is on the Ohio river.
To use the lock, when you approach the lock, there should be a section at the entrance of the concrete wall with a signal rope, hopefully well marked. Paddle up to the rope and pull it, and that will signal the lock operators. They'll then instruct you on what to do.
Going through locks is not a rapid operation, and priority is allocated to commercial traffic, so you may be waiting for awhile prior to entry.
See the following brochure for further info, it has information on the hazards and restricted areas surrounding locks: Locks and Rivers. I'd recommend reading that because since the locks are built where elevation drops the fastest, the pools, dams, and weirs around the locks can be deathtraps if you paddle where you aren't supposed to.
Bring rope 75 to 100 feet of rope. When you enter the lock, the lock master will lower a rope on a hook, put the center of your rope over the hook.  Your rope is placed on the rail and you payout (double) or take in rope as the water elevation changes in the lock.  When the gates open release one end of your rope and pull it all in, and you are on your way.
Some locks may both a small boat and commercial (tug boat/barge) lock. If two, the signal pull cord will be near the small boat lock.
Answer: On the Ohio in Newburgh Indiana small boats enter and pull the rope for the signal bell. You must tie off before the lock master will begin closing the lock. There is no fee for pleasure boats and you will wait for the larger traffic.