Restore iPad to factory-default

Question: How to make iPad back to factory default without iTunes, restrictions code, iCloud, or backup. I want everything erased so I can completely start over.
Answer: Without using iTunes, you can go to Settings > General > Reset, and click reset/erase all content and settings:

It's iOS 7, but it's the same for every version.
If you do it this way, it will prompt you for both your password and restrictions passcode several times.

Restore iPad to factory-default


iPhone SDK - EventKit time zone issue

Question: I am having some trouble with adding an event to a calendar in my iPhone app.
I am using the code:
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
event.title     = self.event.eventTitle;
event.startDate = self.event.startDate;
event.endDate   = self.event.endDate;
event.notes     = self.event.description;

[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];

which adds an event to my calendar just fine. The problem is that my timezone is clearly off. For instance, self.event.startdate outputs in the debugger as 012-05-11 20:45:00 +0000, which is correct.
However, when I look in my calendar, the event was added at 4:45 PM (not 20:45 or 8:45 PM as it should be).
When I output the entire event object using po event, I get:
EKEvent <0xf853320> {EKEvent <0xf853320> {title = Tuesday Night Lights!; location = (null); calendar = (null); alarms = (null); URL = (null); lastModified = (null); timeZone = EST (GMT-05:00) offset -18000}; location = (null); startDate = 2012-05-11 20:45:00 +0000; endDate = 2012-05-11 21:45:00 +0000; allDay = 0; floating = 0; recurrence = (null); attendees = (null)}

Here the startDate reads correctly too. I am located in EST timezone (as is my phone), so how can I get my code to add the event to my calendar at 8:45 PM?
Any thoughts would be very helpful!
Answer: The event is added at the correct time. It is just a matter of showing the time with the correct time-zone corrections. I have found that this solved my problem:
Instead of writing it like this:
NSLog(@"startDate: %@", [startDate description]);

Write it like this:
NSLog(@"startDate: %@", [startDate descriptionWithLocale:[NSLocale currentLocale]]);

Hope this could help you to solve your problem.

iPhone SDK - EventKit time zone issue


Does the price of a domestic US (east to west coast) flight depend on from where I book it?

Question: I'm planning to fly (one-way) from NY to SF. I'm based in Europe and I wonder, will the price (regardless of currency issues) be significantly different if I book it from here, or only when I get to the US? Obviously, I believe its going to be a return flight where I accidentally miss the return part.
Comment: BTW, you've done two things that have increased the price by more than $100, outbound on a Saturday and 'return' on the day after Thanksgiving here in the US. And, as Many carriers offer one-way fares that are precisely half of the round trip.
Comment: Let me echo that this route is flown by a number of carriers (at least JetBlue, Virgin America) that price round-trip as the sum of the one-ways, so there is no _possible_ advantage to abandoning a return ticket. For competitive reasons, other carriers that may offer a round-trip discount on other routes do not on this one. Also, be sure to use all New York airports (including Newark) and as many Bay Area airports (SFO, OAK, SJC) as feasible; this can affect your best fare significantly.
Comment: Hi, welcome to TSE. What do you mean by 'accidentally'? Do you mean that since round trips are sometimes cheaper (strangely) than one-way tickets, you'll buy a round trip and then not show on the return flight? So "accidentally" in quotes? Also, what do you mean by "from here"? I'm assuming you're planning to book online anyway? Do you mean that companies may use your IP address to determine where you are and adjust your price based on that? What exactly do you mean?
Comment: That's what I'm trying to figure out... In my post, I tried to just anticipate the suggestion to book a return flight, even if I only require one-way, because this i know.
To make it concrete, the price I see for
05. Nov., UA1455
25. Nov., UA577
in total is 437 USD.

Could somebody who is physically located in the US check this arrangement and post what price he/she sees?
Answer: It has been proven that websites can do pricing on all kinds of elements (your search history, the browser you're using, your location, your laptop brand, ...)  Check this article: lifehacker: how websites vary prices
I don't know if any of the US airlines use this practice.  I'm a Platinum FF with AA.com and I always compare the prices they offer on their US site with the prices on their European sites.  Sometimes the US site has cheaper prices but more recently is has always been the EU site that showed me the best price.  Know however that (in case of AA) the US site requires a US Credit Card to pay for the fare.
I don't know how long upfront you will arrive in the US but I wouldn't push your luck and wait till the last minute to buy your ticket.  Maybe your dates are flexible and NY-SF is probably a pretty popular route with a lot of competition (just guessing) but you may end up paying a lot more.
The best time to buy your tickets is not the very last minute but rather on average 8 weeks to 1 month upfront.  (Check this article: Best time is 54 days out) I would rather look at this time window than your location.
When travelling domestically I always use the 8-4 weeks time window.  For international travel 6-4 months.  In my experience we always ended up paying a fair price.  To decide what a fair price is I compare with historical and competitors prices.

A LITTLE EXTRA: If you want you can use a browser plugin like Hola.  This would allow you to use a US IP address and would simulate that you're based in US.  Check the first link in my post for some more tricks.
Also, in this particular case a return might be pricing cheaper than a one-way but it's a myth that this is always the case.
Comment: "It has been proven that websites can do pricing on all kinds of elements" ... If you talk to anyone who works in revenue management at a major network airline, no one implements this practice, or even knows feasibly how it could be done given existing technology constraints. The fact is that airline fare distribution has not changed much since the 1980s; the website is a clunky front end to that backend process.
Comment: Just a heads up with Hola specifically, [it turns your comp. into an exit node and they sell your traffic data](http://www.ghacks.net/2015/05/28/beware-hola-vpn-turns-your-pc-into-an-exit-node-and-sells-your-traffic/)
Answer: Due to the vast number of sites offering air tickets, mere probability dictates that the answer might be yes for at least a couple of them.
If you want to investigate whether any given site offers different prices to customers depending on which country they are accessing the site from, you can use an Internet proxy to make it seem to the site that you are accessing it from your country of choice. This will allow you to compare various countries.
You can find a variety of free proxy services. I like hide.me. They allow you to choose from a variety of countries (including the US) as your proxy country.
When using a proxy, you can use the site DNS Leak Test to confirm that the proxy is working as it should be.
Answer: The answer to the specific question is no.  The price will not change significantly if at all based on where you are physically located.
The price you pay can change based on the local site/currency/credit card you use, but that's due to exchange rates.
Note, for US carriers and domestic routes it is highly unusual to find round trip tickets priced less than one way tickets currently.  The 'leisure fare' and 'Saturday night stay' are pretty much gone.
Comment: @Relaxed The network American carriers largely abandoned round ticket pricing for domestic itineraries some time ago. To be fair, unless you travel in business class in Europe, it is a similar story, although Air France is stubbornly refusing to shift any ground for most city pairs.
Comment: @Calchas KLM too, no? As it happens due to my location and professional obligations I often end up flying with either Air France or KLM these days so I might have a somewhat warped perspective on this...
Comment: I assume the last sentence refers to US domestic flights? It's still pretty common in Europe, for one.
Comment: Thanks.  Edit that actually makes the answer more specific to the OP's situation.


Lower bounds on discrete time finite Markov chains hitting probabilities

Question: I am interested in some general theorems related to lower bounds on  discrete time finite Markov chains  hitting probabilities (preferably ergodic chains , but not necessarily ), with references . Similar results related to continuous time Markov chains, that allow discretization,  are welcome. Thank you.
Comment: The question is  too broad.  if you narrow it down a bit you may  get  more helpful answers.   To quote Heisenberg "you can say  nothing about everything, and everything about nothing".
Comment: @LiviuNicolaescu  Thank you for your feedback. The question is connected to this paper that I posted on arXiv   server:  https://arxiv.org/abs/1804.11181      This is my Clustered Sparrow Algorithm.  I claim that NP  complete problems,  like 3SAT can be solved efficiently by randomised algorithms. Basically I propose to prove that NP=RP. My theoretical analysis is incomplete, but I strongly believe this could be an interesting approach. Unfortunately,  my BSc. training level in mathematics limits my success odds in this direction. In other words, I could use some help in this direction.
Comment: Those are the roots of my question.  I have studied this problem (NP=RP) for a few years. I think that some strong results in ergodic Markov chain theory should solve the problem stated in my previous comment.
Comment: I cannot reformulate the question in a more specific manner, unless I talk about the Clustered Sparrow Algorithm and the associated Markov chain model, and this is not meant to be a self .promotional post, but this is the background related to my question.
Comment: Your comments address my suggestion.   Let's hope somebody out there can help you.
Answer: Chapter 10 in the book "Markov chains and mixing times (see http://www.ams.org/publications/authors/books/postpub/mbk-107
  and https://pages.uoregon.edu/dlevin/MARKOV/mcmt2e.pdf )   is all about bounding hitting times for discrete chains.
Comment: Thank you for the free link to your book, as time allows me I will get to work. I explained the background related to my question on stackexchange,  and indicated a link to my paper that I posted on arXiv (second comment), in which I developed the Clustered Sparrow Algorithm.  The fundamental ideas on which my algorithm is based belong to Professor  Schoning (given in references), and all I do is develop his ideas a little bit further. As a consequence,  I do not claim any kind of priority in this direction of research.
Comment: For me this is just a fascinating  problem,  with an importance hard to overestimate.  If you also find these ideas interesting,  and if you can allocate time for this task, please feel free to develop them further. My theoretical analysis is incomplete , but Schoning's ideas are reallly,  really interesting.
Comment: I browsed chapter 10 of your book, yes, this is the real deal. Once again, thank you  @YuvalPeres
Answer: Wouldn't gambler's ruin work? It has a lower bound (being bankrupt), and it is discrete finite MC. You can calculate the probability of being bankrupt too.
Comment: In 1991, Professor Papadimitriou proposed a randomised algorithm that solves 2SAT in quadratic time with high probability.  The associated Markov chain model can indeed be reinterpreted in terms of the gambler's ruin problem.  Your intuition is correct. Unfortunately,  this type of  algorithms cannot be proved efficient for 3SAT,. More refined  techniques and Markov chain models come into play, in relation to this problem.
Comment: I assume you read all the previous comments.  Going back to the question that I asked,  I was hoping for some guidance and specially references related to much deeper results in the direction mentioned in my question.  Unfortunately,  it seems to me that the experts are convinced that these hard problems (mentioned in my comments above )  cannot be efficiently solved by randomised algorithms in every single instance. I dare to disagree, but I am not an expert, so I will stop here.


missing cookies after upgrade to 2.10

Question: after upgrading from v2.1.3 to v2.10 i am no longer seeing several cookies including exp_uniqueid, exp_userhash, and exp_memberid. I can only seem to log into the admin CP and not the site anymore.
Comment: ive been combing through the libraries/Session.php and member login functions and i just dont see where some of these cookies are being set anymore. It looks to me like all the userdata is being tied to the session id and no longer being set discretely in EE 2.10. Shouldnt i be seeing a unique_id cookie still?
Answer: I'm going to jot down what I have in my bog standard 2.10.1 install, after logging in. My install is fully working.

PHPSESSID (for finding server session)
exp_sessionid (for finding your ee session)
exp_csrf_token (for Form anti-forgery)
exp_expiration
exp_last_activity
exp_last_visit
exp_perpage
exp_tracker

I think the 'missing' cookies are actually a good thing! With them MITM attacks and other personal information gathering vectors could be used. I beleive EE now uses a more standard principle of toring your session in the DB, the session vars in your PHP session, and just a couple of reference fields for matching are sent via cookies (noted above).
This method is way more secure, yes we have a couple of nuggets of info but these are de-personalised. i.e. if I visited your machine while you were taking a 'toilet break' I could lift your cookies, they'd tell me when someone was last on the site on your computer, but doesn't tell me anything about what user it was...
Of course we don't have an answer yet as to why your login Is not working. We need to check the basics first (sorry):

Clear Cache, Clear Cookies, Go Private Browsing, authenticate and monitor the cookies sent
Please can you check and let us know your Security Settings (Admin > Security & Privacy > Security & Sessions)
Comment: This is the same set of cookies being set on my instance as well. You more or less answered the question i had which is why am i no longer seeing the exp_uniqueid and exp_memberid cookies - they are no longer being set as discrete cookies and this data is now being stored directly in the session. i cant vote up due to my points but will when i am able to
Comment: Cool, as long as your set :) But did you get your login issue sorted?? You dpn't need to vote up but you can accept as the answer (just below the voting icons you should see a tick to click) if you like. This is the important one (costs no rep) as it shows the question does have an answer attached and helps out anyone else with similar issues.

missing cookies after upgrade to 2.10


What is the most popular chess app for android?

Question: What is the most popular chess app for android that is used for playing against other Human opponents?
Answer: Every good chess website has its own app. Such as chess.com, lichess, chess24, ...
Just lunch play store and enter your favorite chess site name, you will find its app. They usually have human mode or computer mode with various time controls. With chess.com app you are also able to challenge particular opponent by his user ID and in lichess it's even easier, create a challenge and send a link of challenge to your opponent.
It turns out some people here cannot get what is the most popular app to play against other humans in android even w.r.t my answer that I put some of those apps in order. It's clear that app is chess.com app, as the number of members of chess.com is way more than any other website and if someone still says this is not related to app, then 1M+ downloads of this app on play store compare to 10K+ downloads of other apps clear's everything.


Water heater temperature and pressure relief valve plumbing

Question: I recently bought a home in Florida where the electric water heater is located in the garage. I seem to have felt some odd water temperature fluctuations where one day it felt much cooler than normal and the next much warmer than usual. I know the water heater is at least 19 years old, and the last inspection tags on it show July 2004. My question is regarding the placement of the temperature and pressure relief valve. It seems to be plumbed back into the cold water line. Is this correct?? I attached a picture of the top and the T&P valve connects to the cold pipe which also comes from the rear of the heater. I know the hot water line is on top on the left, and the cold water lines on the top right and in the rear. Let me know if the plumbing is incorrect, either way I plan to replace the whole thing soon anyway!
Thanks, Ryan
Comment: I can't comment on the cold side plumbing connection, however the pressure relief valve is top center.  If the tank is electric and has dual elements and the complaint is fluctuations in temp then likely one of the elements is burnt out.
Comment: What is the valve on top of the vertical line on the cold side?  It seems that the T&P drain was manifolded with the line off of it -- a closeup photo of it would be quite helpful.
Comment: The tee on the left and behind the water heater; what does its bottom end connect to?
Answer: The temperature relief valve should never be connected to any water line. This is a safety that keeps the water heater from becoming a bomb. If there is any question about relief valve not working properly, replace it. The piping from the t/r valve should be run towards the floor with no plugs or reduction in size so it can do as its name - relieve pressure if the water heater thermostat should stick on and keep heating water.
If your relief valve leaks water it's either defective or your water temp is too high. Most people are afraid to test relief valves but you should open it at least 1 time per year to make sure it opens properly and reseats. Most valves are 3/4 inch output and should run down to within 4 inches from floor. To test, put a can or container under and lift lever for 2 to 3 seconds and watch for water to escape then stop.  This insures your valve is opening and closing as it should.
Answer: The plumbing is not "incorrect" per se.  The only thing we try to have is the bottom end of the piping from the TPR valve exposed vs plumbed to a drain so you can see if something is awry with the TPR valve.
It is a curious thing what is coming off the cold water line.  What ever is coming off your cold water line is surely designed to release and drain like the TPR valve in its own way for its own reasons.
You TPR valve plumbing that is visible (which is in question) is fine though.
Answer: This is a siphon valve prevents water from being siphoned back Into the water heater probably because the water heaters location is lower in the house for at least one  fixture('s) And the tnp will function normal because that siphon valve has a spring loaded valve in it that only operates one way
Answer: On the cold water pipe is a second relief valve. Its discharge is plumbed together with the discharge of the tpr valve. That should go down to your pan.
Comment: How can you tell from this image that this a relief valve?


Doubt about half adder timing

Question: In my book there is the architecture of a basic circuit with a half adder with 1 AND and 1 XOR for the carry, and a "maimed" half adder with one XOR for the previous carry. Then book say that minimum time of an operation is $$t_{min}=t_{xor} $$ (without carry) and the max time is $$t_{max} = t_{xor} + t_{and}$$ but the max time should not be $$t_{max} = 2t_{xor} + t_{and}$$ ?
Answer: The output of the top XOR is not an input to the logic that generates D1, so the delay through the top XOR does not contribute to the delay from Q0 and Q1 to D1.
Answer: Your "maimed" circuit makes no sense at all. A half-adder is just two gates:

simulate this circuit – Schematic created using CircuitLab
A full adder combines two half-adders and an OR gate to handle carry-in and generate carry-out:

simulate this circuit
If for some reason you wanted a circuit that had a carry-in but no carry-out, you'd simply eliminate all of the AND and OR gates:

simulate this circuit
There is no configuration that has an XOR gate following any AND or OR gate.
Comment: The circuit was written by my professor of Electronics, I thought that it was right.

Doubt about half adder timing


Magento 2 : Is there Any Method to Add 3rd Step Before Final Place Order Button is Clicked?

Question: I want to add step before final checkout is done to show order summary (address, shipping details, and payment method etc. which are selected by customer). how to implement? Please help.
Answer: Not easily. Every payment method handles its own order placement (with its own place order button and corresponding JS code). Adding a post-payment step would require overriding that JS for every payment method you offer to account for the additional step, in addition to the normal process of adding your knockout component.
Magento 2 dev docs detail the process for adding a checkout step here: http://devdocs.magento.com/guides/v2.1/howdoi/checkout/checkout_new_step.html
The doc suggests you can set sortOrder > 2 to have your added step after payment, but as I noted each payment method handles its own submission (assuming it will be the final step). It's unlikely adding a review step will be as simple as the doc lays out.


Switching state server to another machine in cluster

Question: We have a number of web-apps running on IIS 6 in a cluster of machines. One of those machines is also a state server for the cluster. We do not use sticky IP's.
When we need to take down the state server machine this requires the entire cluster to be offline for a few minutes while it's switched from one machine to another.
Is there a way to switch a state server from one machine to another with zero downtime?
Answer: You could use Velocity, which is a distributed caching technology from Microsoft. You would install the cache on two or more servers. Then you would configure your web app to store session data in the Velocity cache. If you needed to reboot one of your servers, the entire state for your cluster would still be available.
Answer: You could use the SQL server option to store state. I've used this in the past and it works well as long as the ASPState table it creates is in memory. I don't know how well it would scale as an on-disk table.
If SQL server is not an option for whatever reason, you could use your load balancer to create a virtual IP for your state server and point it at the new state server when you need to change. There'd be no downtime, but people who are on your site at the time would lose their session state. I don't know what you're using for load balancing, so I don't know how difficult this would be in your environment.


Running Visual Studio Built C# GUI on Raspbian Jessie

Question: I am using a Raspberry Pi 3 with the official 7" touchscreen. I would like to build a GUI on visual studio on my PC, and then be able to run the program on the Raspberry Pi, with the Pi running Raspbian. What is the best way to do this?
Comment: Have you given Windows 10 IoT a look?
Answer: You could use Mono with Xamarin studio. I did some basic application in wheezy, the GUI update speed is quite low.
Answer: Have you considered using windows 10 IOT and writing a UWP application that automatically launches with the pi?
Take a look at: https://developer.microsoft.com/en-us/windows/iot for the windows IOT.
The hello world tutorial is here:
https://ms-iot.github.io/content/en-US/win10/samples/HelloWorld.htm
and at the bottom of the last link you'll see a guide to setup your app as a startup app.
Answer: Microsoft recently released the Visual C++ Linux Development Environment for Visual Studio, which allows to debug and release code from VS directly on the Pi.
Since implementing C# in C++ is possible with manageable effort (even C#-libraries), you might be interested in this workaround. However, you will have to deal with a little C++ though.


Unit test for Pause Reason in a Screen Flow

Question: I've created a script in apex that captures the pause reason in a screen flow.
In general, I use the FlowRecordRelation and FlowInterview to capture the pause reason and save it to a specific field.
The script is working and now I need to test it.
So I started by trying to insert a flow:
<code>@IsTest
private static void testCopyPausedReasonFromFlow() {

    My_Object__c q = [SELECT Id FROM My_Object__c];

    {
        Map<String, Object> inputs = new Map<String, Object>();
        inputs.put('recordId', q.Id);
        Flow.Interview.My_Object_Flow_V1 myFlow =  new Flow.Interview.My_Object_Flow_V1(inputs);
        myFlow.start();
    }

}
</code>
but this didn't work because myFlow.start() threw an error:

System.FlowException: Start can't be called on a flow with the process
type Screen Flow.

I then found that the start method only works for autolaunched flow or user provisioning flow per this article.
So my question is:
Is there a way to create FlowInterview and a FlowRecordRelation records in a unit test without doing the above? The documentation is really limited and this is the actual goal here.
Answer: There is no way to create a FlowInterview regardless of the Test context for Flows other than autolaunched type.
As an example, if you had an screen flow, you could not mock the screen user interaction from you apex code, that is why it does not have much sense to be able to start them, since they will get stuck at that point.
For the good or the bad, Salesforce does not force you to write Apex Test to deploy Flows directly as Active if they are not autolaunched, because this option, even enabled, only applies to processes and autolaunched flows.
As the documentation states:

By default, active processes and flows are deployed as inactive. After deployment, you manually reactivate the new versions. If your org uses a continuous integration and continuous delivery model to deploy metadata changes, enable the option to deploy processes and flows as active. This option applies to processes and autolaunched flows that are deployed via change sets and Metadata API.


Effect of velocity on gravitational force

Question: If I am aboard a spacecraft and have with me two identical metal spheres having rest mass $= m$, what happens to the gravitational force between these two spheres as the space craft velocity approaches the speed of light. According to Newton, $F = G*m1*m2/r2$.  Does $F$ between my two spheres increase according to this equation as the relativistic mass increases, or is it only a function of the rest mass of the two spheres?
Comment: Relativistic mass is an outdated concept and isn't very useful. Also, Newtonian gravity is incompatible with special relativity; you need general relativity to account for gravity.
Answer: In the rest mass system of your spacecraft, there will be no difference in measusring the force of one sphere on the other.
A good example is that Newtonian celestial mechanics is very successful in describing the planetary system.  There exists a star in our galaxy that is moving with 8% of the velocity of light, but at the rest frame of our star, this makes no difference.With respect to the rest system of that star we are moving at 8% of the velociy of light. Observers  on that star's reference system would see our planetary system distorted and would need to unscramble newtonian gravity's $1/r^2$  in our rest system   .
Relativistic mass is not a useful concept, except if one wants to calculate the amount of fuel  needed for a craft to reach a specific velocity with respect to a given star.
Answer: The relativistic force transformation answers your question regardless of whether the force is gravitational, mechanical, or electrical. Therefore, if you place the masses a distance $d$ apart from each other perpendicular to the direction of velocity $v$, the $g$-force should reduce by the inverse of the traditional gamma factor as measured by the lab observer located outside the craft. However, if you locate the masses in a way that $d$ is parallel to $v$, the $g$-force remains unchanged (measured the same as in the craft's rest frame) from the viewpoint of the lab observer.
I do not know how exactly GR demonstrates the forces in your example, however, they must comply with the results predicted by SR while the masses are not accelerated very much due to the mentioned $g$-force nor the field affects the uniformity of the spacecraft motion at a constant $v$.
Comment: @m4r35n357 Irrelevant. It is not about gravitation, but rather the *force*. The force transformation in SR is applicable to force of any sort as long as the observers are inertial.
Comment: @m4r35n357 Why do you think that the force is not calculable in the craft's rest frame? It can easily be calculated using the distance inverse square law as mentioned by the OP., at least, for the weak field produced by two metal spheres. Do not try to upset other people's answers for the subjects on which you do not have sufficient knowledge.
Comment: My apologies, _nothing_ happens to the spheres.


Did God create Jesus' soul?

Question: This is one of a series of questions I have regarding the Christian notion of the Trinity.  Assuming Jesus soul was created, and that Jesus has a free will of his own, then any God-like attributes Jesus possesses would be the gifts given by a Father to a dutiful Son.  If Jesus soul was not created, then presumably "Jesus" would just be another name for "God", being one and the same identically.  Presumably.  Is there a consistent Trinitarian view on this, or are opinions widely varied?
Answer: This was a controversy in the early 1800s and provoked William Huntington to write one of the most spiritual books I ever read (outside of scripture) 'The Soul of Christ' wherein he states :

... divinity is not made, nor created ; much less created out of earth (p5)

where Huntington counters the error of a 'divine soul' saying that no such thing exists and that it is a contradiction in terms.

... if Christ hath not a human soul, every scripture which declares him to be man is absolutely false.

God is the 'Father of spirits' (Heb 12:9). His [Christ's] body was made of the woman's substance. his soul was made by God. His flesh was of the virgin, his human spirit of the Almighty.

Huntington further quotes Jesus himself, saying,

Now is my soul troubled [John 12:27 KJV]

My soul is exceeding sorrowful, even unto death ... [Matt 26:38 KJV]

WH also quotes from the prophets and the prophetic psalms :

thou wilt not leave my soul in hell [Psalm 16:10 KJV]

When thou shalt make his soul an offering for sin [Isaiah 53:12 KJV]

I recommend the whole of this very short book, twenty-eight pages. But I have no link, as yet to it. If I find one, I will add it, in due course.
Comment: @Tennman7 Jesus Christ possesses all the attributes of humanity and all the attributes of Deity. The human soul is a created thing, created at a point in time. The Divine _Person_ of the Son of God is eternal.
Comment: You may purchase and download the PDF of "The Soul of Christ" here:  https://christianbookshopossett.co.uk/doctrine-theology/17631-the-soul-of-christ.html.  It was originally published under the name "The Doctrine of Garrett Refuted".
Comment: Thanks, Nigel. It looks like an interesting book.  But it seems from the quotes you cited here, that it proves/ affirms that Christ indeed had a soul [the psyche, which comprise the mind, will, and emotions, our personality]. Not that they were created.  Christ is God and co-existed with God and the Holy Spirit from eternity past.  The Holy Spirit was not created at Pentecost, or any time- same with Christ. It was only the incarnation, where he became flesh, "and was in all points tempted like we are, yet without sin."
Comment: @MikeBorden I have just ordered a copy from that bookshop. I remember once delivering christian books to that very bookshop in about 1987 or thereabouts. Thank you.
Answer: Yes, Jesus had a true human nature, which includes a created body (made from the matter supplied by the Blessed Virgin) and a created soul (created by God ex nihilo, out of nothing).
Arius and Apollinaris thought that the Son of God assumed (took on) only a body and not a human soul, but this is a heresy. Cf. St. Thomas Aquinas's question "Whether the Son of God assumed a soul?" (Summa Theologica III q. 5 a. 3).
Answer: Did God create Jesus' soul?
The short answer is yes.

Your question was raised in the early centuries of the Church. Christians at that time were trying to figure out more accurately the nature of the Incarnation — what it means to say that "the Word became flesh and dwelt among us" (John 1:14).
In time, the Church gave a definitive answer: When God the Son became a Man, He took for himself a complete human nature. The human nature that He took (the technical theological term is "assumed") included everything that makes us human.
So what does this include? Human beings are composed of both a body and a spirit. The body and spirit are not two natures, but two components so intimately joined that they form together a single human nature.
Are spirit and soul the same thing? In human beings (though not in other living creatures on earth), yes: Their immortal spirit, created by God, functions as their soul, which is defined as the animating principle of a body — that is, the thing that gives life to the body. (When the spirit departs, the body dies.) The term spirit, then, refers to what it is, its essence; the term soul refers to what it does, its function.
As a rough analogy, consider the rock that sits on a stack of papers on my desk. If you ask what it is, I say it's a rock. If you ask what it does, I say it's a paperweight.
Because this single human nature is composed of both body and soul (spirit), when God the Son became a Man, He took for himself not only a human body, but also a human soul. This means that the Incarnate God had (and will always have — He will never lose them) two natures: one divine, and one human, with the human nature being composed of both body and soul.
Why was it so important for the Church to clarify this reality? Because, as the Church Fathers often emphasized, the purpose of the Incarnation was to heal and save human nature. If some part of that nature was not included in the Incarnation, neither would it have been saved and healed.
Do we fallen human beings need healing in our souls? Of course! Jesus came to heal the disorder of our souls: our thinking, our will, our emotions. So He took a human soul as well as a body.
This reality is reflected in the traditional formulation that when we receive Our Lord in the Eucharist, we are receiving not only His Body and Blood, but also His "Soul and Divinity." His Body and Soul are so intimately joined, and His Humanity and Divinity so completely in union, that to receive any one of these is to receive them all — the whole Person, Jesus Christ, the Son of God in the flesh. - Does Jesus have a soul?

St. Thomas Aquinas thus explains it thus in his Summa Theologica.

Whether the Son of God assumed a soul?
As Augustine says (De Haeres. 69,55), it was first of all the opinion of Arius and then of Apollinaris that the Son of God assumed only flesh, without a soul, holding that the Word took the place of a soul to the body. And consequently it followed that there were not two natures in Christ, but only one; for from a soul and body one human nature is constituted. But this opinion cannot hold, for three reasons. First, because it is counter to the authority of Scripture, in which our Lord makes mention of His soul, Mt. 26:38: "My soul is sorrowful even unto death"; and Jn. 10:18: "I have power to lay down My soul [animam meam: Douay: 'My life']." But to this Apollinaris replied that in these words soul is taken metaphorically, in which way mention is made in the Old Testament of the soul of God (Is. 1:14): "My soul hateth your new moons and your solemnities." But, as Augustine says (Qq. lxxxiii, qu. 80), the Evangelists relate how Jesus wondered, was angered, sad, and hungry. Now these show that He had a true soul, just as that He ate, slept and was weary shows that He had a true human body: otherwise, if these things are a metaphor, because the like are said of God in the Old Testament, the trustworthiness of the Gospel story is undermined. For it is one thing that things were foretold in a figure, and another that historical events were related in very truth by the Evangelists. Secondly, this error lessens the utility of the Incarnation, which is man's liberation. For Augustine [*Vigilius Tapsensis] argues thus (Contra Felician. xiii): "If the Son of God in taking flesh passed over the soul, either He knew its sinlessness, and trusted it did not need a remedy; or He considered it unsuitable to Him, and did not bestow on it the boon of redemption; or He reckoned it altogether incurable, and was unable to heal it; or He cast it off as worthless and seemingly unfit for any use. Now two of these reasons imply a blasphemy against God. For how shall we call Him omnipotent, if He is unable to heal what is beyond hope? Or God of all, if He has not made our soul. And as regards the other two reasons, in one the cause of the soul is ignored, and in the other no place is given to merit. Is He to be considered to understand the cause of the soul, Who seeks to separate it from the sin of wilful transgression, enabled as it is to receive the law by the endowment of the habit of reason? Or how can His generosity be known to any one who says it was despised on account of its ignoble sinfulness? If you look at its origin, the substance of the soul is more precious than the body: but if at the sin of transgression, on account of its intelligence it is worse than the body. Now I know and declare that Christ is perfect wisdom, nor have I any doubt that He is most loving; and because of the first of these He did not despise what was better and more capable of prudence; and because of the second He protected what was most wounded." Thirdly, this position is against the truth of the Incarnation. For flesh and the other parts of man receive their species through the soul. Hence, if the soul is absent, there are no bones nor flesh, except equivocally, as is plain from the Philosopher (De Anima ii, 9; Metaph. vii, 34).
Answer: The answer is No.
In order to explain this more completely in a way that makes sense, we have to look at the creation of man in Genesis by God. It says that mankind was created in the image of God? Does this mean that we look like God, have the same facial features, hair color, body style? No, because there are thousands of different features of races across the planet, from fair skinned Skandanavians to Africans and Asians.
We are made in God's image in that mankind is also a tri-une being. 3 in 1. The trinity is one of the most complex concepts to explain in all of Christianity. Every analogy falls short, but here are some that can help.  Travis is one guy, but he is a Husband, a Father and a Son, all at the same time.  Another example is how we have H20 - and it exists in three forms, liquid, ice and vapor, but all still the same element.
Mankind has body, soul and spirit.  The Greek word for soul is "Psyche" where we get Psychology - and is the mind, will and emotions- which make up our personality. This is the same part that animals have. The Spirit is the immortal part, and this Spirit is the part that makes us unique from animals - the part that has a conscience and is accountable for sin, and which lives forever, either in Heaven or Hell.
The Trinity is God the Father, God the son- Jesus and God the Holy Spirit, and it is eternal. Each member of the trinity existed forever and was not created. Jesus was not created by God, nor was the Holy Spirit. The deity of Christ is one of the core- foundational truths of Trinitarian Christianity, and one of the defining points that sets us  apart from denominations like Mormonism and Jehovah's Witness which teach that Jesus was created. He is not eternal.
Jesus was fully God and fully man - so yes, he had a soul, or distinct personality, and sense of humor, separate from his brothers, and he is spirit - but the Holy Spirit and Jesus co-existed with God from eternity past- they were not created, nor was their personality, when Jesus was born.
John chapter 1 says "In the beginning was the word- [Logos], and the word was with God, and the word was God."  Jesus is the Logos, the living word.
"All things were made by him, and without him was not anything made that was made. In him was light, and the light was the light of men."
Comment: This answer demands that God has a soul while Scripture demands that God is Spirit.
Comment: This does not make sense. You begin by saying 'No', then you say 'yes, he had a soul ...' If the soul is human, it is created.
Comment: To join the two words together 'soul' and 'eternity' is to form a contradiction. 'Jesus' did not 'exist with God' 'for eternity'. 'Jesus' is the one born of Mary, who had a human soul. The Son of God is the only begotten of the Father ; his is 'the eternal life which was with the Father'. And these two descriptions describe One Person. But one must understand (and believe) both aspects in order to truly believe in he who is Jesus, the Christ, the Son of God.
Comment: Nigel, the deity of Christ as part of the trinity and eternally existing with God is not only one of the pillars of Christian doctrine, it is found in many Protestant Statements of Faith.  Take away the deity of Christ - [The doctrine that Jesus was fully God, not a created being] and you have no trinity.  The same is true of the Holy Spirit.  Cheers.  You might want to check out some other sources on the trinity. Gotquestions.org  is a good start.
Comment: Does this answer express a non-Chalcedonian view of the incarnation? Non-Chalcedonians can still be Trinitarians, but it is best to be explicit.
Comment: Mike, -it seems like you are agreeing here that Jesus and God are one [Trinity]. I agree God is spirit.  This question is not about God the Father, but about Jesus, and the main point is if Jesus had a soul [when he became flesh, he was still fully God - and he claimed this. and his enemies recognized this]  Yes he had a soul and spirit, but he and the Holy Spirit are co-eternal with the Father.  They are not created beings, like cults teach.

Did God create Jesus' soul?


undefined BIO_new_socket function in OpenSSL library

Question: I get the following problem with some openssl (yeah, I know it's poorly documented, but I wish to use it any way) code in a project of mine (written in c, on osx and tested in ubuntu):

Undefined symbols:
  "_BIO_new_socket", referenced from:
        _main in ccG3cvyw.o ld: symbol(s) not found collect2: ld
  returned 1 exit status

I did have SSL library problems aswel, because I forgot to link my program to the openssl libraries. The above undefined still stands though.
My compile line is:

gcc -o test_app test_app.c -lssl

Versions I use:
(GCC) 4.2.1
OpenSSL 0.9.8l 5 Nov 2009
I'm fairly certain it's a (linked) library issue, as the SSL function SSL_set_bio() works (as in does not produce a build error).
Any clue is very much appreciated :)

Chuck
Answer: The library I was looking for was crypto. D'oh!
Solution: add -lcrypto to gcc line.


How to convert a string Date to long millseconds

Question: I have a date inside a string, something like "12-December-2012".
How can I convert this into milliseconds (long)?
Answer: Using SimpleDateFormat
String string_date = "12-December-2012";

SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yyyy");
try {
    Date d = f.parse(string_date);
    long milliseconds = d.getTime();
} catch (ParseException e) {
    e.printStackTrace();
}

Answer: It's about time someone provides the modern answer to this question. In 2012 when the question was asked, the answers also posted back then were good answers. Why the answers posted in 2016 also use the then long outdated classes SimpleDateFormat and Date is a bit more of a mystery to me. java.time, the modern Java date and time API also known as JSR-310, is so much nicer to work with. You can use it on Android through the ThreeTenABP, see this question: How to use ThreeTenABP in Android Project.
For most purposes I recommend using the milliseconds since the epoch at the start of the day in UTC. To obtain these:
    DateTimeFormatter dateFormatter
            = DateTimeFormatter.ofPattern("d-MMMM-uuuu", Locale.ENGLISH);
    String stringDate = "12-December-2012";
    long millisecondsSinceEpoch = LocalDate.parse(stringDate, dateFormatter)
            .atStartOfDay(ZoneOffset.UTC)
            .toInstant()
            .toEpochMilli();
    System.out.println(millisecondsSinceEpoch);

This prints:
1355270400000

If you require the time at start of day in some specific time zone, specify that time zone instead of UTC, for example:
            .atStartOfDay(ZoneId.of("Asia/Karachi"))

As expected this gives a slightly different result:
1355252400000

Another point to note, remember to supply a locale to your DateTimeFormatter. I took December to be English, there are other languages where that month is called the same, so please choose the proper locale yourself. If you didn't provide a locale, the formatter would use the JVM's locale setting, which may work in many cases, and then unexpectedly fail one day when you run your app on a device with a different locale setting.
Answer: SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
Date date = (Date)formatter.parse("12-December-2012");
long mills = date.getTime();

Answer: Take a look to SimpleDateFormat class that can parse a String and return a Date and the getTime method of Date class.
Answer:
First convert string to java.util.Date using date formatter
Use getTime() to obtain count of millisecs from date
Answer: you can use the simpleDateFormat to parse the string date.
Answer: Easiest way is used the Date Using Date()  and  getTime()
    Date dte=new Date();
    long milliSeconds = dte.getTime();
    String strLong = Long.toString(milliSeconds);
    System.out.println(milliSeconds)

Answer: using simpledateformat you can easily achieve it.
1) First convert string to java.Date using simpledateformatter.
2) Use getTime method to obtain count of millisecs from date
 public class test {
      public static void main(String[] args) {
      String currentDate = "01-March-2016";
      SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yyyy");
     Date parseDate = f.parse(currentDate);
     long milliseconds = parseDate.getTime();
  }
        }

more Example click here
Answer: Try below code
        SimpleDateFormat f = new SimpleDateFormat("your_string_format", Locale.getDefault());
        Date d = null;
        try {
            d = f.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        long timeInMillis = d.getTime();


I can no longer get smooth playback in video editor after 3.1 update. Anyway to fix this?

Question: Hi I recently downloaded Blender 3.1 and I'm now having problems with the video editor.  I know 3.1 has a feature that automatically creates a proxy but since I'm used creating it on my own I changed the setting in system preferences: proxy setup to manual.  Anyway after the proxy is done rebuilding  I can scrub through it without audio fine until I try to play the video in normal time.  It will play in normal time after chugging a bit but after that I can't scrub through it smoothly anymore.  I've found a partial fix that if under playback I change the sync to frame dropping or play every frame I can now scrub smoothly again but I would really like to be able to use sync to audio and scrub smoothly like I could before I updated.  I previously had an older version of blender (2.8 or so I believe)  If anyone could help me I'd appreciate it!
Comment: Does it help if you turn off the audio waveform? I don't think it gets baked down to proxy but it does cache and may fill up ram?
Comment: The audio strip doesn't have the waveform on it.  I tried adding it but it didn't make a difference.
Answer: I found a solution to my problem.  I highlight the audio strip and then on the right select the strip tab and then click on source and then check the caching box.  This loads the audio into ram and allows me to scrub smoothly again.
Comment: I noticed that when I load gopro footage I don't have this problem.  It only happens with gaming footage I recorded with OBS.
Comment: OBS can record at variable frame rates. Blender does not like this. You'd find that it plays better after transcoding to a regular frame rate. Also the Codec might be to heavy for Blender to play back easily.


Can I install a new pressure-reducing valve inline with another one?

Question: I can't find my pressure reducing valve and am not sure if my house even has one. I checked for several feet around the water meter and for several feet before my main water lines enters my house. The rest of my main water line runs underneath my driveway. So I want to know, if putting one just after the water meter box would still be able to fix my water pressure problem?
Comment: Perhaps you could be a bit more forthcoming about what your water pressure problem is. Without knowing that, we can't tell what might address it.
Answer: Yes you can add additional PRV or regulators. The only possible side affect is a reduction in flow as they usually have restrictions. I have machines that I use 2 regulators one to do some basic isolation from the heavily fluctuating main air down to a fairly clean 90 psi then a second to provide a rock solid 80psi. And this machine runs great with no mishandling like that so Yes get the pressure down to what you want.
Comment: I apologize my water pressure is good when only one faucet is being used, but Im having a problem with low water pressure when multiple faucets are running at the same time or someone flushes a toilet while water is running.
Comment: All the homes we built the PRV was in the garage. I have not seen them outside I would think they would be prone to freezing outside. Have you looked inside ? Possibly close to the water heater supply that's where most homes branch out. A PRV will reduce the pressure and in some cases extend your water heater, appliances that use water and faucet life. You may have a plugged PRV with low flow things work but 2 faucets or more and the pressure dives.
Some look like blobs of metal with a screw. But any place on the incoming water line.


Why didn't everyone blown into space from Thor's ship freeze as Ebony Maw did?

Question: Why didn't everyone who got blown into space from Thor's ship freeze within seconds like Ebony Maw did?
Comment: The Æsir are a hardy race.
Comment: Could everyone stop saying Æsir, it really makes us look pretentious.
Comment: We only see one person after they're blown into space from Thor's ship, and that's Thor. If Frost Giants can't freeze him, the cold of space is as a mere lukewarm bath.
Comment: Ebony Maw isn't Æsir.
Comment: Ebony Maw isn't Human either ~ comparing his body & it's responses to physical conditions to those of ours or the Æsir may not make any sense.
Comment: Although according to Tony Stark he may be some sort of squid/octopus.
Answer: We can assume that everyone visible on the ship is Asgardian and while they aren't all gods like Thor we can assume that they probably have some similar physical traits to him. As Paul D. Waite commented (I'm new to StackExchange so I don't know how to tag yet) in the first Thor movie we see several Asgardians who may be heroes but are not gods themselves fighting frost giants on Jotunheim which is probably incredibly cold, implying they have inhuman resistance to elements.
Going by that assumption when we see Thor not frozen drifting in space later in the movie, we can make the assumption that he didn't immediately freeze because he is Asgardian.
Although the fact that he's still alive after being adrift for an extended period of time with no breathable air I would attribute to his god status. Especially since the rest of the Asgardians that didn't escape were all dead.
Comment: If you accept [Marvels Agents of Shield](https://en.wikipedia.org/wiki/Agents_of_S.H.I.E.L.D.) as canon (which you may not of course?) then I can confirm that yes, all the way down to the bog standard Asgardian peasant they do apparently share lifespan & physical attributes of both strength & "resilience" to physical trauma with those Asgardian heroes we're more familiar with as what would appear to be part of their basic racial traits ~ there may be other reference to this subject elsewhere of course, but that's the one I know of.
Comment: ^ I am of course referring to the Berserker Staff story arc & the character Elliot Randolph found in that story-line, starting with [The Well](https://en.wikipedia.org/wiki/The_Well_(Agents_of_S.H.I.E.L.D.)) (the eighth episode of the first season).
Comment: Can I just add that I love seeing Peter MacNicol as Elliot Randolph? He's a great actor and it's fun seeing Num3rs actors superheros. Now if only we can get David Krumholtz as Bruce Banner!


Apache + PHP not showing any formating

Question: What I am going to ask is probably a simple problem but I can't figure out solution. I have installed apache2 on Debian server and updated php to version 7.3. I think that I have made a mistake when disabling/enabling some modules but I am not sure.
Since that moment, text formatting/styles are not shown at all. See the image please, it is a result of pure phpinfo()
What do I do?
Error log shows nothing

[Tue May 25 23:33:51.759710 2021] [mpm_prefork:notice] [pid 27142] AH00163: Apache/2.4.38 (Debian) OpenSSL/1.1.1d configured -- resuming normal operations
[Tue May 25 23:33:51.759811 2021] [core:notice] [pid 27142] AH00094: Command line: '/usr/sbin/apache2'

apache2.conf
<code>#ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#Mutex file:${APACHE_LOCK_DIR} default

#
# The directory where shm and other runtime files will be stored.
#

DefaultRuntimeDir ${APACHE_RUN_DIR}

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5

# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

HostnameLookups Off

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

Include ports.conf

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

AccessFileName .htaccess

<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

<IfModule mod_ssl.c>
SSLStaplingCache shmcb:/var/run/apache2/stapling_cache(128000)
<VirtualHost *:443>

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Header always set X-Content-Type-Options "nosniff"
Header always set X-Xss-Protection "1; mode=block"
Header always set X-Frame-Options "sameorigin"
Header always set Referrer-Policy "same-origin"
Header set Content-Security-Policy "default-src 'self';"
Header always set Permissions-Policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()"
ServerName CENSORED
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/CENSORED/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/CENSORED/privkey.pem
Header always set Strict-Transport-Security "max-age=31536000"
SSLUseStapling on
</VirtualHost>
</IfModule>

Modules:
    Loaded Modules:
     core_module (static)
     so_module (static)
     watchdog_module (static)
     http_module (static)
     log_config_module (static)
     logio_module (static)
     version_module (static)
     unixd_module (static)
     access_compat_module (shared)
     alias_module (shared)
     auth_basic_module (shared)
     authn_core_module (shared)
     authn_file_module (shared)
     authz_core_module (shared)
     authz_host_module (shared)
     authz_user_module (shared)
     autoindex_module (shared)
     deflate_module (shared)
     dir_module (shared)
     env_module (shared)
     filter_module (shared)
     headers_module (shared)
     mime_module (shared)
     mpm_prefork_module (shared)
     negotiation_module (shared)
     php7_module (shared)
     proxy_module (shared)
     proxy_fcgi_module (shared)
     proxy_http_module (shared)
     reqtimeout_module (shared)
     rewrite_module (shared)
     setenvif_module (shared)
     slotmem_shm_module (shared)
     socache_shmcb_module (shared)
     ssl_module (shared)
     status_module (shared)
</code>
If it comes to the modules there might be actually some mistakes; i tried to install php7.3 fpm bud ended up using the "not fpm" version.
Thank you so much for your time.
Comment: Hi Maty, and welcome to ServerFault. Please share your *complete* apache2 config (apart from Debian's defaults of course) to give us any chance of helping you.
Comment: I have added some configs of Apache. What others would you like to see? Thx
Answer: Ok so I resolved the problem. The only thing I had to do was removing the CSP header from SSL apache config file. Since then it works normally.
TIP for everyone: Check developers console

Apache + PHP not showing any formating


pattern of moving electrons in wire under AC

Question: when we use a DC battery into a circuit the flow of electrons in wire creates a clear picture as they flow from negative terminal to positive terminal. under AC(Alternating current) we know how energy flows and what does it mean by $I_{rms}$ or average current etc. But what about the pattern in which electrons move?
Comment: "the flow of electrons in wire creates a clear picture"  Are you sure?  Are you aware that the electrons typically flow at the speed of molasses?
Comment: @endolith Here clear picture means we know the direction of flow of electrons, that is from negative terminal to the positive.
Comment: But the important thing is that the electrons move very slowly, and they behave like a fluid, and the *waves* in that fluid are what's important, not the individual particles.  The particles move like molasses, but the waves move at 2/3 the speed of light. Same for DC and AC.
Answer: The detailed movement of electrons in AC current gets very complex and depends on the exact conductor being used but, simplistically, the electrons simply move back and forth (away from and then towards the generator) over a short space
If you think of DC as a push system analogs to a straight flow of water in a hose, then AC is a push-pull system which would be like water in a hose connected to a piston that, as the piston cycles, first pushes the water down the hose and then sucks it back.
In a DC water hose, a molecule of water can only perform work e.g. moving a turbine, when it travels from one end of the hose to the other. However, in an AC water hose, a molecule of water just oscillates around its starting location and it is just the force of the molecule hitting the next molecule in the chain that transmits the energy. The last molecule in the chain is always the one that strikes the turbine and performs the work.
That is why AC can transmit energy over long distances. In DC, the generator must push an electron all the way down the wire to the load (and eventually back down the other side of the circuit) to perform any work. AC by contrast is just transmitting the electro repulsive force that drive electrons away from each other. (Just like a Newton's cradle transmits momentum instead of moving the spheres.)
Comment: The movement of electrons is not the reason why AC is used for power transmission. The actual reason is that transformers don't work with DC, and that synchronous generators naturally produce AC. DC can be used for power transmission just fine, but high voltage DC conversion equipment is expensive (see [HVDC](https://en.wikipedia.org/wiki/High-voltage_direct_current)).
Answer: Electrical current is the movement of charges, not electrons: I = dQ/dT. As far as the movement of electrons is concerned, that's called electron drift, and it is indeed as molasses.
Answer: "The RMS value of a set of values (or a continuous-time waveform) is the square root of the arithmetic mean (average) of the squares of the original values"
Irms refers to the root mean square value of the current over time.  This value is A/sqrt(2) if I(t) has the form A*sin(wt).  Intuitively, if you look at a sin wave from 0 to pi, the amplitude seems to be average a little more than halfway from y = 0 to y = A.
To come to this result, you would sqare Asin(wt), take the average, and then take the square root, which would leave you with A/sqrt(2).
Current is always generated by very small, (approximately) continuous voltage drops in the wire.  Think about tilting a rainstick one way or another.  So when you are using AC, you are tilting the rainstick back and forth periodically, and electrons will get pushed back and forth in an (approximately) harmonic way.
Electrons will only move a short distance back and forth in the wire because of a drift velocity http://en.wikipedia.org/wiki/Drift_velocity which is very slow to the frequency of the AC current (says .00028 m/s in the wikipedia article, this depends on the wire and current you are using and is approximate)
Hope it helps


Calibration of correlation

Question: Let's say there are two random variables (for example, two time series data of S&P500 and a stock) and their correlation is 0.95. What is the best way to reduce the correlation between these two variables to 0.7, while keeping one as it is? One approach that comes to mind is to add noise (error terms). But how would I know what should the mean standard deviation for the noise? I would appreciate if one could show how to do this in R.
Comment: Yes that helps.  And it shows you are not viewing these as time series, but only as paired data.
Comment: @AK88 in the third method overall variance remains the same. There's no additional noise in any of methods I suggested
Comment: @AK88, another thing to be careful with if you're doing backtesting: watch the higher moments, such as kurtosis of a new variable. In one of my examples the tail thinned a lot, this has huge implication on the metrics such as VaR, you'll be underestimating the tail risk, and also increased the "benefit" of diversification by lower correlation.
Comment: Not quite sure what you're asking here - if two variables are correlated, then they're correlated. You can change them to whatever you want (aka adding noise), but then they're different variables.
Comment: I want to add noise only to one of those random variables and keep the other one as it is.
Comment: Usually a pair of related time series data is described with a cross-correlation *function:* it's unclear what a single "correlation" might mean.  Could you explain?
Comment: maybe an example would help: I have S&P500 index and another stock. Their correlation is 0.95. I would like to change their correlation (reduce it to 0.7) by adding noise to the stock's returns. Does this make sense?
Comment: @AK88, if you stock is a constituent of an index, then it's a bit trickier, since changes in the stock will spill over into the index
Comment: @Aksakal, thank you for taking a look into this, appreciate your response! The second and third methods are really interesting, because as we add noise term to the stocks, the portfolio of these stocks will end up with higher standard deviation, which requires further thinking (although we expect them to wash out, the portfolio is not big enough). Regarding the spillover effect, since this is primarily for backward looking analysis, I think this is not a huge issue. Also, most of the stocks are not in the broad indices like S&P500, the idea is to use the broad index to get the correlations.
Answer: Given the intended application, you might be interested in creating realistic modifications of the series of data.
Overview
This is easier to do than you might think.  (See the three-line function decorrelate in the code below.)  The idea is to generate the "noise" series realistically, according to any model you like.  (You can even use actual data, such as a series for another stock or a portion of the series for the same stock at a different time.)  The desired amount of correlation reduction determines what multiple of the noise series you need to add in order to achieve the intended reduction in correlation.
Analysis
To be explicit, let's suppose you have paired series $(x_t,y_t)$ and can produce a third series $\epsilon_t$ to use for the noise. Let the correlation coefficient of $(x_t,y_t)$ be $\rho$ and suppose you wish to obtain a new series $(y^*_t)$ (with the same average value as $(y_t)$) whose correlation with $(x_t)$ is $\kappa\rho.$  I assume $|\kappa|\lt 1:$ that is, you intend to reduce the correlation.
As a technical preliminary, intended to ensure you will be able to obtain an answer, we need first to "decorrelate" the noise from the original series.  This is readily done with ordinary least squares regression: fit the model $E[\epsilon] = \beta_0 + \beta_x x + \beta_y y$ to the data and replace the series $(\epsilon_t)$ with the residuals of that model, found by subtracting its fitted values from the original values.  Let $(e_t)$ be the residual series.  (If you're truly unlucky, this series could be entirely zero: that would mean the "noise" was originally a linear combination of $(x_t)$ and $(y_t).$  In such a case you will have to come up with a different noise series and try again.)  As a bonus, including the constant term $\beta_0$ in the model guarantees the average value of $(e_t)$ is zero, so that adding the noise does not change the overall level of the data.
The new series will be obtained by adding some positive multiple $\lambda$ of the noise to either $(y_t)$ (when $\kappa \ge 0$) or to $(-y_t)$ (when $\kappa \lt 0,$ which means you want to reverse the direction of correlation).  That is, the solution will be

$$(y_t^*) = (\operatorname{sgn}(\kappa) y_t + \lambda e_t).$$

The value of $\lambda$ is found by comparing the correlation coefficients. The requirement (when $\kappa \gt 0$) is
$$\operatorname{Cor}(x_t, y_t^*) = \frac{\operatorname{Cov}(x_t, y_t + \lambda e_t)}{\sqrt{\operatorname{Var}(x_t) \operatorname{Var}(y_t+\lambda e_t)}} = \kappa \rho .$$
Writing $\sigma^2$ for the variance of $(x_t),$ $\tau^2$ for the variance of $(y_t),$ and $\psi^2$ for the variance of $(e_t),$ this equation becomes
$$\frac{\rho\sigma\tau}{\sigma \sqrt{\tau^2+\lambda^2\psi^2}} = \kappa \rho.$$
If $\rho=0$ there's nothing to do, and when $\rho\ne 0$ this conveniently simplifies (when squared) to
$$\frac{1}{1+\lambda^2\psi^2/\tau^2} = \kappa^2,$$
with the unique solution

$$\lambda = \frac{\tau}{\psi}\sqrt{\frac{1}{\kappa^2}-1}.$$

It's easy to verify this works for negative $\kappa$ as well.
To implement this in R, I offer the decorrelate function at the beginning of the code below.  At line 2, it performs the decorrelation step using lm and residuals.  It invisibly divides by $\psi$ using the scale function (also on line 2), but otherwise directly reflects the foregoing formula (line 3).  For convenience, if you have no definite noise series $(\epsilon_t)$ to supply, it will create one randomly (out of Normal white noise, line 1).

Examples
First, here is the solution using the default white noise.

In this scatterplot matrix, the original series $(x_t)$ is at the top upper left plotted against time.  It exhibits noticeable positive serial correlation: it's not jagged and random, but smoothly undulating.  Beneath it are $(y_t)$ (also serially correlated) and then--this is the first solution, down in the lower left corner--the noisy version of $(y_t).$  (The rest of the matrix displays correlations among the series as scatterplots.  The colors consistently show the times.)
The original correlation of $\rho=0.95$ has been reduced to precisely $\kappa \rho = 0.60.$  However, there's a problem: qualitatively, the noisy series doesn't look much like $(y_t).$  It's too jagged.
We solve this by using a noise series that has (approximately) the same serial correlation as $(y_t).$  Here's what the second solution looks like:

Look at the lower left corner.  Once again, the correlation of this modified series $(y_t^*)$ with $(x_t)$ is precisely $\kappa \rho=0.60.$  If that seems like an improvement, then this method is probably what you want to use.

Code
Here is the R code that generated the data and the figures.  You can modify its parameters to experiment.  When you have real data, you only need the code starting at "Reduce their correlation" (as well as the decorrelate function, of course).
The mysterious part (in the middle) is the generation of a series $(x_t,y_t)$ with specified correlation.  This is carried out by applying the algorithm to the series $(x_t,x_t),$ for which the correlation is $1,$ and reducing that correlation by an amount $\rho.$  I am pleased with this trick :-).
# Multiply the absolute correlation between `x` and `y` by a factor `kappa`
# by adding noise to `y`.  Returns the noisy `y`.
#
decorrelate <- function(x, y, kappa, noise) {
  if (missing(noise)) noise <- rnorm(length(x))
  eps <- c(scale(residuals(lm(noise ~ x + y))))
  y * sign(kappa) + eps * sd(y) * sqrt(1/kappa^2 - 1)
}
#
# Create MA time series data.  A Gaussian window of length 2w+1 is run over an iid
# standard normal series to create a sequence of `n` values.
#
ts.create <- function(n, w) convolve(rnorm(n+2*w), dnorm((-w):w, 0, 2), type="filter")
#
# Create correlated data.
# set.seed(17)
rho <- 0.95
n <- 150
w <- 19
x <- convolve(rnorm(n+2*w), dnorm((-w):w, 0, 2), type="filter")
y <- decorrelate(x, x, rho, noise=ts.create(n, w))
#
# Reduce their correlation.
#
rho.new <- 0.60
y.star <- decorrelate(x, y, rho.new / rho, noise=ts.create(n, w))
#
# Graph the series and show their scatterplots.
#
f <- function(x, y) {
  if (diff(range(x))+1==length(x)) {cex=0.7; lines(x,y,col="Gray")} else cex=1
  points(x,y, pch=19, cex=cex, col=hsv(seq(0, 5/6, length.out=length(x)), .9, .9, .5))
}
pairs(cbind(time=seq_along(x), x, y, `noisy y`=y.star), upper.panel=NULL, lower.panel=f)

Answer: First, since OP's problem is with relation to stock and index returns correlation, I must note that one thing to be aware of is that if the stock, such as AAPL, is a part of index such as SPX, then the problem is a little more complex, because any change to AAPL will spill into SPX index.
So, let's assume that the stock in question is not a constituent of SPX index. In this case I offer you two and half methods. First two would preserve the index as is, and the last one will not, but it will not add external noise either.
mix-in noises with one variable staying the same
I can transform one of the variables in such a way that the other stays the same but correlation changes. It's a simple mixing in the noise from first variable into the second. This is how you do it.
Get new series Y as from original series X by solving for a and b:
$$y_1=x_1\\ y_2=ax_1+bx_2\\var[y_2]=var[x_2]=\sigma_2^2\\cov[x_1,x_2]=\rho\sigma_1\sigma_2\\cov[y_1,y_2]=c\sigma_1\sigma_2$$
Write down variance and covariance of $y_2$:
$$var[y_2]=a^2\sigma_1^2+b^2\sigma_2^2+2ab\rho\sigma_1\sigma_2\equiv\sigma_2^2$$
$$cov[y_1,y_2]=a\sigma_1^2+b\rho\sigma_1\sigma_2=c\sigma_1\sigma_2$$
$$a\sigma_1+b\rho\sigma_2=c\sigma_2$$
You have two nonlinear equations and two unknowns a,b. You can solve this analytically or like me, a lazy guy, numerically with Excel solver, which got me:

a = 1.375
b = -2.0213

and the following plot of new series, where you can see that SPX returns remained the same and only AAPL returns changed while mean and variance were preserved:

Here's the first four moments after the transformation:

Note, that only kurtosis has changed significantly, yet it's a very important moment in portfolio management, for it is responsible for a lot of tail risk. In this case, the tail of the second variable thinnedconsiderably.
re-ordering variables
Second method is to not change the observations at all, but instead rearrange the observations in variables in such a way that correlation changes. Consider this: if I take random samples from both series, and calculate the correlation between these samples, then correlation will be zero. So, simple rearranging the order in variables will change correlation.
Advantage of this method is that variances remain the same, and overall distributions remain intact in the dataset. Since, you work with stock return, there's no autocorrelation, so rearranging doesn't impact this aspect at all, at least in theory. I don't know whether this method can generate drastic changes in correlation such flipping its sign like in the example above.
shuffling noise around
Instead of adding noise, let's push it around! We'll shuffle noise between two variables so that the correlation is what we want while preserving variances of each variable. Here's the final result for S&P 500 and Apple returns in 2020 Jan-Apr, where original correlation was 94% which I changed into -70%:

I used PCA and Cholesky decomposition to do this:

apply PCA to destandardized original series X to get the uncorrelated series F
standardize PC factors F to get unit variance series U
apply Cholesky decomposition to standardized uncorrelated series U to obtain correlated series Y with unit variance
destandardize Y to get to the series with original means and variances X'

This looks a bit intimidating, but you don't have to do this manually, and can use software. We don't introduce external noise. We only push the noise that exists in the data already from one place to another. Total variance of the data set remains the same as well as some other characteristics such as means.
Here's the first 4 moments after the transformation:

You can see how the higher moments change, especially, kurtosis. If the stock returns were normal, then this wouldn't have happened. However, the stock return usually have heavier tails than normal. So, watch out for thinner tails if you are analyzing tail risk metrics.
Comment: I like the last approach of shuffling subsets of the data, as it can preserve important aspects of the original data. Adding noise could get you into situations with impossible values, like if you add noise and wind up with negative time or weight, for example. Shuffling one entire vector will, on average, get you zero correlation, while shuffling some random subset of the vector will lower the correlation by a smaller amount.
Comment: @NuclearWang, I need to figure out the algorithm for shuffling :) thinking about it
Comment: I'm not sure of a surefire way to hit a target correlation value, but it should be easy enough to do empirically. For a vector of *N* values, randomly select some proportion *p* of indices to shuffle. Now just put those *pN* values in random order, and put the reordered values back into the indices you selected in the first place. For *p* =0, you'll have no shuffling and the original correlation value, for *p* =1, you'll have complete random shuffling and zero correlation (on average). You should be able to find any target correlation in between by varying *p*.
Answer: So if $\rho_N$ is the desired Pearson correlation, $\rho_0$ is the current correlation with $\rho_N\le \rho_0$, and $\epsilon$ is our uncorrelated noise:
$\frac{cov(X+\epsilon,Y)}{\sqrt{var(X+\epsilon)\sigma^2_Y}}=\rho_N$
Solving for variance of $\epsilon$
$\sigma^2_\epsilon=\frac{cov(X,Y)^2}{\rho_n^2\sigma_Y^2}-\sigma^2_X=\sigma_X^2\bigg(\frac{\rho_0^2}{\rho_N^2}-1\bigg)$
So, for your example, you'd be setting the variance of the noise to be $\approx .357\sigma_X^2$.
(may want to double check my algebra here)
Comment: Yep - $cov(X+\epsilon, Y)=cov(X, Y)+cov(\epsilon, Y)=cov(X,Y)$ because $\epsilon$ is uncorrelated with $Y$.
Comment: We're adding the noise to $X$, not $Y$ here, so it should be $\sigma_X^2$. Intuitively the equation is saying you need scale up the size of the noise with the variance of $X$. If $X$ has a huge variance, then you're going to need appropriately larger noise to impact it.
Comment: You make some hidden but crucial assumptions: you need $\epsilon$ to be uncorrelated with $X$ as well as uncorrelated with $Y.$  As far as how to do this in `R` goes, see the solution at https://stats.stackexchange.com/a/152034/919.
Comment: sorry, you are right. got messed up in my derivation. Thanks!
Comment: Thanks! Just to make sure that I got this right -- are you saying that $cov(X+\epsilon,Y) = cov(X,Y)$
Comment: Since $cov(X,Y)^2 = \rho_N^2\sigma_X^2(\sigma_Y^2+\sigma_\epsilon^2)$, should not the $\sigma_X^2$ be changed to $\sigma_Y^2$ in the second equation?

Calibration of correlation


image mode - copy buffer-visiting image to clipboard

Question: so I can open a .png file in emacs, copy the content to clipboard so I can paste it to browser for example.
Answer: If you have a buffer visiting an image file, you can mark the whole buffer (M-x mark-whole-buffer), copy it to the clipboard (M-x clipboard-kill-ring-save) and then you can do whatever you want with the contents of that clipboard.
E.g. you can create a new buffer, paste the contents of the clipboard into it (M-x clipboard-yank), and save the buffer to a file. You should now have a file identical to the original.
The only problem (which Emacs cannot solve) is what the other application will do with the contents of the clipboard. In the example above, the other application was Emacs itself and everything worked. But other applications are not always so well-behaved - e.g. you might try xsel -b -o > foo.jpg to save the contents of the clipboard to another file. However, xsel seems to mangle NUL bytes (presumably, it only handles textual data - and there are probably more problems than just the NUL bytes), so that the resulting file is deemed corrupted by the JPEG libraries. There might be a more intelligent program than xsel, but YMMV. However, as mentioned, this is NOT an Emacs problem. You have to get the other application fixed.
Comment: Thanks for pointing out the clipboard-* functions, good additions to the normal kill/yank. as you pointed it out, it works inside of emacs, but not with other applications, for example, if I paste to GitHub or here, it is not recognised as image but strong like �PNG IHDxxxxxxx.


How do I get the "5 routes" achievement?

Question: What is meant in the poker player of using all "5" routes - is it all routes that use 5 carriages or tickets that score 5 points? I did the former but didn't get the achievement.
Comment: this question is not about ticket-to-ride, is it about an online version?
Comment: It sounds like you are talking about a computer version of the game. Although Such questions can be in scope, this particular question deals only specifically with the computer version, and is of no meaning or help with the non-computer version. Voted to close.
Answer: Yes. Get all the 5-car, 10 point scores, there are 8. You must also win the game too. Recommend playing against only one bot.
Answer: It needs to be in the standard version. I tried with the 1910 version and it didn't work.
Comment: Hello user6863! You should add comments as comments to the answer/question as appropriate rather than adding a comment as a new answer. It's best if answers stand by themselves :)


Sitecore Content Profiling - Datasource item

Question: If we assign specific profile card or assign custom profile into data source item(not the page item), then will there be profiling happens?
Answer: Unfortunately the answer is no.
Profiling only works on the visited items. It doesn't work in the items used in API while browsing the page and it doesn't work on datasources which are used while generating page content.
You can think of running some powershell script which would gather datasources for your pages and update profile keys on page items depending on what's there on datasources, but I don't think there is anything ready online that you could reuse.


What's the Green's function of the photon's equation of motion?

Question: The Green's function of the Klein-Gordon equation:
$$\phi_s(x_\mu-y_\mu) =  \int \frac{d^4k}{(2\pi)^4} \;  \frac{e^{-i k^\mu (x_\mu -y_\mu)}}{-k_\mu k^\mu + m^2}$$
is the solution to the equation
$$ \left(\partial_\mu   \partial ^{\mu} + m^2\right) \phi_s = \delta(x_\mu-y_\mu) \, .$$
What's the corresponding equation and solution for a massless gauge field $A_\mu$? The free equation of motion reads
$$\partial_\sigma ( \partial^\sigma A^\rho -  \partial^\rho  A^\sigma) =0  \, $$
but I'm unsure what we write here on the right-hand side to define the Green's function since there is a free index $\rho$ in the equation of motion. Moreover, although I checked several textbooks, I wasn't able to find the expression for the Green's function for photons.
Answer: In momentum space the equation of motion for photon is:
$$(-p^2g_{\mu\nu}+p_\mu p_\nu)A_\mu= J_\nu$$
where $J_\nu$ is the source term. Now the term in the parentheses is not invertible since the determinant is zero (no mass term). This is also a signature of Gauge freedom of the photon fields. To remedy this, a gauge term is added to the original Lagrangian.
$$\mathcal{L}= -\frac{1}{4} F_{\mu\nu}^2-\frac{1}{2\xi}(\partial_\mu A_\mu)^2 - J_\mu A_\mu.$$
Here $\xi$ is the gauge field which satisfies the equation of motions $\partial_\mu A_\mu=0$ (Lorenz gauge). With this Lagrangian, the equation of motion becomes
$$\left[-p^2g_{\mu\nu}+\left(1-\frac{1}{\xi}\right)p_\mu p_\nu\right]A_\mu= J_\nu.$$
Now, one can check that the propagator is given by the following expression
$$\Pi_{\mu\nu}=-\frac{g_{\mu\nu}-(1-\xi)p_\mu p_\nu/p^2}{p^2}.$$
To check that this is indeed the propagator, it should satisfy the equation $\left[-p^2g_{\mu\nu}+\left(1-\frac{1}{\xi}\right)p_\mu p_\nu\right]\Pi_{\nu\beta} = g_{\mu\beta}$.
So, the expression for propagator or Green's function is dependent on the gauge choice as it should be but all the physical observables should be independent of the gauge field $\xi$. Some most used choices of gauge fields in Quantum Electrodynamics are:

Feynman gauge: $\xi=1\implies \Pi_{\mu\nu}=-\frac{g_{\mu\nu}}{p^2+i\epsilon}$.
Lorenz gauge: $\xi=0 \implies \Pi_{\mu\nu}=-\frac{g_{\mu\nu}-p_\mu p_\nu/p^2}{p^2+i\epsilon}$

The $i\epsilon$ part is added to choose the causal Green's function and in the final expression of an observable $\epsilon\rightarrow 0$ limit is taken.
To read more about photon propagators you can have a look at any QED book. The discussion of the propagator should be independent of whether this is a classical or quantum field theory.


Can't access home directory during boot. Any solutions?

Question: I recently switched to Ubuntu 14.04 from windows. I've setup Chrome Remote Desktop but it won't start during the boot process and the following error appears in boot.log
 * Starting Chrome Remote Desktop host for saurabh...       [170G
[164G[ OK ]
 * speech-dispatcher disabled; edit /etc/default/speech-dispatcher
saned disabled; edit /etc/default/saned
 * Restoring resolver state...       [170G
[164G[ OK ]
 * Stopping save kernel messages[164G[ OK ]
Failed to load config: [Errno 2] No such file or directory: '/home/saurabh/.config/chrome-remote-desktop/host#ba729066861c0767fb62791c78a5aeac.json'
2015-02-05 15:31:36,819:INFO:Cleanup.
I was also trying to run another program, which was saved in my documents folder, from rc.local. It failed too because of the same reason.
I've encrypted my home folder. Could that be reason for these failures? If not, does anyone have any solution?
Answer: Yes. Your home won't decrypt and mount until you log in.
You want to move this script to start when you log in.
Answer: you will need to do additional work to setup Chrome Remote Desktop for Linux (beta by the way).  Instructions are here:
https://support.google.com/chrome/answer/1649523?hl=en
Set up Chrome Remote Desktop -> Enable remote access to your computer - Linux (Beta)


Dotted quarter or tied notes

Question: I know in 4/4 you are supposed to clearly indicate beats 1 and 3 in the measure, but does this apply to beat 2 as well? I am transcribing a song on piano and don't know which version of this measure is better/more readable: the one with a dotted quarter on beat 1.5 or a tied eighth+quarter on beat 1.5?
Comment: It really doesn't matter much, regardless of beat.  Tho' there are cases where writing the quarter note rather than two tied eighths gently suggests moving the emphasis off the beat as well.
Comment: Can't see why the 2 A notes need tying - could easily be a crotchet.
Answer: From my own kinda-serious-amateur viewpoint ("classical", plus jazz standards, ...) I'd say that the dotted quarter in the first version is clear enough, because the remainder of the measure is notationally clearly the second half of the measure, so we can infer what's happening in the first half. The tied version is fine, too, but does involve more marks on the page that need interpretation.
Also, I am happy with the tied eighths in the second half of the measure, since that set-up does confirm my sense of the division of the measure. I'd be able to read a quarter note there, instead, but it would somehow seem odd.
Comment: Those tied eighth-notes in the second half of the measure look odd. A quarter-note would be much more usual.
Answer:
I know in 4/4 you are supposed to clearly indicate beats 1 and 3 in the measure

This is not the rule. Quarter - half - quarter in a bar of 4/4/ is correct notation, and breaking the half into two tied quarters is not recommended. Along those lines, your tied eighths should just be a quarter note.
Answer: Generally the aim is to use the notation that is the easiest to read. If it is hard to derive the timing from the score it is not good, but having lots of ties is also not particularly good. So most of the times it depends on the piece. You can have a piece where marking 1 and 3 is not necessary, you can have a piece where marking each single beat can be really beneficial.
In this case we have of course a bit of a special situation as we have a dotted beat. In classical music such notation usually implies some sort of stress or accent (think of the famous renaissance syncopation 4 4. 8).
This means that a notation with an offbeat tied dotted 4th might be slightly harder to grasp and feel (let's be honest — musicians seldomly count but usually simply feel the rhythms). For this reasons I'd probably prefer the second notation in this specific case.
Answer: No need. Even writing through the bar without designating beat 3 seems to becoming the norm, much to the chagrin of many, including myself.  So, your top image is very acceptable, and easily readable, thus playable. Stick with it!

Dotted quarter or tied notes


Embed Text File in a Resource in a native Windows Application

Question: I have a C++ Windows program. I have a text file that has some data. Currently, the text file is a separate file, and it is loaded at runtime and parsed. How is it possible to embed this into the binary as a resource?
Answer: Since you're working on a native Windows application, what you want to do is to create a user-defined resource to embed the contents of the text file into the compiled resource.
The format of a user-defined resource is documented on MSDN, as are the functions for loading it.
You embed your text file in a resource file like this:
nameID typeID filename

where nameID is some unique 16-bit unsigned integer that identifies the resource and typeID is some unique 16-bit unsigned integer greater than 255 that identifies the resource type (you may define those integers in the resource.h file). filename is the path to the file that you want to embed its binary contents into the compiled resource.
So you might have it like this:
In resource.h:
// Other defines...

#define TEXTFILE        256
#define IDR_MYTEXTFILE  101

In your resource file:
#include "resource.h"

// Other resource statements...

IDR_MYTEXTFILE TEXTFILE "mytextfile.txt"

Then you load it like this (error-checking code omitted for clarity):
#include <windows.h>
#include <cstdio>
#include "resource.h"

void LoadFileInResource(int name, int type, DWORD& size, const char*& data)
{
    HMODULE handle = ::GetModuleHandle(NULL);
    HRSRC rc = ::FindResource(handle, MAKEINTRESOURCE(name),
        MAKEINTRESOURCE(type));
    HGLOBAL rcData = ::LoadResource(handle, rc);
    size = ::SizeofResource(handle, rc);
    data = static_cast<const char*>(::LockResource(rcData));
}

// Usage example
int main()
{
    DWORD size = 0;
    const char* data = NULL;
    LoadFileInResource(IDR_MYTEXTFILE, TEXTFILE, size, data);
    /* Access bytes in data - here's a simple example involving text output*/
    // The text stored in the resource might not be NULL terminated.
    char* buffer = new char[size+1];
    ::memcpy(buffer, data, size);
    buffer[size] = 0; // NULL terminator
    ::printf("Contents of text file: %s\n", buffer); // Print as ASCII text
    delete[] buffer;
    return 0;
}

Note that you don't actually have to free the resource since the resource resides in the binary of the executable and the system will delete them automatically when the program exits (the function FreeResource() does nothing on 32-bit and 64-bit Windows systems).
Because the data resides in the executable binary, you can't modify it via the retrieved pointer directly (that's why the LoadFileInResource() function implementation stores the pointer in a const char*). You need to use the BeginUpdateResource(), UpdateResource(), and EndUpdateResource() functions to do that.
Comment: I have one more general wondering asked [here](http://stackoverflow.com/questions/35521857/best-practice-to-protect-resources-against-reverse-engineering). Could you please answer to my second question that is related to your answer? Just how to have a dll file that has a function to contain the code that is in main in your answer.
Comment: " the system will delete them automatically when the program exits" Don't all program when exit the system free resources? Memory leak and resource leak occurs during the execution of an executable. So if this program loads n of the same resource it will issue in a resource leak.
Comment: In the properties of the resource file there's "Null Terminate Strings"
Comment: I have a win32 application. Can I know where I can find the resource file and how I can create a user-defined resource file? I want to load an xml file during the build itself. File size is 20MB.
Answer: You can use xxd (from a linux machine or probably cygwin) to generate the data for a .h/.cc file.
There are lots of stack overflow questions that expand on this in detail:

How can I get the contents of a file at build time into my c string
"#include" a text file in a C program as a char[]
Comment: -1 PE(+) files are already capable of storing custom resources, and the Windows build tools have everything you need. The resource script syntax is documented, and the OS provides APIs for accessing that data. This answer is the answer to another question.


How to change the variable bound from an interval to its lower and upper bound in JuMP?

Question: When I read a model from a ".mps" file using "read_from_file" in JuMP and print it, I find that many bounds are written in the interval format like "x \in [0, 1]". I want to change an interval to a lower bound and an upper bound like "x >= 0, x <= 1" but when I use the function "lower_bound", it tells me "x does not have a lower bound". Why would this happen? How can I do the transformation?
Answer: You can use:
julia> using JuMP

julia> function change_interval_to_bounds(model::JuMP.Model)
           for c_index in all_constraints(model, VariableRef, MOI.Interval{Float64})
               constraint = constraint_object(c_index)
               delete(model, c_index)
               set_lower_bound(constraint.func, constraint.set.lower)
               set_upper_bound(constraint.func, constraint.set.upper)
           end
           return
       end
change_interval_to_bounds (generic function with 1 method)

julia> model = Model();

julia> @variable(model, x in MOI.Interval(0.0, 1.0));

julia> print(model)
Feasibility
Subject to
 x ∈ [0, 1]

julia> change_interval_to_bounds(model)

julia> print(model)
Feasibility
Subject to
 x ≥ 0
 x ≤ 1

We don't have built-in support for this because we assume that models read from file should stay as they are. (And it's only a few lines to implement manually.)
When you create a model using @variable(model, l <= x <= u) we add two separate constraints instead of a single Interval constraint because people want to change bounds, etc.
Comment: p.s. you can also post JuMP-related questions on our forum https://discourse.julialang.org/c/domain/opt/13


Why replication collapse but not stall leads to DNA break?

Question: I have been looking into the concept of replication dynamics and was wondering why collapsing but not stalling leads to a DNA break.
Comment: I recommend improving this post by explaining to us what "collapsing" and "stalling" mean. What context are you talking about? How do you know that collapsing but not stalling leads to a DNA break?
Answer: Stalling precedes collapsing. And collapsing precedes breaking. Hence, both stalling and collapsing precede, and lead to, breaking; but not every stalling leads to collapsing, and not every collapsing leads to breaking.


When was the 23 day rule in Death Note revealed?

Question: In episode 34 Near asks Mogi how long you can manipulate a victim before their death. He replies 23 days because the Yotsuba incident proved this? When in the data from the Yotsuba incident was this proved?
Answer: It was revealed because of Misa in chapter 48. Higuchi promised to stop killing criminals, so he could marry Misa, the second killer and he did. But because he had written down lots of criminals already, the deaths kept on continuing for 23 days until they stopped. From this they could deduce the killings could only be manipulated until 23 days in the future.
Answer: The death note that was dropped by Ryuk contained all the known rules including the 23 days rule. After Light made the Shinigamis switch the books, Yotsuba got the one with the rules that later came to the investigators.
The "fact" that the deaths stopped after 23 days is wrong btw. They explicitly stopped immediately because he never wrote a date of death for criminals.


Where is she? or Where is she at?

Question: Which sentence is grammatically correct?  I have been trying to find the answer to this for a couple years.  I hear people saying both of these types of sentences and I keep wondering which is grammatically correct.  I have researched online but cannot find out, so I decided to ask you.  thank you.
Comment: "Where is she?" is standard English, and "where is she at?" is a US local dialect, mainly Southern.
Answer: Both are acceptable. The first is uncontroversial and I do not discuss it here.
It is common usage to say things such as "She is at the cinema", "He is at the bar", "She was at the races", "He is at home". The "Where is he/she at?" questioning construction parallels these statements so finds itself in frequent and acceptable usage.
The "at" is redundant. It is not needed because the questions could be more concisely put as "Where is she/he?".
This redundancy, and the efforts of seventeenth and eighteenth century grammarians to align English with Latin, lead some people to say it is ungrammatical to end with "at". But it is not: see https://www.merriam-webster.com/words-at-play/prepositions-ending-a-sentence-with for a reasoned historical discussion.
Comment: Mystery down-marker fails to explain what they disagree with. So what is the point they dislike? How can we possibly learn from mute negativity?

Where is she? or Where is she at?