Favorable laws for graywater usage

Question: I know that it is illegal to catch and use graywater in many US states.  What states and/or nations have favorable laws for graywater usage?
Comment: It's a bit of a broad and general question, and probably unanswerable in its current form, but I've provided one example of a regulatory regime where it is favourable, with links to all the regulatory detail
Comment: It is broad, and not amenable to one correct answer.  Even so - those of us fighting to change legislation in unfavorable areas could really benefit from having this info to point to.
Comment: A fine idea!  I'll ask...
Comment: Yes, I guessed that you were looking for some exemplary legislation to use as part of a campaign for change.  And I guess you may be interested in countries where a lot of buildings have greywater recycling - I don't know where to find statistics, but that might make a good question in its own right: you could look at where the highest greywayer recycling rates are, and then look at the regulatory regime there.
Answer: The Building Regulations for England, and the national (largely voluntary) Code for Sustainable Homes, cover water efficiency and greywater recycling. The calculation for legal compliance includes the ability to achieve compliance by increasing your energy efficiency through greywater recycling, so it is actively encouraged by the regulatory regime.

The specific legal documents are the Water Supply (Water Fittings) Regulations 1999 and the Building Regulations (parts G & H). The former requires:

backflow protection of any public mains supply "back up" connection. They also place an obligation on installers not to allow cross-connection of mains-fed pipework with pipes carrying recycled water, and to clearly mark the pipes to distinguish recycled water from mains derived water
Answer: Washington State recently implemented a new set of rules allowing greywater. Details: http://www.doh.wa.gov/CommunityandEnvironment/WastewaterManagement/GreywaterReuse.aspx
In my experience, greywater legislation is typically focused on plumbing and building codes, e.g. "Can I plumb my shower to drain in to the garden?" and not behavior, e.g. "can I take a shower in the garden".
A lot of behaviors are not so much legal or illegal, as outside of the purview of law.

Favorable laws for graywater usage


Where can I listen online to live VOLMET broadcasts?

Question: Are there sites that stream live VOLMET broadcasts? I need to listen to the format but haven't have the time to put together an amateur radio.
Comment: Does it have to be live? There are plenty of recordings on Youtube
Comment: Good to be live, esp when you want to know how to pronounce different airport codes
Comment: The airport names are pronounced in full in a VOLMET (not just their code). As are weather phenomena. Letters and numbers are pronounced exactly as normal (phonetic alphabeat). Still not sure what difference it makes to you if it's a live broadcast or not.
Comment: https://www.youtube.com/watch?v=iX_3XT_hQZU
Answer: The Globaltuners site will allow you to tune their UK radios (subject to them being online) to the UK VOLMET frequencies if you really wanted. Whether this is technically "legal" or not is for you to decide ... it's not in the UK, but it's not enforced either.


What is difference between ATMEGA32 and ATMEGA328?

Question: I'm new in electronics. Just playing with Arduino boards.I just wanted to program ATMEGA328 micro-controller and use it without Arduino for compact design for my personal hobby project. I found there are ATMEGA32 and ATMEGA328 micro controllers in my local store. So, I wanted to know can I use ATMEGA32 instead of ATMEGA328 ? Which one is latest and whats are benefits. Thanks in advance.
Comment: The ATMega32 looks to be essentially the "big brother" of the ATMega328.  Just the same chip internally, but with more IO pins. I don't know about register / code compatibility, or Arduino core API support, having never used one.
Comment: you can't put ATmega32 into the DIP socket on Uno. the DIP version has a different size
Answer: I can't post comments.
One difference is that the ATmega32 has JTAG; ATmega328P has not.
Comment: +1 It's not terribly complete, but it seems okay to post an answer.  It's answer type material at least.  And something not pointed out by others.
Answer: To answer this you'd need to study the according data sheets:
ATmega32
ATmega32u4
ATmega328
ATmega328P
ATmega328PB
Despite a similar name, the chips are quite different.
32u4 for examle has USB built in.
328PB has more 16-bit Timer/Counters.
... and many more differences.
They only differ on the hardware features and can be programmed in more or less the same way. It is up to you to choose which one you want to use.
Comment: The only nearly identical ones are 328 and 328P. If you don't care about the "picopower" feature you just have to know they have different signatures. To _easiest_ move from an arduino (UNO or NANO) to a standalone controller, **atmega328p** is your choice.
Answer: I cannot tell for sure, but from a cursory look at the datasheets, the
ATmega32 looks older:

16 MHz maximum frequency v.s. 20 MHz for the ATmega328
4.5 V minimum supply voltage v.s; 1.8 V for the ATmega328
only one PWN channel per 8-bit timer

From an Arduino-programming point of view, I would prefer the 328, as it
would allow you to prototype your code on an Uno, and then move it to
the bare MCU, knowing it would work identically. The ATmega32 would be
worth consideration if you need more IO than the Uno can provide.


How to manually use Drupal 7's admin Overlay?

Question: I am thinking of using Drupal's built-in admin overlay jQuery script to overlay my own contents. Is it possible?
Answer: You can also use the Overlay Paths module. This is a simple module that enables administrators to use the built-in Overlay for non-admin pages. This means that you can use the overlay for doing popups without adding yet more javascript libraries to your site.
Answer: The Overlay module renders as overlay the pages for which an implementation of hook_admin_paths() returns TRUE for the associated path. For example, the implementation of that hook done from the Node module is the following one:
function node_admin_paths() {
  if (variable_get('node_admin_theme')) {
    $paths = array(
      'node/*/edit' => TRUE,
      'node/*/delete' => TRUE,
      'node/*/revisions' => TRUE,
      'node/*/revisions/*/revert' => TRUE,
      'node/*/revisions/*/delete' => TRUE,
      'node/add' => TRUE,
      'node/add/*' => TRUE,
    );
    return $paths;
  }
}

This means that the node edit form is rendered as overlay, when the Overlay module is enabled. When the Overlay module is not enabled, then those pages are rendered using the administrative theme.
For paths implemented by other modules, a module can implement hook_admin_paths_alter(). An example of implementation could be the following one, which would make the user profile pages rendered in an overlay.
function mymodule_admin_paths_alter(&$paths) {
  // Treat all user pages as administrative.
  $paths['user'] = TRUE;
  $paths['user/*'] = TRUE;
  // Treat the forum topic node form as a non-administrative page.
  $paths['node/add/forum'] = FALSE;
}

Answer: If you want to implement this function for a particular content type, so that all nodes of that content type opens in the administrative overlay, you can use the following code:
<?php
/*
 * Implements hook_admin_paths_alter().
 */
function YOUR_MODULE_admin_paths_alter(&$paths) {
  $query = new EntityFieldQuery();
  $query->entityCondition('entity_type', 'node')
      ->entityCondition('bundle', 'YOUR_CONTENT_TYPE')
      ->propertyCondition('status', 1);
  $result = $query->execute();

  if (isset($result['node'])) {
    $nodes = array_keys($result['node']);
    foreach ($nodes as $node_id) {
      $node_path = 'node/' . $node_id;
      $paths[$node_path] = TRUE;
    }
  }
}
?>

Answer: The Overlay module is hardcoded for a single purpose, displaying admin pages. It would require a huge amount of effort to reliably re-use that code for your own content.
Answer: Maybe one of the numerous contrib module can help you out, like Dialog API.


Can making a donation reduce your tax bill?

Question: If my adjusted gross income is $1000, and I make a donation of $100, then it seems that I'm still going to have to pay a tax on the $1000. The donation is deductible, so I don't pay any tax on that, but it hasn't reduced my tax bill. From saving on taxes perspective, what is my incentive to donate?
Comment: How about doing some good with your money as an incentive?
Comment: But what if you had enough money that it was worth it for you to create a non-profit to shelter money into and then had the controlling interests of the non-profit. Sketchy business.
Also, if you're a business, donating old gear can be used as a tax write-off. You spent money on something, got the use out of it you need and then write it off by donating it. At that point, it's worth nothing to you except for the tax write-off donation. Basically free money back at that point.
Answer: If you itemize your deductions (I'm assuming USA here) then qualifying charitable donations (say, $100 to your church) can be deducted, which means they're effectively an offset to your taxable income.
Your adjusted gross income already takes into account any deductions, including charitable contributions.  So, after all is said and done, if your AGI is $1,000, your tax is calculated on $1,000.  If you didn't make that $100 contribution, your tax would be calculated on $1,100.  That's where the tax savings you smell is located.
Comment: This answer is correct in spirit but wrong in many details. AGI has a specific meaning, and _taxable income_ is **AGI minus exemptions minus deductions**. Charitable donations are part of the deductions and do not affect your taxable income or the tax due unless you itemize your deductions on Schedule A. People whose itemized deductions total less than the standard deduction usually choose the Standard Deduction (except for Married Filing Separately where both spouses must itemize or both must use the Standard Deduction) and their charitable donations do not affect their taxes. (continued)
Comment: The Standard Deduction is set based on the assumption that you did make _some_ charitable contributions, and you use the Standard Deduction,you get the benefit of the assumption even if you never gave a dime. If you made a $100 charitable contribution, you get no _direct_ reduction in taxes from it unless the total of your itemized deductions exceeds the Standard Deduction. But tax savings should be the least of your concerns in deciding on whether or not to make a charitable contribution. As JohnFx suggested, doing some good with your money should be your incentive.  (continued)
Comment: If your marginal tax rate is 20% and your itemized deductions exceed the Standard Deduction, then you can (a) make a $100 contribution and get back $20 in tax savings because your taxable income is smaller by $100. You are out of pocket by $80, or (b) do not make a charitable contribution at all in which case you pay $20 to the IRS and so you are out of pocket by $20 instead of $80. Clearly, alternative (b) leaves you richer while alternative (a) leaves you a little poorer than alternative (b) but might, just might, make the world a slightly better place.  What choice you make is up to you.
Comment: Dilip, needing the space of 3 comments means to me that you had details to offer a full answer. You are right, non-itemizers (save for the charitable RMD) have no deduction.
Answer: Let's imagine you're in the US, there's a flat tax of 20% on all your income, and you're itemizing your deductions.
If you made $100,000 and didn't do anything deductible, your adjusted gross income would remain $100,000, and then you'd pay $20,000 in taxes, so you'd be left with $80,000 after taxes.
If you made $100,000 and donated $10,000 to a qualifying charity, your adjusted gross income would be $90,000, and then you'd pay $18,000 in taxes. So after the donation and taxes, you'd be left with $72,000.
The net result is the charity got $10,000, but your take-home only dropped $8,000, with the government picking up the $2,000 difference. You're still worse off, in terms of your personal cash, than if you hadn't made the deduction. It's just that the bite isn't as bad as it might have been.
It's a little more complicated in the real world where you have marginal tax rates that vary with your income level, but the principle is still the same. If you donate $X, your tax bill will drop by something less than $X.
So I make charitable donations for my own reasons. The tax deduction is icing on the cake, and it can affect how much I donate because the government is picking up part of the tab, but it doesn't affect whether I donate or to whom.
I've heard claims of wealthy people making donations of $X to drop their tax bill by more than $X, but every one I've heard of was something really complicated, used obscure tax loopholes, and involved a donation of art, a building, or securities rather than just money or a check. If you're in that world, you really should retain a tax accountant.
Answer:
The donation is deductible, so I don't pay any tax on that, but it hasn't reduced my tax bill

Why would you expect to pay taxes on a donation?   It's not income.  That fact that it is tax deductible does not mean that you do not owe taxes on it.  You do not owe taxes on it because it is not income.
The tax deductible donation impacts your adjusted gross income, but only if you itemize deductions.  If you take the standard deduction, a tax deductible donation has no impact on your tax liability.
From the horse's mouth, with emphasis added:

Whether to itemize deductions on your tax return depends on how much you spent on certain expenses last year. Money paid for medical care, mortgage interest, taxes, charitable contributions, casualty losses and miscellaneous deductions can reduce your taxes. If the total amount spent on those categories is more than your standard deduction, you can usually benefit by itemizing.

(source}
Answer: Charitable contributions that exceed the standard deduction are deductible. I believe the 2010 Standard Deduction is $5,700 for an individual and $11,400 for a married couple.
Typically, you don't get a deduction unless you own a home, since the mortgage interest and local taxes are generally deductible. YMMV.
How much you save by deducting income is specific to each individual. For me, my combined Federal and State tax savings are about 30%. So if I donate $100, I effectively reduce my tax obligation by around $30.
Comment: In 2010 $5700/$11400 was right, I edited in for you.


Is a laminated padlock really stronger than a solid one, and if so, why?

Question: I used to think that the padlock design of using many layers of metal stacked to form the main body was a cost-cutting consideration. This was my assumption before I came across the idea that it was really a way to make the lock stronger. It might have been from a TV commercial which showed a bullet penetrating a lock in slow motion. This was many, many years ago, but I have always wondered about that. Although anectodal, my experience finds that really sturdy, heavy duty equipment usually has a nice solid frame or enclosure. I'm not counting things like cars that are designed with "crumple zones", because in such cases weight is a major factor. I'm thinking about manufacture where weight isn't an issue, like padlocks. Does anyone have knowledge of something that would support this claim?
Comment: I guess it's unlikely to have any irregular structure/weaknesses that go all the way through if it's made of sheets of metal on top of each other
Comment: It appears this method (folding) was used by Japsnese sword smiths https://en.m.wikipedia.org/wiki/Japanese_swordsmithing#Forging
Comment: A strong casing is considered strongly associated with a durable object, but that's only half true.  Internal components that are well-connected to the shell and won't be easily unhinged by sudden movements are only improved by a strong outer shell.  However, studies have shown that say, the brain on impact only have minimal improvements with a helmet.
Comment: @innisfree - Yeah, those Samurai sword-smiths were phenomenal: right on the cutting-edge of technology :+D (sorry 'bout that one, just couldn't resist!).  I saw an excellent documentary on their amazing ability to produce and work with metal.  They were able to make super precise woodworking tools too. As a result, their carpenters were of the highest caliber.  They would  build entire houses using only dovetails, tongue-and-groove, dowels etc. and not even a single nail! But the most mind blowing thing to me, was how the carpenters would spend two to three hours a day sharpening their tools!
Answer: The multi-layered structure protects against impact fracture.
If you hit an object very hard, you can create a crack; stresses will concentrate at that crack, and make it easier for the crack to propagate (think of the little notch in the ketchup packet: that's where you can tear the plastic...)
Now if you have a solid body (of anything), then that crack can continue to grow. But if you laminate, then the crack will hit the end of one lamina, and stop. That means that a laminated object will be much more impact resistant: it's easy to initiate a crack on the outermost surface (for example with a carbide-tipped object), but it's much harder to do so on an inner surface (which your tool cannot reach).
Comment: Great answer! Concise, thorough, and well balanced in its vocabulay (ie daily use vs technical/higher learning stuff).  You used just enough power to make the point; spiking the ball would be a waste of energy.  But I especially appreciate how you seem to really know your audience. Since the question was from everyday-life, using everyday-life examples in your answer was right on the mark (bullseye with the ketchup packet). I smiled and thought to myself, "Why didn't I think of that?" But best of all, was how it resonated. It made me think of how rip-stop nylon resists the propigation of tears
Answer: @Floris answer is great, but there is another characteristic of a laminated lock, compared to a solid lock, to consider.
A laminated lock, has as few as 4 pins (6 or 8 on larger locks) holding the laminations together. The pins are basically rivets that run from the top of the lock, through all the laminations to the bottom of the  lock, at the 4 corners. On larger locks, there will be additional rivets near the edges toward the middle.
Depending on the characteristics of the impact, these rivets might be the failure point. Breaking even just 1 of the rivets leaves the laminations unsupported and subject to easier penetration. Breaking just 2 rivets (3 on larger locks) will most likely lead to a catastrophic lock failure.


Invalid parameter type error while deploying custom profile

Question: We tried to deploy a custom profile from one dev org to another org using changeset. It fails on validation on the destination org and we get an error message invalid parameter type. Would any body know where to get started on debugging the error message?
Thanks
Buyan
Comment: is the error message coming from a test class, can you paste a screen shot of the error message if possible
Comment: @rao The error message does not say which component is causing the problem. It just lists profile name and error message and no line number or anything.
Comment: Have your run all tests in the destination org before try the deploy ?
Comment: What is the exact message? Does it say which parameter type is invalid?
Answer:
Manually create the Profile and don't bother about permissions .Once manually create deploy the same changeset .It succeeds .Still dont know actual cause but it worked .Thanks
Comment: Thanks @Mohith it helped me, when i validating the package with my prod haven't seen this error but while deploying this error popped up no idea what kind of error it is your Answer helped in my situation when everything is dark outside no info provided any were.
Answer: The reason is this: When you simply deploy a new Profile, the API auto-clones the Standard User or Standard Platform Profile (depending on license associated with Profile being deployed) before overlaying the security settings with the Profile metadata that you are deploying. But, not all permissions are overwritten as negative values are denoted by absences in the Profile XML. So, there are conflicts.
This is solved by you executing your own Profile clone and then deploying.
Makes sense?
Sridhar
Answer: @Mohith Kumar
Thanks for your answer. The problem was that we tried to deploy new profiles in our changeset which did not exist in our destination org. These new profiles were created by our development team and did not exist in our refreshed sandbox org from production. Salesforce just reports this as an invalid parameter type error instead of specific error message.
During deployment, please make sure the profiles exist in the source and destination org.
Comment: .Please mark the answer as answered so it helps everyone .Thanks


Can't remember tool used to create geometry from curve

Question:
It's been a while since I've used Blender and I forgot the tool I used to create this object. I know that I made it by using the Curve Pen, then a tool/modifier that gave it thickness, then a Remesh modifier to give it better geometry. The tool in question made the geometry almost like voxels, where points that were close together created merged geometry, like the center area in my model. Does this sound familiar to anyone? It was very useful because I was able to quickly create this shape.
Answer: You can give curve thickness by adjusting its bevel depth in the Properties Editor, Data tab, Geometry panel, Bevel sub-panel.You can then adjust radius of its individual points, convert the curve to mesh and remesh it. Voxel remesh will join touching parts and quad remesh will make topology nicer.
Comment: Hi Martynas,
Thanks for the help. Your method works, but finally figured out what I was looking for. I was wrong about having used a Curve, it was just vertices put into a Skin Modifier. Thanks again!


Resonance energy of organic compounds

Question: I was solving a problem in organic chemistry, where I had to find the resonance energy of a compound with some information which was given in the question itself. Basically, what I had to do was, to sum up all the energies from the information given and then subtract it with the experimental value of energy given. My question was that if the law of conservation of energy was to be followed while solving the problem then where was the energy which I obtained as a difference of the experimental and theoretical data used? And if it is just a calculation of experimental error, then why was it called as resonance energy, was it related to its name in anyway.
Answer: What I understand from your question is that you were given different bond energies of the various bonds constituting a compound which was showing some resonance and also you were given the experimental value of the energy of that compound.
Now as a compound is formed when different atoms form bonds together so, the total energy of that compound should be equal to the sum of all the bond energies of bonds between different atoms of that compound but this is not the case (most of the time in the real world).
Every compound tries to go to the lowest energy as possible and one way to do so is by doing resonance.

Resonance is the phenomenon of delocalisation of bonding electrons of a bond between many atoms of a compound rather than just two atoms.

By doing resonance, the electrons in a compound are more evenly distributed and delocalised resulting in more stability of the compound and thus a lower energy. So, the actual value of the energy of a compound is lower than just the sum of bond energies of all its bonds and the decrement in the value is equal to the energy it released in the form of resonance energy. Yes! It is released in the surroundings.
I hope it helped.
Answer: As a guide if you are familiar with the quantum model for a particle in a box you will know that the levels becomes lower in energy as the box gets larger. The same is true for a particle on a ring as the ring's radius increases. So, if you have three isolated double bonds, vs. the same bonds with delocalised energy (double - single - double -single  etc., and you may call this resonance if you wish) then you can see that the latter has lower energy.

Resonance energy of organic compounds


Price resolver save custom field

Question: I would like to update a custom field, added to my order items, in the price resolver process. The price resolver process do some sort of queries to select the right price and this selection has a key that I want to save in the custom field.
I'm not sure how could I alter the order line item after the right price was selected.
Comment: How are you doing the price resolver? Custom code or contrib module?
Comment: With a custom module. In "resolve" function I calculate de new price and return the new object.
Answer: You price resolver should have something like
if (isset($result['price'])) {
    return new Price((string) $result['price'], $context->getStore()->getDefaultCurrencyCode());
}

Before your price resolver's return line put:
$cart_provider = \Drupal::service('commerce_cart.cart_provider');
$cart = $cart_provider->getCart('default');
$order_items = $cart->order_items->referencedEntities();
foreach ($order_items as $order_item) {
  if (!empty($order_item->field_custom)) {
    $order_item->field_custom->value = 'Hello World'; // set new value
    $cart_manager = \Drupal::service('commerce_cart.cart_manager');
    $cart_manager->updateOrderItem($cart, $order_item);
  }
}

Comment: Thanks for your answer. It works like a charm.

Price resolver save custom field


Actual Execution Plan - Estimated/Actual Rows Differ Greatly

Question: I'm wondering if I can speed this query up. One thing I noticed is the estimated number of rows differs greatly from the actual number of rows.
https://www.brentozar.com/pastetheplan/?id=H1ya3-3pe
Answer: ClientRequestID in tblCR_ClientRequestTIP has no statistics, and SQL Server would love to have some.  You can see that warning in the actual execution plan.  This leads me to believe perhaps you have auto create statistics turned off.  This may be causing issues.  Have you updated statistics recently?
I'd consider adding the following indexes:
CREATE NONCLUSTERED INDEX IX_tblCR_ClientRequestTIP_ClientRequestID
ON dbo.tblCR_ClientRequestTIP(ClientRequestID)
INCLUDE (TIP_BeginDate, TIP_LocationName1);

CREATE NONCLUSTERED INDEX IX_tblCR_ClientRequestJOB_ClientRequestID
ON tblCR_ClientRequestJOB(ClientRequestID)
INCLUDE (JOB_Date);

CREATE NONCLUSTERED INDEX IX_tblCR_ClientRequestPP_ClientRequestID
ON dbo.tblCR_ClientRequestPP(ClientRequestID)
INCLUDE (PP_BeginningDate)

(there are others that could be added as well, this is just a sample)
Also of note, tblCommitment, tblStaff, and tblProgram do not have clustered indexes.
The tblClientRequestJOB row estimates are not exactly perfect, but the actual data size vs the estimated memory required for that table shows that row estimate is not really problematic.  I doubt SQL Server would choose a different plan if it knew the actual row counts ahead of time in that instance.  A far bigger change is likely to come from getting rid of the eager index spool resulting from the clustered index scan of tblCR_ClientRequestTIP.


Should I deflate a nominal variable when forecasting it?

Question: Say I have a structural equation that is forecasting Y. Y is a nominal financial variable that grows with time due to inflation. I have an economic determinant that is a rate and therefore does not increase with time. Is it wise or necessary to deflate Y so that the variables behave the same way? I do not particularly want Y deflated as this regression will be forecasted and this just introduces another hard to forecast variable.
Comment: If you think the rate is a good predictor of the real future value of Y, but Y also grows with inflation and you are interested in the nominal value of Y, then you will not get around at least implicitly forecasting inflation.
Comment: Right, but implicitly forecasting it introduces less error (from a practical standpoint) than explicitly adding the variable. The other variables will do that work for me, but introducing another variable adds more error. I do not NEED to deflate Y, but I am wondering if doing so to mimic the behavior of the rate (unemployment) adds any value econometrically. A colleague suggested this to me, but I had never heard of that convention before.
Comment: What about inflating all your past values up to today's one. Your forecasting would then predict intrinsically today-related nominal/real values.
Answer: In macro, the standard approach to forecast variables which are intrinsically nominal like GDP seems to be to separate the forecast. This is, you want to have a model for real GDP and for inflation. The final forecast for nominal GDP is the "combination" of both. This is for instance the standard practice of the Fed (of Atlanta) and the Bank of England (pages 39 to 41).
In your case of a financial variable, you could model the real (deflated) variable, and then, as inflation is given by the economy, just take the official inflation forecast of your country from the central bank. They are the real experts on this so is a safe thing to do in my opinion. Also, the market expectations of inflation, crucial in finance, are very much informed by central bank estimates. This approach gives you a cleaner estimation of your model too. As you say, your determinant is a rate, and thus inflation is just molesting in the left hand side.


Install Apple's Podcast app on iOs Simulator

Question: I want to debug my podcast feed but don't have an iPhone. I run iOS simulator on my Mac but the iPhone 6s that it runs does not have Apple's standard Podcast app installed. The iOs version is 9.1. How can I install it?
Comment: Is this the iOS simulator that runs through Xcode? Because if so, the simulator itself will require an upgrade, with which the podcast app will come standard with iOS 9, the first iOS to support them.
Comment: Having the latest simulator does not help. I run my simulators in iOS 9.1 and the Podcast app (and several others) are not present. I suspect that it is not possible to install Apple's apps there either, but someone else might know of a way.
Comment: Yes, it is the iOS simulator that runs through Xcode. Running iOs 9.1 the Podcast app is not present.
Answer: Your best bet for debugging on iOS devices may be to acquire a cheap iPod Touch.


Where can I get AMM for Boeing 737NG?

Question: I am not connected to airlines .I am just an aviation enthusiasts .while studying the 737 FCOM I realized to study AMM also .but in Google I cant find it anywhere .so can anyone tell me how to get access to AMM ?
Comment: I'm voting to close this question because resource location is off-topic within the scope defined in the help center.
Comment: You should precise in the question what is AMM.
Answer: Buy it from Boeing.
Documents like the FCOM and the AMM are copyrighted and proprietary documents and aren't meant to be freely available.  Sometimes you'll find one on the internet that somebody posted, but they did so in violation of a license.
If you do find an AMM (or excerpts from it -- as far as I know the entire document is enormous) on the internet, changes are good that it's well out-of-date.
That said, there are better resources than the AMM to learn about the operational side of the 737.  As a pilot who flies it, the AMM isn't a document that I study or even have in the electronic flight bag.  It's for mechanics, and in some cases its limitations are significantly different than the limitations in the flight crew manuals (the company equivalent of the FCOM).  There are things that the mechanics can do on an as-needed basis that they don't want the pilots doing during routine ops, and so our limitation, for example, was in the 737-300, only one pack run off of APU bleed air for cooling.  The mechanics could run both packs for cooling, but when they did that it wasn't in order to cool the aircraft, it was to load up the APU and see how it responded to a high bleed air demand.  The first time I saw them do that was a "wait, you can't do that!" kind of moment, but their manual allows it.
Boeing, however, does NOT want pilots performing hybrid procedures, or "I saw a mechanic do this..." fixes.  Things that may work fine on the ground at the gate, may be a really bad idea to try in flight.  So Boeing has pilot procedures & limits for the pilots, maintenance procedures & limits for the mechanics, and just like in Ghostbusters, "don't cross the streams... it would be bad."
Comment: How does one go about buying it from Boeing? A simple email? Surely they require more than just currency to obtain this manual?

Where can I get AMM for Boeing 737NG?


How do you find Slices in Sketch - is finding Exportables the only way?

Question: The Problem
I want a way to find Slices in a complex Sketch document.
Why this is a problem
I have used icon templates from Apple and Apply Pixels which are pre-configured to export different icon sizes.
These are often configured with the slices deeply nested, as seen in the screenshot below, so I wanted a search capability.
Possible Workaround
There's a dropdown in the Search box (top of Layer panel) which allows you to choose Exportable and has the slice icon next to it.
However, that does what it says, finding exportable assets including non-slices marked as Exportable.
Is Exportable taken as a synonym for Slice, given that you cannot have a non-exportable Slice?
(Artboards you have made exportable allow you to remove all their export presets, going back to a non-exportable status. Slices will not allow you to remove the last export preset of a list.)
Why the workaround is insufficient
If you use these templates as a starting point, it's OK because they are completely slice-oriented. However, I also have complex documents that used Artboards as the main exportable element. I want a way to find just the Slices in those documents.
Answer: Thanks to Sketch Twitter support
The answer is to use the Automate plugin
Layer - Select Layers in Selection By Type - Slices


sequences and series Does it converge?

Question: The sequence given by $a_1 = 3, a_{n+1} = \frac{1}{2}(a_n + 1)$ for all $n \geq 1$. Determine the limit of the sequence as $n \to \infty $. This is only from the first section in the chapter. So, we do not know any advanced theorems on sequences to use yet.
Comment: @JohnLou (and whoever else *approved* it), that edit didn't come out right, so I had to roll it back.
Comment: Have you heard of the fact that if you can prove that a sequence increases and is bounded above, then it converges, or the fact that if you can prove that a sequence decreases and is bounded below, then it converges?
Comment: Write out a few terms to get an idea.  3, 2, 3/2, 5/4, 9/8,.... look at the denominators.  Look at the numerator.  That should give a hint.  Can prove our hint using induction.  Then we can take a guess as to what the limit is L. The we can prove if $n > N$ then $|a_n - L | < \frac 1{2^N}$.
Comment: Well, we have
$$\begin{align}
&a_1=3\\
&a_2=\frac{1}{2}(a_1+1)=\frac{1}{2}(3+1)=2\\
&a_3=\frac{1}{2}(a_2+1)=\frac{1}{2}(2+1)=\frac{3}{2}=1+\frac{1}{2}\\
&a_4=\frac{1}{2}(a_3+1)=\frac{1}{2}\bigg[\frac{3}{2}+1\bigg]=\frac{5}{4}=1+\frac{1}{4}\\
&a_5=\frac{1}{2}(a_4+1)=\frac{1}{2}\bigg[\frac{5}{4}+1\bigg]=\frac{9}{8}=1+\frac{1}{8}\\ \vdots
\end{align}$$ and so the limit is $1$.
Answer: Hints:

$a_2 = \frac{1}{2}(3+1) = 2 \lt 3 = a_1$
$\require{cancel} a_{n+1}-a_n = \frac{1}{2}(a_n+\bcancel{1}) - \frac{1}{2}(a_{n-1}+\bcancel{1}) = \frac{1}{2}(a_n - a_{n-1}) = \cdots = \frac{1}{2^{n-1}}(a_2-a_1) \lt 0$
$L = \frac{1}{2}(L+1) \iff L = 1$
Answer: Does the sequence increase or decrease (or neither)? Is it bounded above or below (or neither)?
If a sequence increases to an upper bound, it converges. If a sequence decreases to a lower bound, it converges. If a sequence is unbounded or not monotonic (neither increasing nor decreasing), then it diverges.
This is essentially the monotonic sequence theorem.
Answer: Hint: Write a few terms out and so what you get:
$a_1 = 3$
$a_2 = \frac 12(3+1) = 2$
$a_3 = \frac 12(2+1) = \frac 32 = 1 \frac 12$
$a_4 = \frac 12 (1\frac 12 + 1) = \frac 54 = 1 \frac 14$.
So 1) Use induction to prove that $a_n = 1 + \frac 1{2^{n-2}}$
Then 2)  Prove for any $0 < \frac 1{2^N} < \epsilon$ then $|a_{N+2} - 1| < \frac 1{2^N} < \epsilon$.
Answer: It is easy to guess that the limit if it exists is $1$ hence it is better to consider the sequence $b_{n}=a_{n}-1$ and then the given relation reduces to $b_{n+1}=b_{n}/2=b_{1}/2^{n}=1/2^{n-1}$ so that $b_{n} \to 0$ and $a_{n} \to 1$. Note that we have also found here an explicit expression for $a_{n} $ as $1+(1/2^{n-2})$ for all $n\geq 1$.
Answer: Rearrange the difference equation to: $a_{n+1}-1=\frac{1}{2}(a_n-1).$
Change $a_n-1=b_n$ to obtain $b_{n+1}=\frac{1}{2}b_n$, which is a geometric progression (GP) with $b_1=a_1-1=3-1=2$ and $q=\frac{1}{2}.$
The $n$-term formula of the GP is $b_n=b_1\cdot q^{n-1}=2\cdot \left(\frac{1}{2}\right)^{n-1}=\left(\frac{1}{2}\right)^{n-2}.$
Refer to the change above to get $a_n=b_n+1=\left(\frac{1}{2}\right)^{n-2}+1.$
Finally, $\lim_\limits{n\to\infty} a_n=\lim_\limits{n\to\infty} \left(\left(\frac{1}{2}\right)^{n-2}+1\right)=1.$
Answer: It's easy to show each $a_n>1.$ Thus $a_{n+1} = (a_n+1)/2 <(a_n+a_n)/2 = a_n.$ Therefore $(a_n)$ is a decreasing sequence that is bounded below. Hence $(a_n)$ converges to a limit $L.$ That $L=1$ falls right out of the familiar end game: $L=(L+1)/2.$

sequences and series Does it converge?


Increase gain reduction on op amp filter

Question: The image below features the EQ section of a DJ mixer with -26db gain reduction on each frequency band (hi/mid/low). My goal is to modify this circuit so that the op amp filters are "full kill" (aka isolators) - meaning that when you turn the VR all the way down, it kills the frequency band completely. What can I do to accomplish that (or at least increase the gain reduction beyond -40db)?
Comment: The true null only occurs at 1 frequency then the width at -3 and -26 dB depends on Q which cannot notch the entire width @ -26 dB as  this would require more tuneable notches like a half octave EQ rather than a 3 to 4 octave EQ
Comment: From which Yamaha gear this diagram is coming from? And the maximum/minimum gain will be equal around \$\large \frac{R_{120}}{R_{116}} = +/- 28 V/V = +/-29dB\$  or R112 and R108.
Comment: Thanks G36. This is from a Denon X400. I realize based on some of the answers that the db reduction rating is not for the entire band, and in this circuit theres a reduction curve across the frequencies of a given band. For my purposed I'm happy to roughly increase gain reduction per band without much concern for frequency precision (after all DJ EQing is crude). So it sounds like I can just increase R120 from 5.1K to 10K to change all three EQs from roughly -29db to roughly -50db? This should create a more audible "cut" within each given band in my understanding of this answer?
Comment: But for 10K the gain is only 10k/130 = 77V/V which is only 37.7dB not a big improvement. And the R120 sets the "boost" gain. To change the "attenuation" gain only you need to change R106.  But I do not recommend this way
Comment: Gotcha, 37.7dB for the mid range. I'm assuming the R106 your referring to is the resistor preceding the components in the screenshot i've uploaded (from the full schematic)? Just want to make sure that's not a typo. Also yes that's correct, I really just want to increase the attenuation gain, not the boost. Lastly - why wouldn't you recommend adjusting the attenuation gain with R106?
Comment: @wirl In your screenshot, we do not have R106 because you do not show it. And don't recommend it because I do not analyze the influence of changing the R106 resistor on the filter Q factor.
Answer:
My goal is to modify this circuit so that the op amp filters are "full
  kill" (aka isolators) - meaning that when you turn the VR all the way
  down, it kills the frequency band completely.

Redesign using tunable notch filters as opposed to gyrator inductors and series capacitors. Gyrators are great for emulating inductance but it comes at a price of series resistance (R108, R112 and R116).
However, killing a signal completely is largely unfeasible - you might be able to get down to maybe 100 db reduction with careful circuit layout and decent components but you have to ask yourself if this is really what you want.
Comment: No, there is no way to achieve what you want with minor or lightweight modifications.
Comment: Anything under 40db gain reduction would meet my needs. Ultimately these bands should be close to inaudible when turned down, which doesn't necessarily mean they need to be non-existant.

To clarify - i'm modifying a prebuilt circuit in a DJ mixer. This doesn't allow much space for new components. Is there a way to simply change some of the R/C values in this circuit to increase gain reduction?
Answer: Your immediate question is answered, but I wanted to add some thoughts:

You cannot achieve "full kill" across a band of frequencies, even in theory -- at least not if you restrict yourself to filters that don't have an infinite amount of delay.  There is always a delay vs. completeness of attenuation in play.  This isn't just defeatism -- this is a direct consequence of the underlying mathematics.
Even for something theoretically possible, like a notch filter (which gives "full kill" at exactly one frequency) or a collection of them ("full kill" at a finite number of frequencies) you cannot practically achieve total cutoff -- in the real world, signals always leak through.
The closer you push a real-world system to the ideal, the more nasty artifacts you'll create.  In the case of audio, this will take the form of delay, or phase distortion, ringing, or pre-ringing.  You may not mind how these artifacts sound -- or they may drive you (or some fussy recording engineer) up the wall.
Comment: Thanks for this reply. I think what might be throwing some of these answers off is that the term "full kill" is a term commonly used in DJ mixers. It's not a scientific term. It's also not an unusual feat I am trying to accomplish. It's very common. It just means that when you turn the low mid and high eq knobs down, you don't hear anything anymore. There are many DJ mixers that do this, including a similar model the Denon X500. I'm simply wondering if some simple component swapping can turn a traditional -26db eq section into one that reduces frequency bands more dramatically.


Why is SVM calculated in this way?

Question: I have a question regarding SVM. I understand the Lagrange equation,

$L(w,b,\alpha) = \frac{1}{2}w'w - \sum_i \alpha_i (y_i(w'x_i+b)-1)=$
$\frac{1}{2}w'w - \sum_i  \alpha_i y_i(w'x_i+b)+ \sum_i \alpha_i$

and that taking the derivative to $b$ and $w$ gives

$\frac{\partial L}{\partial b} = \sum_i \alpha_i y_i=0$
$\frac{\partial L}{\partial w} = w - \sum_i \alpha_i y_i x_i=0 \rightarrow w =\sum_i \alpha_i y_i x_i$

Filling this in the Lagrange gives

$L(\alpha)=\frac{1}{2}\sum_i \sum_j \alpha_i \alpha_j y_i y_j x_i' x_j + \sum_i{\alpha_i}
$

But this is not how SVM fills in the Lagrange and I like to understand why.
After some time I saw that

$L(w,b,\alpha) = \frac{1}{2}w'w - \sum_i  ((w'\alpha_i y_i x_i+\alpha_i y_i b)-\alpha_i y_i)=$
$\frac{1}{2}w'w - \sum_i  ((w'w+\alpha_i y_ib)-\alpha_i y_i)$,

which then can be rewritten as the familiar dual problem.

$L(\alpha)=-\frac{1}{2}\sum_i \sum_j \alpha_i \alpha_j y_i y_j x_i' x_j + \sum_i{\alpha_i}
$

But what is wrong, or what is the disadvantage of, the first representation?
Comment: Has dontloo answered your question?
Answer: It seems there's a minus sign missing in the "Filling this in the Lagrange" step .
I got something like
$$L = \frac{1}{2}w'w - \sum_i \alpha_i (y_i(w'x_i+b)-1)$$
$$=\frac{1}{2}\sum_i \sum_j \alpha_i \alpha_j y_i y_j x_i' x_j-\sum_i \sum_j \alpha_i \alpha_j y_i y_j x_i' x_j- b\sum_i \alpha_i y_i + \sum_i{\alpha_i}
$$
$$=-\frac{1}{2}\sum_i \sum_j \alpha_i \alpha_j y_i y_j x_i' x_j+\sum_i{\alpha_i}
$$
which is the same as the other representation.
Comment: In the first case I use the fact that $\alpha_i y_i=0$, which is a condition that is derived. Filling in this condition gives the first equation right?  Edit never mind stupid me. I see the mistake
Comment: @Immer ok saw the edit, cheers

Why is SVM calculated in this way?


SSH server accepts key ONLY if user is logged in (on server)

Question: I can connect to my server using (id_rsa) key WHEN the local account on the server is logged in.
If I reboot server and leave it at the login manager,and then attempt to connect,  SSH returns
Permission denied (publickey)

Permissions to /.ssh and .ssh/authorized keys are 700 and 600 respectively on both server and client.
Client:
henry@MSI-LT17:~ > ls -la ~ | grep ".ssh"
drwx------   3 henry henry  4096 Jan 23 16:31 .ssh
henry@MSI-LT17:~ > ls -la ~/.ssh | grep "authorized_keys"
-rw-------  1 henry henry  228 Jan 23 16:31 authorized_keys

Server:
henry@henry-dt:~ > ls -la ~ | grep ".ssh"                                                                                drwx------  2 henry henry    4096 Jan 19 18:24 .ssh
henry@henry-dt:~ > ls -la ~/.ssh | grep "authorized_keys"
-rw-------  1 henry henry  397 Jan 19 18:56 authorized_keys

Here is the -vvv output of the attempted login:
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/henry/.ssh/id_rsa
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type RSA
debug3: sign_and_send_pubkey: RSA 0d:a8:df:84:1b:25:6e:7f:04:ad:98:87:bd:0b:7d:88
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/henry/.ssh/id_dsa
debug3: no such identity: /home/henry/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/henry/.ssh/id_ecdsa
debug3: no such identity: /home/henry/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/henry/.ssh/id_ed25519
debug3: no such identity: /home/henry/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).

I suspect the debug1: key_parse_private2: missing begin marker has something to do with it...
Answer: Here's the answer. Home folder was encrypted...
https://help.ubuntu.com/community/SSH/OpenSSH/Keys#Troubleshooting


What makes drive encryption safe?

Question: Let's build a scene: I'm working on my laptop in the library, and while I'm gone to the toilet for 5 minutes, someone disassembled my laptop and took the hard drive. I encrypted it with VeraCrypt, so I assume it's save. Now, I build some PC's in the past, and a simple step involved in that process is connecting the hard drive or SSD to the motherboard. I was wondering this: What's the exact thing that prevents the thief from connecting my HDD to his motherboard and seeing the contents of it in Windows Explorer? (Or any other way)
Comment: They don't have your keys.
Comment: @MechMK1 The TPM doesn't store keys. It has its own internal "sealing" key which encrypts, or seals, a blob that you pass to it. It's your job to store the encrypted blob.
Comment: @MechMK1 Also, VeraCrypt does not use the TPM.
Comment: @MechMK1 yes but I don't have to type in the keys everytime
Comment: They're in your TPM
Comment: @ÖmerEnesÖzmen what do you mean "not everytime"?
Comment: @ÖmerEnesÖzmen - Are you perhaps *suspending* vice shutting down? Otherwise I don't know why you would not need to enter your keys.
Answer: Disk encryption provides data-at-rest security. That is, the data is only secure if your computer is fully powered down (or the attacker can't or doesn't know how to perform attacks against a live system). In such a case, the reason drive encryption is safe is that only you know your password. This password is used to derive an encryption key. The drive contents can be downloaded, but they would appear to be gibberish to anyone who does not possess the correct key.
Comment: @kelalaka A cold boot attack can be performed in seconds, depending on how it is performed.
Comment: There is a tiny time for cold boot attack.

What makes drive encryption safe?


Algebraic integers in a quadratic number field

Question: I want to show that an element in $\alpha$ in a quadratic number field, $\mathbb{Q}(d)$, is an algebraic integer if the Norm and the Trace of $\alpha$ are in $\mathbb{Z}.$
Comment: What have you tried and where are you stuck?
Answer: Let $\alpha\in\mathbb{Q}(\sqrt d)$ be an algebraic integer; By definition, it is the root of a polynomial $f(x)\in\mathbb{Z}[x]$. One can show that in fact, the minimal polynomial of $\alpha$ over $\mathbb{Q}$, is with integral coefficients
(please tell me if you want me to elaborate on this point). Note that if $\alpha=a+b\sqrt d$, then $\alpha$  is a root of $x^2-2ax+a^2-db^2\in\mathbb{Q}[x]$ and that this is in fact its minimal polynomial, as there is no polynomial of degree 1 over $\mathbb{Q}$ has $\alpha$ as a root (otherwise, $\alpha$ would be a rational number, and this case is easy to handle with). But then it follows that $2a,a^2-db^2\in\mathbb{Z}$, and these are the trace and norm of $\alpha$, so we're finished.
Conversely, write $\alpha=a+b\sqrt d$. Then $tr_{\mathbb{Q}(\sqrt d)/\mathbb{Q}}(\alpha)=2a$ and $Norm_{\mathbb{Q}(\sqrt d)/\mathbb{Q}}(\alpha)=a^2-db^2$. If they're both in $\mathbb{Z}$, then $f(x)=x^2-2ax+(a^2-db^2)\in\mathbb{Z}[x]$. Now by Vietta's formula (or by substitution, whatever you like...) we get that $f(\alpha)=0$ and so $\alpha$ is algebraic.
Conceptually, $\alpha$ is an algebraic integer, iff its minimal polynomial over $\mathbb{Q}$ is a polynomial with integer coefficients. In the case of a quadratic extension, the coefficients of the minimal polynomial (except for the leading coefficient, which is 1) are precisely the norm and the trace of $\alpha$.


Dummy interaction term in an ARIMA model

Question: How to include a dummy interaction term in an ARIMA model? Can we use the dependent variable (in this case, say the log return of an asset price at time $t$) to multiply with the dummy variable as an interaction term?
Answer: An ARIMA model with an interaction term would not be called ARIMA anymore, but certainly you can formulate a model of the kind. E.g. starting from ARMA(1,1) and excluding the intercept for simplicity
$$
y_t=\varphi_1 y_{t-1}+u_t+\theta_1 u_{t-1}
$$
you could obtain
$$
y_t=\varphi_1 y_{t-1}\color{blue}{+\gamma_1 d_1y_{t-1}}+u_t+\theta_1 u_{t-1}
$$
where $d_1$ is the dummy variable. The dummy interacts with a lag of the dependent variable. I am not sure if it would make any sense to interact it with the (nonlagged) dependent variable, though. (If you explain us what you are trying to achieve, perhaps we can elaborate further.)
Comment: Thanks, @Richard Hardy. However, if the model is ARMA(3,2), how do I create the interaction term? Basically, I am trying to establish if a particular exogenous variable has any effect on an ARMA process.
Comment: @JyotiNair, what do you mean by *how*? Conceptually, $d_1y_{t-1}$ is a product of $d_1$ and $y_{t-1}$. If you are asking for code (which is off topic), check out `TSA::arimax` , `sysid::armax` or `marima::marima`. I have not used any of these myself, but Google search suggests they might do what you want.


omp parallel vs. omp parallel for

Question: What is the difference between these two?
[A]
#pragma omp parallel
{
    #pragma omp for
    for(int i = 1; i < 100; ++i)
    {
        ...
    }
}

[B]
#pragma omp parallel for
for(int i = 1; i < 100; ++i)
{
   ...
}

Answer: These are equivalent.
#pragma omp parallel spawns a group of threads, while #pragma omp for divides loop iterations between the spawned threads. You can do both things at once with the fused #pragma omp parallel for directive.
Comment: Update: As it turns out, I am observing this problem only when I use the schedule clause so I guess it is not depending on whether I use the combined parallel for or two different directives.
Comment: In my code I am using this very structure. However when I use `schedule(static, chunk)` clause in for directive, I get a problem. The code runs fine but when I am invoking this code from an MPI program then it runs into an infinite loop. The loop counter is zero in all iterations of this loop. I have the loop counter defined as private in the `#pragma omp parallel` directive. No idea why it only fails when MPI is invoking the code. I am somewhat sure that each MPI process is running on a different processor of the cluster if that matters. No idea if schedule is causing the problem.
Comment: The same thing works fine when I use the `#pragma omp parallel for` directive. There ought to be some difference.
Answer: I don't think there is any difference, one is a shortcut for the other. Although your exact implementation might deal with them differently.

The combined parallel worksharing constructs are a shortcut for
  specifying a parallel construct containing one worksharing construct
  and no other statements. Permitted clauses are the union of the clauses
  allowed for the parallel and worksharing contructs.

Taken from http://www.openmp.org/mp-documents/OpenMP3.0-SummarySpec.pdf
The specs for OpenMP are here:
https://openmp.org/specifications/
Answer: Here is example of using separated parallel and for here. In short it can be used for dynamic allocation of OpenMP thread-private arrays before executing for cycle in several threads.
It is impossible to do the same initializing in parallel for case.
UPD:
In the question example there is no difference between single pragma and two pragmas. But in practice you can make more thread aware behavior with separated parallel and for directives.
Some code for example:
#pragma omp parallel
{
    double *data = (double*)malloc(...); // this data is thread private

    #pragma omp for
    for(1...100) // first parallelized cycle
    {
    }

    #pragma omp single
    {} // make some single thread processing

    #pragma omp for // second parallelized cycle
    for(1...100)
    {
    }

    #pragma omp single
    {} // make some single thread processing again

    free(data); // free thread private data
}

Answer: Although both versions of the specific example are equivalent, as already mentioned in the other answers, there is still one small difference between them. The first version includes an  unnecessary implicit barrier, encountered at the end of the "omp for". The other implicit barrier can be found at the end of the parallel region. Adding "nowait" to "omp for" would make the two codes equivalent, at least from an OpenMP perspective. I mention this because an OpenMP compiler could generate slightly different code for the two cases.
Comment: Best answer for actually identifying a difference and suggesting an alternate equivalence.
Answer: There are obviously plenty of answers, but this one answers it very nicely (with source)

#pragma omp for only delegates portions of the loop for
  different threads in the current team. A team is the group of threads
  executing the program. At program start, the team consists only of a
  single member: the master thread that runs the program.
To create a new team of threads, you need to specify the parallel
  keyword. It can be specified in the surrounding context:
#pragma omp parallel
{
   #pragma omp for
   for(int n = 0; n < 10; ++n)
   printf(" %d", n);
}

and:

What are: parallel, for and a team
The difference between parallel,
  parallel for and for is as follows:
A team is the group of threads
  that execute currently. At the program beginning, the team consists of
  a single thread. A parallel construct splits the current thread into a
  new team of threads for the duration of the next block/statement,
  after which the team merges back into one. for divides the work of the
  for-loop among the threads of the current team.
It does not create
  threads, it only divides the work amongst the threads of the currently
  executing team. parallel for is a shorthand for two commands at once:
  parallel and for. Parallel creates a new team, and for splits that
  team to handle different portions of the loop. If your program never
  contains a parallel construct, there is never more than one thread;
  the master thread that starts the program and runs it, as in
  non-threading programs.

https://bisqwit.iki.fi/story/howto/openmp/
Answer: TL;DR: The only difference is that the 1st code calls 2 implicit barriers whereas the 2nd only 1.

A more detail answer using as reference the modern official OpenMP 5.1 standard.
The OpenMP clause:
#pragma omp parallel

creates a parallel region with a team of threads, where each thread will execute the entire block of code that the parallel region encloses.
From the OpenMP 5.1 one can read a more formal description :

When a thread encounters a parallel construct, a team of threads is
created to execute the parallel region (..). The
thread that encountered the parallel construct becomes the primary
thread of the new team, with a thread number of zero for the duration
of the new parallel region. All threads in the new team, including the
primary thread, execute the region. Once the team is created, the
number of threads in the team remains constant for the duration of
that parallel region.

The:
#pragma omp parallel for

creates a parallel region (as described before), and to the threads of that region the iterations of the loop that it encloses will be assigned, using the default chunk size and schedule (which is typically static). Bear in mind, however, that those defaults might differ among different concrete implementation of the OpenMP standard.
From the OpenMP 5.1 you can read a more formal description :

The worksharing-loop construct specifies that the iterations of one or
more associated loops will be executed in parallel by threads in the
team in the context of their implicit tasks. The iterations are
distributed across threads that already exist in the team that is
executing the parallel region to which the worksharing-loop region
binds.

Moreover,

The parallel loop construct is a shortcut for specifying a parallel
construct containing a loop construct with one or more associated
loops and no other statements.

Or informally, #pragma omp parallel for is a combination of the constructor #pragma omp parallel with #pragma omp for.
For both versions that you have shown if one uses chunk_size=1 and  static schedule the execution flow would result in something like:

Code-wise the loop would be transformed to something logically similar to:
for(int i=omp_get_thread_num(); i < n; i+=omp_get_num_threads())
{
    //...
}

where omp_get_thread_num()

The omp_get_thread_num routine returns the thread number, within the
current team, of the calling thread.

and omp_get_num_threads()

Returns the number of threads in the current team. In a sequential
section of the program omp_get_num_threads returns 1.

or in other words, for(int i = THREAD_ID; i < n; i += TOTAL_THREADS). With THREAD_ID ranging from 0 to TOTAL_THREADS - 1, and TOTAL_THREADS representing the total number of threads of the team created on the parallel region.
Answer: I am seeing starkly different runtimes when I take a for loop in g++ 4.7.0
and using
std::vector<double> x;
std::vector<double> y;
std::vector<double> prod;

for (int i = 0; i < 5000000; i++)
{
   double r1 = ((double)rand() / double(RAND_MAX)) * 5;
   double r2 = ((double)rand() / double(RAND_MAX)) * 5;
   x.push_back(r1);
   y.push_back(r2);
}

int sz = x.size();

#pragma omp parallel for

for (int i = 0; i< sz; i++)
   prod[i] = x[i] * y[i];

the serial code (no openmp ) runs in 79 ms.
the "parallel for" code runs in 29 ms.
If I omit the for and use #pragma omp parallel, the runtime shoots up to 179ms,
which is slower than serial code. (the machine has hw concurrency of 8)
the code links to libgomp
Comment: That is because without a `#pragma omp for` there is no multi-threaded sharing of the loop at all. But that wasn't the OPs case anyway, try again with an additional `#pragma omp for` inside the `#pragm omp parallel` and it should run similar (if not the same) like the `#pragma omp parallel for` version.
Comment: i think it's because omp parallel executes loop in separate thread without dividing it into threads, so main thread is waiting for second thread finished. and time spends on synchronizing.
Comment: I see this answer as the best one as it shows they are not "equivalent"
Comment: @Failed Scientist Please read Christian Rau's comment. it only shows that omp parallel for is not equivalent to just omp parallel. Nothing more. It says nothing about equivalency of omp parallel for with omp parallel AND omp for
Comment: `#pragma omp parallel for` instructs the comiler to parallelize the next `for` block. With `#pragma omp parallel` alone, you have many threads who run the same code. I.e. each thread runs the whole `for` cycle. The slow down comes from race conditions when several/all threads try to access the same memory. This is rookie mistake number one in using OpenMP.

omp parallel vs. omp parallel for


Will importing a View that already exists merge with what isn't there in Drupal 7?

Question: I have a dev and prod instance of my site. I cloned my Prod to my Dev server. Now I created a new display block inside an existing view on Dev. I tested it and it works. Now i want to export it to my Prod, but it has the same View name. I can manually create it on prod, but thats the slow way of doing it. If i export the view code and paste it to my prod, would it throw an error saying that view exist? Or would it just merge the changes and add in the new display i created?
Answer: WHOA STOP. haha
Install the Features module and create a feature with this View in it and deploy (git/sftp) the Feature up to production. then revert feature and boom. latest view is there.

Download, enable Features on Dev
Create a new Feature
Add your View to this Feature
Save the exported feature into your file system for Drupal
Enable on Dev and verify that it is in the default state (it should be)
Download, enable Features on Prod (or use git to merge you dev branch into prod)
Place this new Feature onto prod (either using git or SFTP)
Enable this feature on prod. Since you have the View already, it will probably be Overridden. You can simply view differences (using Diff module) or revert it.

Note: I highly recommend a staging environment between development and production so you can test these types of reverts and adjustments prior to making changes on a production site.
Comment: so in prod create a feature with this view in it? then do the modifications in dev then import it back?
Comment: You don't have to do that. Since you have the View in dev, you can simply install Features (dev) and then export it from Dev. You will need to install Features and enable it on production prior to reverting.
Comment: reverting? u mean importing it to my prod? so just save the view as a feature on dev. then copy that feature to prod and enable it?
Comment: I've updated the answer.
Answer: The views import form has this option:

Replace an existing view if one exists with the same name.

It does what it says.
Comment: yea this is the method i used. much simpler.


Do neutrinos interact gravitationally?

Question: I know that, in theory at least, they do. However, I was wondering if there has been any experimental confirmation of this, or any other reasons for perhaps thinking that they do not interact via the gravitational force.
Comment: If I'm not wrong their mass is negligible right? Like many factors lesser than the mass of an electron. If it is so, how could they show an appreciable gravitational interaction?
Comment: They are, and I don't know how they could, I was wondering if there was some plausible way to test for it.
Comment: Firstly, I have negligible knowledge about neutrinos. Secondly, despite the little knowledge I have, I'm pretty sure they are very and I mean very very hard to detect.
Answer: Photons interact gravitationally, as seen in gravitational lensing.

A gravitational lens is a distribution of matter (such as a cluster of galaxies) between a distant light source and an observer, that is capable of bending the light from the source as the light travels towards the observer. This effect is known as gravitational lensing, and the amount of bending is one of the predictions of Albert Einstein's general theory of relativity.

So even massless particles follow the general relativity equations
If one googles "gravitational lensing and neutrinos a lot of papers proposing effects  come up.
There are various future experiments  proposed, from indirect ones deciphering the cosmic microwave bacground, to the use of neutrino detectors .

Do neutrinos interact gravitationally?


AWS: How to redirect many domains to a page on another domain?

Question: My objective
I have a number of domains (e.g. 10 or 20) and I would like to redirect any visitors to anywhere on those pages to one page on another domain (for example my stackoverflow.com profile page).
This includes

apex domain using http (e.g. http://mydomain01.com)
apex domain using https (e.g. https://mydomain01.com)
sub domains using http (e.g. http://www.mydomain01.com or http://blog.mydomain01.com)
sub domains using https (e.g. https://www.mydomain01.com or https://blog.mydomain01.com)
any paths (e.g. http://mydomain01.com/some_path or https://www.mydomain01.com/another/path.html)

plus the same for all my other domains (mydomain02.com, mydomain03.com, etc.; each with the above use cases).
My research

This AWS article explains how to redirect internet traffic from an apex domain to another domain (case #1 in my This includes list above) using AWS S3 and AWS Route 53: This works for http, but not for https.
This AWS article explains how to redirect internet traffic for a number of cases (by the looks of it, covering all cases in my This includes list above) using AWS S3, AWS Route 53 and AWS CloudFront: This works for both http and https. (Also talks about using an Application Load Balancer, but I guess that's beyond the scope here...)
This AWS article adds some more details on setting up a CloudFront distribution and how to get insight into log files.
This AWS article documents redirection rules to use advanced conditional redirects: Not sure if I need to go there to accomplish my goal, so haven't really looked into that yet.

Plus, there are obviously plenty of SO questions (see Related to the right of this question) and other posts on the subject; problem with most of those is that they use screenshots from previous versions of the AWS Console UI: Most of the contents should still be the same, but correlating those screenshots to the current UI IMO adds another layer of confusion.
Key takeaways from the AWS (and other) docs:

I need to create a bucket in AWS S3 and configure redirection in it,
I need to create a distribution in AWS CloudFront;
in order to use a custom domain in CloudFront, I need to create a certificate in AWS ACM,
I need to create a hosted zone in AWS Route 53 and configure records in it.

My work so far
The latest AWS CLI is installed, region and output are configured in ~/.aws/config, credentials are set up in ~/.aws/credentials (each for every AWS account); AWS_* environment variables are exported.
I am using AWS region US East (N. Virginia) (us-east-1) for everything to prevent any additional issues caused by AWS resources not being available in a region.
$ aws --version
aws-cli/2.2.23 Python/3.9.6 Darwin/19.6.0 source/x86_64 prompt/off

I omit any shell prompts or > shell line continuation characters for easier copying from this post into the shell.
Set up an S3 bucket
Warning: This creates an "all public" bucket without any access restrictions. In this case, this should not matter as there is no bucket contents to protect, but such a public bucket is a bad practice in general. Also, I'm using a public bucket to prevent any additional issues caused by access restrictions: First, get it work; second, make it secure.
create the bucket

AWS S3 create-bucket docs

aws s3api create-bucket --bucket mydomain01.com

response:

{
    "Location": "/mydomain01.com"
}

set up redirection

AWS put-bucket-website docs
no point in redacting my SO profile...

aws s3api put-bucket-website --bucket mydomain01.com --website-configuration \
    '{ "RedirectAllRequestsTo": { "HostName": "stackoverflow.com/users/217844/ssc" } }'

no response

Gotcha: The S3 bucket name must match the apex domain name.
Using any bucket name but mydomain01.com (for my example) seems to fail without any indication as to the cause. The AWS docs don't really make this very clear - in fact, I am still not sure if I massively misunderstand something here, but from what I can tell, the official AWS documentation is actually somewhat sloppy on that - IMO - crucial key point: For example, #2 just says

Create an S3 bucket with a global unique name.

which could be any globally unique name. #1 mentions that in some way - once you know how to read those bits...
On a side note, that article #2 continues to confuse me with

If you aren't using a custom domain ...

Why would I not be using a custom domain ?!? The whole point is to redirect my custom domain, isn't it ?!? Well, anyway...
Gotcha: Must not prepend protocol to hostname.
Neither the AWS Console nor the AWS CLI seem to test if a protocol (http:// or https://) was entered in the Host name UI field / passed in the HostName JSON string. However, if one is prepended, the redirect fails; see test redirection below.
Gotcha: AWS S3 Console UI bug.
After redirection has been set up, the AWS Console displays clickable link in its UI to the bucket URL (http://mydomain01.com.s3-website-us-east-1.amazonaws.com) at the very bottom of the bucket's Properties tab, in the Static website hosting section.
Clicking that link fails to open the page, seemingly because the AWS Console messes up the URL and tries to open http://https//stackoverflow.com/users/217844/ssc/, no matter the protocol.
test redirection

using HTTPie in the shell instead of curl or wget because that's what the cool kids seem to use nowadays
copy the link from AWS Console in browser to shell

http http://mydomain01.com.s3-website-us-east-1.amazonaws.com/
HTTP/1.1 301 Moved Permanently
Content-Length: 0
Date: Mon, 02 Aug 2021 12:39:09 GMT
Location: http://stackoverflow.com/users/217844/ssc/
Server: AmazonS3
x-amz-id-2: rakAqUMnRraGvo/WkSa6AnbuhWn/9YZX/CAlI/OJQKYoWp/OdQIbyhsvHSwNved3suwMdgglqpE=
x-amz-request-id: C5BBG833Q9TQ9J6X

--> seems to work

test the redirection if the protocol was erroneously prepended to the host name; note the broken Location url:

http http://mydomain01.com.s3-website-us-east-1.amazonaws.com/
HTTP/1.1 301 Moved Permanently
Content-Length: 0
Date: Mon, 02 Aug 2021 12:52:10 GMT
Location: http://https://stackoverflow.com/users/217844/ssc/
Server: AmazonS3
x-amz-id-2: Ee2/ob0faTpRdp6mGITdmClozXNmF1Q2oTbPioms8O91VA8n5VA3MoHhveeFz7v2VS65YKFKlDA=
x-amz-request-id: ZJP653R50YD5HSRS

My questions #1
NOTE: I had these questions when I started out writing this; I think I was able to answer them myself since (see test www sub domain record below). Someone please correct me if I'm wrong:

Q: Does the "bucket name == domain name" requirement apply even if I use CloudFront ?
A: Yes.
Q: Do I need to create one bucket each for the apex domain and every subdomain ? so, in my example

mydomain01.com
www.mydomain01.com
blog.mydomain01.com ?
A: Yes.

Set up an Route 53 hosted zone
create the hosted zone

AWS Route 53 create-hosted-zone docs
caller-reference must simply be a unique string

aws route53 create-hosted-zone --caller-reference "$(date '+%Y%m%d-%H%M%S')" --name mydomain01.com

response

{
    "Location": "https://route53.amazonaws.com/2013-04-01/hostedzone/Z123456789EXAMPLE0SKX",
    "HostedZone": {
        "Id": "/hostedzone/Z123456789EXAMPLE0SKX",
        "Name": "mydomain01.com.",
        "CallerReference": "20210802-150736",
        "Config": {
            "PrivateZone": false
        },
        "ResourceRecordSetCount": 2
    },
    "ChangeInfo": {
        "Id": "/change/C1234567890SKXEXAMPLE",
        "Status": "PENDING",
        "SubmittedAt": "2021-08-02T13:07:37.860000+00:00"
    },
    "DelegationSet": {
        "NameServers": [
            "ns-1234.awsdns-12.com",
            "ns-5678.awsdns-34.co.uk",
            "ns-1234.awsdns-56.net",
            "ns-5678.awsdns-78.org"
        ]
    }
}

take note of the hosted zone ID Z123456789EXAMPLE0SKX, needed in the next steps

create a record for the apex domain

AWS Route 53 change-resource-record-sets docs
this should work for http, but not for https
the JSON to pass is somewhat complex; create a local temp file change-batch.apex.json with the contents below
get values for HostedZoneId and DNSName from Amazon S3 website endpoints: Bucket was created in US East (N. Virginia), so use Z3AQBSTGFYJSTF

{
  "Changes": [
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "mydomain01.com.",
        "Type": "A",
        "AliasTarget": {
          "HostedZoneId": "Z3AQBSTGFYJSTF",
          "DNSName": "s3-website-us-east-1.amazonaws.com",
          "EvaluateTargetHealth": false
        }
      }
    }
  ]
}

Gotcha: Must use verbatim s3-website-us-east-1.amazonaws.com for DNSName.
AWS docs talk in all sort of places about example.com or example.com.s3-website-us-east-1.amazonaws.com, etc. In this case, this is not some example to be replaced by own values (e.g. mydomain01.com.s3-website-us-east-1.amazonaws.com), but the verbatim value from the table, i.e. s3-website-us-east-1.amazonaws.com.
Gotcha: Must not prepend protocol to hostname.
Similar to the gotcha above, both AWS Console and the AWS CLI gladly accept a protocol (http:// or https://) prepended to the value entered in the Host name UI field / passed as DNSName. At least, this looks very wrong in the Console, e.g. http\072\057\057mydomain01.s3-website-us-east-1.amazonaws.com.
Both gotchas are somewhat mitigated in the AWS Console where values can be selected from a dropdown box when a record is created or edited; when using the AWS CLI, you must double-check what you send.
The same gotcha and mitigation applies to the Record name UI field / Name JSON value.
create a record for the apex domain, cont.

use jq for a quick test the temp file contains valid json

jq . < change-batch.apex.json 1> /dev/null

no output --> valid JSON

aws route53 change-resource-record-sets --hosted-zone-id Z123456789EXAMPLE0SKX \
    --change-batch "file://$(pwd)/change-batch.apex.json"

response

{
    "ChangeInfo": {
        "Id": "/change/C1234567890EXAMPLESKX",
        "Status": "PENDING",
        "SubmittedAt": "2021-08-02T14:20:09.370000+00:00"
    }
}

test apex domain record

test http

http http://mydomain01.com
HTTP/1.1 301 Moved Permanently
Content-Length: 0
Date: Mon, 02 Aug 2021 15:06:08 GMT
Location: http://stackoverflow.com/users/217844/ssc/
Server: AmazonS3
x-amz-id-2: EfDtCxif2iV4eInskirSBAOjQS7o9arzJCeZjscF6mW7cwwmm9Nxb7QJT50x2kjdslX2fOxA+lk=
x-amz-request-id: WM7K9TDEF75A6P1V

--> looks good

test http with a path

http http://mydomain01.com/some/path
 ... similar output as above ...

test https

http https://mydomain01.com

http: error: ConnectionError: HTTPSConnectionPool(host='mydomain01.com', port=443):
  Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x101a48100>:
    Failed to establish a new connection: [Errno 60] Operation timed out')) while doing a GET request to URL: https://mydomain01.com/

(response wrapped for readability)

--> times out (after 60s ?) - as expected: redirecting using an S3 bucket does not work with https (see above)
Gotcha: DNS change propagation delay.
AWS and Google are very fast in terms of propagating changes to DNS settings (as in seconds or minutes), but there might be other, "slower" name servers involved. Bypass them as described here to eliminate that source of confusion. That approach only works in macOS, but the concept is the same for any OS.
Gotcha: Browser cache.
When testing DNS changes not in the shell, but in the browser, the browser might get results from its cache. I do most of my work using Chrome, but use Firefox (or Safari) for testing, so I can clear the entire cache before every test to eliminate that potential issue - without getting logged out of Google, AWS, etc.
create a record for www sub domain

the only difference is the Name JSON value

sed -e 's|mydomain01.com.|www.mydomain01.com.|g' change-batch.apex.json > change-batch.www.json
aws route53 change-resource-record-sets --hosted-zone-id Z123456789EXAMPLE0SKX \
    --change-batch "file://$(pwd)/change-batch.www.json

response similar as above

test www sub domain record

test http

http http://www.mydomain01.com
HTTP/1.1 404 Not Found
Content-Length: 363
Content-Type: text/html; charset=utf-8
Date: Mon, 02 Aug 2021 15:28:05 GMT
Server: AmazonS3
x-amz-id-2: MGLcynq1iEGKh+pT6N6iRpCuQSN243q/5zm2Y7rXTnM7iW9nvDokF6s20xEUBr7QiEtBPEzZmII=
x-amz-request-id: TK83G35EMYFR8SKX

<title>404 Not Found</title>

404 Not Found

Code: NoSuchBucket

Message: The specified bucket does not exist

BucketName: www.mydomain01.com

RequestId: TK83G35EMYFR8SKX

HostId: MGLcynq1iEGKh+pT6N6iRpCuQSN243q/5zm2Y7rXTnM7iW9nvDokF6s20xEUBr7QiEtBPEzZmII=

I think that answers the second of My questions #1 above: I need one S3 bucket per apex/sub domain to forward.

Set up a CloudFront distribution

NOTE: AWS Console makes it really easy to request a certificate and validate it using DNS.

create a certificate

AWS ACM request-certificate docs
the certificate is supposed to work for the apex and all sub domains, so need to add another name to this certificate / pass --subject-alternative-names; see this AWS article (the upper blue box).
add quotes around *.mydomain01.com so the shell does not interpret the *

aws acm request-certificate --domain-name mydomain01.com --validation-method DNS \
    --subject-alternative-names '*.mydomain01.com'

response:

{
    "CertificateArn": "arn:aws:acm:us-east-1:123456789012:certificate/12345678-90ab-cdef-1234-1234567890ab"
}

123456789012 is my AWS account ID; everything after certificate/ is just a UUID

get certificate details

AWS ACM describe-certificate docs
save response to temporary local file; extract ResourceRecord.Name and ResourceRecord.Value using jq
needed for the AWS Route 53 record that proves I own mydomain01.com
alternatively, use --query parameter with aws acm describe-certificate

aws acm describe-certificate \
    --certificate-arn "arn:aws:acm:us-east-1:123456789012:certificate/12345678-90ab-cdef-1234-1234567890ab" \
 > describe-certificate.json

jq -r '.Certificate.DomainValidationOptions[0].ResourceRecord.Name' describe-certificate.json
_1234567890abcdef1234567890abcdef.mydomain01.com.

jq -r '.Certificate.DomainValidationOptions[0].ResourceRecord.Value' describe-certificate.json
_1234567890abcdef1234567890abcdef.weirdchars.acm-validations.aws.

create a Route 53 record for certificate validation

will be automatically checked by AWS ACM and the certificate will be validated once this record is found
as before, use a temporary local file change-batch.cert.json, see e.g. create a record for the apex domain; contents:

{
  "Changes": [
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "_1234567890abcdef1234567890abcdef.mydomain01.com.",
        "Type": "CNAME",
        "TTL": 300,
        "ResourceRecords": [
          {
            "Value": "_1234567890abcdef1234567890abcdef.weirdchars.acm-validations.aws."
          }
        ]
      }
    }
  ]
}

shell command:

aws route53 change-resource-record-sets --hosted-zone-id Z123456789EXAMPLE0SKX \
    --change-batch "file://$(pwd)/change-batch.cert.json

response similar as when creating records above
NOTE: It might take a couple of minutes for ACM to validate the certificate.

create the CloudFront distribution

AWS CloudFront create-distribution docs
again, CallerReference must simply be a unique string; use e.g. date '+%Y%m%d-%H%M%S' in shell to create and copy into file; see create the hosted zone
as before, use a temporary local file create-distribution.json for complex values; contents below
MinimumProtocolVersion: get value from this AWS article
OriginProtocolPolicy: using http-only because the origin (the S3 bucket) can do only http
ViewerProtocolPolicy: using redirect-to-https as the whole point of creating this distribution is to redirect from http to https
NOTE: I don't know (and the AWS docs don't tell) which fields are mandatorily required; the AWS CLI command displays a clear and detailed message if something about the data sent is missing or wrong.

{
    "CallerReference": "20210802-191725",
    "Aliases": {
        "Quantity": 2,
        "Items": ["mydomain01.com", "*.mydomain01.com"]
    },
    "Origins": {
        "Quantity": 1,
        "Items": [
            {
                "Id": "mydomain01.com.s3.us-east-1.amazonaws.com_20210802-191725",
                "DomainName": "mydomain01.com.s3.us-east-1.amazonaws.com",
                "CustomOriginConfig": {
                    "HTTPPort": 80,
                    "HTTPSPort": 443,
                    "OriginProtocolPolicy": "http-only"
                }
            }
        ]
    },
    "OriginGroups": {
        "Quantity": 0
    },
    "DefaultCacheBehavior": {
        "TargetOriginId": "mydomain01.com.s3.us-east-1.amazonaws.com_20210802-191725",
        "ForwardedValues": {
            "QueryString": false,
            "Cookies": {
                "Forward": "none"
            },
            "Headers": {
                "Quantity": 0
            },
            "QueryStringCacheKeys": {
                "Quantity": 0
            }
        },
        "TrustedSigners": {
            "Enabled": false,
            "Quantity": 0
        },
        "ViewerProtocolPolicy": "redirect-to-https",
        "MinTTL": 0,
        "AllowedMethods": {
            "Quantity": 2,
            "Items": [
                "HEAD",
                "GET"
            ],
            "CachedMethods": {
                "Quantity": 2,
                "Items": [
                    "HEAD",
                    "GET"
                ]
            }
        },
        "SmoothStreaming": false,
        "DefaultTTL": 86400,
        "MaxTTL": 31536000,
        "Compress": false,
        "LambdaFunctionAssociations": {
            "Quantity": 0
        },
        "FieldLevelEncryptionId": ""
    },
    "CacheBehaviors": {
        "Quantity": 0
    },
    "CustomErrorResponses": {
        "Quantity": 0
    },
    "Comment": "",
    "Logging": {
        "Enabled": false,
        "IncludeCookies": false,
        "Bucket": "",
        "Prefix": ""
    },
    "PriceClass": "PriceClass_All",
    "Enabled": true,
    "ViewerCertificate": {
        "ACMCertificateArn": "arn:aws:acm:us-east-1:123456789012:certificate/12345678-90ab-cdef-1234-1234567890ab",
        "MinimumProtocolVersion": "TLSv1.2_2021",
        "SSLSupportMethod": "sni-only"
    },
    "Restrictions": {
        "GeoRestriction": {
            "RestrictionType": "none",
            "Quantity": 0
        }
    },
    "WebACLId": "",
    "HttpVersion": "http2",
    "IsIPV6Enabled": true
}

shell command:
NOTE: add --no-cli-pager to disable paging and store response in temporary local file for inspection

aws --no-cli-pager cloudfront create-distribution \
    --distribution-config "file://$(pwd)/create-distribution.json"
 > create-distribution.response.json

response: a large JSON structure, mostly the config sent with some distribution meta info

Gotcha: CloudFront distribution takes a moment to deploy.
In the Distributions overview, there is a Last modified field that says Deploying for a while after every change; depending on screen and browser window width, this field might be hidden, so the UI might looks like the distribution is up and running while in fact, it is not.
test distribution

get DomainName from response

jq -r '.Distribution.DomainName' create-distribution.response.json
abcdefghij1234.cloudfront.net

test http

http http://abcdefghij1234.cloudfront.net
HTTP/1.1 301 Moved Permanently
Connection: keep-alive
Content-Length: 183
Content-Type: text/html
Date: Mon, 02 Aug 2021 20:14:27 GMT
Location: https://abcdefghij1234.cloudfront.net/
Server: CloudFront
Via: 1.1 8640a37b586353bc916562c577770223.cloudfront.net (CloudFront)
X-Amz-Cf-Id: ooT0Y1QvDE7_yoRmb0p0Un2Db6O713rBvudtmz1xer7YwEU0GE8smw==
X-Amz-Cf-Pop: HAM50-C2
X-Cache: Redirect from cloudfront

<title>301 Moved Permanently</title>

301 Moved Permanently

CloudFront

So the distribution redirects from http://abcdefghij1234.cloudfront.net to https://abcdefghij1234.cloudfront.net - as it should; that's what it was created for.

test https

HTTP/1.1 403 Forbidden
Connection: keep-alive
Content-Type: application/xml
Date: Mon, 02 Aug 2021 20:14:35 GMT
Server: AmazonS3
Transfer-Encoding: chunked
Via: 1.1 c3e656776c8a9f0e1ea24405ab1dcc85.cloudfront.net (CloudFront)
X-Amz-Cf-Id: or4SC8urWEv_8c3jDURv5IINwFU1TDVLSQ3_X7tya7Ncz8ujyz0-IQ==
X-Amz-Cf-Pop: HAM50-C2
X-Cache: Error from cloudfront
x-amz-bucket-region: us-east-1

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  AccessDenied
  <Message>Access Denied</Message>
  <RequestId>EAST1CM5WJR8QM3S</RequestId>
  <HostId>zF2dJm2vsuSM633NHuzcA5VqrCrNkfYGu31FRmKKIkebuI5+6l5DlVnr4kk9be262hcqktoiROw=</HostId>
</Error>

(xml formatted for readability)

That does not look good. Not sure if that is to be expected ?!?
Update the AWS Route 53 records

change from using the S3 bucket to using the CloudFront distribution
as before, create a temporary local file change-batch.apex.updatejson by seding the earlier file change-batch.apex.json
use UPSERT instead of CREATE: The record exists already and must be updated.
HostedZoneId: replace old value Z3AQBSTGFYJSTF (for S3) by Z2FDTNDATAQYW2, some magic value taken from change-resource-record-sets docs
DNSName: quote from change-resource-record-sets docs

Specify the domain name that CloudFront assigned when you created your distribution.
Your CloudFront distribution must include an alternate domain name that matches the name of the resource record set. For example, if the name of the resource record set is acme.example.com, your CloudFront distribution must include acme.example.com as one of the alternate domain names.

--> replace s3-website-us-east-1.amazonaws.com (for S3) by abcdefghij1234.cloudfront.net:
sed -e 's|CREATE|UPSERT|g' \
    -e 's|Z3AQBSTGFYJSTF|Z2FDTNDATAQYW2|g' \
    -e 's|s3-website-us-east-1.amazonaws.com|abcdefghij1234.cloudfront.net|g' \
    change-batch.apex.json > change-batch.apex.update.json

file contents:

{
  "Changes": [
    {
      "Action": "UPSERT",
      "ResourceRecordSet": {
        "Name": "mydomain01.com.",
        "Type": "A",
        "AliasTarget": {
          "HostedZoneId": "Z2FDTNDATAQYW2",
          "DNSName": "abcdefghij1234.cloudfront.net",
          "EvaluateTargetHealth": false
        }
      }
    }
  ]
}

shell command

aws route53 change-resource-record-sets \
    --hosted-zone-id Z123456789EXAMPLE0SKX \
    --change-batch "file://$(pwd)/change-batch.apex.update.json"

response similar as when creating records above

test apex domain record

test http

http http://mydomain01.com
HTTP/1.1 301 Moved Permanently
Connection: keep-alive
Content-Length: 183
Content-Type: text/html
Date: Mon, 02 Aug 2021 19:08:27 GMT
Location: https://mydomain01.com/
Server: CloudFront
Via: 1.1 2408979685aa1bdb752824d292e63bf7.cloudfront.net (CloudFront)
X-Amz-Cf-Id: Ww60Ol_0fdR8SsgcHeRYUd_de1rVejX6w_wuK80aR21e3IHstB-irA==
X-Amz-Cf-Pop: HAM50-C2
X-Cache: Redirect from cloudfront

<title>301 Moved Permanently</title>

301 Moved Permanently

CloudFront

the response now comes from CloudFront and no longer from S3, so the updated DNS record seems to work :-)
test http with a path

http http://mydomain01.com/some/path
 ... similar output as above ...

--> looks good

test https

http https://mydomain01.com
HTTP/1.1 403 Forbidden
Connection: keep-alive
Content-Type: application/xml
Date: Mon, 02 Aug 2021 18:53:51 GMT
Server: AmazonS3
Transfer-Encoding: chunked
Via: 1.1 ea89c67081222c8c680e7a37ad75f4f0.cloudfront.net (CloudFront)
X-Amz-Cf-Id: 5prv5_g5zXOX3aRBp2Gq64JJPuwC2o5dHIp9RCAHm6Ls8hK6EFghXw==
X-Amz-Cf-Pop: HAM50-C2
X-Cache: Error from cloudfront
x-amz-bucket-region: us-east-1

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  AccessDenied
  <Message>Access Denied</Message>
  <RequestId>T78ASF3FA9QGV4T5</RequestId>
  <HostId>xaEgwEtbeesL4XfxMdxVoPAt9Lpb1ZDM9Fs5W4htBbcWNbV9sMUTjVAPIuWwAQ3Xh1yRhh4b4Ts=</HostId>
</Error>

(as before, xml formatted for readability)

NOTE: This response comes from AmazonS3, not from CloudFront as the previous one. The S3 bucket has no access restrictions whatsoever in place - so how can there be an access denied ?!?
double-check bucket permissions

AWS S3 get-bucket-policy docs

aws s3api get-bucket-policy --bucket mydomain01.com

An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist

That matches the empty Bucket policy field in the AWS S3 Console - but is it really ok that there is no bucket policy at all ?!?
Now that look back at test distribution above, I see that the response to accessing abcdefghij1234.cloudfront.net directly also come from S3, not from CloudFront, so the problem seems to be pretty clear:
My questions #2

Why does the S3 bucket deny access ?
Is it normal for an S3 bucket to have no access policy at all ? Don't usually have "public" buckets a policy that explicitly allows access to anyone ?
Similar to one S3 bucket per apex / sub domain, do I also need one CloudFront distribution per apex / sub domain ?
If so, I guess adding *.mydomain01.com as alternate domain to the certificate (and the distribution) does not really make any sense, does it ?!? I'd also need one certificate per distribution, dedicated to one domain, correct ?
Comment: Your bucket needs to be either public or you need to use OAI user for CF access.
Answer: You are on the right track in general. Just one comment: Route53 can be omitted if your domain uses some other DNS service provider already.

Q: Does the "bucket name == domain name" requirement apply even if I use CloudFront ?

No, if you use CloudFront. The CNAME is configured separately in CloudFront.

Q: Do I need to create one bucket each for the apex domain and every subdomain ?

No, you don't need one bucket per domain/subdomain.

Why does the S3 bucket deny access ?

You should use your s3-website-us-east-1.amazonaws.com domain as the CF origin.

Is it normal for an S3 bucket to have no access policy at all ? Don't usually have "public" buckets a policy that explicitly allows access to anyone ?

If you use the bucket just to redirect traffic, no access policy should be fine.

Similar to one S3 bucket per apex / sub domain, do I also need one CloudFront distribution per apex / sub domain ?

Yes, you need one CloudFront distribution per domain/subdomain because one distribution can attach at most one ACM certificate.

If so, I guess adding *.mydomain01.com as alternate domain to the certificate (and the distribution) does not really make any sense, does it ?!? I'd also need one certificate per distribution, dedicated to one domain, correct ?

Adding the wildcard domain does make sense since the CF distribution needs to handle subdomain traffic as well.
If you have any further questions, please join the AWS Chat and @ me in the chat.
Comment: Note, AWS Console UI auto recommends using `example.com.s3.us-east-1.amazonaws.com` format instead of the custom `example.com.s3-website-us-east-1.amazonaws.com` as the article says to use as well:

https://aws.amazon.com/premiumsupport/knowledge-center/route-53-redirect-to-another-domain/

> Make a note of the bucket's endpoint (example.com.s3-website-us-east-1.amazonaws.com). You'll use this information to configure the origin domain name for CloudFront in the following task.
Comment: @Tony-Caffe Good call!


On Stackoverflow why do many people post their answers as comments?

Question: I noticed many people with high rating tend to post their answers as comments. Doesn't this defeat the purpose of the site (by not allowing an answer to be accepted)?
Comment: It also allows other people with lower ratings to "snag" the answer and get the points for it - high rankers don't need more points since they've already got plenty
Comment: @phirschybar my main reason for posting comments is when 1) I'm not sure whether it's the correct answer (which I will point out clearly, though) and/or 2) I don't have the time, or I'm too lazy, to do the research to back it up.
Comment: Because I'm not going to take the time for a full answer, but want to get the main idea out there.
Comment: Because we don't need the reputation. Oh wait I do! my preciouss...
Comment: @Marc B - yeah I thought it was generosity thing but most people with low ratings are not likely to copy somebody else's answer.
Comment: I understand the rationale behind stepping back so a user with a lower rating can formally answer however it is equally annoying to users with lower ratings who are hunting for questions to answer (to boost their rating, perhaps) and look for "unanswered" questions only to find the answers are all in the comments.
Comment: @Marc I'd say it's rare behavior (though it does happen). Such misuse of other person's answer becomes visible for everyone who reads the whole topic, and such answer can be downvoted, thus giving the effect opposite to desired.
Comment: @phirschybar If an answerer's in a hurry and the choice is to post a quick comment that will  put the asker on the right track, or nothing at all, it's usually better to post the comment. But I can understand the frustration
Comment: +1 @John Saunders... I'll take time to write a detailed answer to a question as long as I feel like it's a topic that's hard to find a good, complete answer for. But if I'd just be doing someone else's googling, but maybe I can help them figure out how or where to look for their answer, a comment with a basic gist or a pointer seems sufficient.
Comment: I do not seem to have the ability to award an answer for this question even though I posed it. I think it was migrated without retaining the proper owner info.
Answer: If I have an answer, I'll answer. If the question doesn't contain enough information to answer conclusively, but I have a "try this" suggestion, I'll probably comment.
This seems to be the case more often than not - comments are more like Q&A with the OP, and the question may end up being answered that way. But clearly written questions usually get answers, not comments.
Comment: [Here](http://unix.stackexchange.com/questions/196715/how-to-pad-a-file-to-a-desired-size?noredirect=1#comment330044_196715) is an example of what I think OP means.  User with 10K+ rep drops the correct answer to a clear question in a comment.
Comment: Exactly.  If I'm not quite sure that I have the right answer, but I can suggest something or ask a question to point them in the right direction, I'll comment rather than answering.  Sometimes this solves the problem and sometimes it doesn't.
Answer: Many times answers in comments are not complete answers but more of the form:  "Have you tried X?".   Which is really more of a comment than an exact answer.  From my perspective this is more common for vague questions, where you might have several "Have you tried X" type comments and don't want to clutter up the question with several answers that no longer apply.
Answer: Sometimes if I don't have time to answer properly but have the answer, I'll give the answer (or at list a pointer) as a comment. Ever since I went over 10k rep, I don't care about points that much.
The other case where I would answer with a comment is when I'm not totally sure about my answer, either because the question is unclear or because my knowledge is a bit off on the subject.
Answer: (posted this ANSWER as a comment accidentally!)
Because the other users don't need the reputation.
But I do!
♥ ♥ my preciouss reputation
(Please select as answer and upvote with all your accounts)
{/sarcasm}
Comment: +1 for "my precious" and the sarcasm
Answer: Replies by posters with higher ratings get more attention and even more rating, thus discriminating (to certain extent) perfect posts of people with low score rate. Next, perfectly valid (according to rules) posts are sometimes downvoted by certain groups of people (such as open-source evangelists) who think they are above the rules. To avoid this, it's better to answer in a comment.
Comment: I tend to give upvotes and accept answers from lower-rated people more often (all else being equal). That's just a basic charitable principle, you know, Bill Gates doesn't need my money, so I give it to Wikipedia instead.
Comment: Not sure I understand your point about high ratings getting more ratings, nor do I completely understand why it is better to answer in a comment?
Comment: @jzd . The answer being given with somebody with rating of 10K will (in average) get more upvotes, than the same answer given by someone with rating of 100. This is empirical observation of how SO rating stuff works.
Answer: One explanation. Some of us, upon seeing a question of questionable validity, feel a dilemma. We might know something useful. But we don't want to encourage poor questions by answering them. And often, with low-quality questions, it's quite unclear what's really being asked, and so any answer has a good chance of being (ahem) pointless. There's also a certain hypocrisy about answering and also voting to close. In these cases, a comment is a way of offering some possible assistance to the OP.
Answer: Jon Skeet (no. 1 SO poster) said that points aren't important anymore for him; badges are. Also, it's fair play, since it allows folks with lower amount of points to attain more and it helps keep everything in balance.
Comment: If Jon Skeet jumped off of a bridge... _(...he would not be injured, as a result of some truly marvelous programmatic wizardry. This comment is too small to contain it.)_
Comment: `try { jump off bridge } catch { jon skeet } continue { as if nothing happened }`