What is the semantically correct way to use the `` tag in HTML 5, with `, , and `?

Question: I currently have an ordered list that I want to markup using the new HTML 5 attributes.  It looks like this:

Article A

Some text

Article B

Some text

Article C

Some text

It seems the only way to keep the list AND use HTML 5 tags is to add a whole bunch of unnecessary divs:

Article A

Some text

Article B

Some text

Article C

Some text

Is there a better way to do this?  What are your thoughts?
Answer: If you're using a list to add chronological order semantics to weblog posts, and as @Tomas mentioned each article is self-contained, then your code is ok (I'd remove the containing section though — it's untitled and unnecessary).
However as you say there's some extra markup. If you want to use less HTML, you can remove the list. You may think that you've then lost the chronological order semantics, but you can actually do this better using time with the pubdate attribute. This would look like:

The lolcat singularity

        <time datetime="2010-05-24" pubdate="pubdate">Today</time>

…

The internet is made of cats

        <time datetime="2010-05-23" pubdate="pubdate">Yesterday</time>

…

If you're making a list of articles on the homepage, you'll have to decide if the content stands alone (i.e. would you make a feed out of the article summaries). If so then the above code is still fine. If the summaries are too short to be self-contained, then you could choose to use a list, but at that stage you're not dealing with "article" semantics, so your original classnames would be a little misleading:

Article A

Some text

Article B

Some text

Article C

Some text

and select using .article-list li {} or .article-list h2 {} etc.
Fwiw I actually ended up using an ordered list containing article with time pubdate — the semantic belt and suspenders approach. I'm now wondering if I should remove the list myself :) You can also get carried away with hAtom, but note that ARIA's role="article" shouldn't be used on list items.
While HTML5 is an evolution, you'll get the most benefit from throwing out your old code, starting from the content and a good guide to the spec, and marking stuff up from scratch. HTH!
Comment: you're more than welcome. More goodness at html5doctor.com, or the four articles starting with http://oli.jp/2009/html5-structure1/ ;-)
Answer: According to the last editor's draft:

The article  element represents  a self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.

As I interpret that, your use is perfectly fine semantically, although I really must question your use of a list in the first place. Given that each article is probably much more text than a couple of lines, an unordered list just seems to make things clotty. I imagine you'll "style away" the bullets etc with css, and I can't see why you'd want a bulleted list of articles if the page is displayed with css disabled. I'd suggest merely

The header

Some text

The header

Some text

And maybe another paragraph


Why do I get "Nothing to install or update" when I update to latest core version?

Question: Under /admin/modules/update, Drupal core is listed as requiring update from 8.8.8 to 8.9.2. I have started my Drupal installation using the drupal/recommended-project project template and I used composer update drupal/core-recommended --with-dependencies to update Drupal core, but when I run the above command, all I get is this message.

Nothing to install or update

Am I missing something?
This is the content of the composer.json file.
{
    "name": "drupal/recommended-project",
    "description": "Project template for Drupal 8 projects with a relocated document root",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "homepage": "https://www.drupal.org/project/drupal",
    "support": {
        "docs": "https://www.drupal.org/docs/user_guide/en/index.html",
        "chat": "https://www.drupal.org/node/314178"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "composer/installers": "^1.2",
        "drupal/addtoany": "^1.14",
        "drupal/admin_toolbar": "^2.3",
        "drupal/better_exposed_filters": "^4.0",
        "drupal/blazy": "^2.1",
        "drupal/business_rules": "^1.0",
        "drupal/captcha": "^1.1",
        "drupal/change_pwd_page": "^1.0",
        "drupal/colorbox": "^1.4",
        "drupal/conditional_fields": "^1.0",
        "drupal/core-composer-scaffold": "^8.8",
        "drupal/core-project-message": "^8.8",
        "drupal/core-recommended": "^8.8",
        "drupal/dynamic_entity_reference": "^1.10",
        "drupal/entity_reference_revisions": "^1.8",
        "drupal/eva": "^2.1",
        "drupal/field_group": "^3.1",
        "drupal/field_permissions": "^1.0",
        "drupal/field_timer": "1.x-dev",
        "drupal/firebase": "^2.0",
        "drupal/flag": "^4.0",
        "drupal/fontawesome": "^2.16",
        "drupal/google_analytics": "^3.1",
        "drupal/jquery_ui_accordion": "^1.1",
        "drupal/jquery_ui_checkboxradio": "^1.2",
        "drupal/module_filter": "^3.1",
        "drupal/pathauto": "^1.6",
        "drupal/persistent_login": "^1.3",
        "drupal/reroute_email": "^1.2",
        "drupal/simple_fb_connect": "^3.1",
        "drupal/simplify": "^1.1",
        "drupal/sitewide_alert": "^1.3",
        "drupal/slick": "^2.2",
        "drupal/slick_views": "^2.3",
        "drupal/sms": "^1.3",
        "drupal/sms_simplegateway": "^1.1",
        "drupal/subpathauto": "^1.1",
        "drupal/telephone_validation": "^2.3",
        "drupal/token": "^1.6",
        "drupal/token_filter": "^1.1",
        "drupal/ultimate_cron": "^2.0",
        "drupal/video": "^1.4",
        "drupal/views_infinite_scroll": "^1.7",
        "drupal/webform": "^6.0",
        "drush/drush": "^10.2",
        "wikimedia/composer-merge-plugin": "^1.4"
    },
    "require-dev": {
    },
    "conflict": {
        "drupal/drupal": "*"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "sort-packages": true
    },
    "extra": {
        "merge-plugin": {
            "include": [
                "web/modules/contrib/webform/composer.libraries.json"
            ]
        },
        "drupal-scaffold": {
            "locations": {
                "web-root": "web/"
            }
        },
        "installer-paths": {
            "web/core": ["type:drupal-core"],
            "web/libraries/{$name}": ["type:drupal-library"],
            "web/modules/contrib/{$name}": ["type:drupal-module"],
            "web/profiles/contrib/{$name}": ["type:drupal-profile"],
            "web/themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/Commands/contrib/{$name}": ["type:drupal-drush"],
            "web/modules/custom/{$name}": ["type:drupal-custom-module"],
            "web/themes/custom/{$name}": ["type:drupal-custom-theme"]
        },
        "drupal-core-project-message": {
            "include-keys": ["homepage", "support"],
            "post-create-project-cmd-message": [
                "<bg=blue;fg=white>                                                         </>",
                "<bg=blue;fg=white>  Congratulations, you've installed the Drupal codebase  </>",
                "<bg=blue;fg=white>  from the drupal/recommended-project template!          </>",
                "<bg=blue;fg=white>                                                         </>",
                "",
                "<bg=yellow;fg=black>Next steps</>:",

                "  * Install the site: https://www.drupal.org/docs/8/install",
                "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
                "  * Get support: https://www.drupal.org/support",
                "  * Get involved with the Drupal community:",
                "      https://www.drupal.org/getting-involved",
                "  * Remove the plugin that prints this message:",
                "      composer remove drupal/core-project-message"
            ]
        }
    }
}

Update #1:
I have updated my composer.json file from:
"drupal/core-composer-scaffold": "^8.8",
"drupal/core-project-message": "^8.8",
"drupal/core-recommended": "^8.8",

to:
"drupal/core-composer-scaffold": "^8.9",
"drupal/core-project-message": "^8.9",
"drupal/core-recommended": "^8.9",

But I got the below list of errors:
firstname.lastname@example.com [~/public_html/test.example.com]# composer update drupal/core-recommended --with-dependencies
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package drupal/core-dev (locked at 8.8.2, required as ^8.9) is satisfiable by drupal/core-dev[8.8.2] but these conflict with your requirements or minimum-stability.
  Problem 2
    - drupal/core-recommended 8.9.2 requires drupal/core 8.9.2 -> satisfiable by drupal/core[8.9.2].
    - Conclusion: don't install drupal/core 8.9.2
    - drupal/core-recommended 8.9.1 requires drupal/core 8.9.1 -> satisfiable by drupal/core[8.9.1].
    - Conclusion: don't install drupal/core 8.9.1
    - Installation request for symfony/polyfill-php72 (locked at v1.17.0) -> satisfiable by symfony/polyfill-php72[v1.17.0].
    - drupal/core-recommended 8.9.0 requires drupal/core 8.9.0 -> satisfiable by drupal/core[8.9.0].
    - Conclusion: don't install drupal/core 8.9.0
    - drupal/core-recommended 8.9.0-beta3 requires symfony/polyfill-php72 v1.15.0 -> satisfiable by symfony/polyfill-php72[v1.15.0].
    - drupal/core-recommended 8.9.0-rc1 requires symfony/polyfill-php72 v1.15.0 -> satisfiable by symfony/polyfill-php72[v1.15.0].
    - Conclusion: don't install symfony/polyfill-php72 v1.15.0
    - drupal/core-recommended 8.9.0-beta2 requires drupal/core 8.9.0-beta2 -> satisfiable by drupal/core[8.9.0-beta2].
    - Conclusion: don't install drupal/core 8.9.0-beta2
    - drupal/core-recommended 8.9.0-beta1 requires drupal/core 8.9.0-beta1 -> satisfiable by drupal/core[8.9.0-beta1].
    - Conclusion: don't install drupal/core 8.9.0-beta1
    - drupal/sms 1.3.0 requires drupal/core >=8.6 <8.9 -> satisfiable by drupal/core[8.8.8, 8.6.0, 8.6.0-alpha1, 8.6.0-beta1, 8.6.0-beta2, 8.6.0-rc1, 8.6.1, 8.6.10, 8.6.11, 8.6.12, 8.6.13, 8.6.14, 8.6.15, 8.6.16, 8.6.17, 8.6.18, 8.6.2, 8.6.3, 8.6.4, 8.6.5, 8.6.6, 8.6.7, 8.6.8, 8.6.9, 8.7.0, 8.7.0-alpha1, 8.7.0-alpha2, 8.7.0-beta1, 8.7.0-beta2, 8.7.0-rc1, 8.7.1, 8.7.10, 8.7.11, 8.7.12, 8.7.13, 8.7.14, 8.7.2, 8.7.3, 8.7.4, 8.7.5, 8.7.6, 8.7.7, 8.7.8, 8.7.9, 8.7.x-dev, 8.8.0, 8.8.0-alpha1, 8.8.0-beta1, 8.8.0-rc1, 8.8.1, 8.8.2, 8.8.3, 8.8.4, 8.8.5, 8.8.6, 8.8.7, 8.8.x-dev].
    - drupal/sms 1.3.0 requires drupal/core >=8.6 <8.9 -> satisfiable by drupal/core[8.8.8, 8.6.0, 8.6.0-alpha1, 8.6.0-beta1, 8.6.0-beta2, 8.6.0-rc1, 8.6.1, 8.6.10, 8.6.11, 8.6.12, 8.6.13, 8.6.14, 8.6.15, 8.6.16, 8.6.17, 8.6.18, 8.6.2, 8.6.3, 8.6.4, 8.6.5, 8.6.6, 8.6.7, 8.6.8, 8.6.9, 8.7.0, 8.7.0-alpha1, 8.7.0-alpha2, 8.7.0-beta1, 8.7.0-beta2, 8.7.0-rc1, 8.7.1, 8.7.10, 8.7.11, 8.7.12, 8.7.13, 8.7.14, 8.7.2, 8.7.3, 8.7.4, 8.7.5, 8.7.6, 8.7.7, 8.7.8, 8.7.9, 8.7.x-dev, 8.8.0, 8.8.0-alpha1, 8.8.0-beta1, 8.8.0-rc1, 8.8.1, 8.8.2, 8.8.3, 8.8.4, 8.8.5, 8.8.6, 8.8.7, 8.8.x-dev].
    - drupal/sms 1.3.0 requires drupal/core >=8.6 <8.9 -> satisfiable by drupal/core[8.8.8, 8.6.0, 8.6.0-alpha1, 8.6.0-beta1, 8.6.0-beta2, 8.6.0-rc1, 8.6.1, 8.6.10, 8.6.11, 8.6.12, 8.6.13, 8.6.14, 8.6.15, 8.6.16, 8.6.17, 8.6.18, 8.6.2, 8.6.3, 8.6.4, 8.6.5, 8.6.6, 8.6.7, 8.6.8, 8.6.9, 8.7.0, 8.7.0-alpha1, 8.7.0-alpha2, 8.7.0-beta1, 8.7.0-beta2, 8.7.0-rc1, 8.7.1, 8.7.10, 8.7.11, 8.7.12, 8.7.13, 8.7.14, 8.7.2, 8.7.3, 8.7.4, 8.7.5, 8.7.6, 8.7.7, 8.7.8, 8.7.9, 8.7.x-dev, 8.8.0, 8.8.0-alpha1, 8.8.0-beta1, 8.8.0-rc1, 8.8.1, 8.8.2, 8.8.3, 8.8.4, 8.8.5, 8.8.6, 8.8.7, 8.8.x-dev].
    - drupal/sms 1.3.0 requires drupal/core >=8.6 <8.9 -> satisfiable by drupal/core[8.8.8, 8.6.0, 8.6.0-alpha1, 8.6.0-beta1, 8.6.0-beta2, 8.6.0-rc1, 8.6.1, 8.6.10, 8.6.11, 8.6.12, 8.6.13, 8.6.14, 8.6.15, 8.6.16, 8.6.17, 8.6.18, 8.6.2, 8.6.3, 8.6.4, 8.6.5, 8.6.6, 8.6.7, 8.6.8, 8.6.9, 8.7.0, 8.7.0-alpha1, 8.7.0-alpha2, 8.7.0-beta1, 8.7.0-beta2, 8.7.0-rc1, 8.7.1, 8.7.10, 8.7.11, 8.7.12, 8.7.13, 8.7.14, 8.7.2, 8.7.3, 8.7.4, 8.7.5, 8.7.6, 8.7.7, 8.7.8, 8.7.9, 8.7.x-dev, 8.8.0, 8.8.0-alpha1, 8.8.0-beta1, 8.8.0-rc1, 8.8.1, 8.8.2, 8.8.3, 8.8.4, 8.8.5, 8.8.6, 8.8.7, 8.8.x-dev].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.0].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.0-alpha1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.0-beta1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.0-rc1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.2].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.3].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.4].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.5].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.6].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.7].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.8].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.x-dev].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.0].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.0-alpha1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.0-beta1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.0-beta2].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.0-rc1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.10].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.11].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.12].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.13].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.14].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.15].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.16].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.17].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.18].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.2].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.3].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.4].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.5].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.6].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.7].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.8].
    - Can only install one of: drupal/core[8.9.x-dev, 8.6.9].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.0].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.0-alpha1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.0-alpha2].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.0-beta1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.0-beta2].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.0-rc1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.10].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.11].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.12].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.13].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.14].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.2].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.3].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.4].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.5].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.6].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.7].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.8].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.9].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.x-dev].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.8].
    - Can only install one of: drupal/core[8.9.x-dev, 8.8.8].
    - drupal/core-recommended 8.9.x-dev requires drupal/core 8.9.x-dev -> satisfiable by drupal/core[8.9.x-dev].
    - Installation request for drupal/core-recommended ^8.9 -> satisfiable by drupal/core-recommended[8.9.0, 8.9.0-beta1, 8.9.0-beta2, 8.9.0-beta3, 8.9.0-rc1, 8.9.1, 8.9.2, 8.9.x-dev].
    - Installation request for drupal/sms (locked at 1.3.0, required as ^1.3) -> satisfiable by drupal/sms[1.3.0].

UPDATE #2:
I removed the composer.lock file and ran: composer install command!
A bunch of updates ran smoothly including drupal/core-dev (8.8.2 => 8.9.2), but when I visit /admin/reports/updates/update, I still can see update avaialble for Drupal core (Drupal core  8.8.8 -> 8.9.2) also in the composer.json file, the Drupal version is still "drupal/core-recommended": "^8.8" and in the
composer.lock file the Drupal version is:
"name": "drupal/core-recommended",
"version": "8.8.8",
"source": {
"type": "git",
"url": "https://github.com/drupal/core-recommended.git",
"reference": "69f4e74170c35f2069baafbbb5b7717fe5ddbb66"

Note: After composer install, I did run drush updb and drush cr
Comment: Did you try to remove composer.lock and run composer install again?
Comment: @Ahmad Yes I did try this but same list of errors and without new `composer.lock` file being generated.
Also `composer update` generated the same error while the `composer.lock`file is removed
Comment: Do not change the version in the composer.json file. Leave it as `^8.8` and then remove the composer.lock file and run `composer install`
Comment: @Ahmad I did remove the `composer.lock` file and kept the Drupal version `^8.8` then run `composer install` but still not working... Please check **Update #2** section of the question for more details. Thank you
Comment: Did you try removing composer.lock and vendor directory then updating?
Comment: the version will not be updated in composer.json but it should be updated in `composer.lock`.
Comment: Can you try `composer update drupal/core`?
Comment: @Ahmad when I run `composer update drupal/core` I received `Nothing to install or update`
Comment: @edg I did removed both `vendor` directory and `composer.lock` file then I run `composer install` and I noticed the command `Installing drupal/core-dev (8.9.2)` running but same happened as explained in **Update #2** section of the question.
Also both `composer.` files have the same `8.8.8` Drupal version !
I can't find a solution for this problem
Answer: I think you have to change the following lines of your composer.json
    "drupal/core-composer-scaffold": "^8.8",
    "drupal/core-project-message": "^8.8",
    "drupal/core-recommended": "^8.8",

with
    "drupal/core-composer-scaffold": "^8.9",
    "drupal/core-project-message": "^8.9",
    "drupal/core-recommended": "^8.9",

As the current settings constraints the drupal/core to 8.8.x version.
Comment: Can you please check the update to my question ?
Your suggestion did not work well for me
Comment: Did you manage ? This is the command I used : ```composer update drupal/core drupal/core-recommended drupal/core-composer-scaffold drupal/core-project-message drupal/core-vendor-hardening --with-dependencies```
Comment: @SimonVart , `^8.8` also allows for installation of `8.9.x`, so that shouldn't matter.


How would I find the scale factor of a dilated figure on a coordinate plane?

Question:
The above question is pretty simple, and I used common sense to figure out that the coordinates (3, -7) is the answer, since it is the only viable spot.
I was wondering how I would find the scale factor used to dilate figure ABCD. I tried using image/pre-image. That didn't work, because I was getting different results for different coordinates. I'd like to know a method on finding the scale factor.
Answer: I think you simply need to compute the ratio between the length of the segment $AD$ and the length of the corresponding segment $JM$, in this case:
$$\frac{\sqrt{(-4-(-2))^2+(-7-(-3))^2}}{\sqrt{1^2+2^2}}=\sqrt{\frac{20}{5}}=\sqrt{4}=2.$$


Calculating roller coaster loops - how to get x and y in terms of s?

Question: In this video, the author presents a method to calculate shapes of roller coaster loops. At 13:20, three differential equations are presented to plot the shape of a loop providing a constant force $G$ for an initial velocity $v_0$:
$\begin{align}
\frac{\partial\theta}{\partial s} &= \frac{G-g\cos\left(\theta\right)}{v_0^2-2gy} \\
\frac{\partial x}{\partial s} &= \cos\theta \\
\frac{\partial y}{\partial s} &= \sin\theta
\end{align}$
where $g$ is acceleration due to gravity, $9.80665~\text{m}/\text{s}^2$.
I would like to eliminate the need for the $\frac{\partial\theta}{\partial s}$ term. Do I integrate both sides of all these equations with respect to $s$ and then substitute $\theta$ in for the $x$ and $y$ equations, or am I stuck with three equations?
Another problem is that the first equation has $\theta$ and $y$ on the right side, so how would I proceed?
Comment: The unknown functions $\theta(s)$ and $y(s)$ both appear on the right-hand side of that first equation (the former composed with $\cos$ no less), so you might have some trouble integrating it directly.
Answer: if you use $\delta s = \delta y \sqrt{1+(\tan \theta)^{-2}}$ that changes first equation to
$$\frac{\partial\theta}{\partial y} = \frac{G-g\cos\left(\theta\right)}{(v_0^2-2gy)\sqrt{1+(\tan \theta)^{-2}}}$$
this allows you to separate all theta terms to one size and all y terms to the other
$$\partial\theta\frac{ 2\csc \theta }{\cos\theta-G/g} = \frac{\partial y}{(y-v_0^2/2g)}$$
now you integrate
$$2\int_0^{\theta} \frac{ \csc \phi}{\cos\phi-G/g} d\phi = \int_0^y\frac{dz}{(z-v_0^2/2g)}$$
RHS is $$\ln\left((1-\frac{2gy}{v_0^2})\right)$$
and LHS comes out to be
$$\ln \left[ \left(1-\cos \theta \right)^\frac{1}{1-G/g}  \left( \cos \theta +1 \right) ^\frac{1}{1+G/g} \left( \cos \theta - G/g \right) ^ {\frac{2}{(G/g)^2-1}}\right]$$
exponentiation of both sides
$$ y=v_0^2 /2g\left[1-\left(1-\cos \theta \right)^\frac{1}{1-G/g}  \left( \cos \theta +1 \right) ^\frac{1}{1+G/g} \left( \cos \theta - G/g \right) ^ {\frac{2}{(G/g)^2-1}}\right]$$
Comment: Are you using $ \frac{\partial \theta}{\partial s} = \frac{\partial \theta}{\partial y} \frac{\partial y}{\partial s} $ ?
Comment: Very cool technique!  I don't want to upvote because I don't believe I can give a well-enough informed opinion on the validity of all the steps.  I hope others will be able to check it.
Comment: used that the incremental path length differential $\delta s$ is equal to square root of sum of squares of differential increments along $y$-direction and along $x$-direction ... then just factor out a $\delta y$
Comment: So does $\sqrt{1+\left(\tan\theta\right)^{-2}}$ degenerate to $\csc\theta$?
Comment: Just curious about this, but what would $x$ be as a function of $\theta$?
Comment: i think your "very cool technique" comment is all the upvote i needed
Comment: @JakeMirra or the $\delta s = \delta y \sqrt{1+(\tan \theta)^{-2}}$ equation comes from OP equation 2 squared plus equation 3 squared ... this concept is key for path integrals and calculus of variations
Comment: @ElEctric yes ... made edits to answer to incorporate this (and other) simplification
Comment: due to conservation of energy, $y(\theta)$ directly gives you $\frac{ds}{dt}(\theta)=\sqrt {(v_0^2+2gy(\theta))}$ which then will uniquely determine $x(\theta)$


gitlab-ci.yml cannot resolve predefined environment variables

Question: In my .gitlab-ci.yml i'm trying to deploy on merge request.
My pipeline works, script is executed , everything is ok and running , but i'm not able to read any predefined environment variables. My files looks like :
<code> executeAutomationTests:
  stage: check
  only:
    refs:
    - merge_requests
  script:
    - echo $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
</code>
But $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME is not resolved. I need to know source branch for the merge_request in order to pull the code and make a deployment. I have tried other variables like : $CI_COMMIT_REF_NAME, $CI_JOB_STAGE , but non of them are resolved.
My GitLab version : GitLab Community Edition 13.4.2
Comment: Your job definition appears correct. I would take a closer look at your job output.
Answer: The problem was that in the pipeline job monitor the variable wasn't resolved and that's confused me. It was looking like :

So, for anyone who is fighting with such things, keep that in mind and also, keep in mind differences in syntax between powershell , bash and so on ..


Algorithms/methods for detecting regime changes in data rates

Question: I'm looking at multiple live data streams which I process on a daily basis and would like to monitor in real time.
The way I did it at first was to introduce a somewhat arbitrary upper bound for each of the streams..the monitoring would look at time elapsed between consecutive stream items and if it exceeds its threshold it would alert on possibly missing data on that stream. The problem with this approach is that the streams are very active at some points of the day and rather quiet at other points, so a hard coded limit ends up being unnecessarily high to avoid false alarms during the tranquil periods.
The second way I reworked it was to introduce bucketed data rate thresholds for each data stream. So, for example, something like: Stream A 4am threshold, Stream A 7am threshold, Stream A 5pm threshold...and the threshold used throughout the day is dependent on the time. This is more reasonable but the problem I have now is in coming up with appropiate times for each stream in a better way than arbitrarily choosing them for each data stream. For a given stream, I envision stepping through the data and generating "reasonable" buckets along with their threshold (for now I'm using twice the maximum time between items because their distribution is not approximately normal so I haven't looked at how to get a threshold time which would correspond to a certain low probability of occurrence) but I'm wondering where to start for this? And is this similar or identical to a well studied problem with solutions I might want to use?
Answer: Sounds like the streams you are interested in could be modelled as inhomogeneous Poisson processes.  Not surprising that the time between items is not normal --- I'm guessing it is closer to exponential. You may be interested in this white paper, which discusses a simple stat for detecting a change in rate of this type of data.    It might provide a data-based way to select the buckets for each stream.  In any case, you might want to look into change-point detection in general (e.g., https://stats.stackexchange.com/questions/tagged/change-point)
I could envision monitoring each stream for a few days, using the stat in the above paper (or some other change point algorithm) to find where the rate changes occur.  Then you can model each stream within that bucket as a Poisson process with the average rate seen over those few days.  Since you'd have a model for the data in each bucket, you could then get a probability that a stream is unusually active or tranquil at any particular time.


set_difference for a custom structure

Question: I am trying to find the difference between the following two sets:
A = {(0,0), (0,1), (1,0), (1,1), (2,2)}

B = {(0,0), (0,1), (1,0), (1,1)}

The answer I am expecting is
A - B = {(2,2)}

I tried the following code. But I am stuck unable to compile. Can anyone point out the mistake I am making?
#include <vector>
#include <algorithm>
#include <iostream>
#include <utility>

using namespace std;

class compare
{
  public:
    bool operator()(const pair <int, int> elem1, const pair <int, int> elem2)
    {
      return ((elem1.first == elem2.first) &&
          (elem1.second == elem2.second));
    }
};

int main()
{
  vector < pair<int, int> > v, va, vb;
  va.push_back(make_pair(0,0));
  va.push_back(make_pair(0,1));
  va.push_back(make_pair(1,0));
  va.push_back(make_pair(1,1));
  va.push_back(make_pair(2,2));

  vb.push_back(make_pair(0,0));
  vb.push_back(make_pair(0,1));
  vb.push_back(make_pair(1,0));
  vb.push_back(make_pair(1,1));

  vector < pair<int, int> >::iterator it, result;
  result = set_difference (va.begin(), va.end(),
      vb.begin(), vb.end(),
      inserter(v, v.end()),
      compare());

  // for (it = v.begin( ) ; it != result; it++)
  //   cout << "(" << it->first << it->second << ")" << ", ";
  // cout << endl;

  return 0;
}

EDIT:
The compile error message is the following:
set_difference.cc: In function `int main()':
set_difference.cc:36: error: no match for 'operator=' in 'result = std::set_difference [with _InputIterator1 = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >, _InputIterator2 = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >, _OutputIterator = std::insert_iterator<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >, _Compare = compare]((&va)->std::vector<_Tp, _Alloc>::begin [with _Tp = std::pair<int, int>, _Alloc = std::allocator<std::pair<int, int> >](), (&va)->std::vector<_Tp, _Alloc>::end [with _Tp = std::pair<int, int>, _Alloc = std::allocator<std::pair<int, int> >](), (&vb)->std::vector<_Tp, _Alloc>::begin [with _Tp = std::pair<int, int>, _Alloc = std::allocator<std::pair<int, int> >](), (&vb)->std::vector<_Tp, _Alloc>::end [with _Tp = std::pair<int, int>, _Alloc = std::allocator<std::pair<int, int> >](), std::inserter [with _Container = std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >, _Iterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >](((std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >&)(&v)), (&v)->std::vector<_Tp, _Alloc>::end [with _Tp = std::pair<int, int>, _Alloc = std::allocator<std::pair<int, int> >]()), (compare(), compare()))'
/usr/lib/gcc/x86_64-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_iterator.h:587: note: candidates are: __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >& __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >::operator=(const __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >&)

Comment: FFS. Computer, activate psychic hat.
Comment: What is the compiler error message?
Comment: Even if you get this to compile, You Will Have Problems.
Comment: @OliCharlesworth I added the compile errors.
Comment: @Kerrek can you suggest a better method of doing this?
Comment: You mean "a correct method"? I had one written up as an answer originally, but then saw that your actual problem was a compiling one, not a functionality one. I can undelete that if you like (and won't downvote it) :-)
Answer: (This is addressing the correctness of the algorithms, not the compilation problems.)
Read the documentation: The two input ranges already have to be sorted.
You also have to provide an output iterator for the result.
So do this:
std::sort(va.begin(), va.end(), compare());
std::sort(vb.begin(), vb.end(), compare());

set_difference(va.begin(), va.end(), vb.begin(), vb.end(),
               std::back_inserter(v), compare());

Your compare function should also define a strict, weak ordering, not an equality comparison.
By the way, std::pair<S, T> and std::tuple<T...> already come with built-in lexicographic comparison, so you shouldn't usually need to define your own comparison, unless you want something exotic: std::sort(va.begin(), va.end()); etc.
Comment: `inserter` constructs an output iterator.
Comment: @Kerrek Thanks for correcting the algorithm and for the helpful explanations. It is really unfortunate that I could not pick two answers.
Comment: @Anand: No worries :-) Enjoy the C++ iterators and algorithms!
Comment: I find this answer more worthy then the selected "best answer".
Answer: Your expectation is wrong: A - B is the set of elements in A not also found in B, which in your case is the empty set because every element in A is also found in B. B - A would give the result you expect.
Comment: I believe OP wants (A - B) + (B - A). Or, in math terms, B\A U A\B.
Comment: That's known as symmetric difference. But `set_difference` provides the set difference, as the name already suggests. So if the OP expects it to give the symmetric difference, his expectations are still wrong.
Comment: Change `v` to `v_l` and do `set_difference(vb, va, inserter(v_r))` for the right side. Then `v = v_l + v_r`. It will still produce unintended results unless the predicate `for (size_t i = 0; i < (v.size() - 1); ++i) v[i] <= v[i + 1]` holds for both va and vb.
Comment: No need to use another container. Since the inserter will just add to the existing container, reusing it for the second difference will automatically give the union (note that A-B and B-A are disjunct, therefore you don't have to worry about duplicates; however the result will not be sorted, so you might have to sort them afterwards if a sorted result is needed or desired).
Answer: OK, now with the error message posted it's clear what is the problem:
set_difference returns the output iterator, which in this case is an insert_iterator (constructed by your call to inserter). You try to assign it to result which is a vector iterator. This is a type mismatch.
The simplest solution would be to just omit that assignment and the iterator result because you don't need that iterator anyway; the results have been written to v.
Comment: Removing the assignment to `result` meant it compiled. Thanks a lot.

set_difference for a custom structure


How to apply Bayes' theorem to the search for a fisherman lost at sea

Question: The article The Odds, Continually Updated mentions the story of a Long Island fisherman who literally owes his life to Bayesian Statistics. Here's the short version:

There are two fishermen on a boat in the middle of the night.  While one is
  asleep,  the other falls into the ocean.  The boat continues to troll
  along on autopilot all through the night until the first guy finally
  wakes up and notifies the Coast Guard.  The Coast Guard uses a piece
  of software called SAROPS (Search and Rescue Optimal Planning
  System) to find him just in time, as he was hypothermic and just about
  out of energy to stay afloat.

Here's the long version: A Speck In The Sea
I wanted to know more about how Bayes' Theorem is actually applied here.  I found out quite a bit about the SAROPS software just by googling.
The SAROPS simulator
The simulator component takes into account timely data such as ocean current, wind, etc. and simulates thousands of possible drift paths.  From those drift paths, a probability distribution map is created.
Note that the following graphics do not refer to the case of the missing fisherman I mentioned above, but are a toy example taken from this presentation
Probability Map 1 (Red indicates the highest probability; blue the lowest)

Note the circle that is the starting location.
Probability Map 2 - More time has passed

Note that the probability map has become multimodal.  That is because in this example, multiple scenarios are accounted for:

The person is floating in the water - top-middle mode
The person is in a life raft (more affected by the wind out of the North) - bottom 2 modes (split because of "jibing effects")

Probability Map 3 - Search has been conducted along the rectangular paths in red

This image shows the optimal paths produced by the planner (another component of SAROPS).  As you can see, those paths were searched and the probability map has been updated by the simulator.
You might be wondering why the areas that have been searched have not been reduced to a zero probability.  That's because there's a probability of failure, $p(\text{fail})$, factored in, that is there's a non-negligible chance that the searcher will overlook the person in the water.  Understandably, the probability of failure is much higher for a lone person afloat than for a person in a life raft (easier to see), which is why the probabilities in the top area did not go down very much.
Effects of an unsuccessful search
This is where Bayes' Theorem comes in to play.  Once a search is conducted, the probability map gets updated accordingly so another search can be planned optimally.
After reviewing Bayes' Theorem on wikipedia and in the article An Intuitive (and Short) Explanation of Bayes' Theorem on BetterExplained.com
I took the Bayes' equation:
$$
P(\text{A}\mid\text{X}) =
 \frac{P(\text{X}\mid\text{A})
 \times
 P(\text{A})}{P(\text{X})}
$$
And defined A and X as follows...

Event A: The person is in this area (grid cell)
Test X: Unsuccessful search over that area (grid cell) i.e. Searched that area and didn't see anything

Yielding,
$$
P(\text{person there}\mid\text{unsuccessful}) =
 \frac{P(\text{unsuccessful}\mid\text{person there})
 \times
 P(\text{person there})}{P(\text{unsuccessful})}
$$
I found in Search and Rescue Optimal Planning System that SAROPS calculates the probability of a failed search, $P(\text{fail})$,  by taking into account the search paths and simulated drift paths.  So for simplicity let's assume that we know what the value of $P(\text{fail})$ is.
So now we have,
$$
P(\text{person there}\mid\text{unsuccessful}) =
 \frac{P(\text{fail})
 \times
 P(\text{person there})}{P(\text{unsuccessful})}
$$

Is the Bayes' equation applied correctly here?
How would the denominator, the probability of an unsuccessful search, be calculated?
Also in Search and Rescue Optimal Planning System, they say

The prior probabilities are "normalized in the usual Bayesian fashion" to produce the posterior probabilities

What does "normalized in the normal Bayesian fashion" mean?
Does it mean all probabilities are divided by $P(\text{unsuccessful})$, or just simply normalized to ensure the entire probability map adds up to one?  Or, are these one and the same?
Lastly, what would be the correct way to normalize the gridded probability map after you've updated for an unsuccessful search, considering that since you haven't searched ALL of the areas (grid cells) you'd have some cells equal to $P(\text{person there})$ and some equal to $P(\text{person there}\mid\text{unsuccessful})$?

Yet another simplification note - according to Search and Rescue Optimal Planning System the posterior distribution is actually calculated by updating the probabilities of the simulated drift paths, and THEN re-generating the gridded probability map.  In order to keep this example simple enough, I chose to ignore the sim paths and focus on the grid cells.
Answer:
Assuming independence between the grid cells, then yes it appears Bayes' Theorem has been properly applied.
The denominator can be expanded, e.g.
$$P(X) = P(X|A)P(A) + P(X|A^c)P(A^c)$$
using the law total of probability where $A^c$ is the complement of $A$, i.e. the person is not there. Likely you would assume $P(X|A^c)=1$.
I'm not really sure what "normalized in the normal Bayesian fashion means" since I didn't write the manual. But they are certainly talking about the fact that the following three equations are sufficient to find $P(A|X)$: $$P(A|X) \propto P(X|A)P(A)\quad P(A^c|X), \propto P(X|A^c)P(A^c), \mbox{ and } P(A|X)+P(A^c|X) = 1$$ So you never have to calculate $P(X)$, i.e. the normalizing constant. Whether they used this to update the probability for a single grid cell or for the entire map, I don't know (probably both).
Let's expand the notation to have grid cell $i$ and $A_i$ be the event the individual is in grid cell $i$ and $X_i$ be the event that grid cell $i$ was searched and nobody was found. With the new notation, $X$ is going to be the collection of searches that failed. We assume the following:

$\sum_i P(A_i|X)=1$, i.e. after performing searches, the sum overall cells of the probability that the individual is in that cell is 1. This is the total law of probability again.
If we assume searching in one cell does not tell us anything about any other cell, then for cells that were searched $P(A_i|X) = P(A_i|X_i)\propto P(X_i|A_i)P(A_i)$ and for cells that were not searched $P(A_i|X) \propto P(A_i)$. If we don't assume independence, the formulas will be more complicated but the intuition will be similar, i.e. calculating $P(A_i|X)$ up to a proportionality constant.

We can use these two assumptions to calculate $P(A_i|X)$ and update the map accordingly.
Comment: Thank you for the excellent answers ;)  So, assuming grid cell independence and $\sum_{i}P(A_i|X)=1$, after searching every cell once would it be valid to calculate $P(X|A)P(A)$ for each cell and then divide each cell by the sum of all cells ($\sum_{i}P(X|A)P(A_i)$) to normalize?
Comment: I just realized that searching every cell with a fixed probability of failure would result in absolutely no change among the probability distribution :)
Comment: So to rephrase...   Assuming the law of total probability (as in your answer to 4.), after some (but not all) of the cells were searched could we normalize by dividing each cell by the sum of all of the cells? ...using $P(X|A)P(A_i)$ for the value of cells that have been searched and $P(A_i)$ for those that haven't.
Answer: I was pointed to a book that has a whole chapter dedicated to my question - Naval Operations Analysis - by a former professor who used to be a helicopter pilot and has actually performed search and rescue missions, no less!
In chapter 8 an example is provided something like this (I customized it a bit):
To start with, there's a gridded prior distribution for the location of the missing person(s), boat, etc.
Prior distribution:

A search is performed on part of the grid and the probabilities are updated with a normalized posterior distribution by applying the Bayes' equation in the same way I mentioned in my questions:
$$
P(\text{target in (i,j)}\mid\text{no detection}) =
 \frac{P(\text{no detection}\mid\text{target in (i,j)})
 \times
 P(\text{target in (i,j)})}{P(\text{no detection})}
$$
where (i,j) = (lat,long)
In this case, I decided to search column 3 because that column had the largest total prior probability.
Normalized posterior distribution after searching the third column w/ pFail = 0.2:

My question was mainly about how the posterior was normalized.  Here's how it was done in the book - simply divide each individual posterior probability by the total sum, S:

I chose a 0.2 probability of a failed search because my professor had this to say, "We only search to 80% probability of detection because that is typically the best tradeoff between timlieness and accuracy."
Just for kicks, I ran another example with a pFail of 0.5.  Whereas in the first example (pFail = 0.2), the next best search route (given the normalized posterior and assuming straight-line searches, no diagonal or zig-zag) would be to fly over column 2, in the second example (pFail = 0.5) the next best route is over row 2.
Normalized posterior distribution after searching the third column w/ pFail = 0.5:

He also added this, "Aircraft carry a small checklist with them to help determine best altitude and airspeed.  Working this in a flying helicopter is like sitting atop a washing machine, reading a book that is duct taped to a different washing machine."


A odd question php OOP

Question: Hey guys.  I was designing a model for some data, and wanted it to work like: $this->groupmodel->VARIABLE->FUNCTION(VAR1, VAR2); to call a function, where VARIABLE is changeable to anything, and passed to the function.
This feels more correct (then say $this->groupmodel->FUNCTION(VARIABLE, VAR1, VAR2)), because each VARIABLE has the exact same functions, and the functions are being preformed (technically) on VARIABLE.  Is this possible?
Note that VARIABLE can be set anywhere (in its own function or in the function being called) (it is persistent throughout the class, but needs to be set each call).
Max
Comment: I love how someone who has no idea how my program functions will jump to such high conclusions about how it *should* be done.
Comment: It is not an *OOP*, it is an attempt to do terrible things using objects. *OOP* **is** a paradigm invented to lower complexity of programs, make programs more clear, understandable and readable. But you want something that will prevent of following all those ideas.
Comment: In fact, the example that mazzzzz posted resembles somehow the approach some languages have to implementing OOP.  The object being called is automatically referred to as $this, and that's pretty much all.
Answer: You should create a class implementing the functions you want to use, and all your "variables" should be objects of that class.  For instance:
class Kid {
    private $age = 0;
    public function _construct($age){
      $this->age = $age;
    }
    public function birthday() { // implement in Kid instead of in Groupmodel
      $this->age++;
      echo "Growing old... ";
    }
    public function age($age_new = null){  // age setter and getter
      if(!is_null($age_new)){
        $this->age = $age_new;
      }
      return $this->age;
    }
}

And then inside your groupmodel:
class GroupModel {

  private $variables;

  public function _set($name, $value) {
    if (array_key_exists($name, $this->variables)) {
      $this->variables[$name]->age($value);
    } else {
      $this->variables[$name] = new Kid($value);
    }
  }

  public function _get($name) {
    if (array_key_exists($name, $this->variables)) {
      return $this->variables[$name];
    } else {
      return null;
    }
  }
}

so you can call:
$this->groupmodel = new GroupModel()
$this->groupmodel->var1 = 8
$this->groupmodel->var1->birthday();  // will add 1 to var1's age and print "Growing old"
$this->groupmodel->var1 = 9  // will replace var1's age

What we are doing here is creating objects of class Kid automatically every time you try to set a property of the GroupModel object.  (This is what the magic method _set() does)
In fact it creates them as elements of a private array instead of real properties of GroupModel.
Then, when trying to access those "properties", _get() will be invoked and it will retrieve the element of the array and return it.
As it will be an object of class Kid, you could call every method it implements (like birthday()).
For more information on Overloading and magic methods like _get and _set, see:
http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members
Comment: Could you be a bit more descriptive in you example?  If I wasn't to clear, each function after `variable` is the exact same for each `variable`.  I don't see how I can adapt your solution to do that.
Answer: PHP 5.3 let you use very nice thing called late static bindings
Lets say you have 2 classes: Foo which extends groupmodel:
class groupmodel {
      const MY_CONST = 'groupmodel';

      protected function myName(){
         echo static::MY_CONST; //Will print 'groupmodel';
      }

      protected function whoAmI(){
        //do something here
      }
}

and Foo:
class Foo extends groupmodel {
      const MY_CONST = 'ClassFoo';

      public function tellMyName(){
        $this->myName(); //Will print 'ClassFoo';
      }
}

Actually, the idea is instead of using
$this->groupmodel->FUNCTION(VARIABLE, VAR1, VAR2)
OR
$this->groupmodel->VARIABLE->FUNCTION(VAR1, VAR2);

you will use:
$object = new Foo();
$object->tellMyName(); //Will print 'ClassFoo'

and now $object will grant all of groupmodel methods.
another important thing with your case and for working with OOP as much as you can is setting up an abstract class
Comment: You talk of late static binding, but you don't use it.  None of the functions are static.  This will work without late static binding (except for the static keyword).
Comment: I agree that you may use it while using static methods, but you can use it on your instance. so if you will use self::MY_CONST it won't work (see my example).

You will be able to do some more sophisticated things, and create a fully dynamic inheriting by using late static bindings with both of method types (static and instance).
Answer: Yes it is possible.  php allows you to use variables for both member and function access.  For example: $this->groupmodel->$myvar->myfunc($var1, $var2);
This will call $this->groupmodel->{Whatever-string-is-stored-in-myvar}.
Note that if you want to do this, groupmodel must be set in the class and $myvar must be a public member in the groupmodel and the contents of $myvar must be a valid member that is also a class that implements myfunc().  This is a lot of coupled dependency (hence zerkms' disparaging of this approach).  Would help to know what you're trying to do, though.
Comment: groupmodel manages a group of people.  The groupmodel class is stateless (nothing rolls over from one function call to the other), so I need to set which member of the group (retrieved from the db) I am running the function on (and sense it's a model, and saved directly to the database, I reasoned it should just be stateless).  I wanted an intuitive interface for each member (instead of including their name in the function call, and that is how I came up with this.

A odd question php OOP


Outlook Desktop search contacts To/Cc/Ccn fields during typing

Question: Our company migrate from KerioConnect to Office 365 to better manage
the emails. Lots of people in the company have the same problem, can't
search for contacts when creating a new email and typing in the "To"
field (Click on the "To" button correctly open the address book and
the contacts are shown). I have 10 contacts in my personal folder,
before the migration when I type the name of the person in the "To"
field a list with contacts appear, after the migration this doesn't
happend. Typing the name in the box appear only the email that I have
alredy write to, but not the email saved in contacts.
This seems to be a problem only for some office installation. Here is
a list of the clients:

Do you have any idea on how to solve that?
Answer: Have you tried to export the previous contacts from KerioConnect data base into a .csv file and then import that file into your new outlook database? If user names are the same then it should link contacts to the usernames listed in the .csv. There also are various powershell scripts you can find online to migrate the contacts data.
Comment: Hi, the problem is not that I miss the contacts inside my personal folder. I can't search real-time when typing inside the "To" field, I have to click on the "To" button and search inside the address book. The real-time search only work for the contacts that I have alredy write one-time, but not for the one that I never write before. Using Outlook For Microsoft 365 MSO this real-time search inside the "To" field correctly work, but not on the others installations
Answer: According to a number of articles, there is no way to configure Outlook to use the entire Address Book when generating auto-complete suggestions.

https://answers.microsoft.com/en-us/msoffice/forum/msoffice_outlook-mso_win10-mso_2016/outlook-2016-auto-complete-email-from-global/bea86a68-bb65-4b66-879f-c166ab70d286

There is no setting that I'm aware of that would enable Outlook (desktop) to search the GAL which is part of the Outlook Address Book which in turn is what gets opened when you click on TO/Cc/Bcc.

https://www.msoutlook.info/question/53

[T]he AutoSuggest feature doesn't have a direct relation to your Contacts folder or other address lists configured in your Address Book. Instead, AutoSuggest uses a cache which contains a list of addresses that you've previously used.

If you have a small(ish) number of contacts in the address book, there is a workaround that will load them into the AutoSuggest cache. From https://www.msoutlook.info/question/filling-the-autocomplete-list-with-contact-addresses :

You can directly fill the Auto-Complete list again by creating a new message addressed to all your contacts at once. There is no need to actually send this message.

Create a new message.
Press the To… button.
Select the contact list in the right top corner from which you would like to add the contacts from. Examples; Contacts folder, Global Address List (GAL) or a contacts folder in a Public folder.
Select the first contact.
Scroll all the way down to your last contact.
Hold the SHIFT button on your keyboard while clicking on the last contact to select them all.
Press the To –> button to add them all to the To… field.
Repeat step 3 to 7 if you have contacts in additional lists that you would like to add.
Press OK to close the dialog and to return to the newly created message.
Now, depending on your Outlook version, do the following;

Outlook 2007: Close the message and press "No" when prompted to save changes.
Outlook 2010 / 2013 / 2016 / 2019 / Office 365: You must send the message to actually store these addresses in the AutoSuggest cache. However, by placing Outlook in Offline Mode first via the Send/Receive tab, you can easily prevent it from actually being sent by removing it from the Outbox and then place Outlook back online mode.

Now when you address a new message, the AutoSuggest/Auto-Complete feature will pop-up again.
Answer:
Typing the name in the box appear only the email that I have alredy write to, but not the email saved in contacts.

By this, do you mean the autocomplete list only shows "Recent People" but no "Other Suggestions" or "Suggestions"?
If possible, could you remove all personal information and share a screenshot of both the working and non-working scenario so that we can understand better about the situation?

before the migration when I type the name of the person in the "To" field a list with contacts appear, after the migration this doesn't happend.

Was the office version changed after the migration?
Besides, please try testing on one of the problematic machine by creating a new Outlook profile and see if there would be any difference.


"Playing cornet in open style"?

Question: I am reading a jazz book, "Really The Blues" by Mezz Mezzrow, in which a 1920's cornet player, Bix Beiderbecke, was referred to as playing his horn mostly " open".

He played mostly open horn, every note full, big, rich and round

I'm assuming this is a sort of slang in jazz for a certain style of cornet. I understand that the Bb cornet overtones are C, G, C, E, G with no valves pressed. Has anyone heard the term "open" style?
Comment: Sometimes people talk about playing a horn "open" as distinct from playing with a mute. I have seen Bix discographies that make this distinction, and I suspect that this is what is meant.
Comment: As a side note, if you want a super 'round' huge sound,  play a flugelhorn.  Compared with aflug, a trumpet is "thin' and strident.
Answer: Open horn in this context means to play unmuted. Other cornet/trumpet players were known for the distinct sound they made with a particular mute.
A classic example from a later era is Miles Davis, who was known for his Harmon mute.
Some trumpet players well-known for their mute use closer to Bix Beiderbecke's time are Bubber Miley, Cootie Williams, and King Oliver.
Comment: It's important context that playing with a mute is much more common in Jazz than it is for Classical. From someone with a Classical background, playing without a mute is assumed unless otherwise specified, and you wouldn't really need an extra adjective to describe it as a playing style. In contrast, Jazz makes much more extensive use of mutes, so eschewing a mute warrants special mention.
Answer: The book mentions "every note full, big, rich and round". This means that the instrument is playing unmuted, therefore is "open".
According to David Summer Music Studio (https://www.summersong.net/music-teacher/trumpet-lessons/brass-instrument-mutes/), it also mentions:

When the performer should remove the mute, the word "Open" is used.

In other words, when the instrument is playing while unmuted, it is open. This website refers to brass instruments, including the trumpet and French horn.
Hope this helps.
Comment: And note that when you insert a mute in the bell, you are partially closing off the outflow of air.

"Playing cornet in open style"?


configuring lighttpd for large downloads

Question: i run a web site that hosts pages that are just general scripts (php, etc) and mp3 downloads (some of which are fairly large - up to 200mb).  i am running lighttpd on the servers on linux (ubuntu 64).  everything is fine, but under high load, the server is not accessible (or very slow - even sshing in takes a while), and i am guessing this is due to a huge number of mp3 downloads at that time.  consequently, dns sees the server as down and redirects all the traffic to the other servers, and after a while, it comes back up and things work again.
so what's the best way to fix this?  ideally, i want the server to continue running (and the web pages - php etc - to always work, but downloads don't always have to work).  should i just have 2 web servers running (one for the downloads and one for the php pages), or is it perhaps something i can fix in my lighttpd configuration?
here are the snippets from my configuration:
<code>server.max-worker = 4
server.max-fds = 2048
server.max-keep-alive-requests = 4
server.max-keep-alive-idle = 4
server.stat-cache-engine = "fam"

fastcgi.server    = ( ".php" =>
        ((
                "bin-path" => "/usr/bin/php-cgi",
                "socket" => "/tmp/php.socket",
                "max-procs" => 1,
                "idle-timeout" => 20,
                "bin-environment" => (
                        "PHP_FCGI_CHILDREN" => "64",
                        "PHP_FCGI_MAX_REQUESTS" => "1000"
                ),
                "bin-copy-environment" => (
                        "PATH", "SHELL", "USER"
                ),
                "broken-scriptfilename" => "enable"
        ))
)

# normal php site
$HTTP["host"] =~ "bar.com" {
    server.document-root = "/usr/local/www/sites/bar.com/"
    accesslog.filename = "|/usr/sbin/cronolog /var/log/lighttpd/%m/%d/%H/bar.log"
}

# download site
$HTTP["host"] =~ "(download|stream).foo.com" {
   server.document-root = "/home/audio/"
   dir-listing.activate = "enable"
   dir-listing.hide-dotfiles = "enable"
   evasive.max-conns-per-ip = 1
   evasive.silent = "enable"
#   connection.kbytes-per-second = 256
   accesslog.filename = "|/usr/sbin/cronolog /var/log/lighttpd/%m/%d/%H/download.log"
}
</code>
Answer: Few things:

Adjust your maximum write idle.

Don't run FCGI/PHP on the server serving static content, it will slow you down and append garbage session data everywhere.

Disable any sort of error/access logging.

Add caching entries: setenv.add-response-header = ( "Cache-Control" => "public, max-age=86400" )

Use mod_expire: expire.url = ("/mp3s/" => "access 2 years")
Don't use connection.kbytes-per-second, it's a bit flaky. I would use OS/hardware level firewall for this.


Customizing Wordpress parent/child comments?

Question: Here is what I'm trying to do, and I understand the way that wordpress has it already set up, but I rely heavily on being able to modify and basically change whatever I need too, and in core files as well. However, I am using multisite so changing the core file's is now not an option.
The image below is somewhat how I am wanting the final product to appear, but I noticed other than using wordpress's ul, ol & li styles, I need to be able to customize it more than what has been provided by that, just in case you are wondering why I'm taking the hard way.
Anyways, looking at the image below, where the white rectangle is, I'm wanting to be able to change the color and ultimately allow myself to change the formatting to whatever I want that is different for all user replies. I have no idea how I'd write it, but more than likely it'll have to be an if/else statement. Basically, it'll say:
If parent (depth 0) comment, display this formatting, else (depth of 1 or greater, which would be a child reply), this display it this. Any idea's?
Here is my functions theme file and my comments theme file. AND just in case, the comment-template file under the wp-includes that says how to display and label the comments as parents/children.

I'd also like to point out, that I'm looking for help and suggestions, not criticism. If I knew the answer, I wouldn't be asking for help.
Comment: How is this a MySQL question?
Comment: Because, the final code will more than likely include syntax references in it.
Answer: Based off of what BDHorrigan said, I came up with the following:
<code>blockquote {
  background: #292929;
  border-left: 7px solid #00D9FF;
color: #A3B808;
  margin: 1.5em 10px;
  padding: 0.5em 10px;
}

blockquote:nth-child(1) {
    border-left: 7px solid #FFBE40;
}
</code>
This allowed every child reply to be the same because they would be all at a nth-child of 1. Thank you!
Answer: If it's just colour you want to change, is there any reason you can't just use CSS? E.g. make a rule for li.depth-1, another for li.depth-2, etc.?
Comment: The thing is that the parent comment uses blockquote, and has it's own styling. The way they changed the comments, the child automatically adapts the parent coding, which includes the blockquote/css, and that is what I'm trying to change. I want it to stop using the blockquote/css at the child, but still allow all parents to use the blockquote, etc. Hopefully I am making sense. And it'll be more than just the color, I'm talking about total control over how the comments are displayed and be able to individually display aspects of it ultimately.
Comment: If there is anything else that can be done instead, I'd happily take it.


How To Create Combined Search Filters In Views?

Question: I am currently working on a view that allows me to search "title" of a content type along with 3 other exposed filters. But now I want users to not only be able to search "title" but also "category" field of the same content type, except "title" and "Category" fields need to be one filter.
I tried using contextual filters but I'm afraid I don't quite understand the best method. I'm currently using global:combine fields filter but instead my views results (which worked fine previously) no longer works. I'm trying to avoid complicated coding. Any suggestion?
Answer: The newest version of Views integrates this feature without the need for Views filter populate.  It's a filter called Combine fields filter.
To make use of it you first need to add all of the fields you want to filter on.  You may check Exclude from display if you want to search for it, but don't want to display it.
Once all of the fields are there, add a Combine fields filter, and choose to Expose it.  Choose Single field for the Filter type to Expose
This is a different approach than Views populate filter, but as this is integrated into Views I find it much more intuitive.
Answer: We use this module all over the place, it works just like it says.  Only limitation is that it only works on String fields (Node Reference, Taxonomy ID, etc. won't work).
Views filters populate

This is an utility module. Its sole purpose is to fill in one blank that seems not easy to be done using normal views, which is to use one exposed string filter to search on multiple fields.
Comment: hey thanks..hmm it might work but my categories field are also taxonomy terms linked from my content to taxonomy by node reference. :( Is there any way i can search both taxonomy and node IDs with just one input?


Solve the equation using logarithms

Question: Equation
$$
e^{2x+1.21} = 114\cdot 4^x
$$
steps I've done so far.

$2x + 1.21 = \ln(114) \cdot \ln(4) \cdot x$
$x = (\ln(114) * \ln(4))/1.21$

I don't think I was allowed to move the $x$ from the right side to the left the way I did.
Answer: It should be
$$2x+1.21=\ln(114)+(\ln 4)x.$$
(Recall that if $a$ and $b$ are positive, then $\ln(ab)=\ln(a)+\ln(b)$.)
The rest should not be difficult. The displayed equation is linear in $x$. Bring the $x$ stuff to one side, and everything else to the other side.
Comment: I got x(2 + (ln4)) = ln(114)-1.21 which lead me to my final answer x =(ln(114)/(ln(4)) -3.21 and I'm still getting a wrong answer.
Comment: Yes, because it should be $x(2-\ln 4)=\ln(114)-1.21$, giving you $x=\dfrac{\ln(114)-1.21}{2-\ln 4}$.
Comment: Thank you! I need to refresh on my Algebra. Multiply and dividing polynomials is what I am lacking, right?
Comment: There was a slip about logarithms, easy to make. There was later a problem with a linear equation kind of problem basically like $7x+1-=3x+49$, except with more complicated numbers.  Ideally there should be no issue with these, they come up pretty often.

Solve the equation using logarithms


Cannot autowire service

Question: Como resolvo o seguinte erro:
Cannot autowire service "App\Service\ResponseService": argument "$sucesso" of method "__construct()" is type-hinted "bool", you should configure its value explicitly.
ResponseService.php
<?php

namespace App\Service;

use Symfony\Component\HttpFoundation\JsonResponse;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;

class ResponseService extends ServiceEntityRepository
{
    /**
     * @var bool
     */
    private $sucesso;

    /**
     * @var int
     */
    private $paginaAtual;

    /**
     * @var int
     */
    private $itensPorPagina;

    private $conteudoResposta;

    public function __construct(
        bool $sucesso /*,
        int $paginaAtual,
        int $itensPorPagina,
        $conteudoResposta*/
    )
    {
        $this->sucesso = $sucesso;
        /*$this->paginaAtual = $paginaAtual;
        $this->itensPorPagina = $itensPorPagina;
        $this->conteudoResposta = $conteudoResposta;*/
    }

    public function getResponse(): JsonResponse
    {
        $conteudoResposta = [
            'sucesso' => $this->sucesso,
            'paginaAtual' => $this->paginaAtual,
            'itensPorPagina' => $this->itensPorPagina,
            'conteudoResposta' => $this->conteudoResposta
        ];

        return new JsonResponse($conteudoResposta);
    }
}

metodo que chama ResponseService:
public function buscarTodos(Request $request): Response
    {
        $informacoesDeOrdenacao = $this->extratorDadosRequestService->buscarDadosOrdenacao($request);
        $informacoesDeFiltro = $this->extratorDadosRequestService->buscarDadosFiltro($request);
        [$paginaAtual, $itensPorPagina] = $this->extratorDadosRequestService->buscaDadosPaginacao($request);

        $entityList = $this->repository->findBy(
            $informacoesDeFiltro,
            $informacoesDeOrdenacao,
            $itensPorPagina,
            ($paginaAtual - 1) * $itensPorPagina
        );

        $resposta = new ResponseService(
            true,
            $paginaAtual,
            $itensPorPagina,
            $entityList
        );

        return $resposta->getResponse();
    }

Comment: https://symfonycasts.com/screencast/symfony-fundamentals/service-config Veja se ajuda
Answer: Consegui resolver.
no services.yaml acrescentar:
App\Service\ResponseService:
arguments:
$sucesso: bool
$paginaAtual: int
$itensPorPagina: int
$conteudoResposta: '%kernel.debug%'

Cannot autowire service


What's voice leading and how does it work?

Question: What's is voice leading and how does it work? I'd really appreciate a thorough answer. What I mean by how it works is how is it achieved and what's the basis of it?
Comment: Check this question and answer out: http://music.stackexchange.com/questions/7185/voice-leading-confusion?rq=1 "*Most generally, voice-leading is just the way voices move about in a piece. Usually, good voice leading means that each voice feels smooth, atleast somewhat independent, at least somewhat interesting, and supportive of the background harmony and feel of the piece.*"
Answer: Voice leading is where you write harmony as if you have several instruments, each playing an interesting melody (or at least playing a line that, although it may be boring sometimes, is not UN-melodic, leaping all over the place).  The voices, in combination, form chords, but you're not just plonking down one chord after another.


django-silk Page not found

Question: I did the install and I see the tables silk makes in my database so I know it is working but when I do the 127.0.0.1:8000/silk I get Page not found.
I did add the path('silk', include('silk.urls', namespace='silk')), to my urls file. I added 'silk.middleware.SilkyMiddleware', after 'django.contrib.sessions.middleware.SessionMiddleware'. Any ideas?
Comment: Dumb! I forgot to add the / after silk. silk/ is the answer!
Answer: In my case it was the order of urlpatterns in url.py, I needed add path at the front instead of extending the list later on like:
<code>urlpatterns = [
    path("silk/", include("silk.urls", namespace="silk")),
</code>

django-silk Page not found


Printing at 11.5 inch in SSRS

Question: I have an SSRS data report.  The interactive size and paper size, both are set to 8.5 X 12 inches.  But when I print this report, it does not print at 11.5 inches.
The bottom margin is also set to 0
Please advise.
Thanks
Answer: You might be using landscape mode change it to portrait mode and try it
Answer: To my knowledge SSRS will let you have the 'body' of the report go over margins and this could be an issue but also the default size of portrait is 8.5 x 11.  I would do three things:

Go to the report designer and click anywhere in the blank space to ensure the 'Report' option toolbar displays.  Click it and you should have your orientation set up here to explicitly state Width: 8.5in, Height: 12in.  Set the margins explicitly here as well.  You may have already done this so I apologize if it is redundant
There is a toolbar menu view called 'Report' it contains an L with the point in the upper left.  This will show you inches marked out for you.  I would select that and see if there is anything obvious going over or under set requirements.
Check your printer options where this is being printed.  Does the printer know that the paper is not standard size?  Sometimes certain drivers will not use 100% of the page and use a tiny bit of padding or else assume you are using 8.5 x 11.  I would verify with something other than SSRS you can get the output you want as well.

Printing at 11.5 inch in SSRS


How do I make uWSGI restart when a Python script is modified?

Question: Can't remember where, but I read uWSGI can reload itself like Django development server when a project script is modified. I can't find that in the docs, nor in the internets. How can I do this?
I use Ubuntu 12.04 on my working machines and Debian Squeeze on stage & production server, Django 1.4 and uWSGI 1.2.
Answer: Reference: http://projects.unbit.it/uwsgi/wiki/Management
If you have started uwsgi with the --touch-reload=/path/to/special/file/usually/the.ini option, reloading your uWSGI is a simple matter of touch reloading that file with
touch /path/to/special/file/usually/the.ini
And if you want the "autoreload" capability, this is the tip that gets this done:
http://projects.unbit.it/uwsgi/wiki/TipsAndTricks#uWSGIdjangoautoreloadmode
Comment: 11 years later, please note that touch-reload needs a file that has been changed by the app in order to work. In my case, that file is not the ini, but some html file that my Flask app generates.
Answer: There is a py-autoreload=N option in newer releases. Just set N to the frequency (in seconds) of checks (3 is a good value).
Comment: "use only in development" according to [uwsgi docs](http://uwsgi-docs.readthedocs.org/en/latest/Options.html#py-auto-reload-py-autoreload-python-auto-reload-python-autoreload)
Comment: looks like [touch-reload=/some/file](http://uwsgi-docs.readthedocs.org/en/latest/Options.html#touch-reload) is a safer option
Answer: If you don't want lose the django autoreload, register this reload method (i.e: in settings.py):
import uwsgi
from uwsgidecorators import timer
from django.utils import autoreload

@timer(3)
def change_code_gracefull_reload(sig):
    if autoreload.code_changed():
        uwsgi.reload()

Now if you change your code it will be reloaded.
Author: Simone Federici
Comment: This worked perfectly. Also added a conditional so this only gets called in the development environment.
Comment: `autoreload.code_changed` no longer exists.  what should we use in 2021?
Answer: uwsgi also allow restart using kill SIGNAL. I use it as below:
# ps -efa | grep uwsgi | grep prod
app  13390 13383  0 07:40 ?        00:00:00 /usr/local/bin/uwsgi --ini /etc/uwsgi/apps-enabled/app_prod.ini
app  13417 13390  0 07:40 ?        00:00:00 /usr/local/bin/uwsgi --ini /etc/uwsgi/apps-enabled/app_prod.ini
app  13419 13390  0 07:40 ?        00:00:00 /usr/local/bin/uwsgi --ini /etc/uwsgi/apps-enabled/app_prod.ini
# kill -HUP 13390

If you run same command, you will see child procs pid will be changed as they are re-spawned by master. Also check uwsgi config for master/worker proc counts. This method is easy to integrate with ansible or other automation tools so goes easy to for remote use.
This doesn't need your original proc to be started with --touch-reload.
Answer: As stated in docs to make uWSGI gracefully restart.
# using kill to send the signal
kill -HUP `cat /tmp/project-master.pid`
# or the convenience option --reload
uwsgi --reload /tmp/project-master.pid
# or if uwsgi was started with touch-reload=/tmp/somefile
touch /tmp/somefile


Rejecting a model in favor of another

Question: Let's say currently there is a specific time series forecasting model A in use for some case and I want to test and prove whether another model B is significantly better and should replace model A.
What will be the way to do that statistically? I thought of getting both models MSE and then check if the difference is significant but I saw somewhere that this will work when I need just to choose a model and not try and reject one for another.
Answer: The 'best' way to chose your final model would to compare some goodness of fit statistic based on a holdout sample. For example, if the MSE for model A is materially better than it is for model B, you'd chose model A as your final model. However, if there's no material difference, I'd chose the model that's easiest to interpret and makes the most sense.
If the model A is nested within model B (or vice versa), and the likelihood exists, you could have a look at using a likelihood ratio test. This will give you a more concrete framework for choosing one model over the other.
Comment: Choosing the 'best' model is a bit of an art. There's no hard and fast rule or statistical test. In general, model selection should be based on a combination of subject matter knowledge and goodness of fit statistics. Back to your example - say model A is an ARIMA (MSE = 1.4) and model B is a LSTM network (MSE = 1.3). Model B is much more complex compared to model A, and only gives slightly better performance. For that reason, I'd chose model A over model B. If you wanted some sort of empirical cut-off, you could chose model A over model B whenever the MSE is 10% smaller (or vice versa).
Comment: And how can I be sure the difference is material? Is there some statistical test to justify that?
Answer: So if you have a holdout set then your stat test will either say model a is significantly better than model b or not.  If it's significantly better then it just agrees with your holdout test. But if it's not 'significantly' better then how would you choose your model?  You would probably just use the holdout set accuracy.  So there isn't much use in the statistical test unless you want to know if changing the model is worth the effort like if it has to be switched into production.
Either way, I would just use the holdout accuracy and set a threshold for % increase in accuracy of the holdout set as a 'test'.
Comment: Yep, so I would attempt to equate accuracy back to some dollar amount. For example an increase of performance of 10% would decrease the cost of holding inventory by 5 million.  That would help you make your final decision, if the accuracy gain isn't worth the hours to change models for production then don't do it.  Alternatively, if you just want to tell people that your model is better with high confidence then you could do more rigorous cross validation: https://otexts.com/fpp3/tscv.html .
Comment: The case here is that there is one model in use. That's why I want some assurance that the alternative model is not only slightly better, so it will be worth the transition.

Rejecting a model in favor of another


The unit ball $S^n$ is homeomorphic to the one-point compactification of $R^n$

Question: I saw many different proofs in the community of the statement in the title. And I want to demonstrate my proof of the general case.
I have tried to show the one-point compactification is homeomorphic to $S^n$ directly, but encountered difficulty in showing the continuity. So I found another clean proof which I want to share with you.
Comment: Possible duplicate of [Question on one point compactification](https://math.stackexchange.com/questions/1300027/question-on-one-point-compactification)
Answer: Let $p={(0,0,...,0,1)} \in R^{n+1}$, and consider the stereographic projection $$
f: S^n\setminus\left\{ p\right\} \rightarrow R^n
$$
defined by $$
f(x_1,x_2,...x_{n+1})=\frac{1}{1-x_{n+1}}(x_1,x_2,...x_n)
$$
Now we can directly show that $f$ is a bijective map by direct calculation of the coordinates.
Let $\pi_i:R^n\rightarrow R$ be the projection map. It suffices to show that $\pi_i \circ f$ is continuous for the continuity of $f$. So let $(a,b) $ be an open interval in $R$, we have
$f^{-1}(a,b)=\left\{ x_i\in R: a<\frac{x_i}{1-x_{n+1}}<b
\right\}\cap S^n$,
which is open in $S^n$. So $f$ is continuous.
Consider the one-point compactification $S^n$ of $S^n\setminus\left\{p \right\}$. (One-point compactification is unique up to homeomorphism). We can apply Tietze Extension theorem to get $f_0$, a continuous extension of $f$ on $S^n$. Since $S^n\setminus\left\{p \right\}$ is dense in $S^n$, we have the continuous extension being unique.
Claim: $f_0$ is bijective.
To prove the claim, it suffices to check whether $f_0(p)=a$ for some $a \in R^n$. Suppose so, we consider the sequence $\zeta_n=(\frac{1}{n},0,0,...,0,\sqrt{1-\frac{1}{n^2}})\in S^n\setminus\left\{p \right\}$.
$f_0(\zeta_n)=f(\zeta_n)=(\frac{1}{n-\sqrt{n^2-1}},0,0,...,0)$.
But $$\lim_{n\to\infty} \frac{1}{n-\sqrt{n^2-1}}=\lim_{n\to\infty}(n+\sqrt{n^2-1})$$ does not exist in $R^n$.
So we must have $f_0(p)=\infty$.
Now $f_0$ is a continuous bijection from a compact space $S^n$ to a Hausdorff space $R^n \cup \left\{\infty\right\}$. So it is a homeomorphism.
Comment: The Tietze extension theorem? Do you really need that? If $X$ is a compact Hausdorff space, and $X-\{x\}$ is homeomorphic to a locally compact space $Y$ then $X$ is the one-point compactification of $Y$.
Comment: I agree with @LordSharktheUnknown. All you need to show is that the punctured sphere is homeomorphic to Euclidean space. For this it suffices to observe that the stereographic projection formula is a polynomial, as is the inverse of its restriction onto each of hemisphere. Since polynomials are continuous, this gives the desired homeomorphism.
Comment: Indeed I didn't think it that way before, I used the other way all the time but think little about the converse.
Comment: @AnginaSeng But do you still have to show that $f_0$ is continuous at $p$, right? Isn't the Tietze extension theorem needed for that?
Comment: I'm glad that you share results you like but i don't think your proof, as it stands, is quite clean yet: Some imperfections are that it (1) refers to a hammer like Tietze's theorem (2) glosses over important details  (using "$\infty$" without defining it or defining how it interacts with topology) (3) gets some things wrong (like continuity of $f$).
Answer: Here's a more general idea without Tietze Extension theorem: Assume that $Y$ is a compact and Hausdorff space and let $y$ be a point in $Y$. Suppose $Y\backslash \{y\}$ is not compact, we prove that $Y$ is homeomorphic to $(Y\backslash \{y\})^+$. If this is true, we can use the fact that $S^n\backslash \{y\}$ is homeomorphic to $R^n$ to derive our conclusion.
For the above lemma, since $Y\backslash \{y\}$ is not compact, then $(Y\backslash \{y\})^+$ is compact and Hausdorff. We consider the natural bijection $f$ from $(Y\backslash \{y\})^+$ to $Y$. Since $Y$ is compact, we can easily verify that the pre-image of any open set in $Y$ under $f$ is open, therefore $f$ is continuous, and we have proved that $f$ is a homeomorphism since $Y$ is Hausdorff.


adding a comment with "to_csv" using pandas

Question: I'm saving a dataframe with the method to_csv, and the output is like that:
2015 04 08 0.0 14.9
2015 04 09 0.0  9.8
2015 04 10 0.3 23.0

but I need to make some modifications to this output, I need to add a comment and a column with a constant value and the same size that the others columns. I need to obtain an output like this one:
#Data from the ...
#yyyy mm dd pcp temp er
2015 04 08 0.0 14.9 0
2015 04 09 0.0  9.8 0
2015 04 10 0.3 23.0 0

Does anyone know how to do that?
Comment: Why not just `open` the file and write to it?
Comment: Is it pandas data frame? pandas `to_csv` has option `header`, which is default True, so your columns names should be written automatically
Comment: Can you edit your post and add your dataframe and your script ?
Comment: As @MicahSmith says, write the CSV first, then use something like [this](http://stackoverflow.com/a/5917395/2071807) to add the comment to the top of the file.
Comment: Good morning, this is the only way I found:                                                                                line= "#GEO \n#lat    long    level   date    time    value \n#DATA\n"                                                                                with open(Filename, 'w') as f:
    f.write(line)
df1.to_csv(auxiliar, index = False, sep='\t', float_format='%.6f', header = False)
    with open(nombreFichero, 'a') as f:
         with open(auxiliar, 'rb') as g:
              shutil.copyfileobj(g, f)
Answer: The easiest approach is to add the comment first and then append the data frame. Two approaches to this are given below, and there is more info in Write comments in CSV file with pandas.
Read in test data
import pandas as pd
# Read in the iris data frame from the seaborn GitHub location
iris = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv')
# Create a bigger data frame
while iris.shape[0] < 100000:
    iris = iris.append(iris)
# `iris.shape` is now (153600, 5)

1. Append with the same file handler
# Open a file in append mode to add the comment
# Then pass the file handle to pandas
with open('test1.csv', 'a') as f:
    f.write('# This is my comment\n')
    iris.to_csv(f)

2. Reopen the file with to_csv(mode='a')
# Open a file in write mode to add the comment
# Then close the file and reopen it with pandas in append mode
with open('test2.csv', 'w') as f:
    f.write('# This is my comment\n')
iris.to_csv('test2.csv', mode='a')


Parabola touching a circle

Question:

The parabola $\dfrac {x^2}{d^2}+\dfrac yh=1$ touches the circle $x^2+(y-R)^2=R^2$ at two points, $(\pm p, q)$. It can be easily shown geometrically that $p=\sqrt{2qR-q^2}$. Can it be shown geometrically that $q=d$?

See desmos implementation here. The purple dotted line forms a square.
(See also the solution to this other question on projectiles here).
Answer: In parabola below, $AM=d$, $VM=h$ and $VF=VN=d^2/(4h)$, where $F$ is the focus and $NH$ the directrix of the parabola. We have $FP=PH$ and $\angle FPC=\angle KPC$, because radius $PC$ is normal to the parabola. Hence $CPHF$ is a parallelogram and
$$
CF=PH={h\over d^2} HN^2+VN=
{h\over d^2}(FH^2-FN^2)+{d^2\over4h}={h\over d^2}R^2.
$$
But $CF=h-R-d^2/(4h)$, which gives: $R=d-d^2/(2h)$.
And finally we can compute $q=PK$:
$$
PK=h-PH+VN=h-{h\over d^2}R^2+{d^2\over4h}=d.
$$
Comment: I wrote rhombus by mistake: it is  a parallelogram. Corrected now, thanks.
Comment: ok Aretino, thanks
Comment: Thanks - interesting solution. (+1)

Parabola touching a circle


Sitecore Settings With Page Editor

Question: I have Site settings item for my site, and i have field there for logo, in my code i am using Sitecore Field to display this field on my pages. and from experience editor it can be editable, but when i change the logo and publish the current item from experience editor (ex: home page), all items related to the page is published except the logo. I have to go to Site settings item from content editor and publish it. any idea how i can publish it from experience editor (Logo or any fields in Site Settings)
Comment: Is the logo editable from the page? If the settings item is referenced correctly, the logo should be editable. Any changes should be saved when the page is saved. This is the same process as if you have a rendering/sublayout that has a datasource. When you edit the content in that rendering, the data for the datasource item is updated when you save.
Comment: @dnstommy Logo is editable yes, and i am reading it directly from the settings item, i know that happens because there is no reference between the current page that i want to publish and the settings item.
Comment: Have you check the box "Publish related items" when you publish the single item? I am guessing it works fine if you publish the whole site?
Comment: Did you publish the changed logo image??
Answer: Normally, logo is a field on the home item you don't change it every day.
In your case you can publish your logo using edit related item and publish that item.
Please check below picture:

Sitecore Settings With Page Editor


O que significa dizer que, um app é WebView? Qual a relação com Xamarin?

Question: Iniciando estudos em um projeto Xamarin, encontrei uma série de nomenclaturas e algumas explicações que parecem contraditórias, então tenho algumas dúvidas:

Ouvi dizer que Xamarin e Xamarin.Forms, NÃO são WebView, que na verdade eles geram apps nativos. Por outro lado já ouvi que podem utilizar WebView. Alguém pode me explicar mais sobre isso?
O que é PWA e qual sua relação com Xamarin? e outras tecnologias?
Se utilizar WebView ou tecnologias como Cordova ou Ionic, que tipos de recursos não conseguirei implementar?

Referências de pesquisa sobre esse assunto, será extremamente importante!
Comment: Relacionada: [O que são Progressive Web Apps?](https://pt.stackoverflow.com/q/153860/91)
Comment: O xamarin é a plataform de desenvolvimento, xamarin forms é o frame que ajuda na criação de apps. Basicamente o xamarin faz o mapeamento de APIs do iOS e android através de abstrações.
Answer:
Ouvi dizer que Xamarin e Xamarin.Forms, NÃO são WebView, que na verdade eles geram apps nativos. Por outro lado, já ouvi que podem utilizar WebView. Alguém pode me explicar mais sobre isso?

Significa que tudo feito no Xamarin usa a API do sistema operacional que está rodando, ou do Android ou do iOS. Não tem intermediários, então todo acesso é feito de forma direta sem passar por um browser, mesmo que seja um "sem a cabeça". Mas se precisar que alguma parte específica rode com tecnologias web pode ser um controle WebView que entrega o que precisa só naquele ponto. O PWA roda todo em um WebView, ele depende do core navegador para executar e interagir com o usuário, a API é web.

O que é PWA e qual sua relação com Xamarin? E outras tecnologias?

Já respondido em O que são Progressive Web Apps?. Não há relação com Xamarin, eles são concorrentes indiretos.

Se utilizar WebView ou tecnologias como Cordova ou Ionic, que tipos de recursos não conseguirei implementar?

Isso é um pouco amplo de responder e pode mudar conforme a versão. Hoje tem pouca limitação efetiva já que é possível usar plugins. Muda um pouco o consumo maior de recursos.
Veja mais em App - Xamarin ou Ionic?.
Não é objetivo do site oferecer referências de estudo.
Coloquei no GitHub para referência futura.


Discard views filter on field from referenced taxonomy term when relationship isn't present

Question: I want to show two content types (A and B) in one view. 'A' has a relationship with a taxonomy term 'foo', 'B' doesn't have this relationship. So the relationship isn't required. However when I use a field from 'foo' as a filter in the filter criteria no nodes of content type B are shown, the nodes of content type A are shown correctly.
Is it possible to configure the view such that it doesn't look at the filter with the referenced field for nodes of content type B?
If something isn't clear, ask me!
Thanks!
Answer: Yes, you want to use Grouped Filters in Views. In the View UI, there's an Add/Or, Rearrange option next to the Filter Criteria section.
This allows you to create a complex grouping of filters. To use an example that matches your conditions, here's a setup using Drupal's Standard installation with Basic Page/Article nodes and Tags taxonomy that's exclusive to Article:
Comment: I didn't know this views feature, heh, just when you think you know it all.
Comment: Thanks for the comment, but I already tried this. It doesn't seem to work.


What is the maximum possible value of $k$

Question:
What is the maximum possible value of $k$ for which $2013$ can be written as a sum of $k$ consecutive positive integers?

I tried to write $2013$ as a sum of AP with common difference $1$ then factorize one side of the expression, I don't know if it's true or not, any help will be appraciated.
Comment: $2013 = 3\times11\times61$. If the number of terms is odd, what do we know about the relationship between the number of terms and their average value?
Answer: Suppose $a$ be the first integer in the $n$ consecutive integers. We get $$n(2a+n-1)=4026=2 \cdot  3\cdot  11\cdot  61$$
Now as $$2a+n-1>n \Rightarrow  4026> n^{2}$$
the maximum value of $n$ occurs at $n = 61.$
and we're done
Comment: It's a little hard to see why you made the second part of your argument to conclude that $n = 61$. I assume you were insinuating that due to the factorization, the smallest possible value $n > 61$ would be $n = 2 \cdot 3 \cdot 11 = 66$ and $66^2 > 4026?$? It might help to point that out. I didn't realize $66^2 > 4026$ until I guessed that was what you were getting at and I checked it on a calculator.


Need to print all the function calls Drupal makes

Question: I need to examine all the function calls Drupal makes during it loads a page (even if there are no errors). I guess debugging software can do this but I would also like to know a way to do this without xdebug etc.
I found this link:
https://drupal.stackexchange.com/questions/545/how-to-debug-drupal
but I'm not sure where to put for example this code:
<?php
$bt = debug_backtrace();
foreach ($bt as $key => $value) {
  if ($key == 0) {
    continue;
  }
  unset($bt[$key]['args']);
  unset($bt[$key]['object']);
}
drupal_set_message(str_replace('    ', '    ', nl2br(htmlentities(print_r($bt, TRUE)))));
?>

Answer: I would recommend using Xdebug as opposed to any other methods.
Xdebug can easily be installed and then all you have to do is enable profiling and navigate around your site.
Not only does it list all function calls but it counts how many times each is called during a request and also times the function call, so you know exactly where to look to resolve bottlenecks.
The results can be viewed using Webgrind (browser-based) or KCacheGrind (KDE/linux), amongst others.
This is more efficient because you are not tampering with the code and littering it with debug statements.
Answer: The number of function calls during a single page view can be quite a lot. I don't know the number, but my guess is that it's several thousand. If you want to log all of this data, you shouldn't post it to the screen, but instead write it in a file, like the dd function that the devel module has.
If you want to log all function calls, you should start by the end, that last function that is called in a drupal page. One of the last functions where you could start is drupal_page_footer. You can add the debug_backtrace in that function.
Then you would have to go through all the functions and add debug_backtrace for all the functions that those functions call. Then you would have to go through all the new functions listed in the debug_backtrace you just added and repeat the above step until you or your computer chokes.
It's possible to do this, but to get anything useful you will need a profile tool, which can do all of this in seconds instead of hours. This is where computers excels: recursion.
Answer: If you need to print all the function calls (e.g. just their names separated by comma), try:
print implode(', ', array_column(debug_backtrace(), 'function'));

Note: array_column() is part of PHP >=5.5.0