How to check if an admin (sub)menu already exists?

Question: The title says it all. I'm using WP 3.0.4
Answer: Something like this should work. $handle should be the menu's slug; set $sub to true to search submenus (defaults to top level menus):
function find_my_menu_item( $handle, $sub = false; ){
  if( !is_admin() || (defined('DOING_AJAX') && DOING_AJAX) )
    return false;
  global $menu, $submenu;
  $check_menu = $sub ? $submenu : $menu;
  if( empty( $check_menu ) )
    return false;
  foreach( $check_menu as $k => $item ){
    if( $sub ){
      foreach( $item as $sm ){
        if($handle == $sm[2])
          return true;
      }
    } else {
      if( $handle == $item[2] )
        return true;
    }
  }
  return false;
}

One last quick note: this should not be used before the menu is set. 'admin_init' is a safe bet for the earliest time to use this. I also added some code to leave gracefully if the menus aren't set.
Comment: That looks great. But is there a way to do this from `'admin_menu'`? What I want to do is have one options page for 3 separate plugins, so in each plugin I need to create this options page if it wasn't created yet by one of the other 2.
Answer: Here is a simpler way of doing it:
global $submenu;

$main_menu = 'my_menu_slug';

if (
    isset( $submenu[ $main_menu ] )
    && in_array( 'my_submenu_slug', wp_list_pluck( $submenu[ $main_menu ], 2 ) )
) {
    // Submenu exists.
} else {
    // Submenu doesn't exist.
}

Answer: Sweet! and here I thought I was the only crazy person who wanted to do something like this!
Well, based on what I think you're wanting (something similar to what I posted here), then here's the solution I came up with (taking advantage of the function given above)
Originally I thought I was going to have to check to see which of my plugins were active each time a new plugin was activated.
I had figured I'd use is_plugin_active() to see which menu items to display beneath the parent "main" menu item... However, this turned out to be harder than I thought because that function isn't activated yet when the plugin accesses the file that all this would be in.
Thankfully, it wound up being so simple it was staring me in the face the whole time... Each plugin that's activated can simply add that plugin's submenu to the parent menu without having to worry about checking for the existence of other active plugins...
I added this to each of "My" plugins (aka, the plugins my company released)
if(!function_exists('find_my_menu_item')) {
  function find_my_menu_item($handle, $sub = false) {
    if(!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
      return false;
    }
    global $menu, $submenu;
    $check_menu = $sub ? $submenu : $menu;
    if(empty($check_menu)) {
      return false;
    }
    foreach($check_menu as $k => $item) {
      if($sub) {
        foreach($item as $sm) {
          if($handle == $sm[2]) {
            return true;
          }
        }
      }
      else {
        if($handle == $item[2]) {
          return true;
        }
      }
    }
    return false;
  }
}

Then I added this little snippet to each of the plugins:
if(!function_exists('wpg_add_parent_page')) {
  function wpg_add_parent_page() {
    if(!find_my_menu_item('main_item_slug')) {
      add_menu_page('Main Item Page Title','Main Item Menu Title', 'activate_plugins', 'main_item_slug', 'main_item_function', THISPLUGIN_PATH.'images/menu-icon.png');
    }
    if(!function_exists('remove_submenu_page')) {
      unset($GLOBALS['submenu']['main_item_slug'][0]);
    }
    else {
      remove_submenu_page('main_item_slug','main_item_slug');
    }
  }
  add_action('admin_menu', 'wpg_add_parent_page');
}
if(!function_exists('wpg_add_thisplugin_page')) {
  function wpg_add_thisplugin_settings_page() {
    add_submenu_page('main_item_slug', 'ThisPlugin Settings', 'ThisPlugin Menu Item', 'activate_plugins', 'this_plugin_slug', 'wpg_thisplugin_function');
  }
  add_action('admin_menu', 'wpg_add_thisplugin_page');
}

Just modify that for each of the plugins you wish to add under one menu item, and insert the plugin appropriate modified version in each of the relevant plugins.
Answer: Here's a nice terse way of doing it without all those conditionals and foreach loops.
function submenuExists($submenuTitle)
{

    global $submenu;

    return count(array_filter($submenu['plugins.php'],
        function($submenuPage) use ($submenuTitle) {
            return $submenuPage[0] == submenuTitle;
        }
    )) > 0;
}


Calculating 2018 AMT from taxable income

Question: US Alternative Minimum Tax: What would be the TMT on $500,000 of taxable income for "married filed jointly" ?
Here is what I tried:

This is still below the exemption phase-out threshold, so we can take the full exemption of $109,400 and we are left with $390600.
The first $191,500 of this are taxed with 26% -> $49,790
The remaining $199,100 are taxed at 28% -> $55,748
Total tax would be $105,538

Is this correct? What exactly is the AMTI? The $500,000 taxable income or the $390,600 that's left after the deduction? Is the tax bracket (26% vs 28%) determined by the 500k or 390k ?
I entered these number into https://www.olt.com/main/home/taxestimator.asp and it looked like the TMT came out to be significantly higher: $136,244. Is my calculation wrong?
I checked the IRS website.  The only Form 6251 that I could find is from 2017 and it doesn't have the new rules in them.
Answer: Your calculations look right to me.
AMTI is income after AMT adjustments, before subtracting the AMT exemption. ($500,000 in your example.)
The 26% AMT bracket is the first $191,500 above the AMT exemption amount, just as you calculated it.


What type of study is this?

Question: Suppose someone is trying to estimate the diagnostic prevalence of ADHD in a cohort of individuals born in 1985. What type of study is this? This is not a prospective cohort study because we are not comparing two groups (i.e an exposed and unexposed group). All individuals in this study are exposed (born in 1985).
Answer: It sounds like a cross-sectional study: it's a descriptive study, only looking at one specific time point.
That said, it could still be part of a prospective cohort study if the individuals in the 1985 birth cohort have been followed up over time. In that case, it would be cross-sectional study nested in a cohort study.
Answer: From the information you give, it could be several different study types. If the prevalence of ADHD is collected at a single time point, then this is a cross-sectional study, restricted to the population of individuals born in 1985. If the prevalence is collected over time, then this could be considered a cohort study. If the diagnoses were recorded for research purposes over time starting some time in the past, then this could be a prospective cohort. If you are now going back to medical records to ascertain diagnoses made in the past, then this is a retrospective cohort study.
You don't need to have exposed and unexposed groups to do a cohort study, but you do need to have a follow-up time component. Obviously to look at the effect of exposure on outcome you do need exposed and unexposed. As described above, this is a closed cohort (no one else can ever be born in 1985). You could compare the prevalence in this cohort to that in a cohort of, say, individuals born in 1995, or to the whole population currently. Or you could look within the birth cohort to assess the effects of other exposures, say, birth weight, on ADHD diagnosis.
Comment: Thanks. Also what is the definition of source population? For example, in this example, would everyone born in 1985 be the source population?
Comment: It depends on how you think ADHD will varies over time/place and on what you are trying to study. It could be everyone born in 1985, or everyone born in 1985 in a specific place where you selected the cohort. Or it could be everyone born between 1980-90, if you think that 1985 is representative of an entire decade in terms of risk of ADHD diagnosis. The source population is that population about which you are trying to make some inference. The cohort is your sample. Whether or not the sample actually reflects the experience of your source population determines the validity of your conclusions.
Comment: So it is possible for the population of the entire world to be a source population? I guess the cohort is a sample AND the study population? Or is the study population the "final" sample after removing other people due to missing data, etc.?
Comment: The entire world could theoretically be the source population but your study would need to have in some way sampled a group of individuals that truly represented the entire world. This is highly unlikely in practice. The term 'study population' is not well-defined - I would stick with 'study sample' and 'source population'. 'Study population' is something of a contradiction unless you could enroll every single member of your population into your study. The 'study sample' can refer to all people recruited, or the final set of individuals analyzed. The former is preferable, to me.

What type of study is this?


Cumulative incidence under competing risks: cannot infer event free survival?

Question: Suppose one had performed a competing risk analysis and the 10 year cumulative incidence for the event of interest is 60%. Am I correct in thinking that we CANNOT conclude that the event-free survival is 40% since, in competing risk situations, the survival and cumulative incidence are no longer inversely related? If that's right, am I right that we can't really say anything about event-free survival, but rather we should just discuss the cumulative incidence estimates?
Answer: That is correct.  For concreteness suppose that you are interested in the risk of cancer and there is a competing risk due to fatal heart attack.  Event-free survival probability at time $t$ is the probability of not having cancer or a fatal heart attack before time $t$.  It can be estimated by computing the Kaplan-Meier estimate for the time until the first of the two events.
On the other hand the cumulative incidence of cancer when fatal heart attack is taken as a competing event is the probability of developing cancer that preceeds heart attack death.  Since death will mask some cancer cases, the cumulative incidence curve does not have to reach 1.0 as $t \rightarrow \infty$.
It is often more natural to model multiple event types using multistate transition models.  Therneau, Crowson, and Atkinson have a wonderful article about competing risk and multistate models here.  For example you could model the probability of going from a well state to a cancer state or to a fatal heart attack state, the probability of going from a cancer state to a fatal heart attack state, ...  i.e., any transition probabilities you want as a function of time.  From these you can come mean times in various states.
The article referenced above also explains why the commonly used Fine & Gray competing risk cumulative incidence model makes assumptions that are unlikely to hold.
Comment: Thanks - fixing this now.  Note that thanks is expressed by upvoting anwers, comments, questions.
Comment: Thank you! In your first paragraph you seem to suggest event free survival is 1-KM estimate. Isn't it that the event free survival is just the KM estimate (not 1-KM, which gives cumulative incidence if there is just one type of event)?


12.10 x64 - RTL8188CE - Intermittent/Slow Internet Connection

Question: I have to reset my internet connection often to get it to work.  When it does work, it's definitely slower than when I'm on my Windows installation.  My computer uses an RTL8188CE wireless card from Realtek.  I'm running the 64-bit version of Ubuntu 12.10.  Power management is not on.  I've read on other sites that some people fixed the issue pertaining to this wireless card by downloading and installing the drivers from the Realtek site, but it seems as if that only helped people with 32-bit installations.  Anyone have any luck with this specific wireless card?
Comment: Welcome to rtl8188ce-madness. See this answer for the best solution with 12.04: http://askubuntu.com/a/178098/24489 And no, it is not completely stable (12.04, 64bit).Haven't tried it with 12.10 yet.
Comment: Thanks! How well has it worked for you to mitigate the issues? And is there a PPA or anything I could hook into apt-get, or would I just have to recompile at every stable release?  Are you using 3.5 or 3.6?
Comment: I was using one of the linux-backports-modules-cw packages - so no recompile necessary. I upgraded the machine to 12.10 and did not look into this for now.
Answer: Putting this into /etc/modprobe.d/rtl8192.conf
options rtl8192ce ips=0 fwlps=0 debug=2

then restart, fixed it for me.
Comment: I had a problem with lubuntu 12.10 using the RealTek RTL818CE, where network manager would say it was connected, but I couldn't actually use the wireless until I disconnected and reconnected (same after resuming from sleep/hibernation). Installing  linux-backports-modules-cw-`etc` didn't help, but the solution offered in this answer did (so far at least). I did leave off the debug=2 option.
Comment: I may have spoken too soon. This did not solve all my issues
Comment: I have this problem in Ubuntu 13 and there is no /etc/modprobe.d/rtl8192.conf file.
Answer: I had very poor speed with the RTL8188CE until i disabled hardware crypto:
sudo ifconfig wlan0 down && sudo rmmod -f rtl8192ce && sudo modprobe rtl8192ce swenc=1 && sudo ifconfig wlan0 up

Note: 'swenc=1' means software encoding (default is to use hardware-based).
This sped things up significantly (wget I had running at the time went from 5.83KB/s to 812KB/s upon reconnect after reloading module with swenc=1).
If it works for you, add swenc=1 to the relevant module conf file as an option (for persistence after reboot/module-reload).
Comment: Note: If your wifi doesn't come back up, you may need to restart wpa_supplicant
Answer: The drivers you mention from the RealTek site are no longer maintained by them, and they haven't compiled properly on Linux since kernel 3.2.
In light of this and my cursing to have the RTL8188CE like yourself, I forked the driver and I've been maintaining it on Git Hub.  It still isn't perfect but most people (myself included) have seen improved performance.  I also doctored the driver so that you can crank up your Tx power to 33 dBm if you want, instead of the 20 dBm that the stock driver allows (I can't promise that over-powering won't break you card, but I run mine at 30 quite often with no problems)
You can find the full installation instructions and source code at:  https://github.com/FreedomBen/rtl8188ce-linux-driver


Creating a software manual. Any supporting packages?

Question: So I am about to start writing a manual for a piece of software. Are there any packages available to depict radio buttons, check boxes, tabs, menus etc.?
Answer: Though I don't know any packages that include symbols of radio buttons, check boxes, etc. I know some good GUI mockup software. I'd recommend using standard figures from mockup software, like the Pencil Project. It's licensed under GPLv2, and I think figures from mockup software are pretty straightforward. You could even use those graphics as inline images using a simple raisebox ensuring correct vertical alignment like this:
\raisebox{-0.5mm}{\includegraphics{button.png}}

For code snippets you could use the listings package, and for key-press sequences the keystroke package.
Comment: The Pencil Project looks interesting! The code can be simplified with `\usepackage[export]{adjustbox}`. Then just `\includegraphics[raise=-0.5mm]{button.png}`.
Answer: During a long time, I used dpic language to generate primitive graphics. Xfig is working on Linux distributions to produce graphics with a GUI and is able to generate graphics to the PIC format, a format similar to dpic or gpic.
Years after years, I'm using more and more tikz/pgf but it needs more time to compile with some libraries. PSTriks is also a very good tool to generate graphics.
Symbols graphics or simple graphics placed precisely by entering their positions allow you to reach great quality figures. Don't forget that some documentations need to be printed in black and white, or just three colors. For graphics with full colors that stay also useful to adjust some colors with just few lines of code in LaTeX. With just few lines of graphics command in your (La)TeX code, all the figures of your documentation can change their style of drawing or their colors that why png or jpg are not all the time the best choice for illustrations but they are useful to generate quickly a result.


How to upgrade ngx_pagespeed in production server?

Question: I have a LEMP set-up in CentOS 7. I am planning to install the ngx_pagespeed module to it. When I was reading through the docs I came to realise that unlike Apache, I cannot install this module dynamically with Nginx. So from my understanding, I now need to uninstall the current Nginx, compile Nginx with ngx_pagespeed and re-install this compiled version. This comes to my next question: What happens if I have to upgrade Nginx or ngx_pagespeed module in the future and I already have a working production LEMP server with ngx_pagespeed? Do I then need to do the same i.e uninstall Nginx + ngx_pagespeed first, compile the latest version of the module & nginx and reinstall the newer version? It seems to be a big hassle. Isint there a better or simpler way to do this?
Answer: Yes you will have to rebuild nginx with pagespeed but once you got your RPM spec it's not that long. You can find one here.
You can upgrade between two nginx versions without any downtime with USR2 and WINCH signals so master processes using the new binary are spawn while you gracefully shutdown the old ones.
Comment: Thanks heaps for your answer @Xavier. I wasnt aware of Nginx + pagespeed RPM as well as USR2 and WINCH until you mentioned. I am a newbie to server adm and your pointers have helped a lot. I read the tutorial in rosehosting and I thought I need to do all those steps each time I upgrade. Now your reply has put me to ease a bit since it does make it simple enough. Thanks heaps... :)


How to eliminate duplicate records in a report?

Question: I am using Person Accounts and have 2 custom objects: Ownership and Property.
The Ownership is a junction object and has 2 lookups: Account and Property.
I'd like to run a report with a filter, that gives me unique Accounts where House.Type = 'Maisonette'.
However when I run a report, I may get multiple Accounts because someone owns more than one Property which is a Maisonette.
Any help please?
Comment: Do you just want counts or to eliminate the duplicates all together?
Comment: Is it possible to do both? (in seperate reports at least?)
Comment: You can't remove the duplicates in the report; the report builder doesn't do distinct so I'd recommend Excel. For counting, see http://salesforce.stackexchange.com/questions/8476/how-do-get-the-count-of-distinct-or-unique-parent-records-in-reports/8477
Answer: If I understand correctly, in SOQL you'd express your requirement more or less like that?
<code>SELECT Id, Name
FROM Account
WHERE Id IN (SELECT Account__c FROM Ownership__c WHERE Property__r.Type__c = 'Maisonette')
</code>
It's perfectly doable with a cross filter.
Let's say I want to see Accounts that have at least 1 Contact with title = Director:

Here's how it looks on the "run report" page (note the icon)
Answer: You can't do this in the report builder; it is simply not that powerful. It would be possible query this data using a sub-query in Apex Code (e.g. if you wanted to use Visualforce), by post-processing the data in Excel, or by using a third-party reporting tool that supports this functionality; a list of the latter can be found on the AppExchange.
Comment: I respectfully disagree :)
Comment: @eyescream And I learnt something new. That'll teach me not to read the release notes each release.
Answer: We have been using Excel and Access to handle this. They don't allow me to do the cool programming stuff here. :'(


category filter doesn't work in WPML

Question: I translate the categories to another language,  but in the main page, the two language categories are all displayed. How can I filter another language?
My WPML version is 2.4.1.
I found all the categories are displayed on my theme, is there any way I can get the correspondence between the different language categories, so I can filter it.
Answer: First you should upgrade WPML to the latest version, which is 2.4.3 at time of writing.
To properly translate categories you should start by editing the category of the default language. Once you are in that screen (wp-admin/edit-tags.php?action=edit&taxonomy=category&tag_ID=x&post_type=post where x is the category ID), you will see at the bottom a metabox titled Language. This will show the current language of the category and you will be able to add a translation of it by clicking on the word "Add" under the name of the other language(s) of your site.
Comment: Hi Piet, thank you for reply. I tried but it doesn't work.I think I need change the code of my theme, because it query all the category and display them. Is there any way I can know which language version the visitors are using? So I can filter the category in the code.
Comment: Hi @rocwing very difficult (read: impossible) to say anything that makes sense without being able to see your site and settings.
Answer: Have you created categories for both languages ? eg. if you have blog category in english then you have to create same as for other language. same for posts.
If yes, then please check if language code filters is applied to archive page or not.
if not then you have to make filter for language code.
Thanks,
Aezaz

category filter doesn't work in WPML


Export Enterprise Search from SP2010Server to SP2010Server

Question: Is there a way to export Enterprise Search settings(Scope, managed properties, etc...) from one SP2010 server to another? For example from a Development server to a Production Server.
Answer: I would recommend using PowerShell, both for exporting and importing Your settings. You would need to find the relevant bits and Peaces to Ensure you get everything from search schema, content Sources, crawl rules, etc included.
If you are starting from scratch, consider configuring search using PowerShell and environment specific settings for host names, urls, accounts, etc.
Comment: This sounds like good approach. I wonder if there is a finished script I could use instead of coding something from scratch.


Is there any stable version of Skype for Linux?

Question: I have Skype 188.8.131.52 Beta, but as I see it's not stable, it has quite a lot of bugs. I'm working on remote and I need stable Skype, is there any solution?
Comment: Best thing to do: don't use it and use something else. discord works too and is a lot better.
Comment: @Rinzwind but I need to comnunicate with other skype users
Comment: is it possible to call to skype users from discord?
Comment: I too am very dissatisfied with Skype after it was bought by Microsoft. From alternatives, jitsi meet looks promising to me - it only requires a web browser and works on Ubuntu/Firefox.
Answer: As of September 2017, there is only Beta release of Skype for Linux 64 bit
The point to be noted is that apart from the Bright screen promise on the Skype website they have made zero efforts to release a stable version. It has been in Beta for ages.
============= Update ================
After prolonged searches and I have somehow landed on this skype.com page where you can get the 32 Bit official Skype (Although V 4.3 it works great)
skype 32 bit
I have tried this and works great, even the voice calls ...!!

Offical 64-bit Skype can be found here on skype.com
I guess they are updating the site now...
Comment: Amazing! I thought they had disabled all 4.3 logins! Go Microsoft! Thanks for the info.
Comment: Where did you get this information? Since version 4.3, Skype beta has been available, but since approx version 5.3 it's been called stable (although the web site incorrectly still calls it beta). Now they're recently released a new "preview" version of skype, but you can't get that from the normal download page.
Comment: @heynnema updated the answer while I actually meant beta, thanks for the pointers.
Comment: Your answer is still technically incorrect. Nothing has changed in Sept 2017... other than the new "preview" version (see my answer). Although the web site incorrectly calls it beta, they've renamed it and called it "stable". 4.3 no longer works as you can't sign in.
Comment: @heynnema attached screenshot of skype 4.3 working on my LXLE 32 bit linux machine
Answer: Microsoft owns Skype now, and they say you must have the latest version for it to work properly, as of July 2017, although some people claim older versions are still working.
They offer the .deb for Debian based Linux distros, such as Ubuntu, and the .rpm version for Red Hat based distros.
You can get the latest stable packaes here:
Official Download Page for "Skype for Linux"
Comment: @karel they've renamed the **beta** to **stable**, but forgotten to update the web page... just like they've forgotten to release ANY version after 4.3 that's worth using. Sigh.
Answer: Unfortunately since Microsoft has taken over Skype, and dumped the 4.3 version which worked fine, nothing has been the same. As long as you're using the latest download, which I believe that you are, you'll have to live with the bugs.
They do have new "preview" version of Skype... which I'm sure is even less stable... see https://go.skype.com/skypeforlinux-64-preview.deb


What can we infer about a creatures that uses some kind of oil instead of water for our cellular fluid?

Question: Is it feasible to envision a biology where oil is the main "solvent" (not sure if this word is chemically accurate). Whereas humans are 80% water, these guys would be 80% "canola oil" or something similar. Would this work? I know that humans and all animals produce small amounts of oil within their bodies already, and some plants are quite efficient at doing so. I don't know if they might need to supplement their oil by direct intake, analogous to our own need to consume water, or if they are self sustaining in that regard, or if they can somehow convert water into oil? (is that what plants do?)
Answer: Not much!
There are a lot of things that would have to change, and lots of ways to handle the problems that come up in making those changes, and the exact set of chosen solutions can make a big difference.
They probably don't breathe oxygen, being either purely fermentative or hydrogen-breathing instead, but there are ways around that.
Is the intracellular fluid the same as the extracellular fluid? Terrestrial cells can keep around oil or fat filled vesicles; do your creatures keep around water-filled (or other polar-solvent-filled) vesicles? And if so, do they use them as solvents for chemistry?
If all chemistry is done in the non-polar organic solvent, then you have to deal with the fact that said solvent is aprotic. That's nice in some ways, because it means that a lot of stuff is far more stable than it is in water, which attacks a lot of biomolecules by hydrolysis and disrupts internal hydrogen bonds, which we water-based creatures have to expend energy to deal with. So, your creatures will have a lower base metabolic load than we do. But, on the other hand, a lot of energy chemistry based on shuttling protons around won't work--unless you have specialized vesicles of protic solvents just for that purpose. Thus, your creatures will probably have to rely on single-molecule electron delocalization and conduction to move energy around, rather than solvated charge gradients.
Additionally, while there is a lot of biochemistry that can be done in non-polar organic solvents, polarity turns out to be really important to the function of some basic structures of our biochemistry. E.g., the repeating charges along DNA backbones don't just make it soluble in water, but the self-repulsion between paired strands helps maintain the doubled-up strand structure, rather than allowing it to tangle up and self-interact like RNA does. Meanwhile, the repeating dipoles in polypeptides are critical in getting them to fold up and self-interact. There is a DNA analog (Peptide Nucleic Acid, or PNA) which is soluble in oil and lacks the phosphate charges (and binds much more tightly as a result)... so maybe your creatures could use that, or something similar, but it's not actually known how well that would work on its own (artificial PNA is used in biotechnology to selectively bind to complementary DNA strands; as far as I know, no one has tried to get it to replicate independently in organic solvent).
Proteins frequently have non-polar sites that are shielded from water, so inverse proteins that have non-polar sites exposed to allow them to be solvated by oil with shielded polar sites for specific reactions might work, but they might just use something completely different. (Some vaguely-specific form of complex polylipid is a popular old proposal for aliens using non-polar solvents, but nobody knows exactly if or how such things would work.)
Cell membranes could still work in basically the same way, just inside-out. But if there is a mixed-solvent system, cells may employ simple single-layer micelles instead.
Plants produce oils, ultimately, from water and carbon dioxide, just like they produce sugars from water and carbon dioxide. The sort of world that would be conducive to the evolution of oil-based life, however, is likely to make that unnecessary. Depending on what the homeworld is like and why your creatures evolved this way, they might consume oil like we consume water, or they might manufacture it (e.g., from some combination of water, methane, and CO2).
Comment: Thanks Logan - great answer!
Comment: It's not recommended to mark answers as correct soon after the question is posted because it can discourage more people from answering and from providing a possibly better answer, or just more useful information.
Comment: The answer was very thorough, well thought out, and quick. So yeah
Comment: Well there are a lot of substances we call oil, hydrocarbons which are in fossil fuels methane, ethane, propane, butane, hexane, octane we have seen lakes of methane-ethane (normally a gas on Earth) on Titan where it is cold.  Scientists say that cellular life on Titan, instead of their cells walls being made of phospholipids they were made of azones.  Life under Enceladus and Titan would use Ammonia mixed with Water as anti-freeze, some of the microscopic organic life may have been blown onto Cassini when Cassini flew into a geyser.
Answer: Given that some of the fundamental features of cellular life would no-longer function correctly we can't directly infer much about oil based life based just on that fact alone. We'd first need to make substantial wild guesses about how oil based life functions before we could infer anything else.
There are lots of biological functions that leverage the difference between polar and non-polar chemicals. One of the more fundamental of these is the lipid bilayer. If instead of being suspended in an polar fluid, like water, a lipid bilayer was suspended in a non-polar fluid like canola oil they would no longer function correctly.


Problem with structuremap creating linqtosql datacontext in ASP.NET from background process

Question: I have an ASP.NET MVC application with LinqToSql. The datalayer contains methods for performing crud operations on the database. Each method can request a datacontext from structuremap, which is configured to return the same datacontext per http request (InstanceScope.Hybrid), so I can call several methods on the datalayer, and in the end, submitchanges is called, so all crud operations are contained in one transaction. So far, this is working fine.
I also have workflow activities (using WF4), which of course run in a separate thread, the workflow thread.Some activities also perform crud operations using the same datalayer. The problem is, that structuremap (sometimes) returns the same datacontext for different activities, probably because these activities run on the same workflow thread. This is causing problems, because the datacontext may cache instances of entities, which have been changed between the execution two activities (because data was changed from the web application).
Eg.
Activity1

calls method A on datalayer => method A requests datacontext from structuremap => datacontext X1 is returned
calls method B on datalayer => method B requests datacontext from structuremap =>
datacontext X1 is returned
calls submitchanges, A and B are committed

Web application

calls method B on datalayer=> method B requests datacontext from structuremap => datacontext X2 is returned
calls submitchanges, B is commited

Activity 2

calls method B on datalayer => method B request datacontext from structuremap => datacontext X1 is returned (=> here I would need another datacontext).

Datacontext X1 is caching entity instances, web application has changed entity in between, so I get changeconflict exception
From the webapplication, structuremap instancescope hybrid is ok, because each web request will give me another datacontext instance, from WF this is not ok... I can not configure structuremap in WF to return instance per request, because that would give me different datacontexts in method A and method B... so A and B would not be contained in one transaction.
Maybe if I could tell structuremap to dispose the datacontext, whenever submitchanges is called, this would solve my problem, but I don't know if or how this can be done with structuremap.
Answer: I believe what you want EjectAllInstances method; that will get rid of the cached instance of the data context, so the next time you request one from StructureMap it will be created fresh.
Comment: Isn't this dangerous to do? There may be other background processes having another instance of datacontext, they will get ejected too...
Comment: Yeah, it will call dispose, so that won't work.  I think what you really need is a custom scope that hooks into WF somehow, so SM can be aware of when to dispose the cached instance.


Ayushya Suktam is said to of Yajur Veda. Can someone provide the Vedic Shakha, the Kanda-Suktha number and link to its translation if possible?

Question: Many Vedic Suktas have popular names, but the Vedic literature has Shakha-Kanda-Suktam Number with Devata, Metre, Group, Rishi and more. Some suktas are a collection of hymns/verses from various suktas. In this way, Ayushya Suktam is said to of Yajur Veda. Can someone provide the Vedic Shakha, the Kanda-Suktha number and link to its translation if possible?
Answer: The mantras are not found in the extant Krishna Yajurveda (Taittiriya at least). Reference to the mantras and the homa procedure are found in the Grihya Sutras. In particular the Agniveshya Grihya Sutra 2.5.3 describes the process and the mantras.

Also baudhayana sUtra बोधायनगृह्यसूत्रे तृतीयप्रश्ने सप्तमोऽध्याये


Can non-PhDs or non-Masters be on an accredited college's faculty?

Question: Do U.S. college accreditation agencies forbid teachers with only a bachelor's degree to be on the faculty of an accredited U.S. college?
Comment: The fact that the statistic accreditation agencies use is "percentage of faculty with terminal degree" does mean that Ph.D.s are not the only qualification. Without a terminal degree in the US one is _usually_ limited to non tenure line positions. Again world changing accomplishments can cause any of these rules to be overridden.
Comment: https://academia.stackexchange.com/questions/17707/can-non-phds-or-non-masters-be-on-an-accredited-colleges-faculty/17737#17737
Answer: It depends on what you mean.  If you are asking a theoretical question about whether there are rules that forbid it, then the answer is that it is theoretically possible, at least at some universities.  For example, Andrew Gleason was a tenured professor of mathematics at Harvard from 1953 through his retirement in 1992, without ever having attended graduate school.  (Technically, Harvard awarded him an honorary master's degree when he became a faculty member, but he had no master's degree when he was hired and never received a Ph.D.)  The rules vary between universities, but I do not believe Harvard's have changed since Gleason was there.  For another example, if you invent the World Wide Web, you can become a professor with no master's degree.
On the other hand, it is impossible in practice.  Unless you have received some sort of major academic recognition (a big prize, universities specifically soliciting an application from you despite knowing you have no master's degree, etc.), it's not even worth thinking about, since the chances of being hired are almost indistinguishable from zero.  If you are aiming for an academic career, choosing not to go to graduate school means giving up on that career.
By the way, I'm assuming here that you are asking about fields in which there are very few famous practitioners without advanced degrees.  I can imagine that in certain fields (perhaps art, business, or politics), there might be more people who would be attractive to universities despite having only a bachelor's degree.  But even in those cases, it would require truly impressive achievements.
Comment: (Although, I'm sure there are many honorary doctorates, on university faculties, who only previously had a bachelor's degree.)
Comment: The Gleason of "Gleason's theorem" in quantum mechanics? Wow, I did not know that. interesting
Comment: Yes, my question is mainly about whether accreditation agencies' rules forbid it. I've edited my question to make this explicit. thanks
Answer: Yes, it is possible (at least for part-time appointments).  I am part-time faculty at the University of Washington, and not only do I have just a bachelor's degree, my degree isn't even in the same field as my faculty appointment.  My real world skills and knowledge combined with my mentoring/leadership experience are all that were required.
However, it would be very rare for full-time faculty to not have at least a master's.  UW policy requires the master's degree for full-time faculty and a PhD for professorships, and some departments are adopting rules requiring a PhD for any full-time position.
Answer: It is not forbidden.  Accreditation is based on many factors and percentage of terminal degree holders is one of those statistics that is considered.  Even the most prestigious colleges may have a number of MS/MA/MFA on their faculty.  In rare instances, even people without degrees might be on a faculty.  You may find these rare people on performing or creative arts faculties -- writers, actors, painters, filmmakers, etc. that have outstanding bodies of work or accomplishments.
Comment: MFA is a terminal degree and for teaching purposes is effectively equivalent to a PhD in the creative arts. (i.e. studio art, creative writing etc,)
Answer: Extensive and creative work experience can trump higher ed degrees in cases where the person has something exceptional to bring to the faculty.
The idea behind attaining higher education degrees is that one becomes specialist of a discipline and that lends credence to teaching and research. Becoming a faculty member isn't instantaneous, there is a tenure track process which has its own requirements.
There are several accreditation entities, you have to be more specific about which discipline  and accreditation entity you are referring to.
Comment: For example, the "Southern Association of Colleges and Schools, Commission on Colleges" (SACSCOC). What do they, specifically, say, do you know? Does it really depend on which accreditation agency we are talking about? thanks
Comment: The SACS criteria for accreditation are at http://www.sacscoc.org/pdf/2018PrinciplesOfAcreditation.pdf  They include a requirement that the institution "Justifies and documents the qualifications of its faculty members."  They don't say anything specific about the percentage of faculty with terminal degrees.  You can check to see the requirements of other regional and national accreditors.
Answer: There is a category known as "Professor of Practice", which some schools use to explicitly recognize folks whose teaching authority comes from experience and demonstrated skill in the field rather than from academic credits.
However, if you're talking about tenure track, most schools will ask even these folks to have (or quickly obtain) a "terminal degree" in their field. That may only be a Master's for some fields, but Bachelors generally won't cut it.
Answer: Supposedly yes, but mostly they ask people with a master's degree minimum (depending of course of their publications in the field for both cases). If not they aim for PhD or post-docs.


what does retrievable and replicable access meant for an object in salesforce schema?

Question: From the access level for an object in salesforce schema i understood queryable, deletable and creatable, but what does retrievable and replicable access meant for an object in salesforce schema? please suggest?
Answer:
retrievable---In general, you use Retrieve() when you know in advance the IDs of the records to retrieve. Use Query() instead to obtain records when you do not know the IDs or when you want to specify other selection criteria.
replicable---If object does not have this access you cant use calls like getupdated(),getdeleted() methods .Example will be Accountshare,OpportunityShare etc
Comment: Additionally, it controls whether features such as getUpdated and getDeleted are supported.

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/object-specific_requirements_for_data_replication.htm


14.10 to 15.04 upgrade, now I can't poweroff or reboot!

Question: I was previously running 14.10 without any problems on an Intel NUC Bay trail but then after upgrading it to 15.04 my PC won't poweroff or reboot anymore. At the shutdown messages it says umounting filesystems then "Reached target Shutdown." at that point it just stops, forcing me to press the power button to reboot it.
Comment: How are you getting it to shutdown and/or reboot? Are doing it through Terminal or the GUI?
Comment: Through the Terminal.
Comment: did you find a solution? This is bothering me also...
Comment: I gave up as it appears to be the poor BIOS that affectes the Intel NUCs. Sold the NUC and got a Gigabyte Brix 2955U instead - works flawless.
Comment: I'm still having this same issue as well.
Answer: First this is bug #1464917:
If this affects you please go there and let them know.
After the shutdown or reboot has hanged with this message
Reached target Shutdown
You will only see this if you have removed the splash screen
Try Sysrq

Hold down the Alt and SysRq (Print Screen) keys.
While holding those down, type the following keys in order, several
seconds apart: REISUB
Computer should reboot.

Once it reboots immediately try shutdown button again, it should shutdown properly.  Please add your name to the "This Affects Me" button at launchpad bug link above
You can also try the following after it hangs.
see if you can login tty1 and reboot

Press Ctrl+Alt+F1 or Ctrl+Alt+F2 or Ctrl+Alt+F3 ...
Write your username (lowercase, the name of the user folder in
/home) and hit Enter
Write your password (nothing will appear) and hit Enter

If your password and username are correct, you are now logged in.
If that fails try Ctrl+Alt+Del a couple times at that point in the tty1 screen
You might see a message that states the machine is going to reboot and then it should do just that after a minute or so.
Its better than a hard boot - until its fixed
In the bug notes it is reported that you can upgrade to Vivid-Proposed and it fixes the issue but some still see this after that upgrade.  It might be worth a shot.
Btw the same bug affects me and I have not tried the upgrade yet but the steps I listed do work.


What documents do my sponsor need to sponsor my touristic schengen visa and what is the form of the sponsorship letter?

Question: I am from Madagascar. I am a studying abroad in Turkey. I am on scholarship so I have to go back here in Turkey.
And this summer, I am going in Europe. My father will be sponsoring my trip. Other than his bank statements and the sponsorship letter, what else do I need? And how is the form of the letter?
Thank you.
Answer: The role of your sponsor is to confirm your source of funds. When people travel who cannot really afford the luxury of tourism, the immediate suspicion is that their trip is an investment and that they plan to repay it by overstaying and working. So there are two questions:

Why would your sponsor give you the money as a gift? That's obvious for a father, but more distant relatives would have some explaining to do.
Can your sponsor reasonably afford to give the money as a gift and is the money legal? That requires explaining his financial situation.

Note that you will have to explain your own financial circumstances as well, even if you don't spend your own money on the trip. That's to evaluate your intention to leave the Schengen area.
Answer: You don't say where you're from, which might affect things.
But you should also include some documentation of ties to your home country as proof that you will leave Schengen again.
It might be relevant to read:
Schengen Visa Refusal: Justification for the purpose and conditions of the intended stay was not reliable
and
Schengen Visa Refusal: Justification for the purpose and conditions of the intended stay was not provided
In a comment Traveller has pointed to:
Schengen Visa Application: what are some helpful tips for preparing?
Comment: This https://travel.stackexchange.com/questions/51048/schengen-visa-application-what-are-some-helpful-tips-for-preparing may also be useful
Comment: @Traveller: Indeed, I've added that link to the answer, crediting you for pointing to it.


How to find which planet contains pops of a specific species?

Question: In Stellaris (2.3.3), I want to find out on which planet(s) I can find pops of a specific species. If I go into the Species menu and look up the species, it will tell me there are "X pops living on Y planets" but it doesn't tell me which planets these are. I have a huge empire with a ton of different species, so the Planets and Sectors menu is next to useless for this purpose. How can I track down which planet contains pops of a specific species?
Answer:
Create a new template (gene modification) for the species you're interested in or use an existing one.
Click "Apply Template"

You will then be prompted to check, which planets to apply the template to. This shows you a a list of the planets where the species lives. It also shows you how many pops of the species live on each planet.
Just cancel applying the template after you got the information you want.


Follow up about [delete (cascade/restrict)] and Update (cascade/restrict)

Question: I would like to know when to actually use delete cascade or delete restrict AND update cascade or update restrict. I'm pretty confused using them or applying in my database.
Answer: Using the cascading operators on foreign key constraints is a bit of a hot topic.
In theory, if you know for a fact that deleting a parent object will automatically also mean deleting all its children objects, then cascading delete on the link between child and parent table might make sense.
Imagine a "machine" that consists of "parts". If your logic says that if the machine is deleted, all the parts making up that machine are also to be purged from the database, then you could use a cascading delete option on the foreign key link between the parts table and the machine table.
However: this can be a bit tricky, especially if you end up having a whole chain of tables that are linked with this option. Therefore, a lot of developers tend to prefer to handle this in their own data access code, rather than define it in the database.
The update cascade is typically used when a primary key on a parent table changes - in order to update all related child tables and rows to reflect that change. This is typically considered a database code smell - the better option here is to make sure the primary key never changes, so that this cascading update is never needed - e.g. by introducing an artificial "surrogate" key column into your table, which has no business-related meaning and thus never gets updated.
Does that help at all? Any particular detail you're still unclear on ?
My take is this: while this is a great idea in theory, most developers don't really use this in "real live" - most developers will choose to handle this in data access code, which gives them full and explicit control over what gets deleted (or updated).
Comment: thanks for the response, got the idea of cascading delete/update. Really appreciate for the response.
Answer: As well as what marc_s says..
I've found that CASCADE options can sometimes generate "dummy" updates to a child table when there was no need thus prolonging a transaction, using more locks, using more resources etc.


In what circumstances would an AC produce no condensate but still cool the air?

Question: In what circumstances would an AC produce no condensate but still cool the air?
Comment: Possible duplicate of [My AC is set to 77F and the thermostat reaches that temperature but the AC keeps running. Why?](http://diy.stackexchange.com/questions/91600/my-ac-is-set-to-77f-and-the-thermostat-reaches-that-temperature-but-the-ac-keeps)
Comment: This is basically the same question as your [previous one](http://diy.stackexchange.com/questions/91600/my-ac-is-set-to-77f-and-the-thermostat-reaches-that-temperature-but-the-ac-keeps). You should edit any new information into that question (e.g. does the unit produce no condensate?).
Comment: I think these two are different questions. It does not matter if the same problem made me ask two separate questions. By asking the above I would like to know if there are any circumstances under which an AC would produce no condense. It is a more general question. Ex: I suspect that if I reduce the RH of the air in a room to the maximum possible using a regular DH an AC would have no humidity to condense when it tries to cool that room. This has nothing to do with my other question where the thermostat seems to be the smoking gun
Comment: The body of the question doesn't seem to match the title.
Comment: You have a single, specific problem with multiple symptoms. Asking a question for each symptom isn't going to help you get good answers, nor will it help us build up knowledge on this site.
Comment: I edited the question. The only valid comment above was that of Tester101
Answer: Condensate is a byproduct of air conditioning, which is created when moisture in the air condenses on the cold evaporator coils. There are two situations where an air conditioner would not generate condensate.
If there's no moisture in the air, then there's nothing to condense out of the air.
If the coils are not cold enough (below the dew point), the moisture will not condense out of the air.
Also note, that if the coils are too cold. The condensate will freeze, so it will not drain out until the coil defrosts.
Another note. If the drain does not have a trap,  it's possible that condensate will not drain until the fan shuts off.
Comment: So basically, when you do not have access to the coil, one way to check if your coil freezes is to let it freeze, disconnect the drain tubing from the drain and drain it into an empty bucket. Run the blower to speed up the ice melting and wait to see if water collects into your bucket.
Answer:
Dew point below coil temperature.
Plugged condensate drain.
Coil temperature below freezing (0°C/32°F).
Answer: Well ..one of the possible reasons is that the compressor lost refrigerant. I just realized that. My compressor was doing the job but not well enough. I was not experienced enough so I could say that the tin around the coils should have been a lot colder than it was and the house would eventually reach the set temperature but after some time which made me thing that everything was OK it was just the thermostat that was not getting it. One of the symptoms that was visible to me was "no more condense" hence my question
Comment: This community probably could have been more useful, if you would have described the problem you were having, instead of asking a series of vague questions.
Comment: Well I tried to collect info so I could use my own logic to isolate the problem. I provided enough information in the other threads. Sorry if that was not enough. I added some explanations above
Comment: When a system starts underperforming, the first thing a technician always checks is the refrigerant level.
Comment: I don't have the tools and I am not a technician ..but I will keep in mind for the future. For me, in the beginning it was not under performing , cooling wise, but it was malfuctioning, it was failing to stop..


What's the right way to switch from CFEngine to Rudder?

Question: We have an existing cfengine3-community installation with lots of custom promises and it runs on about 50 machines. I'm interested in switching to Rudder, and I'm wondering about the best way to migrate.  The newest version of Rudder seems to be based on cfengine 3.6.3, and we're running the latest cfengine, which is 3.7.1.  So there's some syntax incompatibility.  Would it work to just swap in the newest cfengine binaries?  If not, what's the proper way to migrate?
Answer: Rudder can run side by side with CFEngine. They use different ports for client-server communication (5309 for Rudder) and different paths (/var/rudder/cfengine-community) so they can work together on the system.
The best strategy would be to have both of them running on yout nodes, and transcript your policies one by one into Rudder (by defining Directives and applying them in Rules, or creating your own Techniques with the Graphical Technique Editor), and disabling the migrating policies in CFEngine.
Direct transcription is quite fast (all bricks are available in Rudder and easy to use); but it is a good opportunity to review:

the relevance of the policies - we often find dead code in migration
the application of policies - it can be that some policies should apply on more (or sometimes less) nodes than they are really aplpied on
the correctness of policies - you get reporting with Rudder, which shows if policies are correctly applied and works. It may be that some of them where failling before without you knowing it, because there were no reports.
Comment: excellent answer. thank you!  I am somewhat disappointed there's not some easy automatic conversion, but your reasons for "transcribing" are good ones.
Answer: rudder use an embedded cfengine-community which is not incompatible with an independant cfengine installation (path are different).
There are some cfengine pactches maintained by Rudder team so I think it will be not a good idea to swap the binaries.
For the incompatibility I don't know, but I know you will need to add some information in your promises to report the state inside Rudder.
Comment: You can have rudder and your own cfengine on the same server. Rudder install cfengine in /var/rudder/cfengine-community/bin/ (cf-agent / cf-execd ...).

So your cfengine installation can still work and migrate the promises in Rudder one by one if you want.

Rudder will not use your cfengine installation
Comment: "not incompatible"? Do you mean compatible? Your second sentence seems to indicate no, that you mean they ARE incompatible.


$wpdb->insert_id

Question: I'm using  $wpdb->insert to insert data to my plugin table.
How can I get the id of the new line I Just insert.
Because I have a lot of users that add data to the table I can't use
$wpdb->insert_id
Because it's not necessary the last one.
Answer: There is no other way, but I can not see how you need any other way then this. I believe that the insert ID accessed by $wpdb is the last ID by this instance of WPDB, other inserts should not affect that but I'm not sure.
<code><?php

  $wpdb->insert("QUERY");

  $this_insert = $wpdb->insert_id;

?>
</code>
Comment: No it doesn't. `$wpdb` is global, but only in this one request, it's not shared between requests of multiple users. As it's also not asynchronous, this will work as expected.
Comment: `$wpdb` is global, all queries share the same instance.
Comment: @toscho but does a query by another user influences the insert ID you get back if they insert a query just in between your insert and read out?
Answer: $wpdb->insert_id is global withint the database session.  since Wordpress creates a new session per user session this is not a problem, even when using a connection pooling.
the only caveat is that this variable will always have the last inserted auto-increment ID, so you have to check after each insert.
If you really want to capture the list of new inserted records, you can do it inside a stored procedure and capture it in a transaction.  or inside a trigger.

$wpdb->insert_id


How to adjust logo with CSS Viewer in QGIS Cloud Pro

Question: I am new to creating web maps and am using QGIS Cloud Pro. I uploaded our company logo onto the web map, but most of the logo is cut off. Using the Viewer tool and CSS there I have tried to adjust it so that all of it shows. I can adjust most other things on the web map using CSS with trial and error, but have not figured out how to get our whole logo to show.
Answer: I solved my problem. Through the inspector on google chrome, I was able to make the correct changes there and copy and paste into the QGIS Cloud viewer.
Comment: What were the changes needed?


Should reverse connections be used to bypass NATs?

Question: I'm planning on doing a demonstration on how remote administrative tools work for my schools computer security club. I plan on writing a RAT in C++ and demonstrating/explaining how it works.  I ran into the issue of dealing with computers behind a NAT, but came up with my own solution.  I decided to make the victim act as a client and the attacker act as a server.  That way, only the attacker needs to make changes in their NAT to establish a connection.  Is this an appropriate way of bypassing the victim's NAT? I have heard of reverse connections being used to bypass victim NATs, but my solution seems to be much simpler. Are there any benefits in sing a reverse connection opposed to my method?
Answer: Having the client connect is the standard way of dealing with NATted connections. It can  also known as a 'Reverse Shell'.
BTW, I know you probably want to write your own RAT, but Metasploit might be a very effective demonstration ....


What tense should I use in the following sentence?

Question: I am writing a descriptive essay about what my life will be like 30 yrs from now.
Which tense should I use?
"I will be wearing/wear the same boyish clothes I wear now".
I mean, I am speaking of a habit in the future.
Comment: It depends from what time period you are narrating the speculative account.
Comment: I am in the present speaking of myself 30 yrs from now.
Comment: In 30 years, I will most likely be wearing a pine overcoat.
Answer: Both are possible, and there is not much difference in meaning.
Saying "I wear boyish clothes" talks about your general style. "I am wearing boyish clothes" talks about the particular clothes you have on right now.

I wear boyish clothes to school every day, but right now I am wearing a long dress because I am at a party.

So putting this in the future has the same meaning. "I will wear..." to talk about what your general fashion sense will be.  "I will be wearing" to talk about the clothes that you have at a particular time.

In 30 years time I'll be wearing a long black dress as I walk up to collect my 10th Oscar. But usually I'll just wear the same boyish clothes that I wear now.

The same structure can also be used to express "determination": "No matter what people think, I will wear the same boyish clothes."
Answer: The future progressive primarily suggests what is actually going to be happening at a relatively precise point in the future. When talking about somewhere that far in the future, it needn't be terribly precise, but it would certainly be appropriate for a period of a day (say, "on this day 30 years in the future"), and less likely for referring to a whole year-long period (say, "in 2049").
The future simple, when talking about that far in the future, would be used for two main scenarios, I think. One is making a prediction of a series of events, like:

I will finish my book, then I will take a holiday somewhere exotic.

The other is refer to habitual things, much as you might use the present simple:

I will wear comfortable clothes, and enjoy a steady income.

That said, it also depends on the verb in question - while you might use either "I will wear comfortable clothes" or "I will be wearing comfortable clothes", some sentences will only work with one or the other. Don't try:

I will be enjoying a steady income.

Most things will work with future simple, and some thing won't work with future progressive.
In a lot of cases, though, it will be a stylistic choice. Even having said that one primarily suggests one thing, and the other would be used for another, those aren't rules. They're factors to think about. You can talk about predicted habits in the future progressive, and things happening on a specific day in the future simple. Apart from the combinations that just don't work, it's not going to matter a huge amount.


Child got A+ blood group when both parents are O+

Question: Based on my understanding of Blood group tables, such as the one below a child can only get O blood group when both parents have O as their blood groups. In a close relative's case, while her parents and two siblings have O+ as their blood groups, she ended up having A+. We are puzzled as how this could happen?
Comment: Blood ABO typing is not as simple as shutterstock makes it. There are weak A types etc. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6910028/
Comment: A much more common occurrence than rare blood groups is non-paternity. Use care when suggesting this to relatives.
Comment: I am completely sure that the OP, the relative who got the blood test result, and absolutely everyone they have discussed it with has considered (assumed) that paternity is the issue. I expect that is why OP is asking, to see if there is any other explanation.
Comment: Someone needs to point out that one possible explanation is that the father isn't who they think it is.
Answer: Although such cases are undoubtedly rare, they are not impossible. Here's a case report from 2005:

Apparent deviation from Mendelian rules of blood group inheritance is rarely observed. Blood group O parents with children expressing weak A subgroups have occasionally been described but not explained. A detailed serological investigation of such a family is described here. [...]
The propositus' RBCs were very weakly agglutinated with monoclonal anti-A but distinctly with polyclonal anti-A,B, i.e. typical for Ax. Serum anti-A1 (titre 4) and -B were present. Her parents' blood groups were both clearly O, with titres of serum anti-A1, and -A at 16 and 4, respectively. Adsorption/elution studies demonstrated A antigen on the daughter's cells only. The ABO genotypes were: mother, AxO1; father, O1vO2; and propositus, AxO2. The Ax allele was an A1-O1v hybrid allele with a crossing-over breakpoint between positions 235 and 446 in intron 6 (Ax-4). Compared to the A1 glycosyltransferase, this allele predicts a protein with two amino acid substitutions (Phe216Ile and Met277Val) known to yield either weakly expressed or no A antigen on RBCs.
This study suggests that the nature of the ABO allele in trans can influence A antigen expression, a phenomenon previously described as allelic enhancement (or reinforcement).
Answer: Theoretically, if both parents are O+, there is no chance of an A+ child.  Type O blood is recessive, and must be homozygous to exhibit as the blood type.  However, if one parent was mistyped, and carried O but had type A blood as his/her dominant type, then of course this would be possible.
Allegedly there are occasional genetic mysteries called "throwbacks" (cf. "atavism") which present unusual anomalies (e.g. two Caucasian parents having a black child).  But aside from something of this nature, of whose possibility in this case I am uncertain, some of the possible causes might include:

One parent actually has type A blood (could have had blood mistyped, or parent was misidentified).
The child was mistyped, and needs to be retested.
Blood samples on test day were cross-labeled (mixed up).
The parents brought home the wrong infant from the hospital.
Etc.

Was the blood test done at school and the child, too afraid of the finger prick, begged some friend to "help"?  There are a number of possibilities that one might consider, but to have an A+ child from two O+ parents is not one that I would consider.
Neither does the Red Cross, though they do seem hesitant to make a perfectly definitive declaration on account of potential issues with testing, as seen in their remarks below their blood-type graphic (available HERE).
Comment: Can you please provide citations to back your claims?


What is the difference between "human," "human being", and "humankind"?

Question: Those words all mean ..... WE!
Comment: Have you looked them up in a dictionary?  None of them mean "we".
Answer:
human: a human being, especially a person as distinguished from an animal or (in science fiction) an alien
human being: a man, woman, or child of the species Homo sapiens, distinguished from other animals by superior mental development, power of articulate speech, and upright stance
humankind: human beings considered collectively (used as a neutral alternative to "mankind")

The NOAD has also these notes.

Traditionally, the word man has been used to refer not only to adult males but also to human beings in general, regardless of sex. There is a historical explanation for this: in Old English, the principal sense of man was "a human being," and the words wer and wif were used to refer specifically to "a male person" and "a female person," respectively. Subsequently, man replaced wer as the normal term for "a male person," but at the same time the older sense "a human being" remained in use. In the second half of the 20th century, the generic use of man to refer to "human beings in general" (as in reptiles were here long before man appeared on the earth) became problematic; the use is now often regarded as sexist or old-fashioned. In some contexts, terms such as the human race or humankind may be used instead of man or mankind. Certain fixed phrases and sayings, such as time and tide wait for no man can be easily rephrased (e.g., time and tide wait for no one). Alternatives for other related terms exist as well: the noun manpower, for example, can usually be replaced with staff or crew, and in most cases, the verbal form to man can be expressed as to staff or to operate.
Answer: human: relating to a person; characteristic of humanity
human being: an individual of the humankind.
humankind: world; all of the living human inhabitants of the earth.
Answer: I read an interesting philosophy pertaining to the question, "What is the difference among 'human' and 'human being'...?" Well first, human is the kind of creature. But "human being" was  described as a fictional creature, a mythical creature that is un changeable. "Being" is to be just "there", compared to the word "becoming", which is a word implying constant change. While a human being is just not changing, which implies a fake creature that "just is", in reality humans are actually "human becomings", because we are always improving, we are growing, developing and becoming more than what we were days, hours, minutes and seconds before. Thus, a human being is actually (to put it in the way it was broken down) a slave to "being" unchangeable and not free to journey and "become". In conclusion, the free refer themselves as (just) "human", while the ignorant slave, unwise of their choice of words, maintain that they are a "human being".
Comment: Welcome to EL&U. You relate one author's definitions as set forth in an article, but I do not think that is necessarily the same distinction that the general public would draw.
Comment: You seem to be unfamiliar with Stack Exchange. This is not a discussion forum, but a Q&A site, and each post should attempt to answer the question posed by the original poster. Yours does not; as I noted, it relates a definition posed by one author whose name you do not even cite, not one that is generally applicable. I strongly encourage you to take the [site tour](http://english.stackexchange.com/tour) and to visit the [help center](http://english.stackexchange.com/help) for guidance.
Comment: [You cannot say "the difference among".  That is ungrammatical. It must be "difference between".](https://english.stackexchange.com/a/193840/2085)


Best collision algorithm for Axis Aligned Bouding Boxes

Question: I have a number of quads (suppose like 20-40) and i want to quickly check the collisions between any of them. I would like to know if there's a quick algorithm to do that 60 times per second without performance decrease
Comment: Regarding my close vote:  your answer lays firmly within the "collision detection" section of the accepted answer to that question.  Spoiler:  the answer is space partitioning.
Comment: Oh i didn't see the duplicate, thanks for that by the way.
Answer: You may want to consider looking to spacial partitioning, such as a Quadtree.
In a nutshell, you would be dividing your world into sub-sections, and only check collisions between objects that are inside of the same sub-sections, greatly improving the complexity.
Answer: In the worst case (for 40 AABBs) you'll need to do 780 tests. There's not going to be any problems with a simple 4 comparison test:
<code>a_min.x <= b_max.x
b_min.x <= a_max.x
a_min.y <= b_max.y
b_min.y <= a_max.y
</code>
If all of these are true, you have an intersection.
At this point partition structures (like AABB trees) are not necessary at all. You might only want to start thinking about them when test count goes over 10 000, which is when you need to test about >140 AABBs.
Best to avoid using the broadphase for as long as you can because it will introduce a lot of complexity and hard choices and measurements. Not one of them is going to give a good speed improvement without serious workload and staying within special constraints with your AABBs.
Comment: So you're claiming that a simple collision test between two bodies will overwhelm having an O(n^2) algorithm for the number of tests?  I disagree.
Comment: @SethBattin I'm not sure what you think I'm saying. And what "bodies"? To my understanding, we're talking about AABBs here.
Comment: I'm saying that recommending against a broadphase because each individual test is simple is bad advice.  Your performance threshold numbers are going to be completely technology- and system- dependent; they aren't good rules of thumb.  And you're conflating bounding boxes of bodies with the structure that holds them (a tree), which doesn't make sense either.
Comment: @SethBattin A low-end 1 GHz CPU on Android can easily crunch at least 100k hash table reads per second, you think 3200 two-instruction cache-efficient comparisons can slow anything down? No need to assume ridiculous things. Any tech this wouldn't work on was discontinued at least 10 years ago. As for "conflating" - you seem to be imagining things now. a) Nobody except you is talking about "bodies". b) OP wants to compare AABBs. c) At no point did I say that AABBs have to be integrated in AABB trees. P.S. BVHs have overhead, you know. It's not like they magically speed things up for free.
Answer: A nice but lesser well known algorithm for this situation is called dimensional reduction.
If you keep your list of rectangles sorted on one axis (say, x axis by sorting on the minimum x value of the rectangles), then collision detection just becomes a 1 dimensional overlap test on the y axis, for whatever overlaps there were on the x axis.
Works better when most objects are stationary, but the same is true of all spatial subdivision algorithms (;


OPGP: tag8 being converted to tag11, part of 4880 spec?

Question: When a tag8 compressed data packet does not contain compressed data i've seen some products simply handle the packet as a tag11 literal data packet, yet i find nothing in the 4880 spec old/new suggesting this is an acceptable behavior. what am i missing here?
Answer: Turns out this was a Bouncy Castle issue that has been fixed in versions since 2.3.2. Basically a rogue Tag08 compressed data packet (old format xA3) was immediately followed by a byte of binary zeros, which was followed by xCB - a new format tag0D packet hdr. The trick was identifying this string and then skipping past the garbage Tag08 hdr.
For more information on this bug... https://www.bouncycastle.org/releasenotes.html  and  https://github.com/bcgit/bc-java/issues/1027
HTH,
mvh


A glass passes visible radiation. Is there "glass" for other types of radiation?

Question: Glass is solid and transparent material for light visible  for human.
Is there any other materials that also "transparent" for other frequency ranges of radiation? For example, X-rays, radio emission. Or maybe it`s still glass?
Answer: How a material interacts with light is controlled by electrons.
The defining characteristic of a metal is that it has electrons that are free to move. This is why metals conduct electricity. Electrons can carry heat, so metals are also good thermal conductors.
Light is an oscillating electromagnetic field. Electromagnetic fields exert forces on electrons. When light hits a metal, it makes the electrons vibrate. The light is absorbed. The vibrating electrons emit new light. This is the basis of reflection.
Nonconductors have electrons bound to atoms. These electrons can vibrate, but not at all frequencies. The frequencies at which they can vibrate depend on the particular chemical bonds in the material. If the frequency of light matches the frequency at which electrons can vibrate, the light is absorbed. This is the basis of colored glass.
Diamond is a material with one of the most unusual optical properties. Diamond has very strong bonds. Diamond is made from carbon, which is one of the lightest atoms. This combination makes all vibrational frequencies very high. Because of this, diamond does not absorb low frequency light. It is transparent to all frequencies up to ultraviolet.
Answer: Yes there are many depending on what frequency you are interested in.
Every substance interacts with a characteristic absorption spectrum of light frequencies. Light or (EM radiation) that doesn't interact with a substance passes through it.
Most people are familiar with x-rays due to their medical applications, for example.
Comment: Well sure but what material can be used to make an x-ray lens?
Comment: compound refractive x-ray lens typically use materials with very low atomic number such as beryllium or lithium. These have to be designed for a particular monochromatic frequency, though. There are other ways to do it though.
Answer: It really depends on the wavelength. Conventional "glass" itself is transparent for a wide range (~ 360 nm - 1.5 µm). There are other materials which can e.g. be used for longer wavelengths like $Al_2O_3$ or ZnSe. Some of these materials, like $Al_2O_3$ can be obtained in crystalline quality, so they technically don't qualify as glass, but from an optics perspective they are transparent. For shorter wavelengths like X-rays and shorter, most materials become transparent.
In general, I recommend looking different materials and their absorption coefficients up at refractiveindex.info


What is .Trash and .Trash-1000?

Question: Can someone tell me what these folders (.Trash and .Trash-1000) mean? They just appeared in my mountpoint and I'm wondering how?
Comment: To prevent the folder from being created, run `touch ` in the parent directory.
Answer: Have a look at How to prevent Ubuntu from creating a .Trash-1000 folder when deleting files from a USB flashdrive?.
According to the article, Ubuntu will create such folders when a file is deleted from a USB drive. Presumably this would allow a file to be restored if you accidentally deleted it.
In any case, the article offers the following recommendations to prevent a Trash folder from being created:

Don't use the delete button only (Otherwise the .Trash-1000 folder will be created)
Press the key combination shift+delete together to delete then Ubuntu won't create a .Trash-1000 folder. (Note: If you delete files and folders this way they are gone forever!)
Comment: Hi,

Sorry I didnt explain the question briefly. I am using fuse mountpoint and not mounting a pendrive. Sorry, it was my mistake. I am reading the link you gave me. I hope it helps solve my issue. Thanks !
Answer: For every mountpoint, Ubuntu creates a "Trashbin" as soon as you delete a file - so the file later can be undeleted.
The 1000 is the UID of the user that created the bin, so every user can have its own.
Comment: hmmm....Interesting ! Let me see if i understood right. When I delete a file in the mountpoint, It will be inside the same mountpoint and not to the general trashbin. And these are created only when I delete a file. Not by default when the mount point was created? Thanks for the answer.
Answer: folders (.Trash and .Trash-1000).
These appear on whatever drives are accessed by any operating system based on Ubuntu. Ubuntu-based systems could be Mint, BlackLab, Zorin, Vinux, Peppermint, etc. The drives access by these operating systems could be any partition format: EXTx, NTFS, etc.
These .Trash folders could be small or large, depending on the deleted files created by the Ubuntu-based system.  Deleting these files can be another problem, especially in the Windows operating system, of any version, including the latest "insider" versions.

What is .Trash and .Trash-1000?


Kafka compatible with Zookeeper 3.5 feature 'Rebalancing Client Connections'

Question: In this document https://zookeeper.apache.org/doc/trunk/zookeeperReconfig.html dynamic configuration functionality is described for Zookeeper 3.5.
There are 2 important points in this document:

When changing the dynamic config of one Zookeeper instance, all Zookeeper instances in the ensemble automatically get their configs updated.
Clients of the Zookeeper ensemble can rebalance their connections when the dynamic config gets updated, provided they subscribe to /zookeeper/config in Zookeeper, or alternatively call getConfig, and update their own list of Zookeeper servers by calling updateServerList

This all seems really promising, because at the moment (Kafka 2.12 and Zookeeper 3.4.9), both Zookeeper and Kafka configurations are static, and when a Zookeeper node needs to get replaced, config changes need to be made on each Zookeeper instance in the ensemble and on each Kafka broker, and all participants need to be restarted to reload configs.
My question is, provided that you go with Zookeeper 3.5 and it's new dynamic reconfiguration, is there a Kafka version that is compatible with this, which will update it's own zookeeper.connect configuration when the Zookeeper ensemble gets reconfigured?
Answer: Kafka 2.0 updates zk to 3.4.12 https://issues.apache.org/jira/browse/KAFKA-6390.
And that has been released quite recently. So I guess that we have to wait just a bit more?


Why these 2 regexp won't work as expected in ModSecurity?

Question: PROBLEMRULE #1; SecRule REQUEST_URI "^/(|(.*)/)(lpt1|lpt2|lpt3|lpt4)(/|\.|\?|$)" "t:none,t:htmlEntityDecode,t:lowercase,t:removeWhitespace,block,msg:'X',id:'1000'"
PROBLEMRULE #2; SecRule REQUEST_URI "^(.*)//(.*)$" "t:none,t:removeWhitespace,block,msg:'X',id:'1001'"

// I also tried those, but no success.
SecRule REQUEST_URI "//"
SecRule REQUEST_URI "^/(.*)/(lpt1|lp...

These 2 things won't work as expected. Other rules are working fine.
I want to block a request something like:
// (too many slash, NOT blocked)
/////////// (too many slash, NOT blocked)
/lpt1 (Apache returns 403, NOT from modsec. Error log: "Forbidden: (web-dir)/lpt1 doesn't point to a file or directory")
/lpt1/blah (Apache returns 403, NOT from modsec. "doesn't point to a file or directory")
/somedir/lpt4.txt (Same as above)
/somedir/lpt4 (Same as above)
/somedir/////// (* SUCCESSFULLY blocked)

I believe these regexpression is O.K., so I really want to know why mod_security2 won't block these requests. I want to block using mod_sec2, not apache.
Environment:
Windows Test Web server | mod_sec2 | Apache 2.4
To moderators:
Sorry for creating another question,
because my email has been hacked and I lost my password.
Please delete http://security.stackexchange.com/questions/47000/why-these-2-regexp-wont-work-as-expected
I use THIS ONE to continue question.

To before question:

The REQUEST_URI variable doesn't include the domain or the protocol. Did you mean to add more to the end of that URL?

Yes, I know.
I want mod_sec2 to deny "GET ////////"(shown in above examples).
If I hit a browser hxxp: // something.mysite.com//////////
REQUEST_URI become "///////", so id:1001 should be applied. Am I right?

Is the rule ID logged for the request that is successfully blocked by Mod Security?

If the mod_security rule was successfully applied, I can see mod_sec error in my
apache's errorlog(including hit ID number, of course.)
"/somedir/lpt4" and other thing, are block by apache, not by mod_security.
(No logs from mod_security)
LTP1?

http://www.hanselman.com/blog/NamingAFileAReservedNameInTheWindowsVistaOperatingSystem.aspx
I want mod_sec to deny these ugly internal commands, so I create a rule(id:1000).
P.S. "RewriteRule" is not an option to me. I want to use mod_sec2 to do this.
Answer: SecRule REQUEST_URI "^/(|(.*)/)(lpt1|lpt2|lpt3|lpt4)(/|\.|\?|$)" "t:none,t:htmlEntityDecode,t:lowercase,t:removeWhitespace,block,msg:'X',id:'1000'

There can be two problems with these rules.

HTTP request Transformation functions i.e t:htmlEntityDecode,t:lowercase,t:removeWhitespace should be in compliance with actual encoding scheme used in HTTP request. Modsecurity transform the input and apply the regular expression for each transformation.
You are using block as a disruptive action, problem with block that it uses SecDefaultAction value that can be pass, deny,drop. Therefore block may not be blocking the malicious HTTP request and replacing block with deny may solve the problem.


How are the experiments ordered in a Qiskit Job?

Question: Using the execute function, assuming the parameter experiments is a list[QuantumCircuit], would each circuit execute on the device in the order specified by the list?
Answer: If the parameter experiments is a list[QuantumCircuit], then the qiskit.execute_function function will run the circuits using a parallel map, and append the results in the returned list in the order they finish.
After the parallel run, you can sort the results list to match the ordering of the input circuits. For an example of how to do so, see https://quantumcomputing.stackexchange.com/a/23382/13991.
Edit:
Lists of jobs sent to actual IBMQ quantum devices are processed through the parallel map function as well, but appear to be submitted asynchronously. Tracking a run down through the stack, you'll find:
IBMQJobManager.run
    ${\rightarrow}$ ManagedJobSet.run
        ${\rightarrow}$ ManagedJob.submit
            ${\rightarrow}$concurrent.futures.ThreadPoolExecutor.submit
ManagedJob.submit invokes ThreadPoolExecutor.submit with callable _async_submit:
def _async_submit(
    self,
    circuits: Union[QuantumCircuit, Schedule, List[Union[QuantumCircuit, Schedule]]],
    job_name: str,
    backend: IBMQBackend,
    submit_lock: Lock,
    job_tags: Optional[List[str]] = None,
    **run_config: Dict
) -> None:
    """Run circuits asynchronously and populate instance attributes.
    Args:
        circuits: Circuits to run.
        job_name: Name of the job.
        backend: Backend to execute the experiments on.
        submit_lock: Lock used to synchronize job submission.
        job_tags: Tags to be assigned to the job.
        **run_config: Extra arguments used to configure the run.
    """

It doesn't seem to be the case that the order in which circuits are executed necessarily matches the order in which they are specified. However, you should be able to find the mechanism that dicates execution / submission order by following the IBMQJobManager.run bread trail that I've started to layout above.
Comment: Is this for simulation, or does this apply to IBMs quantum devices as well? If so, could you point me to a resource explaining how parallel executions are processed on actual quantum devices?
Comment: Answer revised above. Hopefully thats helps


"My goodness!" Mine? Goodness?

Question: Why do we say my goodness?  It doesn't sound appropriate for the contexts in which it is used.  Both the my and the goodness don't seem to bear on a surprising or startling situation.  When was it started, and why?
Comment: What epithet **does** bear on a surprising situation?  That is kind of the point of them.
Answer: The Phrase Doctor writes that my goodness is a minced oath:

My goodness --> My God
My gosh --> My God

So the phrase was used instead of swearing, with goodness being a euphemism. The Oxford English Dictionary adds that goodness! has an established meaning in this vein, writing:

In various exclamatory phrases, in which the original reference was to the goodness of God (cf. sense 2a above), as goodness gracious!, goodness (only) knows! , †for goodness!, for goodness' sake!, in the name of goodness!, (I wish) to goodness! , surely to goodness!, thank goodness!, etc., or simply goodness!

The first written usage is by Shakespeare, who wrote:

1623    Shakespeare & J. Fletcher Henry VIII Prol. 23   Therefore, for Goodnesse sake, and as you are knowne The First and Happiest Hearers of the Towne, Be sad, as we would make ye.

There isn't a notation about the first written use of my goodness, but it definitely uses the sense of goodness which has been around since the 1600s.
Comment: It's not exactly on a daily basis, but I have been known to exclaim *"Landsakes and lawksamussy!"* as being slightly more socially acceptable than *"Fuck me sideways with a seven-foot bargepole!"*. To be honest, I feel that in the UK today, *"Lord have mercy!"* would probablly raise more eyebrows than either of those two.
Answer: It's a socially acceptable way of saying Oh my god! without offence. It's not just a pun, but also a subtle counter to those who say Oh my god by switching the offensive part to something completely opposite: cursing God (bad) -> goodness
Answer: Goodness is an euphemism for God.

"My goodness!" Mine? Goodness?


List of all people who liked a comment.

Question: I have a 168 likes on a comment and want to view all the people who have liked it. How can you view this?
Answer: You aren't really clear on how you want to get at this information. It can be found by going into Central Administration, Application Management, Manage Service Applications, and going to the User Profile Service. Within there, there will be a link called Manage Social Tags and Notes.
Here you can provide a URL or a user and see what tags or notes have been left on the page or by the user.
There are web service end points to get to this information as well as server side code (obviously).
Expand your question so you get the response you are looking for.
Answer: Currently I cannot check the details, as I don't have a 2013 environment (you are on 2013, right?). Also: are you in a Microblog or where is your comment?
However if you have the information LikesCount you also have a hidden column LikedBy.That column contains a csv list of the users who liked your comment.
Depending on "who you are", e.g. developer, admin, etc. there are different ways to see the values. Also it's unclear if you only want to check for this one comment or always display who liked a comment in the UI.
To be able to see that on this specific comment you'd still need to find the comment in the respective MicroFeed list.

List of all people who liked a comment.


Easy ways to solve

Question: I learned how to solve a rubik's cube this summer. On my first try (after memorizing all the algorithms) I got a sub-50. Now, my personal best is 31 seconds. I tried learning the Fridrich method but I don't ever have the time to sit and watch a tutorial. I use the beginners method. Though sometimes I do 1-look instead of 2. Any ways on how to get faster?
Answer: If you want to improve your times you should learn F2L.
I guess you also mean the same thing with Fridrich (althought F2L is only the second step of Fridrich).
You can learn it by watching a tutorial and by practicing a lot. And don't come with the excuse of not having time. If you don't have time watching a 10 minute tutorial you also have no time on practicing the cube and you'll not achieve your goal of getting faster. There is no magic trick, that improves your times without effort.
You can learn F2L from here: How To Learn F2L Intuitively. The video is not only 9 minutes long. Although you probably will take much longer to get used to the idea of F2L and it will take a few weeks until you get good times with it. At first your solving time will skyrocket. But don't give up! If you practice a lot, you'll get used to all the different cases and you'll be faster than ever.
And from time to time you should learn a few 1-look cases. Quite a lot of them are really easy (especially the OLLs). For instance you probably know the alg F (R U R' U') F'. Another OLL is F (R U R' U')2 F' (the middle term is executed twice). Or another one is Fw (R U R' U')2 Fw' (take the first to layers of F instead of only one).

Easy ways to solve


Does drinking a potion permit an opportunity attack?

Question: I've seen a question on here before that mentioned drinking a potion opens up a character to an opportunity attack, but the question was referring to Pathfinder. Is this the case for DnD 5e?
Answer: No. Opportunity Attacks list one event that triggers them: When you move out of a creature's reach.

Opportunity Attacks.
In a fight, everyone is constantly watching for enemies to drop their guard. You can rarely move heedlessly past your foes without putting yourself in danger; doing so provokes an opportunity attack. You can make an opportunity attack when a hostile creature that you can see moves out of your reach. To make the opportunity attack, you use your reaction to make one melee attack against the provoking creature. The attack interrupts the provoking creature's movement, occurring right before the creature leaves your reach.
-PHB p. 195. Basic p. 74

Some abilities can give a creature additional opportunities for opportunity attacks, such as Mage Slayer, which provides one when someone in reach casts a spell. But without an explicit exception (none of which currently exist for potions), drinking a potion will not trigger an opportunity attack.
Comment: @NateKerkhofs mechanics aren't intended to model realism, and in this case it's one of *numerous* abstractions that are made. 5e is designed to *not* worry too much about position or penalize you for taking most combat actions. The *only* thing that merits an OA is moving out of reach without disengaging. That's it. You could of course choose to have more things trigger one, but that would be the answer *For your game* not *in general* or *as written*
Comment: Which to me sounds silly. To drink a potion in mid-combat, you need a free hand and at least part of your attention: pull out the flask, uncork it, put it to your mouth, drink it and get rid of the bottle. I don't think that you can do all of this while still keeping your attention to the fight.
Comment: @Nate If this was 3.5e then your intuition would be right, but in 5e OAs don't represent distraction, they represent "movi[ng] heedlessly past your foes". For another explicit thing that demonstrates that 5e's OAs are not equivalent to 3.5e's except in name: firing a ranged weapon or casting a spell in an enemy's reach doesn't trigger an OA.