java.lang.RuntimeException: Unable to start activity ComponentInfo{...EditCity}: java.lang.NullPointerException

Question: this is the xml file.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="20dp"
    android:layout_marginTop="15dp"
    android:text="@string/edit_city"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView2"
    android:layout_below="@+id/cityName"
    android:layout_marginTop="20dp"
    android:text="@string/country_name" />

<EditText
    android:id="@+id/countryName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/textView3"
    android:layout_alignLeft="@+id/cityName"
    android:ems="10"
    android:inputType="text" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/countryName"
    android:layout_alignLeft="@+id/textView1"
    android:text="@string/city_name" />

<EditText
    android:id="@+id/cityName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_toRightOf="@+id/textView1"
    android:ems="10"
    android:inputType="text" />

<TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView3"
    android:layout_below="@+id/textView3"
    android:layout_marginTop="20dp"
    android:text="@string/population" />

<EditText
    android:id="@+id/population"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/textView4"
    android:layout_alignLeft="@+id/countryName"
    android:ems="10"
    android:inputType="text" >

    <requestFocus />
</EditText>

<TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView4"
    android:layout_below="@+id/textView4"
    android:layout_marginTop="20dp"
    android:text="@string/traditions" />

<EditText
    android:id="@+id/traditions"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/textView5"
    android:layout_alignLeft="@+id/population"
    android:ems="10"
    android:inputType="text" />

<TextView
    android:id="@+id/textView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView5"
    android:layout_below="@+id/textView5"
    android:layout_marginTop="21dp"
    android:text="@string/impressions" />

<EditText
    android:id="@+id/impressions"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/textView6"
    android:layout_alignParentRight="true"
    android:ems="10"
    android:inputType="text" />

<TextView
    android:id="@+id/textView7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView6"
    android:layout_below="@+id/textView6"
    android:layout_marginTop="21dp"
    android:text="@string/url_image" />

<EditText
    android:id="@+id/urlImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/textView7"
    android:layout_alignParentRight="true"
    android:ems="10"
    android:inputType="text" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="38dp"
    android:layout_toRightOf="@+id/textView3"
    android:background="#444444"
    android:textColor="#FFFFFF"
    android:onClick="editCity"
    android:text="@string/edit_button" />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/button1"
    android:layout_marginLeft="56dp"
    android:layout_toRightOf="@+id/button1"
    android:background="#444444"
    android:onClick="displayCity"
    android:text="@string/view_button"
    android:textColor="#FFFFFF"
    android:textSize="20sp" />

  </RelativeLayout>

this is the logcat content.
09-10 16:55:15.975: D/AndroidRuntime(297): Shutting down VM
09-10 16:55:15.975: W/dalvikvm(297): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-10 16:55:15.995: E/AndroidRuntime(297): FATAL EXCEPTION: main
09-10 16:55:15.995: E/AndroidRuntime(297): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.citiestoremember/com.example.citiestoremember.EditCity}: java.lang.NullPointerException
09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-10 16:55:15.995: E/AndroidRuntime(297):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 16:55:15.995: E/AndroidRuntime(297):  at android.os.Looper.loop(Looper.java:123)
09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.ActivityThread.main(ActivityThread.java:4627)
09-10 16:55:15.995: E/AndroidRuntime(297):  at java.lang.reflect.Method.invokeNative(Native Method)
09-10 16:55:15.995: E/AndroidRuntime(297):  at java.lang.reflect.Method.invoke(Method.java:521)
09-10 16:55:15.995: E/AndroidRuntime(297):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-10 16:55:15.995: E/AndroidRuntime(297):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-10 16:55:15.995: E/AndroidRuntime(297):  at dalvik.system.NativeStart.main(Native Method)
09-10 16:55:15.995: E/AndroidRuntime(297): Caused by: java.lang.NullPointerException
09-10 16:55:15.995: E/AndroidRuntime(297):  at com.example.citiestoremember.EditCity.onCreate(EditCity.java:44)
09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-10 16:55:15.995: E/AndroidRuntime(297):  ... 11 more

Hello! When I run my program it goes well until a specific moment.I get this error in my logcat.
The EditCity.java file where the error occures is below. Can anyone help me ? Thank you!
package com.example.citiestoremember;

import java.util.HashMap;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class EditCity extends Activity{

EditText cityName;
EditText countryName;
EditText populationNumber;
EditText traditions;
EditText impressions;
EditText urlImage;

DBTools dbTools = new DBTools(this);

public void onCreate(Bundle savedInstanceState){

    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit_city);
    cityName = (EditText) findViewById(R.id.cityName);
    countryName = (EditText) findViewById(R.id.countryName);
    populationNumber = (EditText) findViewById(R.id.populationNumber);
    traditions = (EditText) findViewById(R.id.traditions);
    impressions = (EditText) findViewById(R.id.impressions);
    urlImage = (EditText) findViewById(R.id.urlImage);

    Intent theIntent = getIntent();

    String cityId = theIntent.getStringExtra("cityId");

    HashMap<String, String> cityList = dbTools.getCityInfo(cityId);

    if(cityList.size() != 0){

        cityName.setText(cityList.get("cityName"));
        countryName.setText(cityList.get("countryName"));
        populationNumber.setText(cityList.get("populationNumber"));
        traditions.setText(cityList.get("traditions"));
        impressions.setText(cityList.get("impressions"));
        urlImage.setText(cityList.get("urlImage"));

    }
}

public void editCity(View view){

    HashMap<String, String> queryValuesMap = new HashMap<String, String>();

    cityName = (EditText) findViewById(R.id.cityName);
    countryName = (EditText) findViewById(R.id.countryName);
    populationNumber = (EditText) findViewById(R.id.populationNumber);
    traditions = (EditText) findViewById(R.id.traditions);
    impressions = (EditText) findViewById(R.id.impressions);
    urlImage = (EditText) findViewById(R.id.urlImage);

    Intent theIntent = getIntent();

    String cityId = theIntent.getStringExtra("cityId");

    queryValuesMap.put("cityId", cityId);
    queryValuesMap.put("cityName", cityName.getText().toString());
    queryValuesMap.put("countryName", countryName.getText().toString());
    queryValuesMap.put("populationNumber", populationNumber.getText().toString());
    queryValuesMap.put("traditions", traditions.getText().toString());
    queryValuesMap.put("impressions", impressions.getText().toString());
    queryValuesMap.put("urlImage", urlImage.getText().toString());

    dbTools.updateCity(queryValuesMap);
    this.callMainActivity(view);

}

public void displayCity(View view){

    Intent theIntent = new Intent(getApplicationContext(), DisplayImage.class);
    String urlImage = theIntent.getStringExtra("urlImage");
    theIntent.putExtra("urlImage", urlImage);

    startActivity(theIntent);

}

public void callMainActivity(View view){

    Intent objIntent = new Intent(getApplication(), MainActivity.class);

    startActivity(objIntent);

}

 }

Comment: show all logcat information!!
Comment: `DBTools dbTools = new DBTools(this)` move this inside `onCreate` and post the stacktrace and there is no need to  initialize your views twice
Comment: post the line that causes the NPE. `EditCity.java:44` ?
Answer: try this :-
DBTools dbTools ;

public void onCreate(Bundle savedInstanceState){

    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit_city);
    dbTools = new DBTools(this);
    cityName = (EditText) findViewById(R.id.cityName);
    countryName = (EditText) findViewById(R.id.countryName);
    populationNumber = (EditText) findViewById(R.id.populationNumber);
    traditions = (EditText) findViewById(R.id.traditions);
    impressions = (EditText) findViewById(R.id.impressions);
    urlImage = (EditText) findViewById(R.id.urlImage);

    Intent theIntent = getIntent();

    String cityId = theIntent.getStringExtra("cityId");

    HashMap<String, String> cityList = dbTools.getCityInfo(cityId);

    if(cityList.size() != 0){

        cityName.setText(cityList.get("cityName"));
        countryName.setText(cityList.get("countryName"));
        populationNumber.setText(cityList.get("populationNumber"));
        traditions.setText(cityList.get("traditions"));
        impressions.setText(cityList.get("impressions"));
        urlImage.setText(cityList.get("urlImage"));

    }
}

you do not initiate this value before your activity start or run. First activity started then you have to get context of activity or you app (this , getBasecontext(),etc).
In above your initiate this before your activity start thats why logcat say null pointer exception.
Comment: @user2759836 what is line 44  `EditCity.java`
Comment: @Golu how do you know that is the line that causes NPE is it line 44 `EditCity.java`
Comment: @Raghunandan this is line 44 : countryName.setText(cityList.get("countryName"));
Comment: @user2759836 `countryName` may not be initialized properly cross check the id in xml
Comment: what do you mean "may not be initialized properly"? can you give me an example? i checked the xml file but i did not noticed anything wrong
Comment: @user2759836 post the xml the id used in xml may be different form the one used in activity to initialize. `If(cityList.size() != 0){` THEN   `countryName.setText(cityList.get("countryName"))` and you say you have NPE @ `countryName.setText(cityList.get("countryName"))` which is line 44 according to you. so your `countryName` could be null. and what example do you need?


Confused by the way TypeScript uses "require(...)"

Question: I've tried reading several blog posts but TypeScript modules still have me totally confused. In particular, I have used 3 different modules (all installed via npm) and each seems to show totally different behaviour:
(1) I can import and use Angular 2 from npm like this in my .ts:
import {bootstrap, Component, Directive, CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/angular2';
Then in my html I have:

This has the following results:

The TypeScript compiler knows to look for the angular2.d.ts file under node_modules, even though I just said "angular2/angular2"
The TypeScript compiler adds "var angular2_1 = require('angular2/angular2'); to the output JavaScript
The browser does not attempt to load the angular 2 JavaScript again despite the presence of the require, it somehow knows it's already loaded it via "angular2.dev.js" in the script tag

(2) The npm D3 module does not have a typescript definition, but I can download the one from DefinitelyTyped and then use it by putting:
/// <reference path="../../typings/tsd.d.ts" />
at the top of my .ts. and

in my html. It seems that being an old-style module it doesn't need an import statement, and as long as I leave it here the output JavaScript works fine. If I do try to use an import statement immediately after the reference line:
import * as d3 from 'd3';
then as with Angular2 it now adds:
var d3 = require('d3');
to the output JavaScript. However, unlike with the Angular case it doesn't realise it's already loaded the JavaScript via the script tag, and so the browser tries and fails to load a file simply called "d3" from the same directory as the html file, which  fails.
(3) The npm Phaser module does include a .d.ts file, in a "typescript" subdirectory of the npm module. This is an old style module ("declare module Phaser"), so it seems I need not use "import.." syntax but instead just:
/// <reference path="../node_modules/phaser/typescript/phaser.d.ts"/>
at the top of my .ts file, as with the D3 example. The TypeScript compiler is happy, but unlike with the D3 example, under some circumstances (I haven't worked out quite what yet, doesn't seem to always happen) it outputs:
var phaser_1 = require('phaser');
in the JavaScript even when I haven't used an import statement. I'm not even using commonjs/requirejs in my phaser project, so "require" isn't even defined, causing failure.
And for completeness, unlike with either the Angular or D3 example, if I try putting an import statement after the reference line:
import * as Phaser from 'Phaser';
even the TypeScript compiler isn't happy. Perhaps in the D3 example the TypeScript compiler is treating the tsd.json or typings folder from DefinitelyTyped in special way, or maybe there is some other reason the import compiles for D3 but not for Phaser.
I have all sorts of questions:
1) What determines whether the TypeScript compiler includes a "require(...)" line in the output JavaScript?
2) Under what circumstances does the TypeScript compiler know where to find an external module in "npm_modules" when using "import", with or without needing a reference line at the top of the file?
3) Under what circumstances does the TypeScript compiler know where to find an ambient module in "typings" when using "import", with or without a "reference" line at the top of the file?
4) Under what circumstances does the TypeScript compiler know where to find an ambient module in "npm_modules" when using "import", with or without a "reference" line at the top of the file??
5) Maybe a commonjs/requirejs question rather than a typescript question, but if the TypeScript compiler does output a "require" line in the JavaScript, what do you do if the source of the JavaScript module is not set up with ES6 module exports?
Answer:
1 ) I can import and use Angular 2 from npm like this in my .ts:

This is because

angular2 ships with its .d.ts file
The browser doesn't attempt to read require because of magic in angular2.dev.js

The npm D3 module fails && the phaser module fails at runtime

They don't have the magic you get from angular2.dev.js. Use something like webpack or browserify to provide this magic.

Unlike with either the Angular or D3 example, if I try putting an import statement after the reference line: import * as Phaser from 'Phaser';

This is because of how Phaser definition is declared. Apprarently it is missing declare module "Phaser" which is what is provided with d3 see here and angular.


Show that $θ=2sinθ$

Question: This is probably an easy question for most people but for me I am stuck I don't get how this works. And I have no teacher as I am self studying . Any help is much appreciated.

It says this is the working out put I don't get it.
Answer: Hint
The area of a triangle is given by, $$\frac{1}{2}ab\sin(\theta)$$
where a and b are the sides and $\theta$ is the included angle.
The area of a sector is given by, $$\frac{1}{2}\;\theta \ r^2$$
where r is the radius.
Comment: AAAA i see thank you vert much!
Comment: Thank you very much I added how its worked out but don't get the steps could you look at it please.
Comment: @Hiran The LHS is the area of the triangle and the RHS is the area of the sector minus the area of the triangle. Expand the RHS and it will be more clear.

Show that $θ=2sinθ$


Outlook Prompting for password from Exchange server in domain environment

Question: We are running exchange 2007 in a domain environment.  We have mostly outlook 2003 clients, but in process of upgrading to outlook 07 over the next couple of weeks.
Some users (both 03 & 07) are constantly getting prompted to enter their credentials.  The 07 client I was working on this morning states "needs password" in the bottom right corner.
It is also speratic, as it will work fine most days but not some other days.  The user I was working with this morning, has been working fine. Now it just started up today.
I have been googling this, and have found lot's of information, but nothing that has helped yet.  A lot of the information out there is for outlook users using a external email account.
Being they already logged into the domain, these users should not be prompted for their credentials.
Any advice out there?
Comment: I just started having this today as well. Did you find a solution?
Comment: Are you sure that they are logged into the domain?  Does the problem recur after logging in and logging out?
Comment: +1 this is one of the most annoying problems I see on a daily basis! Some machines just randomly have this for no reason and after Googling and trying out so many solutions, I just don't know what causes it on some machines.
Answer: Check to see if the clients are configured to use Outlook Anywhere

Email accounts > Change > More settings... > Connection

If they're connection via Outlook Anywhere it will always ask for credentials. You can run a netstat -n to see if you have any 443 connections to your CAS server as well.
Comment: Thanks @Chirs Hupman - I had the same issue and turning off outlook anywhere I'm no longer locked out of Outlook... however the password prompt dialog still constantly pops up but at least I can read my mail now! (I just move the password dialog out of the way.
Comment: Or ctrl+right-click the Outlook tray icon and select Connection status - it will show HTTPS for Outlook Anywhere and TCP/IP for direct connection.
Answer: I've had this exact same issue for two of my clients. It happened after updating the certificate to a signed one. Doing the following has always resolved this.

Install the latest Service Pack of Exchange.
Next, in the Exchange Management shell, take note of the following and document it (in case you need to revert the info).

Get-OabVirtualDirectory|fl
Get-WebServicesVirtualDirectory|fl
Specifically make note of the InternalUrl. You'll want to change the InternalUrl for both the OabVirtualDirectory and WebServicesVirtualDirectory with the following commands. You'll want to change where it says servername to the name of your server.
Set-OABVirtualDirectory -Identity "Servername\OAB (SBS Web Applications)" " -InternalUrl https://servername.domain.local/oab

Set-WebServicesVirtualDirectory -Identity "Servername\EWS (SBS Web Applications)" -InternalUrl https://servername.domain.local/ews/exchange.asmx

Answer: What does your authentication look like in IIS? If it's set to anything other than Integrated Auth, you could see this. Also, are your Autodiscover services configured correctly? How about a certificate, do you have a signed or self-signed one? If I remember correctly, 2003 clients aren't affected by Autodiscover the same way 2007 clients are though.
When you say constantly, does that mean entering creds more than once after opening Outlook, or once per session?
Have you rebooted the Exchange server?
Comment: That is something I was looking into, but I haven't been able to find in IIS where I set the integrated Auth.  I was also looking into the autodiscover.
Comment: Go to the site properties that Exchange is under and click on the Directory Security tab. Then click Edit under Authentication and access control. Once there, at the bottom you will see the auth method that the site is using.


Semitones vs perfect fifth

Question: This website:

https://www.musictheoryacademy.com/understanding-music/intervals/perfect-fifth/)

is saying that:

"A perfect fifth is an interval of 7 semitones between 2 notes."

The internet is saying that:

"A semitone is a difference in pitch between one note and one immediately higher or lower after/before it."

(check photo attached)
I am going little bit crazy now; what's right and what's wrong?
I don't see 7 semitones anywhere. All I see is 2 semitones in a major scale/Diatonic scale.
Comment: two semitones equals one tone
Comment: Both are correct. You count the black notes too.
Comment: `1 tone == 2 semitones`. C (root) to G (fifth) is `Tone + Tone + Semitome + Tone` so using "algebra" we can write this as `(2*Semitone) + (2*Semitone) + Semitone +(2*Semitone)` which is 7 semitones.
Comment: Hint: what does the prefix "semi" mean? (To be clear: did you already know that the perfect fifth is the interval, for example, from C to G? or were you trying to figure that part out?)
Comment: Please help me locate 7 semitones on C major scale, where are those 7 semitones which perfect fifth is talking about, where are the 2 notes? I see7 notes C to B and 2 semitones :'(
Comment: Might also help: [Chromatic scale](https://en.wikipedia.org/wiki/Chromatic_scale).
Answer: If you start on C: the first semitone is C#, the second semitone is D, 3rd is D#, 4th is E, 5th is F, 6th is F#, and the seventh semitone is G.
So the interval of a perfect fifth up from C is G.
Answer: This is why sometimes we want to use hyper-accurate words like "pitch" rather than colloquial words like "note." Let's give some more accurate definitions:

When we're talking about music, an interval is a measurement of distance, like a mile or a centimeter. If we name two pitches, we can also name the interval that separates them.
A semitone is a very small interval. It's the smallest distance apart that two pitches could be, at least on a modern piano.* On a piano keyboard, two keys that are right next to each other, including a black key and the white key that's next to it, are a semitone apart. Other words for the same idea are "half step" or "minor second." The two images are a bit confusing because the only semitones they label as such are the places where there are two white keys with no black key between them: E to F and B to C. But from C to C#, for instance, is also a semitone.
A perfect fifth is also an interval, along with thirds, fourths, and so on. The easy but imprecise definition is "It's two notes that are five notes apart—like from C to G: C, D, E, F, G." The stricter definition is "It's two pitches that are separated by seven semitones," since if you had a C# and a G you could still name five notes, but they would be only six semitones apart. To count the seven semitones from C to G, you play all the white and black keys: C, C#, D, D#, E, F, F#, G.

* In general, and over-simplifying, you could think of a semitone for now as "the smallest musical interval." The way we name notes in western traditional music, "C", "C#" etc., gives names to pitches that are semitones apart. Other musical systems include smaller intervals, and even in western music, smaller intervals are often played or sung, but describing and naming these is a bit trickier.
Comment: "pitch" is nearly as ambiguous as "note."  It can denote a letter-and-accidental designation, a specific frequency, or just the frequency chosen for A4.
Answer:
I am going little bit crazy now; what's right and what's wrong?
I don't see 7 semitones anywhere. All I see is 2 semitones in a major scale/Diatonic scale.

Look more closely at the image. On the left, there are note names; on the right, there is a diagram of a piano keyboard. With the note names, you can see that some notes are connected by lines labelled Tone; these notes correspond to the white keys on the keyboard.
However, there are also black keys on the keyboard, that correspond to in-between notes. These are labelled in lighter text. On the left side, we see C# (pronounced "C sharp") in between the C and D; this note can also be called Db (pronounced "D flat"), with the standard system of notes we are using here. The piano keyboard diagram puts both labels on that black key.
You can also see that the E and F, and the B and (upper) C, are connected by lines labelled Semitone. This is because these notes/white keys don't have another note/black key in between them.
In English, "semi-" is a prefix meaning "half". The conceptual "distance" between the notes of a tone - i.e., "how much higher" D is than C - is twice that between the notes of a semitone (e.g. between F and E).
In the approximations that we use in teaching Western musical theory at an elementary level, we say that the note played by the G key on the piano is a perfect fifth above the C note - that is the name we use for that interval. The notes played by each key in sequence are equally spaced out: it takes 12 semitones, or 6 tones, to get from one C to the next C, an octave up. Similarly, from the C to the G we count 7 semitones: C-C#-D-D#-E-F-F#-G. (Or, using the "flat" names: C-Db-D-Eb-E-F-Gb-G.)
The reasons for all of these alternate names, for having black keys between some but not all white keys, etc. will become clear as you learn more of the theory - it would be out of scope to try to explain them here. Similarly, "perfect fifth" is actually intended to mean an interval that is very slightly larger than the distance from a piano's C to a piano's G (smaller than most people would be able to notice by listening).
There are specific reasons why we divide the octave up specifically into 12 notes, and then make these kinds of approximations, that will become clearer if you study more theory. (There's also history behind why we have the name "Tone" for the distance e.g. from C to D - i.e., two notes up in our sequence of adjacent notes.) It's also possible to do it any number of other ways. There aren't any specific "notes"; you can make sounds at any pitch  want - they just won't be ones that Western musical instruments are designed to play, and won't necessarily sound good, or make sense to include in music written in Western styles, or have any natural representation in Western music notation.
Answer: A "semitone" uses a Greek prefix to say "halftone".  On the assumption that all tones are identical, all semitones are identical, that two semitones constitute the same frequency interval as one tone, the three tones and one semitone making up a fifth in a scale are the same as seven semitones or 7/12 of an octave.
That is called 12-EDO.  There is also 19-EDO where a semitone is 2/3 of a tone and a fifth is thus 3⅔ tones or 5½ semitones or 11/19 octaves in size.  Then there is 31-EDO where a semitone is 3/5 of a tone, and a fifth is 3⅗ tones or 6 semitones or 18/31 of an octave in size.
An accidental will cover the difference between a semitone and a tone.  As you can see, as soon as "semi" is no longer taken at its literal meaning "half" but more like "small", your question stops having a trivial answer.
But those more elaborate and much less used temperated scales built from an equal-tempered microscale are not typically available from most instruments.  They do offer some purer intervals than the customary 12-EDO scales do.
Comment: I'd avoid calling any of the intervals that 19-edo and 31-edo have to offer just "semitone". What you're talking about are _diatonic semitones_. The other ones, the "difference between a semitone and a tone", are _chromatic semitones_. (And specifically in 19-edo, really neither of them deserve the "half" in the name.)
Answer: The 12 keys (C, C#, D, D#, E, F, F#, G, G#, A, A#, B) on a piano represent 12 "equally spaced" pitches. This is called 12-tone equal temperament. Each piano key has a frequency that is exactly 21/12 times larger than its immediately preceding piano key. [see footnote 1/2]

Recall:
21/12 · 21/12 · 21/12 · 21/12 ·
21/12 · 21/12 · 21/12 · 21/12 ·
21/12 · 21/12 · 21/12 · 21/12
= (21/12)12 = 2
Thus, when you take 12 steps up from any given piano key, you will end up at a note that has exactly double the frequency. This is called an octave. [see footnote 8] When two notes that are an octave apart are played simultaneously, their sound waves will overlap every 2:1 cycles, which sounds breathtakingly beautiful.

Furthermore:
21/12 · 21/12 · 21/12 · 21/12 ·
21/12 · 21/12 · 21/12
= (21/12)7 ≈ 1.498 ≈ 1.5 = 3/2
Thus, when you take 7 steps up from any given piano key, you will end up at a note that has roughly 1.5 times the frequency. This is called a perfect fifth. [see footnote 5] When two notes that are a perfect fifth apart are played simultaneously, their sound waves will overlap every 3:2 cycles, which sounds simply sublime.

Additionally:
21/12 · 21/12 · 21/12 · 21/12 ·
21/12
= (21/12)5 ≈ 1.334 ≈ 4/3
Thus, when you take 5 steps up from any given piano key, you will end up at a note that has roughly 1.33 times the frequency. This is called a perfect fourth. [see footnote 4] When two notes that are a perfect fourth apart are played simultaneously, their sound waves will overlap every 4:3 cycles, which sounds suitably striking.

1/2 Every adjacent piano key is a semitone apart. From C to C#. From C# to D. From D to D#. And so on.
8 An octave up from any given white key is seven white keys to the right. Example: from C4 to C5.
5 A perfect fifth up from any given white key except B is four white keys to the right. Example: from C to G.
4 A perfect fourth up from any given white key except F is three white keys to the right. Example: from C to F.
Comment: Better. But it's not true that the piano is tuned to perfectly equal temperament. The theory says that's what the tuning should be, but the reality is that adjustments to the ideal tuning are made to account for a variety of acoustical effects.
Answer: It's true, there is only one semitone between two of the notes on the way to making up a perfect fifth.(Between notes ^3 and ^4  in the quoted case), BUT there are also three tones, and they must be counted too.
Each tone is worth two semitones, making the P5 7 semitones altogether. The phrasing is unfortunate, and could have been improved.
To further muddy the water, 7 semitones also make the interval of a diminished 6th, so don't go away with the 'knowledge' that every two notes 7 semitones apart will constitute P5 - the letter names and appropriate accidentals (♯/♭) will have some bearing on the calculation.
So, without reading the 'important note' at the end of that site, the statement is not actually true - there are 7 semitones making up a P5 - it's only half true!
Answer: Think about it like this:

First the octave (which means doubling the frequency) is divided into 12 equal parts. These are the notes that we are talking about. These 12 equal parts are the semitones.

Some of these notes are labeled A through G using this pattern:
A   *   B   C   *   D   *   E   F   *   G   *
It's the pattern that you get if you label the white keys on a keyboard with letters while labeling the black keys with *. This is the diatonic scale used in either A-minor or C-major.

The large steps that skip over a * are called tones while the small steps are called semitones as above. So, the octave is divided into five tones (A-B, C-D, D-E, F-G, G-A) and two semitones (B-C, E-F) by the scale of the labeled notes.

As you can see, a perfect fifth (like the one from A to E) contains a total of seven small steps in this sequence. That is equivalent to saying that a perfect fifth is seven semitones. And it's the same as saying that a perfect fifth contains three tones and a semitone. (Makes sense: 3.5 = 7/2)

However, intervals are named for the letters, only. As such, the fifth from A to E is called a fifth because it encompasses the five letters A, B, C, D, and E. The interval A-C is called a third (A, B, C), and the interval C-E is also called a third (C, D, E), irrespective of the fact that the later is one semitone larger than the former. That is why the interval B-F is called a diminished fifth while the interval F-B is called an augmented fourth. It's six semitones (or three tones = tritone) either way, but there is one more letter on the way in B, C, D, E, F than in F, G, A, B.
Answer: You're mixing up a couple things and skipping the important fact that 1 tone = 2 semitones (hence the name semitones).
The images you posted tell you how to obtain a (major) scale: you begin at a certain note, in this example  C, then get the next note by adding a tone (= two semitones = move two keys -> D), then another tone (-> E), then a semitone (->F since there's no black key in between), then repeat...
With this in mind, adding 7 semitones (= going to the note that is 7 semitones above yours) means adding 3 tones and one semitones... or simply counting 7 keys including the black ones.
So from C: C# (1 semitone away), D (2), D# (3), E (4), F (5), F# (6), G (7)

Semitones vs perfect fifth


How to add a jQuizzy?

Question: I've been searching and trying for two days to add the jQuizzy engine to my site with no luck!
I've successfully added some jQuery plugins to my site, but I can't seem to be add this one?!
I created a block. In the block is a link that calls a menu item. The menu item gets a drupal form. In the form I added all the JS and CSS ... Nothing is happening?!
Help!!!
Comment: why drupal form? why you don't create a simple page?
Answer: Are you retrieving that form via AJAX ? Then you get the HTML, but in your page is not present the JavaScript/CSS files. You need to add them before, so they are ALREADY present in whatever page the block is placed.

How to add a jQuizzy?


jquery .one() load and error events not working

Question: i have a simple html, that i want an event to trigger once the last image is loaded, or if there is an error on the last image being loaded. here is my code
html

Jquery
var imageCount = $('#compare-table-scrollable img').length;
var counterIMG = 0;
$('#compare-table-scrollable img').one("load error",function(){
           counterIMG++;
           if (counterIMG == imageCount)  // do stuff when all have loaded
           {
                alert(counterIMG);
           }
});

here is my FIDDLE
Comment: `load` events don't work reliably with images. [Here's what you can do about it](http://stackoverflow.com/questions/3877027/jquery-callback-on-image-load-even-when-the-image-is-cached).
Comment: @Blazemonger: `load` events **do** work reliably with images. You just have to be sure you're there to catch them. If you're not (if you set `src` before you've hooked the event), you may miss it. That's not the same thing as the event being unreliable.
Comment: @T.J.Crowder [It's well-known to the jQuery developers that if an image is cached, the browser's normal `load` event may not be triggered at all.](http://api.jquery.com/load-event/) You seem to be describing "reliable under certain circumstances," which is not what I'd consider "reliable" at all.
Comment: @Blazemonger: I'm quite sure that the jQuery developers know as well as I do that `load` is reliable **if you do things correctly**. But in the face of too many people hooking the event **after** setting `src`, a big yellow warning in the docs is not out of line at all (although it should be reworded). I would say "`load` events don't work reliably with images" is the greater falsehood by far than "`load` events only work reliably if you hook the event before setting `src`" Obviously, feel free to point me at an evidence-based article with replicatable code demoing a missing `load` event. :-)
Comment: @T.J.Crowder I'd be happy to point you to a project I had myself a year or so ago, but sadly I already fixed the code using [this plugin](https://github.com/desandro/imagesloaded). The problem was exactly as described: large rotating background images were sometimes firing the `load` event, but usually weren't, because the browser was pulling them from the cache.
Answer: Here's one I wrote myself a while back.  It's very similar to what you have above, but a little more robust...
function onImagesLoaded($container, callback) {
    var $images = $container.find("img");
    var imgCount = $images.length;
    if (!imgCount) {
        callback();
    } else {
        $("img", $container).each(function () {
            $(this).one("load error", function () {
                imgCount--;
                if (imgCount == 0) {
                    callback();
                }
            });
            if (this.complete) $(this).load();
        });
    }
}

And how to use it...
onImagesLoaded($("#compare-table-scrollable"), function() {
    alert("images loaded");
});

Notice the addition of if (this.complete), which allows the function to count images that are cached and therefore load before the function is called.
Answer: You're not hooking the events until very late in the page load process, after the events have already fired. Note the second drop-down box on the upper left side of jsFiddle, which says "onload". This is jsFiddle's extremely surprising default, which is to wrap your JavaScript code in a window load event handler. That handler doesn't get fired until all the images have loaded or failed to load.
If you change that drop-down to no wrap - , you get the alert: http://jsfiddle.net/X4AmG/3/
That said, with the images being specified in the markup, I'd be worried about a load or error event managing to get fired before your code hooked up its handlers. For that reason, I'd probably do something like this instead:
// Get the images
var imgs = $('#compare-table-scrollable img');

// Schedule the first check for DOM ready
$(checkForImagesDone);

// Our check function
function checkForImagesDone()
{
  var counter = 0;
  imgs.each(function()
  {
    if (this.complete)
    {
      ++counter;
    }
  });
  if (counter === imgs.length)
  {
    alert("All complete");
  }
  else
  {
    setTimeout(checkForImagesDone, 50); // 50ms
  }
}

Comment: For some reason I thought he was using document ready event. My fault ;)
Comment: @ClaudioRedi: Do you have a reference for `load` and `error` not firing earlier? I'd **love** to know for sure that they won't. :-) But I find it hard to buy it, not least as jQuery's DOM ready varies from browser to browser...
Comment: I can't tell for sure that this applies for ALL browsers but document ready event [doesn't wait for all assets to be loaded](http://api.jquery.com/ready/). I do think it is safer to assume that this restriction applies to all browser and use windows load instead of document ready if we need all assets to be loaded :)


Can't extend/override parent "move" element

Question: In catalog_product_view.xml in the parent theme there is this, just copied up to one line past the line Im trying to change:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

        <referenceContainer name="content">
            <block class="Infortis\Base\Block\Product\View" name="product-view-wrapper" template="product/view.phtml" before="-">
                <container name="container_product_image_1" label="Product View, Image Column" />
                <container name="container_product_primary_1" label="Product View, Primary Column, Container 1" />
                <container name="container_product_primary_2" label="Product View, Primary Column, Container 2" />
                <container name="container_product_secondary_1" label="Product View, Secondary Column, Container 1" />
                <container name="container_product_secondary_2" label="Product View, Secondary Column, Container 2" />
                <container name="container_product_lower_primary_1" label="Product View, Lower Primary Column, Container 1" />
                <container name="container_product_lower_primary_2" label="Product View, Lower Primary Column, Container 2" />
                <container name="container_product_lower_secondary_1" label="Product View, Lower Secondary Column, Container 1" />
                <container name="container_product_lower_secondary_2" label="Product View, Lower Secondary Column, Container 2" />
                <block class="Magento\Cms\Block\Block" name="block_product_secondary_bottom">
                    <arguments>
                        <argument name="block_id" xsi:type="string">block_product_secondary_bottom</argument>
                    </arguments>
                </block>
            </block>
        </referenceContainer>

        <move element="product.info.main" destination="product-view-wrapper" />
        <move element="product.info.media" destination="product-view-wrapper" />
        <move element="bundle.options.container" destination="product-view-wrapper" />
        <move element="product.info.details" destination="product-view-wrapper" />
        <move element="catalog.product.related" destination="product-view-wrapper" />
        <move element="product.info.upsell" destination="product-view-wrapper" />
        <move element="product.info.overview" destination="product.info.main" before="product.social.links" />
        <move element="container_product_primary_1" destination="product.info.main" before="product.info.price" />

But I need to move it somewhere else in my child theme, like so:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

        <move element="product.info.overview" destination="product.info.main" before="product.social.links" />

</page>

but it doesn't want to extend the parent and as soon as I delete the line from the parent layout file it moves it right where I need it to go. What am I doing wrong?
Edit:
It is in the Infortis > Ultimo theme
The parent xml file:
/app/design/frontend/Infortis/base/Magento_Catalog/layout/catalog_product_view.xml
The child xml file
/app/design/frontend/Infortis/childtemp/Magento_Catalog/layout/catalog_product_view.xml
Answer: Are you sure you located the correct path for the layout extend in your custom theme? Seems to me that the fallback is the issue.
Comment: Yes, because as soon as I remove the parent theme line, then my child theme line takes over.. which means my child theme, at least for the "move" element is not overriding the parent theme. Maybe "move" can not be overridden?
Comment: The first thing is, that you are actually not overriding, you're extending the layout. So perhaps is something about the order of the XML handlers. You can move whatever you want on your own theme based on the blank or vendor/module layout structures.

So to start, can you edit your post with more specs? Like paths of each file, vendor and your theme, and an extra piece of the XML you are trying to extend from the parent.
Comment: There you go, hopefully that's more helpful, thank you for the suggestion and the verbiage. Im not sure why I typed override!
Comment: Awesome! let me take a look!
Comment: Mmmm, seems to be the product itself, are you in a simple, configurable one? or a downloadable/virtual? Because the latest ones had a different XML inside the Magento structure with other movements. On the other hand, I don't know for sure if they are doing something else besides those moves in your custom theme. If your parent were the Blank theme from Magento, it should work, and if your theme is just a child inherited one, it should too. Check the other product_view.xml from every type of products to see. It is weird, it should work :(
Comment: Ok thanks, yeah like I said when I remove the line from the parent xml file then the child takes over and works just fine, so it's correct, but that's why I was thinking maybe a child "move" does not override a parent "move"?
Comment: It does actually. That is why it is odd.
Comment: Yeah I figured out the problem in my answer, it was a very strange one and Im still unsure of why it makes a difference, but it fixed the problem!
Answer: Ok I finally figured out the problem. In the theme table in the database the theme was set to "1" instead of "0" like all the rest of the themes.. Im not sure how it got set to 1, but I believe that means Virtual instead of Physical.. which Im not even sure what that means either, but that solved the problem. Now my child xml extends the parent xml just fine. Thank you for your help!


Create a full page image in HTML for iPhone 6s Plus in horizontal mode

Question: I am trying to create a full page image using HTML / CSS for mobile phones (something similar to https://www.w3schools.com/howto/howto_css_full_page.asp).
I drew a Rhombus (actually a square rotated 45 degrees) and placed it into the HTML page. I am expecting the vertices of the Rhombus to touch the border of the page. Here is my code:

<!DOCTYPE html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width; initial-scale=1.0;
                                  maximum-scale=1.0; user-scalable=no">
  <title>FGFSControllerWeb</title>

  <img style="height: 100%; width: 100%" src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5QECCRksuz0/3gAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAV1SURBVHja7d1bblpBFEXB5sx/zuQvimLHwRjua9X+tBTJhlU0RMC93e/3ZZvvdrt9/KH7YvuNm+Ag9X/xcwPg+vUzAEC9fgYA8LyfAQBi9TMAQP2xnwEA6s98GAAg/byfAQDS9TMAQL1+BgCo188AAPX6GQCgXj8DANTrZwCAev0MAFCvnwEA6vUzAEC9fgYAqNfPAAD1+hkAoF4/AwDU62cAgHr9DABQr58BAOr1MwBAvX4GAKjXzwAA9foZAKBePwMA1OtnAIB6/QwAUK+fAQDq9TMAQL1+BgCo188AAPX6GQCgXj8DANTrZwCAev0MAFCvnwEA6vUzAEC9fgYAqNfPAAD1+hlIA1A/A10A6megC0D9DHQBqJ+BLgD1M9AFoH4GugDUz0AXgPoZ6AJQPwNdAOpnoAtA/Qx0AaifgS4A9TPQBaB+BroA1M9AF4D6GegCUD8DXQDqZ6ALQP0MdAGo/2gGAFB/2sBJD4FRv731rgFA/V4MAKB+BgBQPwMAqJ8BANTPAADqZwAA9TMAgPoZAED9DACgfgbaANTPQBeA+hnoAlA/A10A6megC0D9DHQBqJ+BLgD1M9AFoH4Gdjcw6reygVG/lQ2M+q1sYNRvZQOjfisbGPVb2cCo38oGRv1WNjDqt7KBUb+VDYz6rWxg1G9lA6N+KxsY9VvZwKjfygZG/VY2MOq3soFRv5UNjPqtbGDUb2UDo34rGxj1W9nAqN/KBkb9VjYw6reygVG/lQ2M+q1sYNRvZQOjfisbGPVb2cCo38oGRv1WNjDqt7KBUb+VDYz6rWxg1G9lA6N+KxsY9VvZwKjfygZG/VY2cHv8H5idep8+0Hvst7SBm/qtbOCmfisbcAKYE4AB8xqAAavVv9aaI1yu3myX+u/3+6wDXK7ebJf61++3QjBgwfrXn2+GY8Bq9a+/3g7NgKXqXx8/EMOAdepfn34kkgGL1L/+9aF4BqxQ//ria1EYsMvXv77+YiwG7Nr1r/9+NSIDduH61yNfjsuAXbX+9eDXozNgl6x/PX6BDAbsevWvb10iiQG7WP3ruxfJY8CuVP964jKpDNhl6l/PXSibAbtG/U8CYMCuUf/zABiwC9T/IwAM2Nnr/ykABuzU9b8AAAN23vpfA4ABO2n9LwPAgJ2x/lcCYMBOV/+LATBg56r/9QAYsBPV/xYADNhZ6n8XAAbsFPW/EQADdvz63wuAATt4/W8HwIAduf4tADBgh61/IwAM2DHr3w4AA3bA+jcFwIAdrf6tATBgh6p/BwAM2HHq3wcAA+o/SP27AWBA/Ueof08ADKh/9/p3BsCA+vetf38ADKi/DoAB9dcBMKD+OgAG1F8HwID66wAYUH8dAAPqrwNgQP11AAyovw6AAfXXATCg/joABtRfB8CA+usAGFB/HQAD6n/Ln3CuX/eL4k/3h6jfCfCyc8BRoP4KAAbUXwfAgPrrABhQf/RFcOFecTs7AX56FDgH1F8BwID66wAYUH8dAAPqrwNgQP11AAyovw6AAfXXATCg/joABtRfB8CA+usAGFB/HQAD6q8DYED9dQAMqL8OgAH11wEwoP46AAbUXwfAgPrrAMoG1A9A14D6AegaUD8AXQPqB6BrQP0AdA2oH4CuAfUD0DWgfgC6BtQPQNeA+gHoGlA/AF0D6gega0D9AHQNqB+ArgH1A9A1oH4AugbUD0DXgPoB6BpQPwBdA+oHoGtA/QB0DagfgK4B9QPQNaB+ALoG1A9A14D6AegaUD8AXQPqB6BrQP0AdA2oH4CuAfUD0DWgfgC6BtQPQNeA+gHoGlA/AF0D6gega0D9AHQNqH/H3dzQm97cj/1PqDvFCRA6B9QPAAPqByBvQP3b7xcuJts4sQLiTwAAAABJRU5ErkJggg==" alt="Red dot" />

I tested this page using two devices, one is iPhone 6s, another is iPhone 6s Plus.
The page works well in most cases, including on computers (I tested it with Firefox):

However, for iPhone 6s Plus horizontal mode, it fails:

Expected (shown in red):

Why is it happening? Is it possible to use any other techniques (e.g. Javascript) to retrieve the actual height of the browser window?
I also encounter the same problem when following the code in https://www.w3schools.com/howto/howto_css_full_page.asp . I am not sure whether this happens on other iOS devices.
Answer: You can use JS to detect the orientation and height e.g.
var  width = window.innerWidth || document.body.clientWidth,
var  height= window.innerHeight || document.body.clientHeight

if (window.matchMedia("(orientation: portrait)").matches) {
   // you're in PORTRAIT mode set width and height here
   width  =  550+'px';
   width  =  350+'px';
}

if (window.matchMedia("(orientation: landscape)").matches) {
   // you're in LANDSCAPE mode set width and height here
   width  =  550+'px';
   width  =  350+'px';
}


How to restrict access to a child SVN directory only?

Question: I'm trying to configure permissions for an SVN repository accessed through Apache 2. What I want is to let anyone access the root directory, while restricting to authenticated users a child directory. Example:
/demo
/demo/project1
/demo/project1/sensitive-data  # This path should require user authentication.
/demo/project2

At first, I thought this was as simple as:
<Location /demo>
    DAV svn
    SVNPath /home/svn/demo
    AuthType Basic
    AuthName demo
    AuthUserFile /etc/subversion/passwd
    <LimitExcept GET PROPFIND OPTIONS REPORT>
        Require valid-user
    </LimitExcept>
</Location>

<Location /demo/project1/sensitive-data>
    DAV svn
    Require valid-user
</Location>

When used through HTTP (for example with CURL), Apache conforms to the configuration: I can access:

http://example.com/demo/,
http://example.com/demo/project1/ and:
http://example.com/demo/project2/,

and I get, as expected, a HTTP 401 Unauthorized when trying to retrieve http://example.com/demo/project1/sensitive-data.
On the other hand, doing:

svn checkout http://example.com/demo/ . or:
svn checkout http://example.com/demo/project1/ .

retrieves the whole directory tree, including demo/project1/sensitive-data.
At least, svn checkout http://example.com/demo/project1/sensitive-data/ . requests for a password.
How should I configure the permissions to restrict the access to sensitive-data directory when doing svn checkout http://example.com/demo/ .?
Answer: The <Location /demo/project1/sensitive-data> block is irrelevant when doing a checkout: it is used only when accessing http://example.com/demo/project1/sensitive-data directly, which is the reason why HTTP requests result in HTTP 401 Unauthorized and a checkout of this particular directory requires authentication.
The proper way to configure path-based authorization is explained in Subversion documentation:

<Location /demo> points to an access file:
<Location /demo>
    ...
    AuthzSVNAccessFile /etc/subversion/access.conf
    ...
</Location>

The access file defines who can access the specific files and directories. Basic example:
[/]
* = r                  # Everyone should be able to access the repository.

[/demo/project1/sensitive-data] # Note that there is no trailing slash.
* =                    # Nobody should access the sensitive directory.

Comment: Can this be used similarly in reverse? I want to give guest access to a sub-directory only, and disallow "guest" to browse the rest of the repository.

Or maybe the easiest way would be to just create a separate repository?
Comment: @Zack: I don't have a test environment right now, but I believe that yes, you can do that. Also relevant: [What are the permissions to set on SVN root?](http://serverfault.com/q/538036/39827)


Getting the URL of the Calling Application

Question: When using JAX-RS is there a way of getting information about who is calling the webservice? Can we get the ip or url of the calling application? If so how do you do it?
Thanks
Answer: The below should work on Weblogic (servlet container).
Once you get the HttpServletRequest via the @Context, you can access any of the methods of HttpServletRequest.
@GET
@Produces("text/plain")
public String showIP(@Context HttpServletRequest hsr) {
   return hsr.getRemoteAddr();
}

Note that there is no way to figure out what the real client IP address if there are any proxies in between.


Modified Euler explanation

Question: I've implemented the modified Euler's method to solve ODEs as described in my lecture (here only important parts):
F = @(x,Y) [Y(2),-sin(Y(1))];
...
for i=1:N
    Yh=Y+h/2*F(x,Y);
    Y=Y+h*F(x+h/2,Yh);
    x=x+h;
   ...
end
What I don't get is: Why do I give $x$ over to the function $F$? It is not used there, because only the elements of vector $Y$ are used. Therefore it does not make sense to me to give $x$ or $x+h/2$. Can anybody help me?
Answer: Generally, ordinary differential equations are formulated as non-autonomous, $y'=f(x,y)$. One can make such an ODE autonomous by adding $x$ as additional coordinate to the vector $y$. This is often useful for theoretical purposes, the expansions for Runge-Kutta methods are shorter for the autonomous case. In applications this transformation is an unnecessary complication.
That is why numerical integration methods for ODE are formulated for the more general equation $y'=f(x,y)$. That $x$ is unused in autonomous ODE is then not even a disadvantage. There are no essential simplifications in the autonomous case to value the extra effort for a separate implementation of this case.
Thus your integration loop applies to a greater class of ODE than required for the example, autonomous as in the example as well as non-autonomous.
Comment: sorry, I do not get what you want to say :/
Comment: There are cases where the $x$ is used. It just happens that in this case the $x$ is not used.
Comment: Thanks! But then I do not get why I call this function one time with 'x+h/2'. I could also call it with 'x' only, would be the same. But modified euler is calculation the derivate at two different places on the graph. What therefore would not be achieved by this function calling...
Comment: $y_0(x)=x$ satisfies the differential equation $y_0'=1$. In this extended version, $K_1=[1, Yh]$ and $[x,Y]+h/2·K_1=[x+h/2·1, Y+h/2·Yh]$. This is not arbitrary, but consistent.

Modified Euler explanation


WPF MVVM Datagid with ComboBox column set Background of ComboBox with alternate color

Question: I have edited the ComboBox Style to bind the ComboBox ToggleButton's Background to the ComboBox Background property (the only way to do it apparently).
...

                                                </Style>
                                          </ComboBox.Style>
                              </ComboBox>
                          </DataTemplate>
                      </DataGridTemplateColumn.CellTemplate>
                  </DataGridTemplateColumn>
              </DataGrid.Columns>
</DataGrid>

How to achieve that?
Answer: Use:
<DataTrigger Binding="{Binding Path=(ItemsControl.AlternationIndex), RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" Value="1">
     <Setter Property="Background" Value="#FFFFFFCC"/>
</DataTrigger>


SPN generation for multiple service account on a Web server

Question: I am trying to achieve Azure SSO in my organisation. I have a web server hosting multiple websites and web application under those sites. Users access them in below fashion
https:// < SiteName > / < ApplicationName > /

We have a service account configured for different application, means I have multiple service account for a single "WebSite" and same service account being used for different applications.
Now to achieve Azure SSO, I must configure SPNs for my service accounts, and as per microsoft same spn cannot be assigned to multiple service account.
to configure spn we have below command
Setspn –S HTTP/NETBIOS_NAME_OF_IIS_SERVER domain\username
Setspn –S HTTP/FQDN_OF_IIS_SERVER domain\username

How can I assign same FQDN/NetBIOS name to all service account ?
Even if I use DNS name for my web Sites still I have to assign same spn to multiple service account.
Answer: Yes, this is a fundamental issue with SPN's, you can't have more than one SPN for a URL on a single server. So in your situation where you different apps run under a single website and you need to use delegation or SSO, then they all have to run with the same service account, so you can register a single SPN for that URL.
If that is not possible you either need to host your apps with different service accounts on the same server under a different URL (assuming you setup the SPN for the URL), or different server  if you are limited to using server names
Comment: Hmm , yeah i also think same but , let see what others have to say about this..
Comment: Can we add application path in SPN like "https /  / < ApplicationName > /" ?
Comment: No you cannot do that


MVVM + multilevel/nested databinding

Question: The Structure
The scenario is that I have a Pivot where each item is the menu of a certain day. Inside that PivotItem I need to display the dishes on the menu, grouped by category (e.g. soups, desserts, ...).
I have implemented this with the MVVM-model.
I thus have the folowing models:
public class Menu{
    public string Date;
    public List<DishList> Categories;
}
public class DishList
{
    public string Category;
    public List<Dish> Dishes;
}
public class Dish
{
    public string Name;
    public string Price;
}

Edit: these are simplified here, the actual structure for each field is like this:
    private string _date;

    //Get_Set
    public string Date
    {
        get
        {
            return _date;
        }
        set
        {
            if (value != _date)
            {
                _date = value;
            }
        }
    }

So the structure would be like this: a PivotElement containt a Menu-object. Inside it, I show Categories, a number of DishLists. Inside that Dishlist, I show the Category and the different Dishes, each with it's Name and Price. A mockup to make things a bit more clear (pdf-file on SkyDrive); http://sdrv.ms/12IKlWd
I have the following viewmodel
public class MenuViewModel : INotifyPropertyChanged
{
    private ObservableCollection<Menu> _Menus;
}

The view that should implement (the structure) of the desired layout is as following:
<phone:Pivot
        ItemsSource="{Binding Menus}">
        <phone:Pivot.HeaderTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Date}" />
            </DataTemplate>
        </phone:Pivot.HeaderTemplate>
        <phone:Pivot.ItemTemplate>
            <DataTemplate>
                <ItemsControl
                    ItemsSource="{Binding Categories}">
                    <TextBlock
                        Text="{Binding Category}"/>
                    <ItemsControl
                        x:Name="Dishes"
                        ItemsSource="{Binding Dishes}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="300"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>

                                    <TextBlock
                                        Grid.Column="1"
                                        Text="{Binding Name}"/>
                                    <TextBlock
                                        Grid.Column="2"
                                        Text="{Binding Price}"/>
                                </Grid>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </ItemsControl>
            </DataTemplate>
        </phone:Pivot.ItemTemplate>
    </phone:Pivot>

As you can see, there's nested databinding to get to the data it needs.
The only code I then do on the page is
DataContext = App.ViewModel;

The Problem
When I launch it up, I get the correct Data displayed in the PivotItems header, and the correct number of PivotItems. Ufortunately, that's it; the content of the PivotItem stays empty. The first level of databinding thus works, but no further.
The way I was thinking

1st level: each PivotItem is linked to an object of type Menu, with header Menu.Date
2nd level: Inside that PivotItem I set the ItemsSource of a ItemsControl to that Menu.Categories
3rd level : The ItemsSource now is Menu.Categories.Dishes

I have already searched quite a bit and fiddled around with Datacontext and ItemsSource and different kinds of "{Binding ...}", but I can't get it to work. I would like to do the binding in xaml, and not in the code-behind.
Notes

The only function is to display data. The data is stationary and loaded once from a file.
That's why I chose ItemsControl instead of ListBox, there is no need to select anything.
This is a MVVM-approach to my previous question: Databinding + Dynamic Pivot
Answer: First off, you're trying to access a private field in the title so that won't work. These also have to be properties, not fields.
<TextBlock Text="{Binding Date}" />

private string Date;

Next you're binding to Category, which is also private and not a property.
<TextBlock Text="{Binding Category}"/>

private string Category;

And you're binding to the Categories field which needs to be a property.
<ItemsControl ItemsSource="{Binding Categories}">

public List<DishList> Categories;

Even if you correct these issues, you still won't get what you want because your outer ItemsControl doesn't have an ItemTemplate.
<ItemsControl ItemsSource="{Binding Categories}">
  <TextBlock Text="{Binding Category}"/>
  ...
</ItemsControl>

Added: Your new error is because the DataTemplate can only have one child element so you need to use a container like a StackPanel.
<ItemsControl ItemsSource="{Binding Categories}">
  <ItemsControl.ItemTemplate>
    <DataTemplate>
      <StackPanel Orientation="Horizontal">
        <TextBlock Text="{Binding Category}"/>
        <ItemsControl x:Name="Dishes" ItemsSource="{Binding Dishes}">
          ...
        </ItemsControl>
      </StackPanel>
     </DataTemplate>
   </ItemsControl.ItemTemplate>
</ItemsControl>

Comment: And no lists please, `ObservableCollection` is the preferred collection type in MVVM.
Comment: 1. Al of the values actually have properties instead of fields, but I didn't type them here in hope to keep it simple. Apologies, I edited the post with an example of what it's like in the real code.
Comment: 2. I added the ItemTemplate for the outer ItemsControl. However, I now get the error in VS saying "The property VisualTree is set more then once". Is it not possible to put an ItemsControl inside an ItemsControl?
Comment: 3. As regards to the Lists; I had ObservableCollection before. However, since none of the data will change, there isn't any need for the Nofitystuff, and the overhead associated with it. I therefore changed it to Lists. I used ObervableCollection in my ViewModel though, because it's needed only there. Is that reasoning incorrect?
Comment: YES, It's finally working! Spent hours on the databinding and MVVM concept ... Thank you! I also changed the Lists to ObservableCollections, but still not sure if that's really better.

MVVM + multilevel/nested databinding


Solve the ordinary differential equation

Question: The problem is:

Solve the ordinary differential equation:
$$\tan(y) \;dy-\left(\frac{e^{(2x)}\cdot\cos(y+3)\cdot \sqrt x}{2}\right) \cos(y)\; dx=0$$

I am trying to find the solution of this by using an integrating factor or linear equation, but not get anything.
Comment: @Psuresh: **Hint:** It is a Separable Equation - a bit of an ugly result.
Comment: I edited the formatting of the equation by adding parenthesis. Check if that's what you want to express.
Answer: Well, we know that:
$$\tan\left(\text{y}\right)\space\text{d}\text{y}-\left(\frac{\cos\left(3+\text{y}\right)\cdot e^{2x}\cdot\sqrt{x}}{2}\right)\cdot\cos\left(\text{y}\right)\space\text{d}x=0\tag1$$
This gives that:
$$2\cdot\frac{\text{y}'\left(x\right)}{\cos\left(\text{y}\left(x\right)\right)\cdot\cos\left(3+\text{y}\left(x\right)\right)\cdot\cot\left(\text{y}\left(x\right)\right)}=e^{2x}\cdot\sqrt{x}\tag2$$
Take the integral of both sides with respect to $x$:

For the LHS, substitute $\text{u}=\text{y}\left(x\right)$:
$$\mathcal{I}=\int2\cdot\frac{\text{y}'\left(x\right)}{\cos\left(\text{y}\left(x\right)\right)\cdot\cos\left(3+\text{y}\left(x\right)\right)\cdot\cot\left(\text{y}\left(x\right)\right)}\space\text{d}x=$$
$$2\int\frac{1}{\cos\left(\text{u}\right)\cdot\cos\left(3+\text{u}\right)\cdot\cot\left(\text{u}\right)}\space\text{d}\text{u}\tag3$$

Now, substitute $\text{v}=\tan\left(\text{u}\right)$:
$$\mathcal{I}=2\int\frac{\text{v}}{\text{v}\sin\left(3\right)-\cos\left(3\right)}\space\text{d}\text{v}=2\cot\left(3\right)\int\frac{1}{\text{v}\sin\left(3\right)-\cos\left(3\right)}\space\text{d}\text{v}+2\csc\left(3\right)\int1\space\text{d}\text{v}=$$
$$2\cot\left(3\right)\int\frac{1}{\text{v}\sin\left(3\right)-\cos\left(3\right)}\space\text{d}\text{v}+2\csc\left(3\right)\ln\left|\text{v}\right|\tag4$$
Now, substitute $\text{w}=\text{v}\sin\left(3\right)-\cos\left(3\right)$:
$$2\cot\left(3\right)\int\frac{1}{\text{v}\sin\left(3\right)-\cos\left(3\right)}\space\text{d}\text{v}=2\cot\left(3\right)\csc\left(3\right)\int\frac{1}{\text{w}}\space\text{d}\text{w}=2\cot\left(3\right)\csc\left(3\right)\ln\left|\text{w}\right|+\text{C}_1\tag5$$

For the RHS:
$$\int e^{2x}\cdot\sqrt{x}\space\text{d}x=\frac{4e^{2x}-\sqrt{2\pi}\cdot\text{erfi}\left(\sqrt{2}\cdot\sqrt{x}\right)}{8}+\text{C}_2\tag6$$

So, we get that:
$$2\csc\left(3\right)\left(\cot\left(3\right)\ln\left|\tan\left(\text{y}\left(x\right)\right)\sin\left(3\right)-\cos\left(3\right)\right|+\ln\left|\tan\left(\text{y}\left(x\right)\right)\right|\right)=\frac{4e^{2x}-\sqrt{2\pi}\cdot\text{erfi}\left(\sqrt{2}\cdot\sqrt{x}\right)}{8}+\text{C}$$


"Ordinal" is to "level of measurement" as "dependent variable" is to __________

Question: The Question
If I'm drawing up a table that describes some variables -- a data dictionary, say -- and I consider whether a variable is "ordinal", or "nominal", or "interval", or "ratio", I'm said to be thinking about the levels of measurement of that variable. (At least according to intro stats textbooks.) "Levels of measurement" is the category that those words belong to.
In the same way, if I'm thinking about the concepts "yellow" and "blue" and "red", those belong in the category "colors".
But if I'm thinking about whether a variable is dependent (my outcome) or independent (my predictor), what category does that belong to? Being a dependent or independent variable is what kind of thing? Does that status have a commonly used name?
For you Americans out there, I can phrase it in the form of one of those classic SAT questions:
Ordinal is to level of measurement as dependent variable is to _________.
Can anyone fill in the blank?
(Note that I'm not saying that levels of measurement have anything to do with whether a variable is independent or dependent. I'm just using "levels of measurement" as an analogy for "name of category".)
What I (and others) have come up with
My best guess at an answer is type of variable, as in
<code>Q: Which type of variable is 'smoking status'?

A: Oh, 'smoking status' is my independent variable.
</code>
But that's too ambiguous, isn't it? People could confuse "variable type" with "level of measurement" or "numeric" or "string" or something.
This was a difficult question to phrase, so while I searched CV for previous answers before I asked, I may well have missed something. In fact I may well have missed an extremely obvious answer to this question (though I checked two textbooks to see how they talk about this topic and neither gave a category or kind).
EDIT
He may not have intended it, but @whuber has posed a possible answer in the discussion below: he's called it "the role of a variable in a regression model" (my emphasis). That's getting a lot warmer, in terms of what I'd been looking for, but it doesn't sound that official. (Maybe it is!) But it's a good one.
Comment: This reminds me of Lewis Carroll's (joke) riddle, "why is a raven like a writing desk?"  The organizing principle of Stevens' typology (groups of transformations) has *absolutely nothing* to do with the role of a variable in a regression model (that is, "dependent" vs. "independent").  This makes it very hard to determine what you're trying to ask.
Comment: logjammin Indeed, which is why I agree with @whuber that it isn't clear what is being asked by comparing these two topics.
Comment: Many sources are discussing elements of [Stevens 1946](https://www.science.org/doi/10.1126/science.103.2684.677). This comes down to what, if any, group structure you want to preserve with transformations of your variables.
Comment: See: https://en.wikipedia.org/wiki/Dependent_and_independent_variables
Comment: Also contrast to: https://en.wikipedia.org/wiki/Independence_(probability_theory)
Comment: One way to fill in the blank is that a dependent variable is a 'variable'. But I suspect you are not looking for something that obvious.
Comment: @whuber Thanks, yes, I know -- it was an analogy. I might have said "Volvo" and "type of car" just as easily.
Comment: @DifferentialCovariance thanks, but Stevens doesn't mention dependent or independent. (Though this is an extremely cool old paper, thanks for referring to it.) Also, the wikipedia for ind/dep variables does not name a category they belong to.
Comment: I'm not comparing them directly at all. I know they have nothing to do with each other. I just chose "measurement level" as an analogy because this is a stats website, but it didn't need to be that. The SAT question could easily be "Yellow is to color as dependent variable is to _____"
Comment: @DifferentialCovariance yeah that's getting warmer -- seriously! They're "variable types", of course, but what type of type? If I just call those words "types of variable" people are liable to go "oh, like measurement levels?"
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/135097/discussion-between-logjammin-and-differentialcovariance).
Comment: "[Official](https://stats.stackexchange.com/questions/246302)"??
Answer: If you want to split variables into 'roles' you might get some joy out of categorizing them as 'observed' vs 'unobserved' plus mentioning their position in a DAG describing your study setup. Discussed in depth in https://xcelab.net/rm/statistical-rethinking/
There's not really a right or wrong with terminology/categorization because the 'right' answer is whatever is most convenient for your purpose! But this is one way. And I do think this language is convenient for describing why dependent and independent variables are usefully distinct, while also extending very naturally to inference in observational studies where the experimental language doesn't apply. It also naturally handles situations were there might be occasional NA gaps in any of the variables, forcing you to do inference over them regardless of their 'role', which is totally a thing that happens sometimes.
Comment: While [observable](https://en.wikipedia.org/wiki/Observable_variable) vs l[atent](https://en.wikipedia.org/wiki/Latent_variable)  variables is a worthwhile distinction, it is not clear how it relates to a general class for which dependent variables are a member as asked for in the question. Dependent vs independent variables is a logically independent distinction from observable vs latent variables.
Comment: This is a neat line of thought -- thanks!. I've admired McElreath from a distance for a while now, and have him on the top of my list for "people to read when I try and get into Bayesian stats", so I'm eager to take a look at this. But ultimately my question wasn't about splitting variables into roles, nor about right or wrong; it was just about whether there's a commonly accepted name for a certain category of thing. Trying to cover my bases for a table I'm making in a study. If there isn't such a name, I'll feel better about making up my own at the top of my Data Dictionary.


Datepicker Clears Modal Data Value

Question: I have a foreach loop with buttons which trigger a modal. The modal has a form which includes a datepicker input field. For convenience, some of the other form fields are prefilled with variables from the initial trigger button. However when I select the datepicker all other input fields are wiped. I assume this is because my datepicker event is overwriting my data fields, but can't figure out how to get them both in harmony.
I've tried reordering date picker and modal event, and have followed other examples with various datepicker versions but to no success. I can put other none datepicker fields in which don't cause an issue.
Version: bootstrap-datepicker/1.7.1/

the trigger button with some variables:
<button data-toggle='modal' data-one='{$row['thingone']}' data-two='{$row['thingtwo']}' data-target='#myModal'>The Button</button>

the form in my modal:
<form method='post' action=''>

                One Thing
                Two Things
                The Date

                <input class='form-control' type='text' name='one' id='one' >
                <input class='form-control' type='text' name='two' id='two' >
                <input class='form-control' id='the_date' type='text' data-date-format="yyyy/mm/dd" name='the_date' >

        <button type="submit" class="btn btn-primary"> Update </button>

</form>

and my script at the end of the page for this iteration:
$('#myModal').on('show.bs.modal', function (event) {

    var button = $(event.relatedTarget)
    var one    = button.data('one') //info from data-*
    var two    = button.data('two')
    var modal  = $(this)
    modal.find('.modal-body #one').val(one)
    modal.find('.modal-body #two').val(two)

    $('input[name="the_date"]').datepicker({
        format: "yyyy/mm/dd",
        autoclose: true,
        todayHighlight: true
    });

})

Data thing one and thing two populates to their respective fields correctly, but clicking on the datepicker input field deletes the other fields if they've been populated from the trigger button.
Any help would be greatly appreciated!
Comment: We can be a little tricky and set other filed's value's again when datepickers 'onDateChange' event triggered.
[documentation](https://bootstrap-datepicker.readthedocs.io/en/stable/events.html#changedate)
Comment: It seems that when the date picker is getting focused the modal show function is getting triggered. You can move the datepicker initialization out from the function and add  a check `if(!event.relatedTarget) return;` at the top of the function.
Comment: Might be a good work around until I can figure out something cleaner thanks!
Comment: Your selector `$('input[name="the_date"]')` might be ambigious, I believe the right way to use it would be without the double quotes `$('input[name=the_date]')`
Comment: removing the double quotes gives the same results, I also tried using: `#the_date` but most examples I came across used the double quotes method..
Comment: Thanks Suraj, I did something similar to your suggestion and got it working! If you want to post an answer I'll accept it.
Answer: Similar to @suraj's suggestion in the comments I simply put a check at the beginning of my function which solved the issue of wiping the other fields when selecting the date input. It doesn't matter for the result if datepicker is in or out of the main function.
 if ( event.relatedTarget != null) {
     var button     = $(event.relatedTarget) // Button that triggered the modal
 }

Using: alert (event.relatedTarget) in my show function I realised that the entire function was being re triggered by the date field, only when using the .datepicker, which would result in event.relatedTarget being null, because obviously the data info for the other fields isn't stored in the datepicker, and because it re-triggers the function, it would update the find fields with the new empty data.
The above snippet prevents the variables from being rewritten as null when datepicker is selected, but the show function still runs again when datepicker is selected, only now it doesn't change any input data.
I still don't fully understand why the show modal is triggered again by the datepicker, but this is the most simple workaround I've found until I can better understand what's going on...

Datepicker Clears Modal Data Value


What does conditional probability $P(A|B)$ mean when $P(B)=0$?

Question: Does anyone ever ascribe a value to $P(A|B)$ when $P(B)=0$? I realize that it being undefined makes sense, but I also feel like there should be a sensible definition.
Comment: @Ahmed isn't $P(B)=0$ exactly what OP just said?
Comment: @blue The question rendered oddly on my screen $P(B)=0$ looks like $P(B)=o$ for some reason in the title. Maybe a meta-math thing
Comment: I don't have an answer set to go, but I think it might be interesting to think about this question in terms of measures instead.  http://en.wikipedia.org/wiki/Conditional_expectation
Comment: It's the unfortunate typesetting of the numerals used on this website that caused Ahmed's confusion.  $0123456789$ without dollar signs becomes 0123456789.  The zero, 0, looks more like a lowercase o than the mathmode numeral $0$.
Comment: Worth mentioning: [Borel–Kolmogorov paradox](http://en.wikipedia.org/wiki/Borel%E2%80%93Kolmogorov_paradox)
Comment: Do you mean when $P(B) = 0$ ?
Comment: $P(B)=0\,\Rightarrow\,P(A\cap B)=0\,\Rightarrow\,P(A\cup B)=P(A)$
Answer: As an example of where this is meaningful, consider two independent standard normal random variables $X$ and $Y$ so each with mean $0$ and variance $1$.
Suppose $A$ is the event $X\le 1$ and $B$ is the event $X+Y=2$.
Then $P(A)=\Phi(1) \approx 0.8413$, $P(B)=0$ since this is a point in a continuous distribution,  and $P(A|B)=0.5$ by symmetry.
Answer: Let $a,b$ be real-valued random variables on $\Omega \subset \mathbb{R}$ whose joint density $f$ is absolutely continuous with respect to the Lebesgue measure on $\mathbb{R}^2$. Then conditional probability has the definition:
$$ P(a \in A | b \in B) : = \frac{ \int_{A \times B} f(x,y) \, dx \, dy}{ \int_{\Omega \times B} f(x,y) \, dx \, dy} $$
If $B$ has Lebesgue measure zero, then intuitively, we would like to define this same quantity by taking some sequence of non-negligible measurable sets $B_n \downarrow B$ and using the limit $P(a \in A | b \in B_n)$. However, it should be easy to show that this limit is not independent of the choice of $B_n$ when $B$ contains more than one point. Intuitively, if there were two points, then any weighted sum of Dirac masses in the $b$ direction supported at those two points can be obtained by some limit. This shows that, in general, $P(A | B)$ is not well-defined for $P(B) = 0$.
However, if $B = \{b_0\}$ is a singleton, then this limit is defined (intuitively, at the limit, we have a Dirac mass in the $b$ direction), and we obtain
$$ P(a \in A | b = b_0) : = \frac{ \int_{A} f(x,b_0) \, dx}{ \int_{\Omega} f(x,b_0) \, dx} $$
Thus, in this restricted setting, the conditional probability is defined.
Here is a concrete example: Suppose both $a,b$ are i.i.d. uniform random variables on $[0,1]$. Suppose $A = [1/4, 3/4]$ and $B = \{1/3\}$. Then $P(a \in A | b \in B) = 1/2$. To see this, notice that the event $b \in B$ means that $a$ is allowed to take any values on $[0,1]$. Therefore the event $\{a \in A \cap b \in B\}$ means $a$ is allowed to take only values on $[1/4, 3/4]$, which is half the length of the full interval, so the conditional probability is $1/2$. Essentially, this example relies on the fact that sections of a larger sample space can "inherit" a measure in a well-defined way under certain nice conditions.
Henry's excellent example also falls under this same framework.
Comment: what... are the implications of this that can be understood by intuition?
Comment: I have added a concrete example.
Answer: From Wikipedia:

If $P(B) = 0$, then the simple definition of $P(A|B)$ is undefined.

And with regard to your question:

I also feel like there should be a sensible definition.

Being undefined is a sensible definition, in fact, it's the only sensible definition! By analogy, consider $\frac 1 0$: it is undefined. Does that sound like a sensible definition to you?
Comment: I mean, I see that $1/0$ is a problem. I just didn't know if maybe some other value would give something useful... I guess not.
Comment: @anthony I can't really think of a *useful* value that it could return. What exactly would be a useful value when the situation in the first place is meaningless?
Comment: It might make sense to return a $1$ in this circumstance.  In general, we would say that $P(A\mid B) = 1$ corresponds to the truth of the implication "if $B$ occurs, then so must $A$".  In the circumstance of $P(B) = 0$, the statement becomes vacuously true, so perhaps it is logical to say $P(A\mid B) = 1$.
Comment: I would like $1/0$ to be the positive infinity, or at least a complex one. Now $0/0$ is a problem...
Comment: @Omnomnomnom that's a fair point. I should have considered vacuous truths when writing this answer.
Comment: @Omnomnomnom But in that case, you also have the opposite truth, $P(\bar A\ |\ B) = 1$, corresponding to "if B occurs, then A must not". But then when $B = 0$, we have $P(A\ \textrm{or}\ \bar A) = 1+1=2$, which is absurd. I think the best you could hope for is describing $P(A\ |\ B)$ as a limit as the size of $B$ vanishes, which may or may not be possible depending on the context.
Answer: Conditional probability could be seen as a useful tool to create new probabilistic spaces from a given one. It is a process equivalent to create new algebraic structure from others well know. For example, think of the euclidean vector space $(\mathbb{R}^3,+,\cdot,\mathbb{R})$, it represents the physical space, a new space can be constructed from it by considering only the first coordenates, obtaining $(\mathbb{R},+,\cdot, \mathbb{R})$ which represents an endless straight-line. In the case of the probabilistic "structure", given a probabilistic space, $(P,\Omega,\mathcal{A})$, the conditional operator $\lvert$ gives place to a new probabilistic space, whose probability function is defined by $P(A \lvert B) = \frac{P(A \cap B)}{P(B)}$ which means the probability the event A occurs once the event B has happened. That is the reason by which the conditional operator is also called the dynamical operator... What happens if P(B)=0? In such a case, you would obtain a trivial probabilistic space, since each even would be impossible, like the nil vectorial subspace $({0},+,\cdot,\mathbb{K})$ in Linear Algebra, but the Kolmogorov axiomatic definition of probability function imposes the condition of that the probability of the space is 1, that is the reason by which it is not studied the case $P(B) = 0$, because the natural definition doesn't give rise to a new probabilistic space.
Answer: Well, the actual probabilistic rule is $P(AB) = P(A|B)P(B) = P(B|A)P(A)$ and Bayes' Theorem is exactly that: a theorem derived from the product rule. So yes, $P(A|B)$ can have some value even if $P(B) = 0$, but it's not a very useful value since it will never be used. If $P(A)\neq 0$, then $P(B|A) = 0$ also necessarily and $P(A)$ is the only potentially useful number there (in other contexts, not with $B$); and if $P(A)=0$ then both $P(B|A)$ and $P(A|B)$ can have some value and it would be meaningless.


Getting error while adding a webview in IntentService android

Question: I was refering this post for adding a webview in service. However, I keep getting the error that windowManager is being added, but it already has a parent.
Code:
<code> WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.TOP | Gravity.START;
    params.x = 0;
    params.y = 0;
    params.width = 0;
    params.height = 0;

    LinearLayout view = new LinearLayout(this);
    view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));

    webView = new WebView(this);
    webView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));

    view.addView(webView);
    webView.loadUrl("http://google.com");
    windowManager.addView(webView, params);
</code>
Log:
<code>Process: com.demo.webviewscriptapplication, PID: 32282
    java.lang.RuntimeException: Unable to create service com.demo.webviewscriptapplication.MyService: java.lang.RuntimeException: view android.webkit.WebView{9e874fa VFEDHVC.. ......I. 0,0-0,0} being added, but it already has a parent
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3201)
        at android.app.ActivityThread.-wrap5(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6126)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
     Caused by: java.lang.RuntimeException: view android.webkit.WebView{9e874fa VFEDHVC.. ......I. 0,0-0,0} being added, but it already has a parent
        at android.view.View.assignParent(View.java:15012)
        at android.view.ViewRootImpl.setView(ViewRootImpl.java:731)
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:94)
        at com.demo.webviewscriptapplication.MyService.onCreate(MyService.java:67)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3191)
        at android.app.ActivityThread.-wrap5(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6126)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
</code>
Comment: can you share your layout xml and code. The error is you are to add web view which has already been added in other layout.
Comment: @Praveen added the code
Comment: windowManager.addView(webView, params); >> here is the error. You should use windowManager.addView(view, params); according to your code
Comment: @Praveen Thanks a lot!
Answer: view.addView(webView) Just remove this line then it should work properly.
If not create proper webview object using application context or creating xml file.
Basically error is you are adding webview two times to the view.


Achieving Interpolation in Angular 2

Question: Hi I am new to angular 2 and typescript and am trying to add html inside the tags of a component. This is what I have so far:
Component({
    selector: 'chart',
    templateUrl: './app/chart/chart.component.html'
})

export class Chart {
}

The html has the following strcuture:

What I would like is to use the component in the following way:
<chart>

'Hello World'

</chart>

When angular parses this code it should display the following:
  <chart>

'Hello World'

  </chart>

In angular 1 this was achieved via directive interpolation.Is there any way to achieve this in angular 2?
Comment: Possible duplicate of [Passing a component as an 'argument' to another component in Angular 2](http://stackoverflow.com/questions/34575897/passing-a-component-as-an-argument-to-another-component-in-angular-2)
Answer: chart.component.html should look like

      <ng-content></ng-content>

to achieve what you want.

Achieving Interpolation in Angular 2


Gradle test fixtures plugin for Android development

Question: attempting to use gradle test fixtures with gradle 6.6.1, using the following set of plugins
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'org.jetbrains.kotlin.kapt'
apply plugin: 'java-test-fixtures'

produces an error along the lines of
org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method testFixturesApi() for arguments [io.kotest:kotest-property:4.3.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

(similar results for testFixturesImplementation)
Adding the java-library plugin as apparently required by the documentation:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'org.jetbrains.kotlin.kapt'
apply plugin: 'java-test-fixtures'
apply plugin: 'java-library'

yields something along the lines of
The 'java' plugin has been applied, but it is not compatible with the Android plugins.

How can I get gradle testFixtures working when building with kotlin 1.4 (and possibly kotest) for Android on Ubuntu 20.04?  My overall intent is to use custom kotest generators for creating property testing fixtures shared among several testing source trees under the same app project, namely
./app/src/test/java
./app/src/androidTest/java

There are good reasons for sharing test helpers in support of code dryness; such approach is not the subject of this discussion; I am not looking for advice in that regard.  The goal of this question is a manner to get testFixtures working, since I'm obviously not understanding how to do so, and your help in this direction is much appreciated.  I can provide additional details if the above description, deliberately terse, is lacking in necessary detail.
Answer: They are not supported at android projects, I tested on production project, also created example projects. I have such error

Unable to find a variant of project :modtwo providing the requested
capability Fictures:modtwo-test-fixtures:unspecified

It seems they have conflicts with product flavors. Also wrong information here, because in the example it is not an android project.
Answer: apply plugin: 'java-test-fixtures'
apply plugin: 'java-library'

You don't want to put either of those plugins in your application module. The belong in the library module that's producing the fixtures.


Contextual filter using taxonomy alias

Question: I have a list of nodes that I want to attach as a block to another node using a contextual filter. Depending on the URL alias I want a specific node to be attached to it. The problem is that I want the contextual filter to be based on a taxonomy alias as oppose to a taxonomy ID.
I looked at this solution: Contextual filter with a block view and this one: Views contextual filters taxonomy name  and I'm close however the second solution has an option that I can't find on my version. It reference a Filter Value Type option which would allow me to Term name converted to Term ID. This is exactly what I need, however I can't find this option.
I followed the instruction step-by-step; I tried creating different View and display versions, different items as my Contextual filter but nothing works.
These links are from 2011 and 2012, respectively. I'm using Drupal 8, so I'm wondering if this option has been removed or replaced with some other way to accomplish this task. Either way, I'd appreciate it any help.
Thanx
Answer: I got it to work by adding a relationship to a taxonomy field that exposed the taxonomy name. Then on the Contextual Filter I followed what the links said in regard to Specify validation criteria. But since I still can't find the Filter Value Type option, I just set the Case option to Capitalize each word and in the More section I checked the Transform spaces to dashes in URL option.
This allowed the value in the URL (which was a URL alias) to match my Taxonomy term field.
I don't know if there's an easier way to accomplish this and I'd still like to know why I couldn't find the Filter Value Type option, but at least it's working.

Contextual filter using taxonomy alias


How to prevent a particular application like YouTube from starting?

Question: Basically I want to prevent a particular application from starting. A further question may be related to the Android internal behaviors from clicking application button to application running. Help clarifying each internal step will be highly appreciated.
Put it in detail: When the user clicks 'YouTube' button on the screen (assuming YouTube has not been started by far), who gets to know first this particular click is YouTube? Also, I think finally Zygote will spawn a new process representing YouTube, and this process will be written in process table in kernel. Should I let Zygote know this is an application that the user should not start?
Answer: If the user starts an app by clicking on an app icon per default you won't be able to intercept it.
You might be able to do something if you made your own launcher application which had it's own shortcuts to all apps that reside on the phone. That would be my best suggestion to a possible work around.
Comment: Thank you and I am sorry I did not come back to this thread quickly. My solution would be working with ActivityManager, then you can discover package name.


How to change date format in datepicker using JqueryUI?

Question: I have datepicker, it does display date, but i want use correct date format according my timezone(in SA).

   <input type="text" class="input-sm form-control" name="from" placeholder="startdate"/>
   To
   <input type="text" class= "input-sm form-control" placeholder="enddate"/>

 // date functionality
    $(function() {
    $('.input-daterange').datepicker({
      autoClose:true,
      dateFormat: 'yy-mm-dd'

    });
  });

Comment: please share yout date format
Comment: I did, check the above Jquery code and HTML
Comment: please check my answer as per your required format
Answer:

$(document).ready(function () {
  $('input[id$=tbDate]').datepicker({
    dateFormat: 'yy-mm-dd' //add your format here
   });
});
<!DOCTYPE html>

    <title>jQuery UI Datepicker - Change Date Format Example</title>
    <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css" rel="stylesheet" />

Set focus on the box to select a date. (shows default format)

        Date: <input type="text" id="tbDate" />

Please check link for more info
Link


How do I add JS libraries in DrupalGap

Question: I am hoping to add Slick Library within my DrupalGap but when I try to use it, I am unable to.
The library is added normally within index.html but when one my node page (which has the HTML in it) tries to use it, it doesn't work.
Any idea how to do this correctly.
Answer: Including the Slick carousel .js file in the index.html file is correct.
You can use the brand the new hook_entity_view_alter to attach a pageshow handler to the node's page:

http://api.drupalgap.org/7/global.html#hook_entity_view_alter
http://docs.drupalgap.org/7/Pages/Page_Events

In the pageshow handler is when you'd initialize the carousel. The pageshow event fires after page is shown to the user. There are a few other hooks you could use to have a chance to place the pageshow event on a node's page within the app:

http://api.drupalgap.org/7/global.html#hook_entity_post_render_content
http://api.drupalgap.org/7/global.html#hook_entity_post_render_field

The hook_entity_view_alter is the most powerful and is brand new, so you need the latest bin/drupalgap.min.js file and the latest jdrupal.min.js file to run it. But that is the hook I'd recommend using

How do I add JS libraries in DrupalGap