Acceptance of an answer

Question: Form Help Center:

But this happened for my answer.

Am I misunderstanding about sentence that I have specified by red line?
Answer: I think this is just a misinterpretation of the language used. The phrase:

they may not change the accepted answer

doesn't mean:

they cannot change the accepted answer

It just means:

they might not change the accepted answer

It means that even if a better answer comes along the OP isn't necessarily going to change which answer they have accepted. They may not think the new answer is better, or they may simply have abandoned the site and never returned to check for new answers.
I have had answers of mine unaccepted months or I think even years after they were originally accepted. There is no time limit for an OP to change which of the answers to their question they accept.
Comment: Thank you very much John! I think my poor English finally kills me!
Comment: @lucas - Don't blame yourself. Since questioners are allowed to change the selected answer, the cited clause (*they may not change the accepted answer*) is grammatically incorrect. I'm going to change my now deleted comment to an answer, and also ask a follow-on question (how to fix buggy Help Center pages).
Comment: That's one of my pet peeves, actually: "may" being used to indicate probability ("might") rather than permission (my not-so-favorite being signs regarding bridges' potential of ice formation). I had misunderstood the acceptance-paragraph in the same way until just now -- thankfully, the Help Center entry has since been changed.
Answer:
Am I misunderstanding about sentence that I have specified by red line?

You understood the underlined clause, they may not change the accepted answer, perfectly. That clause is in the present tense and uses may as a modal verb to denote permission (or in this case, the denial of permission). Since questioners are allowed to change the selected answer, the clause is grammatically incorrect. The clause should have been phrased in the present perfect tense rather than the present tense, and because it reflects a possibility that might or might not have happened, it should use might rather than may.
A correct rewording is they might not have changed the accepted answer.
Update
As a follow-on to this question, I asked how to suggest edits for help center pages. It was suggested that I use the "contact us" link. I did just that and suggested a rewording.
The wording at the cited Help Center page has just been changed. It now reads

Accepting an answer is not meant to be a definitive and final statement indicating that the question has now been answered perfectly. It simply means that the author received an answer that worked for him or her personally. Not every user comes back to accept an answer, and of those who do, they might not change the accepted answer even if a newer, better answer comes along later.
Comment: Thank you very much!

Acceptance of an answer


Algorithm to compute average length of a simple path

Question: Given a connected graph and two nodes s and t, there can be many different simple paths (without cycles) from s to t.  Is there an efficient algorithm to find the average length of these paths?
Comment: Are you looking for exact algorithms or are you fine with approximations of the average length? By intuition, I would say that calculating the exact average length is NP-hard (seeing as checking if there exists a Hamiltonian path is already NP-hard), but approximating it to within $[(1-\varepsilon)L, (1+\varepsilon)L]$ (where L is the solution) might be possible efficiently.
Comment: @SmeltQuake Anything would be interesting. Can Hamiltonian circuit/path really be reduced to this problem? You can certainly determine if there is at least one path between s and t in poly time.
Comment: I do not know if Hamiltonian path can be reduced to this problem. This is just an intuition about why I think the exact problem is probably NP-hard: If you cannot even determine if there exists a path of length n, calculating the average over all lengths (which also sums over the paths of length n) is probably also hard.
Comment: @SmeltQuake I understood your intuition but the reduction, if it exists, is not clear to me. Hopefully someone here will see it more clearly.
Answer: I guess you already know that a polynomial algorithm for counting the number of simple paths between two nodes would imply P=NP, this result is due to Valiant (The complexity of enumeration and reliability problems, 1979).
Now imagine, expecting to discover a contradiction, that you could compute $\text{avg}(G, u, v)$ in polynomial time.
Let $G+l$ be the graph resulting from adding a simple path of length $l$ between $u$ and $v$ in $G$. This new path is made of $l-1$ new nodes and it does not interfere with any previous path from $u$ to $v$, provided $l \geq 2$.
Then, $\text{avg}(G+3,u,v) - \text{avg}(G+2,u,v)$ = $1/(\#\text{Paths}(G,u,v)+1)$, from which you can get $\#\text{Paths}(G,u,v)$ in polynomial time. But we know this cannot be expected to be done in polynomial time, a contradiction.
Comment: "The complexity of enumeration and reliability problems" L. Valiant 1979. There are free PDFs online, sorry I can't properly cite it, I won't have my computer with me today.
Comment: Thank you. Do you know a reference for the result of Valiant?


Franke Ascona kitchen tap dripping with intermittent flow

Question: My Franke Ascona kitchen tap (only 2.5 yrs old) recently started dripping from the faucet.
Pretty sure it's the hot side that's dripping as water is tepid or room temp rather than ice cold. Dismantled and descaled both hot/cold cartridges (using vinegar solution) to be safe (we live in medium water area so do get some limescale) but has made zero difference.
Can the cartridges really need replacing after only 2.5 yrs?
The other thing confusing me is the drip isn't consistent. Sometimes it's slow & steady, sometimes it's a continuous trickle of water rather than a drip, and sometimes (rarely now) it stops altogether but the latter usually only happens immediately after running the hot tap fully open and hot for a period of time. This change of flow happens spontaneously over the day without anyone touching the tap.
Any idea what's going on?
Comment: Bad Cartridge. There literally isn't anything else in the system - sure you have a seal - but your cartridge controls the flow of hot water and cold water. Once they leak they leak ..
Comment: Thanks. Was afraid of that. Frustrating as Franke meant to be a good brand. New cartridges due in the post today so fingers crossed!
Comment: Please write up an answer indicating that you purchased replacement cartridges to fix this problem, then give yourself a check-mark for it. That will help others know that the is the solution that worked for you.
Answer: I had this problem for a while, I stripped it down cleaned the ceramic parts umpteen times still no joy.
I could push my finger onto the tap head and this would stop the drip, I read somewhere it could be the silicone rubber seal at the end of the cartridge but so many different sizes and the cost from a Franke dealer was stupid.
I decided to have one last go putting a very small ring of Plumbers Mait (correct spelling) on the end of the rubber silicone seal & brass housing (in effect making the seal fatter) and Voila! its stopped.
Now everytime I go to make a cuppa I turn the tap on & off just to make sure it wasn't a fluke, perfect everytime so chuffed with myself.
Hope this helps anyone else having the same problems.


Does mesh size affect performance/should I make my object life-size scale?

Question: All of the things I've googled regarding this issue deal with what to do when your mesh is at real life scale but is really small.
I want to make a giant creature and put it in an environment that looks tiny. Should I make the actual mesh of the monster enormous (like...hundreds of meters, as it would be if it was real?), or should I just make the trees really small (like...a few centimeters and make the monster a couple of feet?). I'm a newbie but I've heard that making the mesh real-life scale is the best practice, though I'm not sure if making a HUGE mesh would slow down the program, which is my main concern as my computer is not a super high-performance one (it's not mediocre, it's just...not made for hardcore rendering.) The materials and textures and such will be pretty simple. I'm also planning to add a depth node in compositing that will make it look like the monster is far in the distance, so I don't know if that affects anything.
Thanks in advance, and...please be gentle with me. I'm still new to the program and I'm just doing this for fun. :)
Comment: Life size could be the best practice if you are going to use physics, like gravity or objects falling apart, also camera efects (but you could fake that with a bit of imagination) goog luck
Comment: Hello :). Scale of your models doesn't affect performance, polycount and texture resolution does. Working in real life scale has many advantages, so I'd stick to that.
Answer: while using real life scale, be careful, some simulations don't work all that great because of the tiny space between meshes, so if you do a sim and it feels off, that's probably why.


Stake Pool Locations. How is the best way to obtain a list of cardano stake pools by country?

Question: I'd like to develop a list of cardano stake pools by country. A static list would be OK, but a repeatable method of developing an updated list by country would be much better. Is there a way of doing this? There are some groovy maps around like The https://input-output-hk.github.io/shelley-node-map/, but a live list by country? Pool explorers dont seem to offer it easily if at all.
Answer: In general I do not think there is a reliable way to do this.
The recommended best practice is to have the actual block producing node hidden behind two public relay nodes. If the BP and the 2 relays are in three different countries, which country are you going to assign it to?
If a pool operator says their node is for country X but they run their nodes from another country Y, which country are you going to assign it to?
Comment: Makes sense! I guess I am interested in the pools claim to be from country X. So back to the website for that - as you say not particularly reliable.
Comment: You may want to look at some of the web sites like https://pooltool.io which may have country information


How could a universal translation drug work?

Question: Rather than a machine or computer to translate things, how could a sci fi drug of some sort (such as a pill that one or both parties has to take and be under the influence of, or a gas that fills an environment) act as a universal translator and allow users to understand other species' languages by affecting their brain?
Comment: Welcome to the site blatherskiteb, we invite you to partake of our wonderful [tour] and refer to the [help] as and when you might need it. Nice job of finding the correct tags for a first post.
Comment: I was thinking instant, but if you've got a concept for it that involves a period of adjustment I'd still be interested in hearing about it
Comment: VTO clark tech clearly, and not necessarly better than just runtime translation, 7 not so bad answers, anyone who answered care to cast another 3 reopen votes, eh?
Comment: Is it supposed to be "instant", or is an adjustment/learning period allowed?
Answer: The universal translation "drug" isn't a drug.
Oh, it's administered and used like a drug, but it's actually an infusion of nanocomputers that have two functions.  Obviously, they contain the software to not only translate a large sheaf of pre-loaded languages, but to learn other languages (the more bizarre the structure of the language, the longer that will take, of course), but the second function is just as important: they also construct neural interfaces to the optic and auditory nerves and to the language centers in the brain, allowing the nanomachine network to intercept sight and sound (there's an upgraded version that can work on scent and taste as well), perform the translation (in real time, for loaded languages) and convey the translated content directly to the language centers of the brain.
Going the other way, motor nerves to the mouth, throat, and hands are interfaced (the upgraded version also assumes control of normally autonomic functions like pheromone production, as well as adding additional chemosynthesis capability for scent-based languages), so that the user "speaks" the way they're used to doing, and their voice (and hands, and optionally their entire skin) produces the language they're currently communicating in.
Don't even ask about the ethical violations in the development tree that led to this capability -- but the end result is awesome, and bugs in the process are unheard of -- it says so right here in the sales brochure.
In the unfortunate case of the user allowing their subscription to expire, the nanomachines will harmlessly (it says so right here) dissolve into simple sugars and nutrients, leaving any non-original languages (the ones they've learned in service) backed up in multiple locations against the expected result of a mere late renewal; these backups are guaranteed to last a minimum of one year.
Comment: This seems like it is the most probable. Imagining that different brains represent the same concept the same way is a bit too far-fetched for me,
so trying to transfer the concepts without passing through the language centers and having machines doing the actual translation is a bit too much
Comment: I nearly wrote the same, with the nanobots attaching to the word generation and meaning centers (Wernicke and Brocca) and some in the aliens too, which can then communicate and translate each meaning. However, it's not a drug, so I removed it (also I checked if someone had written it in the meantime).
Answer: Scientists have found that, no matter what languages they spoke, most of the test people exposed to meaningless sounds like zizi would associate them to spiky objects, while sounds like bubu would have been associated to more rounded objects (I am quoting this out of memory, so the sounds might be slightly different).
Now, let's assume because science-fiction that behind every word in every language there is a link to the "thing" signified with that word and that a rose will always be a rose also under another name, and imagine a drug which amplifies the capability of the brain to decode sounds, and let it connect the sound of a word with the "absolute substrate" out of which that word was made.
Under the influence of this drug everybody would understand that 私は魚を食べています means "I am eating a fish", because it would connect the "absolute substrates" of I, fish, eat, act of doing.
Comment: Every french speaker can back up the fact that "zizi" can be associated with "spiky objects"
Comment: That is fundamentally not how human languages work.
Comment: @Trioxidane, there is the precedent of the Babelfish
Comment: Trouble is, can this be applied across species? Aliens might not use words or even vocals. With different frames of reference we're not able to say that the aliens would feel the same. Still a good answer.
Comment: @AlexP, this is worldbuilding, not linguistic. Some leeway is admitted
Comment: The Russian language distinguishes between 'pravda' and 'istina' which are both translated into English as 'truth'.  'Pravda' and 'istina' are not interchangeable as they mean two conceptually different things. How your proposed method will work for cases like this?
Comment: `let's assume because science-fiction that behind every word in every language there is a link to the "thing" signified with that word` That is the argument of Wittgenstein's Tractatus, which I think is called the "Picture Theory". He said that each word is magically linked to its real-world referent. He abandoned this view, and I think nobody takes it seriously anymore -- although they do still study the Tractatus. I would argue that "science fiction" cannot handwave this into truth.
Answer: Temporary super enhanced language learning
Language is difficult. Even within humans we have words that don't, or are difficult to translate to another language. Even within the sake language, with dialects of big cities not far from another, I found that people can use a word as an insult or as everyday use. Interspecies it becomes so much more difficult. The way one speaks can be different, but also the importance can radically change. To learn something from the ground up takes years, just look at babies. Even if there's a basis it can take a long time. There are a 1001 things that can go wrong. A drug is near impossible to be of assistance.
Caveats out of the way, a "real" drug could work as the following:
The drugs are taken, together with a machine on the head that helps the drugs find the way to the right brain area's. The targets are word generation, word meaning, empathy and cultural understanding.
There the drug changes the DNA expression to become as neuroplastic or even more than a babies. Together with a boatload of materials and energy for nerve growing, a rapid learning process can begin. Training is preferred, but mayne it works so well you can start talking and quickly you start to understand the meanings behind it. You can extrapolate a lot from there according to some research.
Why wouldn't you use this with other parts of the brain? Huge neuroplasticity isn't what you want everywhere. Parts like the brainstem and cerebellum are better off with stability. You don't need to learn much more with heart control, digestion or vascular control. That is why you want to target specifics when needed, like with language learning.
Answer: Have a panpsychic reality, and the drug induces a shared consciousness.
If you decide to have panpsychism be a true feature of your universe, then you could use it as a ground to argue (or just handwave) for the plausibility of a conscious entity being put in such a state-of-mind that they end up picking up, sharing or leaking consciousness with their surroundings.
If your universal translation drug were instead a mind-altering drug that causes the user to receive or leak consciousness in this manner, then having two nearby sentient beings use the drug at the same time could allow them to communicate at a sort of shared-experience level, where the languages in which the thoughts are composed come packaged with their own interpretations.
Leaving it at this point would come with lots of corollaries, however, many of which could be showstoppers or add too much noise to your worldbuilding:

It would be either impossible or a really cunning trick to lie to someone using the drug.
Because of this, one might be forced to take the drug as part of an interrogation in order to obtain information.
There would probably be a thriving trade in using the drug to share experiences that are particularly valuable, or educational, or interesting, or...ahem...yes.
You probably need to worldbuild a sensible picture of the "background noise" of conscious experience of everything else in their vicinity when they use the drug (all the way down to the fundamental wave/particles; all the way up to the lower hierarchies of their own brains?) and how they filter it out.

You could perhaps overcome some of these by designing around them, such as:

Making users capable of "closing" their minds voluntarily while under the influence of the drug,
Creating side effects which would render the drug unenjoyable to use as a form of recreation,
Limiting the experiences being shared in some way (perhaps direct sensory is not shared, only "internal monologue"; perhaps you're limited to what the other entity is currently focusing on, etc.)

Could be fun. Could be too much. Hope it's helpful :)
Comment: I like the concept of Panpsychism, as it answers some questions of my own. Thank you!
Answer: ONE PILL CASE:
Each pill has several thousand nanorobots which have three basic functions:

They find and latch onto specific neurons
They can sense and produce an electric potential, taking energy from the ambient environment
They can communicate to other nanorobots via background EM Waves, ambient Wi-Fi

The nanorobots find the language center in the brain and due to previous conformal mapping of the brain's networks, they are aware where exactly in the brain they need to cross the BBB(Blood Brain Barrier) to gain access to these neural networks and attach to respective neurons (both for language processing and speech generation)
Due to the presence of free Ultra-high bandwidth Wi-fi everywhere, when they sense neural networks firing in a particular pattern which is similar to a pattern stored in the World's Linguistic Data base, they identify the language being spoken by the speaker.
The host's activation pattern of the neurons in the speech generation area is now responsible for harnessing the linguistic data from nanobots in the language processing area and utilizing the database data over Wi-Fi to control the neurons firing in the speech generation area to produce speech in the other language.
TWO PILL CASE:
The nanorobots can use background EM waves/ Wi-Fi to also send data across two hosts who are not separated by a distance over 5 meters. This data is directly transmitted between nanorobots at language processing centers which fire respective neurons upon translation, and hence this acts as telepathy.
Answer: Bioengineered semi-parasitic symbiotic bacteria
The pills contain a special bacteria, specifically for a (or several) group(s) of languages and cultures. The bacteria moves to the brain, identifying the language center. There it'll start the consumption of the brain matter, replacing ut with itself and growing nerve tissue. This process continues until the full language center is taken over. They grow initially in a set pattern, which makes the right connections to understand the important human and alien languages, as well as some dialects. After the initial growth the bacteria will behave just like mormal nerves, being fed by the host and making new connections where needed.
Replacement by symbiotic or parasitic organisms is quite commonplace. An example us a parasite that goes into the mouth of a fish, constricts the tongue until it dies off and then takes it's place, functioning as a tongue.
This is a bioengineered product, meaning its specific to the species. The aliens need a different one, tailored to them. Earlier products had to be engineered specifically per person to avoid rejection. Nowadays the bacteria is so good it blends in with most subjects immune sysrems without further engineering. The ones that are rejecting the bacteria are unfortunate and will have to go to surgery immediately to remove the debris and see what's hasn't been devoured of the language center.
The pill needs to be engineered again with each new species, so after a new species is discovered it'll take time before the pills are ready.
Answer: Humans find the virtual communication environment disconcerting.
Just humans need to take the drug.  There is another species that takes another drug and a couple of species that just cant do it.  Several species do OK with no drug but one must sit still while they do it.
There is a virtual environment that hacks into brain pattern structures and facilitaes communication.  Communication happens via a Snow Crash type virtual environment, or a Pokemon Go virtual overlay - that is the experience of the humans anyway.  The AI might do it differently for other species.
For the humans, having the AI add stuff to the perceptual environment is disconcerting at best and in some cases sickening.  People can freak out.  The drugs make it easier to accept what is happening and roll with it.
The drugs change other aspects of reality though in mostly tolerable ways.
There will of course come a time when the human protagonists need to communicate without drugs and so enter the program "sober".  It is a different experience.


Glow discharge : Why is the voltage stable with increasing current in the normal glow mode?

Question:
In the characteristics shown, the normal glow mode is from F to G, the voltage is stable with increasing current. I understand the explanation of how the electrode current density stays constant(the plasma contact area with electrode increases as the current increases). However, I don't understand how the constant electrode current density is keeping the voltage drop constant. What is the relationship between the current density and the voltage drop?
Answer: in that range of current, adding more current "lights up" more electrode area, and voltage stays constant. subtracting current in this zone causes parts of the glow discharge to be extinguished, reducing the active area of the electrode. voltage stays constant during that process too.
Comment: Thanks. But how does increasing the contact area with the plasma keep the potential constant?
Comment: Here is my thought process: the increased area can be thought of as a lower resistance path for the charge carriers towards the electrodes. And a lower resistance means a higher current can flow through the tube at the same voltage. Is this true ?
Comment: I believe that is correct.


How long will a sauce last for when placed in a refrigerator and in a freezers?

Question: How long will a sauce last for when placed on freezer and in a refrigerator?
Comment: It depend on the sauce; what kind of sauce are you talking about?
Answer: If it's sugary, or contains enough protein, a -20°C freezer won't stop problems. Sugar epimerization, taste change, happens down to -70°C. You find those units in labs, not homes. Generally a freezer is good against bacterial and fungal growth. But you'll still have freezer burn after a year or so.Even with freezer bags. Actual containers work better, as 5-8mil plastic is fairly water permeable.


Decoherence/wave function collapse between entangled photon pair

Question: If photon 1 and 2 are position entangled and they go in different directions, would making a measurement on photon 1 effect photon 2? If photon 1 is detected can photon 2 still create interference?
Comment: How exactly do you position entangle two photons?
Answer: I'm unsure what position-entanglement of photons would mean, but with entangled particles in general, performing a measurement on one particle does not affect the other, contrary to what some science popularizers would have you believe.  An entangled system is just a system where the measurements performed on the two particles will be correlated in a way that is impossible under classical assumptions.  If it were possible to actually affect the other particle by making a measurement, then you could communicate instantaneously over an arbitrarily large distance, which would violate special relativity.
Answer: If you have a pair of position entangled photons ,you measure one of them ,the other will collapse .For example ,entangled photons emitted at orgin , and photon 1 was detected at x,then photon2  you will detect it at -x .
"If photon 1 is detected can photon 2 still create interference?" I do not know what you want to express.  Actually, when one of photons is measured ,the other will be a real single photon and a single photon can interfere with itself.
Hope it can help you.


Fried eggs and boiled eggs, which is better for muscle build up?

Question: I want to build a muscle body, and heard I should eat eggs, but I don't know if I should eat fried eggs or boiled eggs, is there any suggestion?
Comment: Fried eggs, will include the olive oil used to fry them in, thus will provide more calories.
Answer: It really depends on what kind of diet you follow , Fried Eggs doesn't make much difference . If you compare both Fried and boiled ,both will give 6gms of protein, 1gm of carbohydrate .But the Boiled on differs in Fat and Calories content  ,as it gives you 70gm calories where as Fried one will give you 90 and the fat content will also differs from 5.3 to 6.8 .
Answer: I think it depends on whether or not you want a chunky muscle body or a lean and ripped muscle body.  I am not a body builder, nor have I ever trained to be one, but I have skimmed through the diets that some of them follow and I don't ever recall seeing fried eggs on those menus.  In fact, typically they do eat a lot of eggs in the form of egg whites, but little to no egg yolk.  If you're really serious about developing a muscle body, I recommend you train yourself to start incorporating egg whites into your diet.  You can even buy them by the carton at most grocery stores.  I've listed a few links to some articles that may interest you on this topic:
Ava Cowan's Diet Plan (you'll see egg whites on the menu):
http://www.fitflex.com/ava-cowan-pics.html
She doesn't describe how she prepares the eggs, but I doubt she fries her egg whites in butter.
Recipes from Monica Brant (many include egg whites):
http://www.bodybuilding.com/fun/monica4.htm
Lots of ideas here that don't involve frying:
http://www.bodybuilding.com/fun/7-ways-to-cook-eggs.html
I myself am a big fan of the Egg White Frittata.  Below is a recipe I've never tried, but it looks quite good:
http://www.foodiecrush.com/2015/02/spinach-and-mushroom-egg-white-frittata/
You'll find a lot of new and interesting diet strategies out there these days, but you asked about eggs, so I'll stop here.
As always, exercise (and diet) at your own risk and see a doctor if you're concerned about your health or the diet you're about to follow.  If you decide to stop eating fried eggs, with or without the yolk, I think most doctors would be okay with that.  For further proof that frying may not be all that healthy, you may want to read this article here: http://www.hsph.harvard.edu/news/hsph-in-the-news/eating-fried-foods-tied-to-increased-risk-of-diabetes-and-heart-disease/.


Rendering ocean scene, but ends up as a cube

Question: I am new to blender, and I am trying to render my animated ocean scene. However, when I render only the cube I started with is visible, not the ocean. And the cube does not show in my viewport. Any suggestions on what I can do to render my ocean animation?
Comment: Your question lacks the information to be able to help you. Please consider adding more details and upload your scene, or a https://en.wikipedia.org/wiki/Minimal_working_example  to https://blend-exchange.giantcowfilms.com/ and add the generated link to your question by using the "edit" button
Answer: If you are using the ocean modifier, then it would be best to use a plane not a cube. Also, you need to subdivide the plane before you add the modifier. You can do this by adding a subdivision surface modifier, or subdividing in edit mode. You also may need to keyframe the ocean modifier, if you have not done so.


Adobe Illustrator 8: trying to resize an image

Question: I forgot how to resize an image... I did look this up in the Help section, but was not able to find what I needed.
Comment: Use scale tool.
Comment: If you did not find [Scale, shear, and distort objects](https://helpx.adobe.com/illustrator/using/scaling-shearing-distorting-objects.html) as the top result by searching for "adobe illustrator scale image" then you may need to update your google.
Answer: Click on the image to select it, click & drag from any of the corners, holding SHIFT if you need a proportional resize.
Comment: Note those "hidden tools" are not present in **AI8** (If the user *actually* means 8). They were added at CC2014.
Answer: Ensure View > Show Bounding Box is on. Then merely click a corner handle and move it to resize an object.
The Bounding Box was a new feature in AI8 (circa 1998).
Or you can use the Scale Tool or simply double-click the Scale Tool in the tool bar to resize.
You can also use the menu -- Object > Transform > Scale
Or the Free Transform Tool, merely select the tool, grab an handle and move it.


Windows Service in Docker container

Question: I am looking at possible dockerisation of an application. The application includes multiple Windows Services (.NET WCF). I am yet to try out creating a dockerfile for the windows services. But shall appreciate if someone may provide me with some pointer whether this works well.
Comment: Yes, this will work fine. As long as your service runs in Windows Server Core OS it will most likely run fine inside container too. So I suggest before putting it container learn steps which needs to be taken inside real Server Core OS
Answer: In your situation, I'd probably create one image for each Windows Service.
The following Dockerfile works well for me in building a Windows Service into a docker image.
All your service files need to be in the 'Installs' folder of the docker context, plus a copy of the InstallUtils.exe file (from .NET / Visual Studio).
<code># escape=\

FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2-windowsservercore-1709

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

COPY ["Installs/", "/Service/"]

WORKDIR "C:/Service/"

RUN "C:/Service/InstallUtil.exe" /LogToConsole=true /ShowCallStack SmartFormsToWorkInjuryReportingService.exe; \
    Set-Service -Name "\"My Windows Service Name\"" -StartupType Automatic; \
    Set-ItemProperty "\"Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\My Windows Service Name\"" -Name AllowRemoteConnection -Value 1

ENTRYPOINT ["powershell"]
CMD Start-Service \""My Windows Service Name\""; \
    Get-EventLog -LogName System -After (Get-Date).AddHours(-1) | Format-List ;\
    $idx = (get-eventlog -LogName System -Newest 1).Index; \
    while ($true) \
    {; \
      start-sleep -Seconds 1; \
      $idx2  = (Get-EventLog -LogName System -newest 1).index; \
      get-eventlog -logname system -newest ($idx2 - $idx) |  sort index | Format-List; \
      $idx = $idx2; \
    }
</code>
FYI, you can then run the service by:
<code>docker run --rm --net=MyNet --platform=windows -p 80:80 --name MyWindowsServiceContainer mywindowsserviceimage
</code>
Comment: Can InstallUtill.exe be replaced by New-Service?
Comment: Let me ask a basic question - when an app is a candidate to be windows service, is it not evaluated to be a candidate of deamon services (linux version of windows services) and why would we need the Windows Service hosting when we move towards docker container?
Comment: i have used the same snippet and at the time of running it is saying

**docker: Error response from daemon: failed to create endpoint MyWindowsServiceContainer on network nat: failed during hnsCallRawResponse: hnsCall failed in Win32: The process cannot access the file because it is being used by another process. (0x20) **
I tried  the following but those did not helped
Stop-Service docker
Stop-service hns
Start-service hns
Start-Service docker
docker network prune

Windows Service in Docker container


Widgets missing after update

Question: After doing an update to 4.7, all widgets are missing. I queried the database for any records wp_options like '%widgets%' and all is the same as the backup. What can cause this or how can the widgets be restored?
Comment: Try searching `wp_options` for option name like "widget" (singular): `SELECT * FROM wp_options WHERE option_name LIKE '%widget%' `.
Answer: I had to restore sidear_widgets in wp_options and any other entries with option_name including 'widget' from a database backup to resolve. Something must have go wrong during the update and all widget settings were lost.
Answer: Your update probably went wrong.
Start again from the update page, or upload the missing/incomplete files by ftp.
If you want to verify manually, you will find the related files in wp-includes folder widgets.php and widgets folder with classes for core widgets.
Hope it works after.
Comment: You mean try the 'Reinstall Now' button on the update page?
Comment: Yes, "reinstall now" button, or check manually before but it could be long
Comment: Same after reinstall :( It seems only widgets are missing, would those types of things be affected by files?
Comment: Did you try to enable debug mode to see if some of your widget works with the last version. Some plugin throw warning about the method that is deprecated.
Answer: Next step would be to look at your PHP error log and see if there are any clues in there. You may have an incompatibility issue.  Make sure all plugins are up to date as well.

Widgets missing after update


Rename Relationship Class labels

Question: Is there a way to rename relationship class labels (forward and Backward labels)  after I've created them ? or I have to delete them and create them again ?
Answer: Base on the Arcgis Help, you cannot change relationship class properties that were assign during the creation of relationship class.
Link:
http://resources.arcgis.com/en/help/main/10.1/index.html#/Viewing_and_modifying_relationship_properties/004t0000000q000000/
So, You have to recreate you relationship classes!
Answer: Use ArcCatalog to rename relationship classes:
http://resources.arcgis.com/en/help/main/10.1/index.html#//004t0000000r000000
Comment: Thanks Rayner, but that is for The name of the Relationship class. I need to rename the labels (forward and Backward labels)  a property inside the relationship class .

Rename Relationship Class labels


How does Tezos Checker work?

Question: I am looking at Tezos Checker and wondering if there is a visualization of the process flow how it works? Specifically something like this for example?
Comment: Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
Answer: Open a github issue on that project to ask questions regarding its usage.

How does Tezos Checker work?


How can I add a class to a view list item that has a moderation state of draft

Question: I have a view that outputs a list of nodes for a menu. The view
displays the title linked to the node. The View allows published nodes or
nodes in the moderations states draft or review. How can I add a class around the titles that are in draft or review. I would like to style these differently. I am using drupal_view to print the block inside a template. Can this be done in a theme preprocess or custom module?
Comment: This is similar to https://drupal.stackexchange.com/questions/276153/clean-way-to-programmatically-add-attributes-to-a-view-field-entity-label-link. You can create a Views field plugin "link_with_moderation_state" which adds a class to the link (or add a surrounding div to add the class) depending on the moderation state of the entity.
Comment: Thank you @4x4. I think I found another way
Answer: This can be done through the Views interface.
You can add classes based on existing Field values to entire rows in Format > Settings, or you can add classes to individual Fields (you mentioned title) under Style settings wrapper or field HTML options.
Tokens to use in all of these cases can be found in the settings of the Field according to which you want to style the rows/other fields. The settings are under Rewrite results > Override the output of this field with custom text > Replacement patterns options.
You don't have to actually keep the rewrite enabled, you just need to temporarily reveal and uncollapse to copy the tokens you need.
Then add CSS for those classes to your subtheme as usual, or through CSS editor module.
You can hide the field ("Exclude from display") but it needs to be there on the list, arranged before any other fields that may use its value for classes.
Comment: I found that I could a new field for moderation_state. Then exclude it from display. Then add a rewrite to the title field like this `{{ title_1 }}
{{ moderation_state }}`
Comment: But I only want to display the moderation state IF its in draft or review state. I tried this below but its also prints 'Published' and I only want to display it for draft.
`{{ title_1 }}{% if field.moderation_state == draft %}
{{ moderation_state }}
{% endif %}
{% endif %}`
Comment: Your question was about a class, and you can still display "draft" text through CSS `content` property, for example after the title text. But if you don't need different styles and just want to output the state as a Field, you can Rewrite it the way you tried, only fix your syntax. You have one endif too many, quote the string value, and check the debug for correct name, it's usually something like `{{ content.field_name }}`.


How to manually restore emails in Lion?

Question: Before upgrading to Mac OS X Lion with a clean install, I backed up Mail app according to this article on Apple Discussions. I know have the com.apple.mail file and the Mail directory and I have no idea how to restore it. As it seems, theses paths have changed. Do you have any ideas on how to restore my emails?
Answer: Put the contents of the mail directory in /Users/yourusername/Library/Mail (or  ~/Library/Mail in other words)
com.apple.mail.plist goes to /Users/yourusername/Library/Preferences (~/Library/Preferences)
Comment: I've done that already. It didn't work and that's why I'm asking it here. Any more suggestions?
Comment: @João I have confirmed this process works with a clean install of Lion. If it didn't work for you, you may be experiencing a different problem. Are there any more details you can provide?
Comment: No, @Adam. But hey, I completely forgot I had all my emails stored on my server, so no big deal. I tried doing it a few more times, but it didn't work for me. I'm not using a DP version of Lion, I'm using the one from App Store (I know it may not make the difference, but it's the only extra detail I've got).
Answer: Firstly copy the com.apple.mail.plist from the backup to the user library (~/Library/preferences) and it does ask to replace, just click yes.

Secondly copy the mail folder to the user library (~/Library) and when complete, just open mail as normal.
Comment: I've done that already. It didn't work and that's why I'm asking it here. Any more suggestions?
Comment: @João Ramos You are completely spot on. Copying the mail.plist and even any other preference file related to mail does not work any longer in Lion. It is a real pain in the neck. This worked for as long as OS X existed, on top of that they killed off mobile me. I did not realize that it was killing off also the synchronization of the mail accounts. Yes it was clearly stated by Apple, however somehow I was thinking about iPhone and iPad which can be synchronized. The only other option seem to use migration assistant, but that makes not much sense as it is an all or nothing approach. That leaves

How to manually restore emails in Lion?


Copy data from en language version to other language version

Question: I need to copy item field data from en language to all other available languagesin all versions. Any powershell script of achieving this.
Comment: https://doc.sitecorepowershell.com/working-with-items/item-languages
Comment: @MichaelWest these script create a new version doesn't copy value to existing version. I am looking for something that copy value to existing version
Comment: I just want to clarify that the Add-ItemLanguage command does copy existing values. You can configure if you do not want this with the -DoNotCopyFields flag. Additionally, you can specify which fields you do not want to have copied by using -IgnoredFields
Answer: Probably the below script can help you. The comments are added to the script to make each step obvious. You can do modifications to it to suit your purpose -
<code>#Get all language versions defined in System/Languages
$languages = Get-ChildItem /sitecore/System/Languages -recurse | Select $_.name | Where-Object {$_.name -ne "en"} | Select Name

#Ensuring correct items are updated by comparing the template ID
$items = Get-ChildItem -Path "/sitecore/<your item location>" -Recurse |
    Where-Object {'<item template id>' -contains $_.TemplateID}

#Bulk update context to improve performance
New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) {

    foreach($item in $items) {
        foreach($language in $languages) {
            $languageVersion = Get-Item -Path $item.Paths.Path -Language $language.Name

            #Check if language version already exists
            if($languageVersion -eq $null){
                Write-Host "Creating "$language.Name" version for "$item.Name
                Add-ItemLanguage -Item $item -Language "en" -TargetLanguage $language.Name -IfExist OverwriteLatest
            }
        }
    }
}
</code>
The script is also available at my blog.


Why does a 2-input OR gate cause the input to stay on when there is feedback?

Question: As I understand it, latches are made from OR gates, but I am trying to understand the basis for how they work and came across this video https://www.youtube.com/watch?v=KM0DdEaY5sY. When you make simply one OR gate with two inputs, A and B, except that the input B is the feedback output, you get a latch that doesn't reset. At around 3:00, he demonstrates that when you turn the button on, it stays on forever and that you can only reset it by creating an open circuit. But, why does the output stay high forever just because the input was high one time?
Answer: Because an OR gate's output is high if either input is high. If you tie the output to one of the inputs, once the output is high (for any reason), it can never go low again. It doesn't matter what the other input does after that.
It's pretty much the simplest example of positive feedback in a Boolean system.
Comment: this is an incorrect assumption ...`latches are made from OR gates`
Comment: `why does the output stay high forever just because the input was high one time` ... there are two inputs that go high
Comment: Okay, but what's the actual mechanism by which it's staying at 1? All you did was reiterate what the video stated which didn't really solve anything.
Answer: Try an analogy. You are in a room. You have a rule that you follow and a switch and a red light and a green light and a white light.
The Analogy
There are two switches outside the room that control the red and green lights. Whenever you see either the red light or the green light on, you flip the switch on, which turns the white light on. If both the red and green lights are off, you flip the switch off, and the white light turns off.

That's how the OR gate works.
Now let's put another person in the room beside you. She has a white light that turns on and off with yours. Her job is to flip the switch on if she sees the white light on and off if she sees the white light off. Her switch turns your red light on. The green light is controlled by someone else.
That's the feedback.

Now if both red and green are off, you don't turn the white light on and nothing happens.
Then the dude controlling the green light turns his switch on for some reason. You see the green light and flip your switch on. A bit later the person controlling the red light sees the white light that came on as a result of your action and flips her switch on, and the red light also comes on.
In your room you see the green light and the red light, so you keep your switch closed. The dude controlling the green light decides to turn his off. So you're left with just the red light, so you still have to keep the white light on. The person controlling the red light still sees your white light, so she never turns her switch off.
And we're stuck here forever until the rules change.

Timing
Note that there are reaction times involved here- if the green light flickers on only briefly it's possible it could get missed and then you'd never flick the switch. Or maybe you get to flick the switch and the white light goes on briefly, but the green light goes off and you flick it back before your neighbor gets a chance to react, so the latch never catches.

Electronic Reality
Inside a typical 4000-series CMOS OR gate the transistors are arranged like this:

(it's implemented as an inverter on each input, followed by a NAND gate (with two cascaded inverters afterward). You can see the NAND in the middle- two n-channel transistor in series (both inputs have to be high for the output to be low) and two p-channel transistors in parallel (if either input is low the output is high).
As you probably know \$A+B = \overline{\overline{A} \cdot \overline{B}}\$, it implements an OR gate.


.net application deployment

Question: I have multiple web applications. I am wondering if I should put them in one virtual server or put them in serveral separate servers meaning one application on one virtual server. What is the better practice?
Answer: Considering you don't mention any OS or dotnet versions, that's hard to answer conclusively.
Generaly, IIS 6.0 and higher allow you to allocate separate application pools (running different dotnet versions under separate identities in separate process spaces) to any part of the web site.
Prior to IIS 6.0, this was not possible.
Managing web sites is really an administrative concern, and has little technical impact.

.net application deployment


What is the difference between the two types of red Aloe Vera?

Question: What is the difference between these two red aloe veras? And what's unique about them?
Answer: The second picture is Aloe cameronii - its gets redder in sun, but new leaves usually start out green. https://en.m.wikipedia.org/wiki/Aloe_cameronii
The cut aloe in the first picture is not possible to identify because the whole plant is not visible,though it is clearly a different variety from the second plant. The red gel inside might be a feature of the plant, or it might mean the leaf section is not fresh, and bacteria has invaded the gel. There are over 500 varieties of Aloe, but Aloe vera is usually the one juice is extracted from. Juices from Aloe vera are sometimes pink/red, other times clear, and it seems no one's quite sure why, see here https://aloe1.com/pink-aloe/


Find files that will be backed up by Time Machine

Question: It'd be useful to see what Time Machine will backup before the backup actually occurs. I believe it should be possible to approximate this with mdfind. Is there a standard search query that accomplishes this? Or a way to ask Time Machine directly?
Answer: In OS X 10.7 (Lion) you can use tmutil.  To compare the current state of the machine with the most recent backup you simply use the command,
tmutil compare

But you'll probably want to redirect the output to a file because there may be a lot of it.  You can restrict the comparison to certain types of difference (e.g., file size, file permissions).  It does more, but I can't describe the details more succinctly than the tmutil man page itself:
compare [-@esmugtdrvEX] [-D depth] [snapshot_path | path1 path2]
       Perform a backup diff.

       If no arguments are provided, tmutil will compare the computer to
       the latest snapshot. If a snapshot path is provided as the sole
       argument, tmutil will compare the computer to the specified snap-
       shot. If two path arguments are provided, tmutil will compare
       those two items to each other.  tmutil will attempt to inform you
       when you have asked it to do something that doesn't make sense or
       isn't supported.

       The compare verb allows you to specify what properties to com-
       pare. If you specify no property options, it is assumed that you
       want to compare a basic set of metadata. This default property
       set is equivalent to the -smugt option set. Specifying any prop-
       erty option overrides the default set.

       Options:
           -a    compare all suppored metadata
           -@    compare extended attributes
           -e    compare ACLs
           -s    compare sizes
           -m    compare file modes
           -u    compare UIDs
           -g    compare GIDs
           -t    compare modification times
           -d    compare file data forks
           -r    ignore specified root paths and compare descendents
                 instead
           -D    limit traversal depth to depth levels from the begin-
                 ning of iteration
           -E    don't take exclusions into account when comparing items
                 inside volumes
           -v    enable verbose mode (enables reporting of all identical
                 items, which is noisy)
           -X    print output in XML property list format

Answer: The other answer mentioning tmutil compare is the canonical way to ask OS X to simulate the next backup event and check which files and/or metadata have changed since the last backup. However, there is a very useful binary called tmdiagnose that I haven't seem mentioned here on SuperUser which is intended for diagnosing issues with Time Machine that will also let you know in excruciating detail the configuration for the next backup, the system exclusion paths, the user exclusion paths as well as what rules were used on all prior backup and snapshot events.
Look inside the hostname -s.tmdiagnostic.zip file for both the configuration.txt as well as the exclusions.plist text files to determine which files and paths are and were excluded.
Answer: I have the same question. Since there does not appear to be an exact answer, let me propose this:

Allow Time Machine to make the backup.
Look inside of it using BackupLoupe to see what was backed up.
If you're not happy with it, adjust the exclusions.
If you want to delete the snapshot, mount the sparsebundle file by clicking on it, then browse to the snapshot you don't want and remove it.

BackupLoupe

Exclusions

Answer: Something like this could be used as a starting point

mdfind "kMDItemContentModificationDate >= '\$time.iso($(cat /Private/var/db/.TimeMachine.Results.plist | grep "BACKUP_COMPLETED_DATE" -A1 | grep "<date>" | cut -d">" -f2 | cut -d"<" -f1))'"

might have to add other meta info the the query to ignore directories, special files and the like...
The kMD* keys are documented here: http://developer.apple.com/library/mac/#documentation/Carbon/Reference/MetadataAttributesRef/Reference/CommonAttrs.html#//apple_ref/doc/uid/TP40001694-SW1
Answer: if you know when the last backup run was, you can list files changed after that:
For example, to find all files in /folder with .doc as the extension that were modified less than two days ago:
find /folder -iname "*.doc" -mtime -2

Answer: 1: Parse the last backup time from the folder names on the Time Machine backup volume. Use the one the "latest" link points to, if possible. Dismiss those with ".progress" extension (not on a Mac right now, so I could be off a little)
2 and 3: Read the property lists and use them as exclusion file, if possible, or simply create a regular expression from those paths and "grep -v $excluded".


My name in publications as an author is different from my name in the passport, how to prove that I'm the same person?

Question: My name in all of my publications is Mohamed Abd El-Ghafour (Abd El-Ghafour, M.) while in passport is Mohamed Abd El-Ghafour Omar, so Abd El-Ghafour is a middle name, is this will be a problem in linking my publications to my passport?
Thank you very much
Comment: In all my years, no academic ever looked into my passport. Also, the difference does not seem to be completely understandable - there is just one name more in the passport, no?
Comment: Not something to worry about. It is more important that all your papers show the same name, however. If you have some with one name and others are different it will just confuse people.
Comment: There have been many similar questions on this site, e.g. https://academia.stackexchange.com/questions/16333/choosing-my-name-as-an-author-when-publishing-a-scientific-paper-can-i-use-my.  The short answer is that it is not a problem.
Comment: I guess the OP is asking the question for immigration-related questions. The name discrepancy might invite suspicion of identity theft from custom officers. Note that "Mohammed abd-el-X" is a widespread name pattern in the Arabic world, so homonyms are frequent.
Answer: I would not be worried about the passport having a different name. However, if you want to claim the publications as your own, I would setup an ORCID. That would link them to you and each other. On your ORCID account, list your full name. ORCID also lets you list other names as well.


Pydev + Eclipse not doing code analysis on a new project

Question: I have several existing projects in Eclipse + Pydev and it does code analysis on them just fine.  However, I added a new project and Eclipse isn't analyzing any of the code files in it.  What's wrong?
Answer: I fixed this issue for me. Code Analysis only works on source folders. If you created your project and haven't assigned a source... Right click on the project, and go... Properties -> PyDev - PYTHONPATH -> Source Folders -> Add Source Folder, and Add the project path to itself as a source.
Comment: Thank you, fixed the problem for me. Weird that this is not mentioned on the PyDev website.
Comment: No problem :) It drove me crazy.
Comment: This is a great answer. It also solves the problem of PyDev live reload not being applied after function(s) are changed. Thanks!
Answer: The project name needs to match the name of directory containing the project for Eclipse to automatically include its contents for analysis.
Comment: This is the case but I still have the issue. Any other ideas?


Mining Eth with a pathetic laptop

Question: I am a newbie in mining, I have a couple of shitty laptops around 8-16gb ram and an Intel graphics card.
I don't pay for the electricity and don't really care if the laptop dies. I tried to search around if I can mine ETH in this laptop. but all the software wants me to set up the miner with parameters related to the AMD or Nvidea graphics card. Could anyone suggest me any miner which is easy to setup and will work for my case?
Comment: Do you have SSD in the laptops? If not, you can't get even synchronized with the network
Comment: The geth client has a software mining component that uses CPU. IMHO mining using cpu is not worth the time spent setting up the computers.
Comment: @LauriPeltonen, no it doesnt have an SSD
Answer: If you want to mine, you have to get your mining node synchronized with the network. To get synchronized there are certain hardware requirements: SSD being one of them. So, since you don't have SSD, you can't get synchronized with the network. And since you can't get synchronized you can't mine either.
Even if you installed SSDs it would most likely not be worth it. I have no idea whether you can mine with Intel. If no, you'd need to mine with CPU which is totally pointless (you will never get any profit). If yes, your hashrate would still be probably very low, so it would be pointless.
Comment: Lauri's answer is 100% correct, I just wanted to add that even if you joined a mining pool (which as far as I recall would negate the need to sync the chain), your percentage of the hash rate would almost certainly be too low to ever receive any payout.
Answer: you can use the minergate software. It won't create a lot of profit, but in your case it's worth it I guess. Here's the link: https://minergate.com/eth-mining-pool

Mining Eth with a pathetic laptop


Indy 10 - IdSMTP.Send() hangs when sending messages from GMail account

Question: I am trying to send an e-mail using gmail account (Delphi 7, Indy 10) with these settings:
TIdSmtp:
Port = 587;
UseTLS := utUseExplicitTLS;

TIdSSLIOHandlerSocketOpenSSL:
SSLOptions.Method := sslvTLSv1;

Everything seems to be set ok. I get this response:
Resolving hostname smtp.gmail.com.
Connecting to 18.104.22.168.
SSL status: "before/connect initialization"
SSL status: "before/connect initialization"
SSL status: "SSLv3 write client hello A"
SSL status: "SSLv3 read server hello A"
SSL status: "SSLv3 read server certificate A"
SSL status: "SSLv3 read server done A"
SSL status: "SSLv3 write client key exchange A"
SSL status: "SSLv3 write change cipher spec A"
SSL status: "SSLv3 write finished A"
SSL status: "SSLv3 flush data"
SSL status: "SSLv3 read finished A"
SSL status: "SSL negotiation finished successfully"
SSL status: "SSL negotiation finished successfully"
Cipher: name = RC4-MD5; description = RC4-MD5                 SSLv3 Kx=RSA      Au=RSA  Enc=RC4(128)  Mac=MD5
; bits = 128; version = TLSv1/SSLv3;

And then it hangs and doesn't finish. E-mail is not sent. What can be the problem?
Answer: yes, i've seen lots of issues with indy10 and tls (generally gmail).
first make sure you have the latest ssl libraries from here
i've seen intermittent stalls and errors that have been resolved in the bleeding edge version of indy (ie. a non-stable release).  see http://www.indyproject.org/sockets/download/svn.DE.aspx
for gmail, i generally use implicityTLS on port 465..
  idSmtp := TIdSMTP.Create(nil);
  try
    idSmtp.IOHandler := nil;
    idSmtp.ManagedIOHandler := true;

    // try to use SSL
    try
      TIdSSLContext.Create.Free;
      idSmtp.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(idSmtp);
      if (smtpSettings.port = 465) then
        idSmtp.UseTLS := utUseImplicitTLS
      else
        idSmtp.UseTLS := utUseExplicitTLS;
    except
      idSmtp.IOHandler.Free;
      idSmtp.IOHandler := nil;
    end;

    if (idSmtp.IOHandler = nil) then
    begin
      idSmtp.IOHandler := TIdIOHandler.MakeDefaultIOHandler(idSmtp);
      idSmtp.UseTLS := utNoTLSSupport;
    end;

    // send message, etc

  finally
    idSmtp.Free;
  end;

Comment: Excellent! Your post helped me. My app also freezed during smtp.send. I think the key was utUseImplicitTLS option but i also don't understand what this TIdSSLContex.Create.Free does.
Comment: TIdSSLContext.Create.Free creates an object and immediately frees it.  It's there to trigger an exception if the TIdSSLContext object can't be created.
Answer: The problem was simple. I was not patient enough and application didn't hang, there was long timeout. The timeout was result of wrong settings.
Answer: First off, have you verified the code is working with other email servers?
Some time ago someone mentioned they were having problems with certain servers accepting http requests with the Indy TIdHTTP component.  The reason was they had Indy included as part of the useragent:
      Request.UserAgent := 'Mozilla/3.0 (compatible; Indy Library)';

When they removed Indy Library it worked.  Evidently there have been some malignant web services created with Indy, so some sites will refuse connections from applications created with it.
I am not sure if the component you are using has any sort of UserAgent property.  But if it does, null out any references to Indy.
Comment: UserAgent is for HTTP requests, not SMTP
Comment: **glob** you are correct; I did conclude by saying "I am not sure if the component you are using has any sort of UserAgent property"
Answer: When testing Indy, you should be sure that "Stop on Delphi Exceptions" is checked (Tools, Debugger Options, Language Exceptions).
Some routines, specifically idSMTP.Send, 'eats' (or hides) exceptions resulting in a hang up.


PHP post to REST web service

Question: I'm totally new to REST web services.  I have a need to post some information to a REST web service using php and use the response to give users a product(the response is the code for the product).  My task :
  1) HTTP method is post
  2) Request body is XML
  3) Headers need to have an API key ex: some-co-APIkey: 4325hlkjh
  4) Response is xml and will need to be parsed.
My main question is how to set the headers so that it contains the key, how to set the body, and how to get the response.  I am unsure exactly where to start.  I'm sure it's quite simple but since I've never seen it I'm not sure how to approach this.  If someone could show me an example that'd be great.  Thanks in advance for any and all help.
I'm thinking something like this;
<code>  $url = 'webservice.somesite.com';

  $xml = '<?xml version="1.0" encoding="UTF-8"?>
      <codes sku="5555-55" />';
  $apiKey = '12345';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);

  ## For xml, change the content-type.
  curl_setopt ($ch, CURLOPT_HTTPHEADER, $apiKey);

  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // ask for results to be returned
  if(CurlHelper::checkHttpsURL($url)) {
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    }

  // Send to remote and return data to caller.
  $result = curl_exec($ch);
  curl_close($ch);
</code>
Does that seem about right?
Comment: That's a good start.. run the code and tell us if there are errors.
Answer: You should use cURL for this.  You should read the documentation, but here is a function I wrote that will help you out.  Modify it for your purposes
<code>function curl_request($url,  $postdata = false) //single custom cURL request.
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, TRUE);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    curl_setopt($ch, CURLOPT_URL, $url);

    if ($postdata)
    {
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
    }

    $response = curl_exec($ch);

    curl_close($ch);

    return $response;
}
</code>
As for XML, php has some great functions for parsing it.  Check out simplexml.
Comment: you can send the request with curl then read the xml response
Answer: If you can install/have access to cURL it will do what you want:
cURL Manual:
http://php.net/manual/en/book.curl.php
Examples:
http://php.net/manual/en/curl.examples.php
And an XML parser:
http://php.net/manual/en/book.xml.php
Answer: Just check the PHP manual how to perform a HTTP request and read the response. The HTTP context options and parameters are useful for what you would like to achieve.
If you need a general tutorial on how make a HTTP POST request, you find a more lengthy one here: HTTP POST from PHP, without cURL. It has a generic REST helper as well, so it might be exactly what you're looking for.

PHP post to REST web service


Transcribing a Standard MIDI File to sheet music

Question: I have a couple of nice guitar midi files that I would like the scores for; is there any software out there that can do this sort of conversion, and output it as a PDF file?
Thanks
Comment: If you're on a Mac, I believe `GarageBand` can do that. I'm not 100% sure though.
Answer: Musescore is free as opposed to many other programs such as Sibelius or Finale. However, it is still very good and can do almost everything that paid programs can do.
One of the input files accepted in Musescore is MIDI and it can output PDF among other formats. However, as guidot said, it takes a human to do it right because a MIDI file does not contain all the information needed to create a complete score. Blanks, such as key signatures, time signatures, ornaments, articulations, and enharmonics, must be filled in by guessing.
That's where a human operator comes in. Your software, such as Musescore, must take the MIDI file and create a clean score with it. Musescore does a very good job at this, but the blanks in the MIDI file must be filled in by guessing. It takes a human operator to correctly fill these in, but having software to do the rough draft is helpful.
Once you have your software (such as Musescore), open the MIDI file. Musescore will convert the MIDI to sheet music, but you will still have to correct things (such as those mentioned above). If you have a good understanding of music, it shouldn't be too hard for most pieces. Once you've tidied the score up, output it as a PDF and you're done.
Answer: Guitar pro does midi import and pdf export, so you should be able to obtain tabs and scores from it.
Answer: This is not quite a "conversion", since the midi file is on a much lower level than a score. So while you will surely get some output, it is more than questionable, whether somebody can play from it without considerable editing. As an example midi contains nothing about a key and so has to make wild guesses concerning accidentals, same for time signature, dotted notes, arpeggios may not be recognized as such but separate notes and many more issues. So I'm afraid to state, that there is nothing to replace human (here: a musicians) brain for that task.
Answer: As @guidot said, nothing replaces human oversight. But a good piece of software (I use Digital Performer, which is decidedly not free) can quantize the MIDI performance, which helps it render a more conventional-looking score. But you will still have to clean it up.
Answer: If you are looking for a free solution, Tuxguitar can help. It does have a midi input and a PDF output. It will work on windows, linux, and mac. However, you might have to do a bit of clean up; it won't know what key you are using or anything like that.
Answer: If you know what you want the score to look like, the score-writing programs already mentioned will help you do the job.  If the MIDI is configured as one string=one channel and you want guitar tab rather than staff notation, you might even get some way towards automatic conversion!
Answer: The free software Lilypond comes with a tool called midi2ly, it converts midi-files to lilypond-files and lilypond outputs pdf-files by default. But as many of the other answers already stated: "The real work starts when the conversion is done!"
I think many of the aspects are covered in the other answers but I'll show a quick example how a score can look like directly after a midi import:
$ midi2ly infile.midi -o outfile.ly
$ lilypond outfile.ly

And here is a the finished score, witch apart from:

typing the notes
setting key and time signature

needed to be completely remade.

Note: Lilypond is available for major distributions such as: Windows, Linux, macOS, FreeBSD a.o. but it does not come with a classical graphical user interface (GUI). Instead it is working on source files that can get created with a text editor and get compiled with the program more comparable to a TeX/LaTeX workflow. There is editing software available such as Frescobaldi or software more gaining towards a GUI workflow such as Denemo.
Answer: MidiSoft Recording Session for Win 95 Running on WIN-XP. (You can use Oracle VM VirtualBox to host WIN-XP on Linux, Win-10) MidiSoft is out of business but there are copies of this program on the Internet.
Answer: Hands down Rallentando Software\MidiIllustrator Maestro 3.
Comment: Without some additional experiences given, I'm somewhat tempted to vote for close as "commercial".


How can a router or my ISP protect against phishing?

Question: I see a few services advertising the ability to protect against phishing and ransomware attacks. ISPs sell services which supposedly protect you and some routers like Check Point 700/900 series. Is this real? How does this work? If I download malware/ransomeware or am sent a phishing email - that's likely TLS encrypted. Can the ISP/router decrypt and scan such traffic? Or is what they're advertising only for non encrypted traffic or just doesn't work?
Comment: It often requires you allow the router to MITM you by installing a root certificate it generates into your trust store. And it can only use heuristics. They aren't perfect.
Answer: In general, phishing attacks comes on emails, and the majority of ISPs gives you email services for you in their platforms not on the home routers (in general). So the email services are hosted and process by your ISP, that is normally how ISPs protects you from that types of attacks.
For phishing attacks normally they have antispam/antiabuse systems that allows them to filter domains, ips, suspect emails and so on


How can I open an url file in emacs dired?

Question: When using dired in emacs, how can I open an url file in a web browser outside emacs?
Comment: have you tried `browse-url-at-point`  ?
Comment: Here is a snippet that I could use on OSX (if I wanted to):  `(let ((file (dired-get-file-for-visit))) (start-process "my-process" nil "open" "-a" "/Applications/Firefox.app/Contents/MacOS/firefox" file))`.  If you are on a different OS, then you can probably eliminate "open" and "-a", but you may need to add something specific to your OS to ensure that the browser receives input focus (if so desired) -- on OSX, that is what the "-a" is for.  If you want to open multiple files, then you'll need to use `dired-get-marked-files` and loop through the list of marked files.
Comment: @lawlist `browse-url` should be even better for this.
Comment: @DoMiNeLa10 The OP is actually talking about a file format: http://fileinfo.com/extension/url . The best solution in my mind is http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html
Comment: Thanks both of you! @lawlist: for some reason I got am error message on your solution, but will not investigate it since I found a perfect solution offered by DoMiNeLa10 and xuhdev.
Answer: You can add a key binding, such as C-RET to open any files in system defined default external programs such as xdg-open on Linux and open on macOS. In this way, URL files are opened by default browsers. A detailed approach is available on ErgoEmacs: http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html
Comment: By the way, how did you bind C-RET? When I tried with this:
             `(global-set-key (kbd "C-return") 'xha-open-in-external-app)`
I got the error "C- must prefix a single character, not return"
Comment: @myotis `(define-key dired-mode-map (kbd "") 'xah-open-in-external-app)`


Downloading simultaneously multiple files with big file lists on windows

Question: I am looking for a program that could download simultaneously (like, about 100 files in parallel) multiple files. The only thing is, that this program should be able to handle very big lists of files (like 200MB of links), and should work on windows.
As for now, I have tested aria2, but when I load my file list I get out of memory exception (aria is trying to use over 4Gb of memory!). Also I tried using mulk, but this thing just is not working (because I don't believe that it is loading my files list for about two hours now, when generating this list and writing onto the disk took me about a half of a minute). I haven't tried using wget yet, but as far as I know it cannot download in parallel, am I right?
Is there any software that could handle my requirements?
Answer: With aria2, you can use --deferred-input option to reduce memory footprint for list input. Also making --max-download-result option low, such as 100, may reduce memory usage too.


Problems with Android Gameloop (openGL ES 2.0)

Question: Overview
Having a lot of problem with choppy animations in my game loop.  I'm running the loop from
onDrawFrame and as you can see, my loop allows for frame skipping if it takes too long (I'm using a fixed time delta and my time 'slice' for 60fps is 16.666666ms).
I've confirmed that the stuttering happens when frames are skipped.

When there are frame skips, how can I stop the animation from going choppy?

If it absolutely has to skip frames (I concede there will be times on certain devices when this will happen), how can I mitigate the choppiness?

onDrawFrame(GL10 gl) seems to be called up to 24ms since the last time it was called.

On my Google Nexus 10 Tablet, my actual rendering can take anywhere between 5 and 14ms and my game updates only take between 0 and 4ms so most of the time it should fit nicely into the 16.6666 time slice.  However, when I remove everything from onDrawFrame, it seems to be called anywhere from 16 to 25ms apart.  (Most times, it is above 16ms), therefore, it's skipping a lot of frames - even without rendering or updates being called!!
This seems to go against the whole point of a device running at 60FPS - is this VSync doing this?  What's the point of it taking more than 16ms?
Things I've attempted
OK, I tried spawning a separate thread on which I run my updates (again, limiting them to 60 per second).  I still get the problem.
I've also tried interpolation but this again, hasn't made any difference.  (I am going to be posting a separate question to see if I've got that right).
I'm really struggling with this so I hope someone can help!
Code
float interpolation;
long nextGameTick = System.currentTimeMillis();
//loop counter
int loops;
//This is the amount of frames that we allow our app to skip before logic updating is affected (generally shouldn't happen)
final int maxFrameskip = 5;
//Game updates per second
final int ticksPerSecond = 60;
//Amount of time each update should take
final int skipTicks = (1000 / ticksPerSecond);

    public void onDrawFrame(GL10 gl) {

        //Set/Re-set loop back to 0 to start counting again
        loops=0;

        while(System.currentTimeMillis() > nextGameTick && loops < maxFrameskip){

        SceneManager.getInstance().getCurrentScene().updateLogic();
        nextGameTick+=skipTicks;
        timeCorrection += (1000d/ticksPerSecond) % 1;
        nextGameTick+=timeCorrection;
        timeCorrection %=1;
        loops++;
        tics++;

     }

        interpolation = (float)(System.currentTimeMillis() + skipTicks - nextGameTick)
              / (float)skipTicks;

    render(interpolation);
}

Applying interpolation
render(float interpolation){

    //This example shows interpolation for X axis only.  Y position (spriteScreenY is assumed to be valid)
    interpolatedPosX = spriteGridX+(SpriteXVelocity*dt)*interpolation;
    spriteScreenPosX = interpolationPosX * screenWidth;

    drawSprite(spriteScreenX, spriteScreenY);

}

Comment: Do you allocate any memory in your game loop (remember that iterating through collections with for-each syntax allocates a an iterator)? GC may cause stuttering. Check logcat debug messages for "D/dalvikvm GC_CONCURRENT freed", it will show you how long it paused.
Comment: Hi @thanks for the comment - there is no allocation happening during my loop - this is one of the first things I checked so I ruled that out early on - cheers!
Comment: @Zippy Do you solve the isssue.I have the same problem
Comment: Hi @Sunny, unfortunately, I haven't solved it. I've tried everything but still have choppy animation when frames are skipped.  For now, I'm just living with it but need to re-visit it at some point.  If you come across any suggestions, would love to hear them!! :-(
Answer: Try using RENDERMODE_WHEN_DIRTY. This means not using onDrawFrame anymore, but instead using requestRender() in your game loop.


Content Type Layout for Users

Question: I have a content type with fields that I want to customize for my clients to look more professional that it does in the current layout. Is this possible?
Comment: Do you mean you want to change the CSS?
Comment: i've done it that way. i was just wondering if there was a different way to do the layout.
Comment: It is also possible to change the admin theme, but apart from that and CSS modification there really is no standard way to change it.
Answer: You could use Display Suite to create custom layouts of your forms and content displays.

Display Suite allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your nodes, views, comments, user data etc. the way you want without having to work your way through dozens of template files. A predefined list of layouts (D7 only) is available for even more drag and drop fun!

A combination of Display Suite and css will allow you to really tweak the standard layout of your theme.
Otherwise Panels is another module that allows you to customize the layout, among many other features.

Content Type Layout for Users


Regarding Multiplicative functions and the Möbius Inversion Formula

Question: I am out to prove that if $$f(n)=\prod\limits_{d|n}g(d)$$ then $$g(n)=\prod\limits_{d|n}f(d)^{\mu{n\over{d}}}$$
I have been grappling with this for a bit too long now, and would really appreciate some help. I suspect logarithms might be helpful after looking at similar problems, namely this one, however I am not to familiar with their workings.
Comment: Taking the logarithm, if $ F(n) = \sum_{d | n} G(d)$ then $\sum_{d | n} \mu(n/d) F(d) = \sum_{d | n} \mu(n/d)  \sum_{k | d} G(k) = \sum_{k | n} G(k) \sum_{l | n/k} \mu(l)$ $ =  \sum_{k | n} G(k) 1_{n/k = 1} =G(n)$
Comment: You're first step is confusing me, sorry.
Comment: $F(n) = \log f(n)$
Answer: You can also avoid logarithms. If $f(n)=\prod_{a\mid n}g(a)$, then
$$ \prod_{b\mid n}f(b)^{\mu(n/b)} = \prod_{b\mid n}\prod_{a\mid b} g(a)^{\mu(n/b)}=\prod_{a\mid n}\prod_{c\mid\frac{n}{a}}g(a)^{\mu\left(\frac{n}{ac}\right)} $$and for a fixed $a$ which is a divisor of $n$,
$$ \sum_{c\mid \frac{n}{a}}\mu\left(\frac{n}{ac}\right)=0 $$
unless $a=n$. It follows that the previous product is exactly $g(n)$, as expected.
Comment: This looks interesting, but I'm having trouble following it starting with the last equality on the first line after the one ending 'then'. Any additional explanation would be nice.
Comment: @GregB.Hill: that is just reindexing. We want to sum over $a\mid b\mid n$, so by setting $b=ac$ we get the shown rearrangement of the double product.
Comment: @Jack.D'Aurizio That's a cool solution: I would never have thought of that.
Answer: You just need to use that $\log(xy)=\log x + \log y$ and $\log(x^y)=y \log x$. Applying $\log$ to your equations (and making the necessary assumptions for the values of $g$ so that the logarithms are defined) yields the usual Möbius inversion formula.
Comment: I was intentionally vague about the necessary assumptions for the values of $g$, since the OP did not specify what the codomain of $g$ was. In general $g$ could take values in $\mathbb{C}\setminus\{0\}$ and the same argument works if you consider the complex logarithm as a multivalued function, i.e. $\log(r e^{i\theta}) := \{\log r + (\theta+2 k \pi)i \mid k \in \mathbb{Z}\}$. Alternatively, if you are interested only in $g$ taking values in $\mathbb{R}\setminus\{0\}$, then you know the statement is true for $|f|$ and $|g|$. All that remains is to show that the signs agree.
Comment: How would you get rid of the logs at the end?
Comment: By applying the exponential function which is the inverse of the logarithmic one.
Comment: Ok, the relation is valid assuming that $g$ is always positive, but shouldn't you address the case where $g$ is not always positive?  (One could make a case to ignore $f(n)=0$ which can cause $f(d)^{\mu(n/d)}$ to be undefined, but negative numbers are perfectly within reason here.)
Comment: I should probably mention that even more generally, the Möbius inversion formula holds for $g$ taking values in any abelian group. The cases we are discussing are just $(\mathbb{R},+)$, $(\mathbb{R}_{>0},\cdot)$, $(\mathbb{R}\setminus\{0\},\cdot)$ and  $(\mathbb{C}\setminus\{0\},\cdot)$.
Answer: The Mobius inversion formula states that for sequences $\{f_n\}_{n \geq 1}$ and $\{g_n\}_{n \geq 1}$, if $f_n = \Sigma_{d|n}g_d$, then $g_n = \Sigma_{d|n}\mu(\frac{n}{d})f_d$. There is a nice proof of this in Wilf's book Generatingfunctionology, which should be available as a free PDF file.
I think what the other logarithm based answers are saying is correct, that your version can be reduced to the form above by taking logarithms, and then applying the Mobius inversion formula, and exponentiating at the end to get your RHS. That is,
Taking logarithms (to your LHS), ${\text log\ } f_n = \Sigma_{d|n}{\text log\ } g_d$.
By the inversion formula referenced above,
$${\text log\ }g_n = \Sigma_{d|n}\mu(\frac{n}{d}){\log\ }f_d = \Sigma_{d|n}{\text log }f_d^{\mu(\frac{n}{d})}$$
and then exponentiating,
$g_n = \Pi_{d|n}f_d^{\mu(\frac{n}{d})}$.
The comments to @posilon 's answer give some additional clarification about making sure the operations are defined: I'm just giving detail on the basic steps and don't have anything to add regarding those subtleties.


Org Id when managed package is installed

Question: Is it possible to get org Id when i install a manage package to any salesforce org. i.e. I have a managed package when it get installed in a org I want to get the org id and send it to an another org, where it get saved. Is this possible.
Answer: Yes, you can get the org id in post install script and post it to your ORG.
here is how to get org ID from .
Id OrgId = context.organizationId()

Here is how you can use InstallHandler Interface to automatically run your code which post the org id.
global class PostInstallClass implements InstallHandler {
    global void onInstall(InstallContext context) {
        Id OrgId = context.organizationId();
        //call future method and pass OrgId
        //From future method call api and pass the orgID
    }
}

Ref : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_install_handler.htm
Answer: If you are using the LMA (Licence Management App), then a sfLma__License__c object will be added to the LMA Org when the managed package is installed. That object has a sfLma__Subscriber_Org_ID__c field that contains the org ID you are interested in. You can use normal salesforce techniques in the LMA org to respond to that insert and perform what ever additional processing you want.
Comment: I would really advise this. While @AtulRajguru9 's solution may work, why reinvent the wheel? the LMA gives you quite a few features out-of-the-box.
Comment: Can you plz provide some doc related to this 'sfLma__License__c' object not able to find anything here.
Comment: @Anu Install the LMA and you can see the object definitions.


Show that $\prod_{k=1}^n (n+k) = 2^n \prod_{k=1}^n (2k-1)$ for all $n\in Z^+$

Question: Show that $$\prod_{k=1}^n (n+k) = 2^n \prod_{k=1}^n (2k-1)$$ for all $n\in Z^+$.
I think I'm supposed to use induction to prove this, but I can't seem to figure out how. Any help would be appreciated, thanks in advance!
Comment: The proof basically amounts to factoring out $2$ from every even number in the original product, thus leaving you with a product of odd numbers. Every other term in the product will ultimately be even. It feels like it might be easier to demonstrate in cases specifying where $n$ is even in one case, and inducting on the even integers, and then inducting on odd $n$ in another case, since it might make the math a little cleaner and the logic/wording in the proof less cumbersome, but that's just a guess.
Comment: Welcome to math.SE. Please see [How to Ask a Good Question](https://math.meta.stackexchange.com/questions/9959/how-to-ask-a-good-question) for information about what we look for on this site. In particular, you should try to the extent possible to include the source and motivation of each problem, not just a statement of a problem that you are trying to solve.
Answer: Induction is not necessarily needed.

We obtain for $n\in Z^+$
\begin{align*}
\color{blue}{2^n \prod_{k=1}^n (2k-1)}&=2^n(2n-1)!!\tag{1}\\
&=2^n\frac{(2n)!}{(2n)!!}\tag{2}\\
&=2^n\frac{(2n)!}{2^nn!}\tag{3}\\
&=\frac{(2n)!}{n!}\tag{4}\\
&\,\,\color{blue}{=\prod_{k=1}^n(n+k)}
\end{align*}
  and the claim follows.
Comment:

In (1) we use double factorials $(2n-1)!!=(2n-1)(2n-3)\cdots3\cdots 1$.
In (2) we use the identity $(2n)!=(2n)!!(2n-1)!!$.
In (3) we use the identity $(2n)!!=(2n)(2n-2)\cdots 4\cdot 2=2^n n!$.
In (4) we have $\frac{(2n)!}{n!}=(2n)(2n-1)\cdots(n+1)$.
Answer: Maybe you can prove by induction that
$$\prod_{k=1}^n(n+k)=\frac{(2n)!}{n!}.$$
Then, prove that
$$\frac{(2n)!}{n!}=\prod_{j=1}^n\frac{2j}{j}\ \prod_{k=1}^n\,(2k-1).$$

There is a combinatorial proof for the whole thing though.  Let's say you want to create $n$ pairs from a group of $2n$ people, say with names (or labels) in the set $\{1,2,\ldots,2n\}$.  In each pair, one person is the leader, and the other is the follower.  The order of the groups does not matter.
We may do the job as follows.  First, select the leaders.  The first leader can be chosen in $2n=n+n$ ways, the second leader can be chosen in $2n-1=n+(n-1)$ ways, so on and so forth.  So, there are $\prod_{k=1}^n(n+k)$ ways to pick the $n$ leaders.  Now, let $t_1,t_2,\ldots,t_n$ be the remaining people, with $t_1<t_2<\ldots<t_n$.  Since we do not distinguish the order of the groups, the pairing of $t_j$ with the $j$th leader creates a unique  grouping.  Therefore, the work can be done in exactly $\prod_{k=1}^n(n+k)$ ways.
On the other hand, we may pick people as follows.  First, the person named $a_1=2n$ has to be paired with somebody.  There are $2n-1$ ways to choose this person's partner, and $2$ ways to decide who the leader is going to be.  Then, we let $a_2$ be the guy with largest label who has not been paired.  There are $2n-3$ ways to pick $a_2$'s partner, and $2$ ways to decide who's boss.  We continue to do so, and at the end, the work can be done in $\prod_{k=1}^n2(2n+1-2k)=2^n\prod_{k=1}^n(2k-1)$ ways.
Answer: Hint: Induction
\begin{eqnarray*}
(n+1) \prod_{k=1}^{n+1}(n+1+k)=\left(\prod_{k=1}^{n}(n+k) \right) (2n+1)(2n+2) = \cdots
\end{eqnarray*}


Error when using Azimuth and Distance plugin

Question: I've use Azimuth and Distance Plugin in the past and it worked with an earlier version of Qgis.  It even kind of worked this morning.  I realized I had the incorrect active layer.  I've closed the project and reinstalled the Plugin.  However, I still get this error.
Answer: I don't think I have the completely correct answer.  Instead of using the active layer.  I used the Memory layer.  That allowed me to complete the drawing.  When I hit the Draw button it brought up a temporary scratch layer, and the Plugin drew the shape on the scratch layer.  I was then able to convert the shape to a polygon and put it on the correct layer.


Allow a user to like a post without having to log in?

Question: I got into an argument with two people who insisted that users do not have to log in to like a blog post. Is this okay? I'm sorry if it seems a silly question, but I was really concerned with the accuracy of the number of likes if we had to implement it this way. I tried explaining to them that a computer can have multiple users and a user can have multiple devices, but they still insisted, suggesting that we could use cookies or even identify a user using the computer's IP address to determine whether a certain post has already been liked or not. If this is okay, I would love to have someone explain to me why (aside from it removing the hassle of creating an account for the users/visitors of the site). Thank you.
Comment: As your question is about the accuracy of *likes*, this would be better aimed at StackOverflow as it's a technical question. From a UX perspective, not requiring the user to log in will always be better than requiring them to log in because it requires less effort on their part.
Comment: I see. Thank you. But when a user who has already liked a post, then comes back to the same post on a different device, wouldn't they think it is a bug since they've already liked that post previously?
Answer: The ability to 'Like' a post without logging in is very attractive in terms of surface level UX - The user doesn't have to bother with usernames and password, they just express an immediate emotion.
In order to retain a meaningful 'Like' system, the 'Likes' would need to be restricted to one per user per post. Without a login, the technical overheads become so expensive that it's not worth doing. You would need to write cookies, check cookies, and check IPs, and that still doesn't prevent someone using proxies or different machines to hit that 'Like'.
To retain an 'Like' system without a login and no technical overhead would render the 'Likes' meaningless as anyone could simply keep hitting like as many times as they wanted.
In both cases it may even be possible to write bots capable of 'Liking' posts on an industrial scale.
The only way to retain a meaningful 'Like' system is to make each 'Like' accountable - attributable to a measurable number of user accounts.
Of course this doesn't prevent cheating but it does make the effort/reward ratio much less attractive.
One route you could take is a persistent login state whereby the user only has to enter their details again if they have specifically logged out or not visited the blog for an extended period - this would allow users to express their emotion with the least amount of friction but would also maintain the meaningfulness of the 'Likes' they apply
Comment: Thanks! I'll see if  I could get them to understand about the technical overehead and the meaningfulness of the likes if it would be implemented the way they wanted it to.
Comment: Actually, the website we're building is a CRM and there are more steps than the usual for a user to sign up, and the blog is just a feature for the marketing guys to use. This is probably why they insisted, but I did suggest that we could use Facebook's API so we don't have to force the user to go through our sign up process and still allow them to like our posts. But they turned it down. I'll see if I could get them to shift with your points which I actually agree with. Thanks.
Answer: The reason large social media platforms have you create an account is because they want to keep track of what you like so they can present you with more accurate advertising.
A more practical approach is that it is easier to for users to keep track of what they like when users have an account. As you said, a computer can have multiple users. What if all were 'logged in as a guest' and started liking different blogs and pages? You wouldn't know how to separate your likes from the others.
I do not know about your blog or product and what your goals are. I can imagine that as an owner of a personal blog you might not need user information. Likes and comments are all that matters. Think of this for your blog and make a decision based on this. Good luck!
Comment: I see. Thanks a lot for your answer. I'm actually a technical guy so I would be more concerned of the accuracy and implementation, not with the marketing strategy or something, so I really had a hard time understanding why. Thanks a lot.
Comment: I'll think it through and write down the pros and cons I could think of.


Mail to SMTP Server via Exchange

Question: The title already says much;
I want to send mails with an adress ( email@example.com )
Until we got our Exchange-Server, we were recieving via POP and sending via SMTP.
The office (4 People) wants still to recieve and send with this E-Mail.
The recieve is easy to solve with the POP-Connector that distributes the mails to the accounts, but how about sending? (All mails should go via Exchange-Server but with source adress: firstname.lastname@example.com)
Comment: It doesn't have to change: instead of using POP3 protocol to pull your mail from a third-party into your mail server, reduce complexity by having the MX records point to Exchange (well, point to an A record that resolves to the IP address that Exchange is behind/using) and receive mail with SMTP, not just send it.
Comment: I'd also turf the POP accounts if you have the option (have control over something.com's MX records) and send mail directly to Exchange.
Comment: @gravyface The problem ist that the current mail address is known and thy don't want to change...
Answer: You will have to create a mailbox on the Exchange server with that address as the primary SMTP address. Then give the users SendAs privileges to that mailbox. When sending a message, they can pick this mailbox from the menu next to "From" on the new message.
Comment: @heysamhey you need to make Exchange authoritative for your domain.  I suggest you read up on Exchange fundamentals; there's quite a bit to running your own Exchange (mail) server; you might be better off with a hosted solution.
Comment: How can I add a mailbox with an adress that hasn't the ending @something.local ?

Mail to SMTP Server via Exchange


I'm having difficulty populating a two dimensional array with random Boolean values and then reading those values back out in JavaScript

Question: I'm working on a really simple cellular automata program in JavaScript.  For right now I just want to write a bunch of random Boolean values to a two-dimensional array and then read that array back to be manipulated or displayed in some way.
var dimension = 5;

var grid = new Array();

for (x = 0; x < dimension; x++) {

        grid[x] = new Array();

}

//populate grid

for (i = 0; i < dimension; i++) {

        document.write('
');
        for (j = 0; j < dimension; j++) {
           grid[i,j] = Math.floor(Math.random()*2);
           document.write(grid[i,j]);
 }
}

for (i = 0; i < dimension; i++) {

          document.write('
');
                  for (j = 0; j < dimension; j++) {
                  document.write(grid[i,j]);
    }
}

So, I've whittled the code down to a few nested for loops where I cycle through and populate the array and then print it back.  Note that the output generated during the population loop is what I want, random values.  But when I read the array back, it seems like the last row (I think it's really a column, but it's displayed horizontally) has been copied to all the others...
I've done this sort of thing before in other languages and never had a problem like this.
I'm new to this community and JavaScript in general so this might be a dumb questing or I may not have presented it helpfully.  I would really appreciate any help or advice on how I can improve my question.
Answer: Array indexes in JavaScript are not comma seperated. You need to use brackets. So for your two dimensional array it will be:
grid[i][j]; // not grid[i,j]