Nginx configuration issue for proxying IDM

Question: I was working on accessing IDM using nginx, but somehow css and js files are not able to redirect properly.My configuration in nginx is as follows:
location /idm/{

proxy_pass           https://keyrock-host:keyrock-port/;
proxy_set_header   X-Forwarded-Host    $host;
proxy_set_header    Host                $host;
proxy_set_header    X-Real-IP            $remote_addr;
proxy_set_header    X-Forwarded-For        $proxy_add_x_forwarded_for;
rewrite ^/$  $1/idm/$2 redirect;
}

But it is not working properly still.

Update 1:
172.16.40.7 - - [2019-04-01T11:34:01+00:00] "GET /stylesheets/bootstrap-select.min.css HTTP/1.1" 404 564 "https://172.30.66.248/key/" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36" "-" "0.000" "-" "-"
2019/04/01 11:34:01 [error] 15#15: *9 open() "/etc/nginx/html/javascripts/tour.js" failed (2: No such file or directory), client: 172.16.40.7, server: , request: "GET /javascripts/tour.js HTTP/1.1", host: "172.30.66.248", referrer: "https://172.30.66.248/idm/"
172.16.40.7 - - [2019-04-01T11:34:01+00:00] "GET /javascripts/tour.js HTTP/1.1" 404 564 "https://172.30.66.248/idm/" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36" "-" "0.000" "-" "-"
2019/04/01 11:34:01 [error] 15#15: *9 open() "/etc/nginx/html/javascripts/others/see_password.js" failed (2: No such file or directory), client: 172.16.40.7, server: , request: "GET /javascripts/others/see_password.js HTTP/1.1", host: "172.30.66.248", referrer: "https://172.30.66.248/idm/"
172.16.40.7 - - [2019-04-01T11:34:01+00:00] "GET /javascripts/others/see_password.js HTTP/1.1" 404 564 "https://172.30.66.248/idm/" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36" "-" "0.000" "-" "-"

It shows the files are not found :
 *9 open() /etc/nginx/html/javascripts/others/see_password.js"

Update 2: While accessing the backend application directly and observing the behaviour.
URL : 172.30.66.235:3443 ---> Home Page
After Login : 172.30.66.235:3443/idm
(During Login if I click anywhere, /idm remains appended to it and after logging out.)
URL after Log out : 172.30.66.235:3443  ; similar to homepage.

The code line that does the same is :
https://github.com/ging/fiware-idm/blob/7.5.1/routes/web/index.js#L23
Or you can access the link : https://account.lab.fiware.org/ (Global instance of Keyrock)
Comment: $1 and $2 in your `rewrite` are backreferences to the regex. But your regex has no matching groups to be referenced at. Could you supply us with URLs and what they supposed to look like in the backend?
Comment: Yes, for backend the url is : https://172.30.66.235:3443/ on (HTTPs) and the IP for nginx should be https://172.30.66.248/idm (on HTTPs) while accessing idm.
Answer: Please try:
location /idm/ {
   proxy_set_header   X-Forwarded-Host    $host;
   proxy_set_header    Host                $host;
   proxy_set_header    X-Real-IP            $remote_addr;
   proxy_set_header    X-Forwarded-For        $proxy_add_x_forwarded_for;
   rewrite ^/idm(/.*)$  $1 break;
   proxy_pass           https://172.30.66.235:3443;
   proxy_redirect / /idm/;
   sub_filter '="/' '="/idm/';
   sub_filter '= "/' '= "/idm/';
   sub_filter '=\'/' '=\'/idm/';
   sub_filter_once off;

}

Edit 1: Added proxy_redirect
Edit 2: Added sub_filter options
Edit 3: Changed sub_filter to replace all possible occurrences with the new location.
A nicer way would probably be nginx_substitutions_filter and a proper regex.
Comment: Hi Sir, it's not working still. While looking at the console in web-browser i get :
GET https://172.30.66.248/javascripts/tour.js net::ERR_ABORTED 404 (Not Found) for (approx. 25 files) that are mostly css and js. whereas, while accessing https://172.30.66.248/idm/javascripts/tour.js shows the content of file.
Comment: I've added `proxy_redirect`, try it pls.
Comment: Hi Sir, Still no success. IDM being a nodejs application https://github.com/ging/fiware-idm is still not loading css or js only.
Comment: I've added `sub_filter` options, pls try again :x
Comment: hi Sir, bingo! the first page gets loaded but after logging in or clicking on sign in or sign up it shows 404 Not found, but if I write idm in the url it displays. So, in these cases its not working, but from earlier, its loading all the css and js for front page.
Comment: It would be easier to use the vhost feature of nginx (using a different `server_name` (sub-)domain) than rewriting all content of the website because of the relative and absolute paths in the source code.
Comment: you mean to say, I should create a new server block in which we have the same contents as provided by you in location block  as above?
Comment: Again edited my post.
Comment: Hi Sir, The front page are loading and working properly. But login is not happening; as for example after logging in the URL is -> 172.30.66.235:3443/idm and during the login if I click on organizations option the URL is 172.30.66.235:3443/idm/organizations and  after logout 172.30.66.235:3443. I am unable to attach the screenshots.
Comment: Hi sir, how can we use nginx_substitution_filter for the same ? or is it possible that if we place a root directive (for eg: root /var/ ) settings inside the location block.
Comment: Hi @unNamed, fiware keyrock is working fine and thank you immensely for you help. Just wanted to know one thing that I am unable to understand the purpose of sub_filter '= "/' '= "/idm/';
   sub_filter '=\'/' '=\'/idm/'; Can you help me understand with it?
Comment: `sub_filter` is a simple replace tool. It replaces `= "/` with `= "/idm/`. It searches all the HTML transferred to the client for the specified text and replaces it. The client then uses the changed path to request resources.
Comment: Hi @unNamed can you help me with this last thread in nginx. https://serverfault.com/questions/963610/unable-to-run-wso2-ui-consolr-i-e-carbon-using-nginx-reverse-proxy-server
Comment: Hi @unNamed can you just help me with just on issue, in the above while configuring it with nginx, I am getting the- "Cannot read property 'length' of undefined " issue, can you please help me just with it?
Comment: This sounds like a javascript error. I cannot help you with that.
Answer: When adding a new server block it should look like this. So you forward / to the same location / of your backend server just by calling a different name/IP. You should replace the name in server_name as well as the certificate files.
server {
        server_name subdomain.example.com;
        listen 443 ssl http2;
        ssl_certificate         /etc/nginx/your_certificate.pem;
        ssl_certificate_key     /etc/nginx/your_certificate.key;

        location / {
           proxy_set_header   X-Forwarded-Host    $host;
           proxy_set_header    Host                $host;
           proxy_set_header    X-Real-IP            $remote_addr;
           proxy_set_header    X-Forwarded-For        $proxy_add_x_forwarded_for;
           proxy_pass           https://172.30.66.235:3443;
        }
}

Comment: Sir, actually the requirement resists me from running this on root.However, the one which you have written on location / above makes it run in the earlier scenario also. But I need to have /idm/ with the URL appended everytime. You can check the working of IDM on https://account.lab.fiware.org/ . The one on my local  creates the same url after logging in and after logging out. Additionally, at code level when the user session is acquired it appends /idm to it only after logging in. https://github.com/ging/fiware-idm/blob/master/routes/web/index.js#L22
Comment: Also,if I remove the rewrite ^/idm(/.*)$  $1 break; in configuration and keeping the proxy_redirect, it still doesn't works. is it possible can we have a direct chat??


"Symmetric" property of stationary distribution

Question: The above symmetric property isn't referring to the double stochastic property
\begin{bmatrix}
0.2&0.8&0&0&0\\
0.2&0.2&0.6&0&0\\
0&0.4&0.2&0.4&0\\
0&0&0.6&0.2&0.2\\
0&0&0&0.8&0.2 \end{bmatrix}
The stationary distribution is given as (1/16,1/4,3/8,1/4,1/16).
Is it true that for an irreducible and aperiodic markov chain, if we can label the first row to last row (state 1 to 5) and also alternatively (state 5 to 1)
and we get the same transition matrix, we will have a symmetric stationary distribution i.e. (a,b,c,b,a)?
Answer: More generally let $\pi$ be a permutation matrix. The act of permuting rows an columns is equivalent to $\pi P \pi$. Let $\mu$ be the stationary distribution of $P$, and suppose $\pi P\pi=P$. Define $\mu'=\pi^T\mu$. Then:
$$\mu^T=\mu^T P = \mu^T \pi P\pi=\mu'^TP\pi$$
Multiply both sides on the right by $\pi^{-1}=\pi^T$ ($\pi$ is orthonormal afterall). This gives:
$$\mu'^T=\mu^T\pi^T=\mu'^TP.$$
Since the Markov chain $P$ is assumed to be irreducible and aperiodic, it has a unique stationary distribution, which allows us to conclude $\mu'=\mu$. Thus if $P$ is left invariant under permutations of its rows and columns by $\pi$, this implies $\mu=\pi\mu$, i.e. $\mu$ is invariant under $\pi$.
If you look at the individual coefficients, you get $\mu_i=\mu_{\pi^{-1}(i)}$.
Comment: did that mean my inference that we will have a "symmetric" stationary distribution is true for all Markov chain P when it is assumed to be irreducible and aperiodic
Comment: @Joseph: Right, I added a line to clarify that. In your case you have the reverse permutation, which implies $\mu_i=\mu_{n-i}$, since $\pi^{-1}(i)=n-i$.


Pedidos maior que 30 dias

Question: boa tarde.
Estou montando um relatório na qual preciso informar em uma coluna, os produtos que não tiveram movimentação por mais de 30 dias. A campo que utilizo é de padrão DATETIME. Toda vez que é inserida alguma informação de movimentação, é adicionado dia e hora. Exemplo:
Produto A | OCORRÊNCIA | 01/06/2019 10:00:00
Produto A | OCORRÊNCIA | 01/06/2019 12:00:00
Produto A | OCORRÊNCIA | 01/06/2019 16:00:00

Produto A | OCORRÊNCIA | 10/07/2019 10:00:00

Neste caso eu precisaria informar que o produto A ficou mais de 30 dias sem movimentação. Não sei o que posso utilizar para verificar essa lógica, visto que tenho somente um campo que campo para fazer a manipulação. Tentei com HAVING mas não consegui.
Comment: Utilize a função de agregação MAX, juntamente com a cláusula GROUP BY produto, e na cláusula WHERE filtre apenas as datas máximas que sejam menores que a data atual - 30 dias.
Comment: Deu certo, muito obrigado!
Answer: SELECT produto FROM movimentacao WHERE data < DATEADD(Day, -30, GETDATE());

Chutei os nomes das colunas e da tabela, mas a ideia é essa... e não sei qual banco de dados você tá usando, então a função de somar a data pode ser levemente diferente.
Comment: Opa, deu certo. Muito obrigado. Estava confundindo se iria precisar de outro campo data. Mas agora foi!

Pedidos maior que 30 dias


probablistic output for binary SVM classification

Question: I'm using libSVM for a binary classification problem. After a test instance is assigned a label (1 or -1), I also want to know how likely it is assigned such a label.
I'm thinking about calculating the distance from the instance to the hyperplane in the feature space. The larger the distance is, the more likely the label assignment is correct.
Is my idea correct? Or is there already such an option in libSVM for my purpose?
Comment: See also this question: [Calculate probability for LibLinear classification results](http://stats.stackexchange.com/questions/36167/calculate-probability-for-liblinear-classification-results/36204#36204)
Answer: The usual approach is to use Platt's method of fitting a univariate logistic regression model to the output of the SVM.  However, if you want a probabilistic output, it is probably better to go for kernel logistic regression, which estimates the probabilities directly, rather than training a discriminative classifier and post-processing the output.
Gaussian process classification would also be another method that may be better suited, see the excellent book by Rasmussen and Williams, and the equally excellent MATLAB toolbox that goes with it.
Comment: Thanks. One more question, is there a c/c++ library for the Gaussian process classification?
Comment: I suspect there is something suitable in the list of software packages here: http://www.gaussianprocess.org/#code .  I use the GPML Matlab toolbox myself, so I can't offer a useful opinion on the other packages.


How do I navigate related entities from a stored procedure that is mapped to an entity

Question: I have a complicated full-text search stored procedure that I have mapped to return an entity type. It won't allow me to navigate the references in the result though:
using (MyEntities kb = new MyEntities())
{
   var results = from customer in kb.SearchCustomers("blabla") select new
   {
       CustomerName = customer.LastName + ", " + customer.FirstName,
       RegionName = customer.Region.Name
   };
}

This is throwing a null reference exception when referring to the customer.
Comment: Usually you need to call .Include("Region") when you are querying a normal table.  Perhaps you have to do the same when using a Stored proc?  Not sure I haven't started using stored procs yet :)

.............
var results = from customer in kb.SearchCustomers("blabla").Include("Region")...............
Comment: LastName and FirstName work but Region doesn't? Make sure that SearchCustomers returns the expected data first.
Answer: We should check LastName and FirstName first. I think there are customers who don't have FirstName or Lastname.
using (MyEntities kb = new MyEntities())
{
   var results = from customer in kb.SearchCustomers("blabla") select new
   {
       if(customer.LastName != null && customer.FirstName != null)
       {
         CustomerName = customer.LastName + ", " + customer.FirstName,
         RegionName = customer.Region.Name
       }
   };
}


Given two dictionaries containing arrays of different capacities add elements to the lesser populated array

Question: So given this data
var data =
  ["groupA":
        [1, 2, 3, 4, 5, 6],
   "groupB":
        [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]

I want this output:
["groupA":
        [0, 0, 0, 0, 1, 2, 3, 4, 5, 6],
 "groupB":
        [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]

This is the best answer I was able to come up with but I feel like its lacking as I have access to the accumulator that I want to mutate within the reduce function.
let maxElement = data.reduce(data.first!) { (acc, obj) in
  return acc.value.count > obj.value.count ? acc : obj
}

for dict in data {
  if dict.value.count < maxElement.value.count {
    var mutableValues = dict.value
    mutableValues.insert(0, at: 0)
    data[dict.key] = mutableValues
  }
}

I think I'm not understanding how to best refactor my reduce function.
Answer: If, like me, you don't like for loops, how about this:
data.reduce(data.values.reduce(0){max($0,$1.count)})
{ data[$1.0] = Array(repeating:0,count:$0-$1.1.count) + $1.1; return $0}

Comment: Ayyy there it is. Thanks! That's exactly what I was looking for.
Answer: You can get the maximum count of your arrays and create an array of zeros with the difference to append to the lesser populated arrays as follow:
var dict: [String:[Int]] = ["groupA": [1, 2, 3, 4, 5, 6],
                            "groupB": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]

let maxCount = dict.values.map{ $0.count }.max() ?? 0
for (key, value) in dict {
    let difference = maxCount - value.count
    if difference > 0 {
        dict[key] =  repeatElement(0, count: difference) + value
    }
}

print(dict)    // ["groupB": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "groupA": [0, 0, 0, 0, 1, 2, 3, 4, 5, 6]]

Comment: The `map(_:)` is applied to `dict.values` which is a lazy collection, therefore the map is evaluated lazily – so there shouldn't really be any performance difference (no temporary array created at least). I only really suggested it for a slightly nicer syntax.
Comment: You could also say `let maxCount = data.values.map{$0.count}.max() ?? 0` for the max count. Also I would use a `for ... in` loop here, as you can do `for (key, value) in dict {...}`. Also also you can say `repeatElement(0, count: difference)` for the prefixed zeroes, which saves allocating a temporary array buffer.
Comment: @Hamish do you think using map for the count it is faster than the syntax I have now?
Answer: As per your question you need to refactor your code for the reduce function, I did it the following way.
Hope this helps,
let maxElement = data.reduce(data.first!) {
    $0.value.count > $1.value.count ? $0 : $1
}

further I modified the code you provided to achieve the results you were trying.
and the code worked well for me.
let maxElement = data.reduce(data.first!) {
    $0.value.count > $1.value.count ? $0 : $1
}

let minElement = data.reduce(data.first!) {
    $0.value.count < $1.value.count ? $0 : $1
}

for dict in data {
    if dict.value.count < maxElement.value.count {
        var mutableValues = minElement.value
        let arrayOfZeros = Array(repeating: 0, count: maxElement.value.count - minElement.value.count)
        mutableValues.insert(contentsOf: arrayOfZeros, at: 0)
        data[dict.key] = mutableValues
    }
}


ES6 spread operator output

Question: I have a very basic question regarding spread operator. When we do
let numbers = [1,2,3,4];
console.log(...numbers);

While it flattens out the list, is the output format actually a string like "1 2 3 4" OR are they still separate number list?
Comment: Spreading is equivalent to `console.log(numbers[0], numbers[1], numbers[2], numbers[3])`, I'm not sure whether that answers your question, since I'm not sure I understand it.
Comment: output format is not a string but 4 values in a row. It depends on your environment. Try, for example, `console.log({a:1},{b:2},3,4)` to see it's not a string. Alternatively try `console.log('1,2,3,4')` to see a string
Answer: Spread syntax allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected.
Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax
In your example you would have
let numbers = [1,2,3,4];
console.log(...numbers);

// This is the same
console.log(1, 2, 3, 4);

Your values are spreaded as seperate values out of the array. You can do this with functions as well:

const numbers = [1, 2];
const add = (a, b) => { return a + b; };
console.log(add(...numbers)); // -> add(1, 2) -> 3
Answer: const numbers = [1, 2, 3];
const [ firstNumber, ...restOfTheNumbers ] = numbers;
console.log(firstNumber, restOfTheNumbers);   // 1 [ 2, 3 ]

ES6 spread operator output


Simple drop-down "list" items (inside a html "body") --- content (un)hiding upon click --- Not a navigation bar, no redirect, no menu, no forms

Question: I would like to ask if it were possible to have certain content (nothing too special, just regular lines of text with standard formatting) on a html article, like e.g. ordered in a list, which can be unfolded (or hidden again) by a mouse-click?
When searching information on this, I easily come by navigation drop-down menu's; but a navigation side-bar or top-bar is not what I am looking for.
I have found another question asking for something similar, but wanting to be redericted to another page (similar to a navigation menu), that is also not what I want to do: I do not want to navigate to another page.
I would simply like a drop-down "list" inside a html's "body" article. The visitor should be able to open or close these "frames" or "list items", e.g. by clicking on the title or on a list button. I am just looking for a "1-level-depth" list.
It would be nice if the items had a title and a number, ordered vertically, like a regular ordered list:

>click to unfold< List item 1
>click to unfold< List item 2
>click to unfold< ...

If, for example you would click on list item 1, the content of list item 1 would show:

>clicked, click to hide content again< List item 1
<<< Content of list item 1, which is just standard lines of text, perhaps with standart formatting. >>>
>click to (un)fold< List item 2
>click to (un)fold< ...

The text I have put between ">"..."<", is just to clarify; isn't specifically needed. This could just be a triangular list bullet for example, which could just change by pointing downwards when clicked.
Is this possible by using a Drupal module, or perhaps just via html code?
Any help on this would be greatly appreciated,
Vincent Verheyen.
P.S.: I am very new to Drupal and understand the basics such as installing modules.
Comment: Hi and welcome to Drupal Answers. This appears to be more like a jQuery issue to me. Take a look at http://stackoverflow.com/questions/24701915/show-hide-text-using-jquery
Comment: Ok, thanks a lot @Wtower. Is it easy to implement this into a Drupal html article? Can I just the jQuery codes over there, or should I use some kind of a module? --- I will look definitely into jQuery, it seems like a very good trail.
Comment: I am glad. This question is not Drupal per se, jQuery is a common and powerful JS library which is included within Drupal as you probably already figured out.
Answer: @Wtower's help above makes this pretty straightforward. Drupal (I am using 7) can use these jQuery codes without any additional install.
One can just put the following right inside a drupal "node", such as a standard article. This solution works for list items; the following is to be implemented [I used ordered lists (ol) in my example]:

List tem 1.

Content of list item 1.

List item 2.

Content of list item 2.

I haven't looked at triangular (changing upon revealing or hiding content) list bullets yet.
If you want other items than list items, look here:

http://renaudjoubert.com/fr/node/56
http://triq.net/articles/hide-and-slide-drupal-content-jquery
Answer: I think you can acheive what you want with the https://www.drupal.org/project/field_group module. Enable to module and go to you content type, add the different groups you want to collapse/expand and add one or more fields inside.
You can change how you want to users to see the fields groups.
Comment: When the field group module is installed and enabled, you should be able to add groups. This video explains it very well http://youtu.be/5GU_tb4K-f4. At 1m57 it starts where you are http://youtu.be/5GU_tb4K-f4?t=1m57s. If you don't see the add group, something went wrong when installing the module and you should re-install it.
Comment: Thanks a lot @Maarten! This seems very interesting. However, I am not completely sure yet how to use this. Might I ask you very friendly for some more clarification? --- **Field group**-module is installed. My content type (or node) is called [Article]. --- In Drupal's `(Structure)`->`(Content types)`->`[Article]`->`(Manage fields)`; I can notice the "Add new field" option. Should I use this, and how?
Comment: @VincentVerheyen this is a nice approach, it would require to organize content into fields, which might be better depending on the requirements.
Answer: Another possibility just for the record (more intermediate approach) would be to organize the collapsible content into nodes, then use Views in order to present the relevant nodes in a page.
Then you can either:

Use a module such as Views Accordion
or theme the view to facilitate collapse.js

so that the views rows be collapsible.


Conditional probability by joint distribution

Question: I have read the following equation:
$$P(E_1|H)*P(E_2|H)*P(H) = P(E_1,E_2,H) $$
I don't understand why this equation is true. I know that
$$P(E_1|H)*P(H) = P(E_1,H)$$
thus:
$$P(E_1|H)*P(E_2|H)*P(H)=P(E_1,H)*P(E_2|H)$$
but why:
$$P(E_1|H)*P(E_2|H)*P(H) = P(E_1,E_2,H) $$
As a extra information it is also given that:
$$P(E_1|H,E_2) = P(E_1|H)$$
Comment: How/When did you use the "extra information"?
Comment: ((This is not a question of [tag:stochastic-calculus] at all.))
Answer: We are given that $$P(E_1|H,E_2)=P(E_1|H)$$
hence,
$$\frac{P(E_1,H,E_2)}{P(H,E_2)}=P(E_1|H)$$
$$P(E_1,H,E_2)=P(E_1|H)P(H,E_2)$$
but we have $P(H,E_2)=P(H)P(E_2|H)$, hence the result.


Can Entity Framework map two associations into a single navigation?

Question: I have two simple tables as described here...
<code>Table = Person
   PersonID  (int, PrimaryKey)
   FirstName (char)
   LastName  (char)

Table = Related
   RelatedID    (int, PrimaryKey)
   Person1      (int, ForeignKey for Person.PersonID)
   Person2      (int, ForeignKey for Person.PersonID)
   Relationship (int)
</code>
The generated entity for Person has two navigation collections. One for the Related.Person1 and another for Related.Person2. This is a pain because it means I have two collections to investigate to look up all the relationships that are relevant to that person.
I need to have instead just a single navigation collections that contains both of these sets. Is it possible to have this generated as part of the entity frameowrk? The only alternative is to generate a third collection myself that contains the aggregate set of entities and it feels like that should not be needed.
Comment: This seems like a bad idea. If you added an entity to the proposed, merged collection, how would the EF know in which of your two collections to put it?
Answer: As Craig states what you are asking for is not something core to EF but... a friendship type relationship is one of those nasty ones to model, so I see what you are trying to do.
There is a workaround to make this possible by mapping the Association Set to a view (DefiningQuery) in the SSDL.
The association/relationship backed by the view will then be read-only, so you will probably want to leave the other two relationships in place to allow you to add / remove from the correct collection or for when you want to search in one direction only.
Check out this post which shows the techniques involved for more.
Hope this helps
Alex
Comment: Thanks for the help. I was thinking that you have two nodes A and B that are stored and there is a relationship between them. I only want to store that relationship once. But I want to know about the relationship from node A and from node B. So it is stored once but represented in two places, the two ends of the relationship.
Comment: Storing it once, but representing it in multiple places is what I was suggesting. In fact that is what that blog post does.


How to setup sendmail to actually send mails (!)

Question: I'm configuring a mail server but sendmail doesn't let me send mails from remote devices or/and softwares. My config : CentOS 6.4, Sendmail 8.14.4.
Here's the message I get when trying to send emails from outside the server
sendmail[25390]: rA4Fp855025390: [213.x.x.x] did not issue MAIL/EXPN/VRFY/ETRN during connection to MTA
sendmail[25391]: rA4Fp86s025391: ruleset=check_rcpt, arg1=<firstname.lastname@example.com>, relay=[213.x.x.x], reject=550 5.7.1 <email@example.com>... Relaying denied. IP name lookup failed [213.x.x.x]
sendmail[25391]: rA4Fp86s025391: from=<email@example.com>, size=0, class=0, nrcpts=0, proto=ESMTP, daemon=MTA, relay=[213.x.x.x]

I know there's something with the relay host but what if you don't know the relay host !? I mean... Anyway, here's the sendmail.mc file
divert(-1)dnl
include(`/usr/share/sendmail-cf/m4/cf.m4')dnl
VERSIONID(`setup for linux')dnl
OSTYPE(`linux')dnl
dnl define(`confSMTP_LOGIN_MSG', `$j Sendmail; $b')dnl
dnl define(`confLOG_LEVEL', `9')dnl
dnl define(`SMART_HOST', `smtp.your.provider')dnl
define(`confDEF_USER_ID', ``8:12'')dnl
dnl define(`confAUTO_REBUILD')dnl
define(`confTO_CONNECT', `1m')dnl
define(`confTRY_NULL_MX_LIST', `True')dnl
define(`confDONT_PROBE_INTERFACES', `True')dnl
define(`PROCMAIL_MAILER_PATH', `/usr/bin/procmail')dnl
define(`ALIAS_FILE', `/etc/aliases')dnl
define(`STATUS_FILE', `/var/log/mail/statistics')dnl
define(`UUCP_MAILER_MAX', `2000000')dnl
define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl
define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
define(`confAUTH_OPTIONS', `A')dnl
MASQUERADE_AS(mydomain.com)dnl
MASQUERADE_DOMAIN(mydomain.com)dnl
dnl define(`confAUTH_OPTIONS', `A p')dnl
dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
dnl define(`confCACERT_PATH', `/etc/mail/certs')dnl
dnl define(`confCACERT', `/etc/mail/certs/CAcert.pem')dnl
dnl define(`confSERVER_CERT', `/etc/mail/certs/MYcert.pem')dnl
dnl define(`confSERVER_KEY', `/etc/mail/certs/MYkey.pem')dnl
dnl define(`confCLIENT_CERT', `/etc/mail/certs/MYcert.pem')dnl
dnl define(`confCLIENT_KEY', `/etc/mail/certs/MYkey.pem')dnl
dnl define(`confDONT_BLAME_SENDMAIL', `groupreadablekeyfile')dnl
dnl define(`confTO_QUEUEWARN', `4h')dnl
dnl define(`confTO_QUEUERETURN', `5d')dnl
dnl define(`confQUEUE_LA', `12')dnl
dnl define(`confREFUSE_LA', `18')dnl
define(`confTO_IDENT', `0')dnl
dnl FEATURE(delay_checks)dnl
FEATURE(`no_default_msa', `dnl')dnl
FEATURE(`smrsh', `/usr/sbin/smrsh')dnl
FEATURE(`mailertable', `hash -o /etc/mail/mailertable.db')dnl
FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable.db')dnl
FEATURE(redirect)dnl
FEATURE(always_add_domain)dnl
FEATURE(use_cw_file)dnl
FEATURE(use_ct_file)dnl
dnl define(`confMAX_DAEMON_CHILDREN', `20')dnl
dnl define(`confCONNECTION_RATE_THROTTLE', `3')dnl
FEATURE(`relay_hosts_only')dnl
FEATURE(local_procmail, `', `procmail -t -Y -a $h -d $u')dnl
FEATURE(`access_db', `hash -T<TMPF> -o /etc/mail/access.db')dnl
FEATURE(`blacklist_recipients')dnl
EXPOSED_USER(`root')dnl
dnl define(`confLOCAL_MAILER', `cyrusv2')dnl
dnl define(`CYRUSV2_MAILER_ARGS', `FILE /var/lib/imap/socket/lmtp')dnl
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
dnl DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl
dnl DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, M=s')dnl
dnl DAEMON_OPTIONS(`port=smtp,Addr=::1, Name=MTA-v6, Family=inet6')dnl
dnl DAEMON_OPTIONS(`Name=MTA-v4, Family=inet, Name=MTA-v6, Family=inet6')
FEATURE(`accept_unresolvable_domains')dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
dnl FEATURE(`relay_based_on_MX')dnl
LOCAL_DOMAIN(`mydomain.com')dnl
dnl MASQUERADE_AS(`mydomain.com')dnl
dnl FEATURE(masquerade_envelope)dnl
dnl FEATURE(masquerade_entire_domain)dnl
dnl MASQUERADE_DOMAIN(localhost)dnl
dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl
dnl MASQUERADE_DOMAIN(mydomainalias.com)dnl
dnl MASQUERADE_DOMAIN(mydomain.lan)dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
dnl MAILER(cyrusv2)dnl

What should I do ? How do I know if SMTP-AUTH works ? TLS ?
Thank you very much for your help -.-
Comment: For sendmail to take email from random devices, for delivery to random third-parties, would be to run as an open relay, and it won't do that by default.  You would do well to look into SMTP AUTH; setting it up and configuring it is painful, but if you just configure your system to be an open relay, you'll end up blacklisted and unable to send to noone.
Comment: I know :( So what can I do ? It shouldn't be so hard to just allow authenticated users to send mails from their devices...
Comment: It isn't - but you **really, really shouldn't**.
Comment: @Mike You *really* need to do a lot of groundwork before you throw a machine on the internet and let it start sending mail. If you are already familiar with postfix (as your comments below suggest) you should stick with it, and configure it properly. If you are being forced to use sendmail [The Bat Book](http://shop.oreilly.com/product/9781565928398.do) is a mandatory purchase and required reading, as are pretty much ***all*** of the documents on http://www.sendmail.com/sm/open_source/docs/ and http://www.sendmail.com/sm/open_source/tips/ (as needed when configuring your system)...
Answer: For novices sendmail has quite a steep learning curve, the recommended MTA is postfix.
To determine what sendmail currently supports; telnet to the smtp port and issue the help command, sendmail will display it's capabilities:
]$ telnet localhost 25
 220 example.com ESMTP Sendmail 8; Mon, 4 Nov 2013 17:27:20 +0100

help
214-2.0.0 This is sendmail
214-2.0.0 Topics:
214-2.0.0       HELO    EHLO    MAIL    RCPT    DATA
214-2.0.0       RSET    NOOP    QUIT    HELP    VRFY
214-2.0.0       EXPN    VERB    ETRN    DSN     AUTH
214-2.0.0       STARTTLS

AUTH means that this sendmail servers supports SMTP authentication.
STARTTLS means that SSL/startTLS is supported.
To enable both you'll need to modify your sendmail configuration. The sendmail configuration file is, well, let's say as clear as mud. The easier way is to edit the sendmail.mc a macro file that can be used to generate a functional sendmail.cf configuration. Lines starting with # are comments as are lines starting with dnl.
The uncomenting following three lines will enable smtp authentication:
 # /etc/mail/sendmail.mc
 <snip>
 define(`confAUTH_OPTIONS', `A p')dnl
 TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
 define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
 <snip>

To enable TLS/SSL uncomment the following lines and make sure that you certificates are (self-signed or public) are present.
define(`confCACERT_PATH', `/etc/mail/certs')dnl
define(`confCACERT', `/etc/mail/certs/CAcert.pem')dnl
define(`confSERVER_CERT', `/etc/mail/certs/MYcert.pem')dnl
define(`confSERVER_KEY', `/etc/mail/certs/MYkey.pem')dnl

Most clients will use starttls over smtp port 25 but you can have a SSL only smtp sendmail listening on port 465 by uncommenting:
DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, M=s')dnl

make sure the sendmail-cf and cyrus-sasl rpm packges are installed:
 ]#  yum -y install cyrus-sasl sendmail-cf

Generate the new sendmail.cf from your modified sendmail.mc and restart sendmail
 ]#  cd /etc/mail ; ./make
 ]#  service sendmail restart

Configure sasl authentication server with your preferred authentication method for mail users and make sure it will be running. (default is set to pam in /etc/sysconfig/saslauthd)
 ]#  chkconfig saslauthd on
 ]#  service saslauthd start

Now to test SMTPAUTH we'll use the PLAIN method, we'll check if the earlier telnet test now shows support for the AUTH method.
If it does we'll try plain auth. This requires a base64 encoded string containing a NULL seperated username+password:
 ]$  perl -MMIME::Base64 -e 'print encode_base64("\000USERNAME\000PASSWORD");'
 AFVTRVJOQU1FAFBBU1NXT1JE

Now we can catch two birds with one stone, check the SSL setup and PLAIN auth (PLAIN and LOGIN are only allowed over SSL encrypted connections):
 ]$  openssl s_client -starttls smtp -connect example.com:25
 .   <snip more SSL stuff>
 .   ---
 .   SSL handshake has read 17078 bytes and written 357 bytes
 .   ---
 .   New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
 .
 EHLO example2.com
 .
 .   250-mail.example.com Hello example2.com [1x.2x.3x.4x], pleased to meet you
 .   250-ENHANCEDSTATUSCODES
 .   250-PIPELINING
 .   250-8BITMIME
 .   250-SIZE
 .   250-DSN
 .   250-ETRN
 .   250-AUTH LOGIN PLAIN
 .   250-DELIVERBY
 .   250 HELP
 .
 AUTH PLAIN AFVTRVJOQU1FAFBBU1NXT1JE

Now clients that use valid SMTP authentication can use your sendmail server to send email.
Comment: I know, I usually install postfix but the boss needs the php mail thing and asked me to move to sendmail... Anyway, from this output (help), both should be supported by sendmail. But when I 'telnet localhost 25' the STARTTLS option doesn't show rrr...
Comment: I'll add some additional instructions to my earlier response.


Can't update core with composer: "Your requirements could not be resolved to an installable set of packages"

Question: I am not able to perform a security upgrade of Drupal core with composer.  I get "requirements could not be resolved."  Here is my composer.json:
https://pastebin.com/KxEQdPkt
Here is the response:
<code>Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for symfony/psr-http-message-bridge v0.2 -> satisfiable by symfony/psr-http-message-bridge[v0.2].
    - drupal/core 8.3.2 requires symfony/psr-http-message-bridge ^1.0 -> satisfiable by symfony/psr-http-message-bridge[1.0.x-dev].
    - drupal/core 8.3.3 requires symfony/psr-http-message-bridge ^1.0 -> satisfiable by symfony/psr-http-message-bridge[1.0.x-dev].
    - drupal/core 8.3.x-dev requires symfony/psr-http-message-bridge ^1.0 -> satisfiable by symfony/psr-http-message-bridge[1.0.x-dev].
    - drupal/core 8.4.x-dev requires symfony/psr-http-message-bridge ^1.0 -> satisfiable by symfony/psr-http-message-bridge[1.0.x-dev].
    - Conclusion: don't install symfony/psr-http-message-bridge 1.0.x-dev
    - Installation request for drupal/core ^8.3.2 -> satisfiable by drupal/core[8.3.2, 8.3.3, 8.3.x-dev, 8.4.x-dev].
</code>
Answer: The solution in my case was to delete the vendor directory and delete composer.lock.
I am not totally sure I needed to delete the vendor directory, because I tried that first without deleting composer.lock, and it didn't work.  Deleting composer.lock was necessary.
I also changed the minimum-stability to "stable" before deleting vendor and composer.lock, but I doubt that was necessary.  In any case, I now have...

"minimum-stability": "stable",


Mixing pieces of Phonegap to native app

Question: We have a requirement where we need to generate FORM like UIs in some areas of our app. For this we are considering writing a layer using phonegap / titanium etc so that the same can be used for iOS / Android. With Phonegap I understand that I can include a CDVWebView using Cleaver that will display all the forms.
My question is, is there any way to embed a custom native view ( say a custom UIView which shows a graph ) inside the phonegap view?
Comment: I am confused... are you asking how to include a graph in appcelerator or how to create a native form in appcelerator?
Comment: Sorry for the confusion. I need to be able to dynamically generate forms which may have simple layouts with labels, text fields, buttons along with complex views which need to be plugged in from the native side. However I want to be able to integrate this crossplatform module onto my native apps.
Answer: You can implement this as a plugin, so that something on your PhoneGap view triggers the display of the native view, but you can't really embed it in the phonegap view because the phonegap view is just rendered html inside a webview. What you'd get is something like a child view or popover.
Comment: Thanks for the input. Would you recommend any other framework or workaround that you could think of? I think Titanium can do this since it renders everything as native ( correct me if I'm wrong ), but I guess we can't seem to mix pieces of titanium code in our xcode project.
Comment: @MahadevanSreenivasan I don't have any experience with Titanium, but I wouldn't be surprised if it did let you do this, because of it compiling native code - but you still might have to do it via some sort of plugin interface.

Mixing pieces of Phonegap to native app


What does the p-value mean in this binary random-effects model output?

Question: I am doing a meta-analysis using the Open Meta software. The findings being meta-analyzed are simply the proportion of those with disease X who also have disease Y for each study. I am given an estimate of the overall proportion, the lower and upper  bounds of the CI, and the significance value. I am not really sure how to interpret the significance value in this case. I have attached a photo.
Comment: Rather than being necessarily a pure statistics question, your inquiry may simply call for checking the Open Meta documentation to see what null hypothesis is being tested via their version of this procedure.  (You won't find many instances of "binary random effects model" on this Stack Exchange site.)  But at any rate I'm guessing what will matter to you is not any *p*, not any significance test result, but the 0.122 and the 0.012.
Comment: @rolando2 Thank you for your response. Their help section is not helpful. But yes, you are correct those values will be more useful to me.
Comment: @aspire94 what is the objective of your meta'analysis.
Comment: Shall apprciate if I get a brief about binary random effects model.
Comment: The question is vague. need more details.
Answer: it is significant.
reject the null hypothesis, so there is a significant relationship with your variables
Comment: Welcome to [stats.se]!  Please take a moment to view our [tour].
Comment: I understand it means it is significant. But WHAT is significant since I am only looking at the proportion in each meta-analysis?
Comment: What null hypothesis does it reject? Note that there is no moderator variable supplied for it to relate to either.
Comment: the null hypothesis is there is no relationship
Answer: The only thing it can be testing is whether the estimated proportion could be zero which it clearly is not. Whether that hypothesis makes any sense in your scientific situation is up to you but I would have thought it rarely, if ever, does.
If the documentation for this program is so poor that it does not tell you I would suggest you change to another program as it does not seem state of the art.


Bind Complex Type in Silverlight Datagrid

Question: I have created a Complex Type called "EmployeeName" using the Entity Framework designer in VS 2010.
EmployeeName consists of FirstName,LastName & title.
Now question is how do i display/bind to datagrid in  silverlight?
Right now it is displayes in Datagrid as "Namespace.EmployeeName" in each row.
Answer: Firstly you need to set AutoGenerateColumns to false on the DataGrid to avoid getting the default column type of DataGridTextColumn for all the properties of your bound objects.
You then need to define the columns in xaml for each of the properties of your bound objects that you want displayed. For properties with a simple type like string or int (for example) you can just use a DataGridTextColumn with a standard binding in the binding property.
For your complex type (EmployeeName) you need to use a DataGridTemplateColumn, and then define a DataTemplate for the DataGridTemplateColumn.CellTemplate property which tells the column how to display an EmployeeName. A simple example which just uses a single TextBlock and a Run for each property of the EmployeeName would be as follows
<sdk:DataGrid ItemsSource="{Binding MyCollection}"
              AutoGenerateColumns="false">
     <sdk:DataGrid.Columns>
        <sdk:DataGridTemplateColumn>
            <sdk:DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock>
                        <Run Text="{Binding EmployeeName.Title}"></Run>
                        <Run Text="{Binding EmployeeName.FirstName}"></Run>
                        <Run Text="{Binding EmployeeName.LastName}"></Run>
                    </TextBlock>
                </DataTemplate>
            </sdk:DataGridTemplateColumn.CellTemplate>
        </sdk:DataGridTemplateColumn>
     </sdk:DataGrid.Columns>
</sdk:DataGrid>

Comment: this assumes Silverlight 4 where the Text property of Run is a dependency property (thus bindable). If you aren't using 4 you could just stack 3 TextBlocks using a StackPanel oriented horizontally.
Comment: I think this is a bit of overkill.... but if OP says its fine then i will upvote your answer because its far more complete than mine XD
Comment: @Drknezz not sure what you mean by overkill. Only difference between your answer and mine is that mine uses a single grid column to display the name where yours would require 3.
Comment: DataTemplates arent really needed here as the elements can just be bound to their ToString()'s and thats pretty much it, but i guess both ways are totally viable. Also, having separate columns would be nicer if you ask me :p
Answer: You have to create each column in XAML and set AutoGenerateColumns to false, as well as binding each column manually to the property you want to display using the Binding property of each column.
http://www.wpftutorial.net/DataGrid.html
That site has more info in the subject. It is designed for WPF but it will work for Silverlight as well ;)
Good Luck and Enjoy programming.


Add the same field multiple times to a display suite node display

Question: So I'm using display suite with a 2-column layout, and my node has an entity reference field (field_journal). I'm already displaying field_journal as a rendered entity in the LH column, but I'd also like to display a different grouping of fields from the linked entity in the RH column.
I was thinking the best way to do that would be to add field_journal again to the RH column, but I can't figure out how to duplicate fields in display suite.
Is there some way to add the same field to a node display in 2 different places in the layout? Or can anyone help me with a workaround?
Answer: Since you're using display suite you can use hook_ds_fields_info for defining a new display suite field that you can use to clone your existing field.
<code>/**
 * Implements hook_ds_fields_info().
 */
function MODULE_ds_fields_info($entity_type) {
  $fields = array();

  $fields['node']['journal_clone'] = array(
    'title' => t('Journal clone'),
    'field_type' => DS_FIELD_TYPE_FUNCTION,
    'function' => 'MODULE_journal_clone',
  );

  if (isset($fields[$entity_type])) {
    return array($entity_type => $fields[$entity_type]);
  }
  return;
}

/**
 * Render a clone of journal.
 */
function MODULE_journal_clone($field) {
  $build = '';
  if (isset($field['build']['field_journal'])) {
    $build = $field['build']['field_journal'];
  }
  return render($build);
}
</code>


How to fix "UnsatisfiableError: The following specifications were found to be incompatible with each other: - pip -> python=3.6"

Question: So, i trying to install with the command ecmwf api client conda install -c conda-forge ecmwf-api-client then the warning in the title shows up. I don't know how to proceede
(base) C:\Users\caina>conda install -c conda-forge ecmwf-api-client
Collecting package metadata (current_repodata.json): done
Solving environment: failed
Collecting package metadata (repodata.json): done
Solving environment: failed
UnsatisfiableError: The following specifications were found to be incompatible with each other:

pip -> python=3.6
Answer: Install into a new environment instead of the conda base environment. Recent Anaconda and Miniconda installers have Python 3.7 in the base environment, but you're trying to install something that requires Python 3.6.
Answer: As others have said, it's recommended to create a new, clean environment and conda install into that.
This can be done with the following:
# Create new environment
conda create --name <name> python=3.6
# Activate new environment
conda activate <name>
# Install packages into new environment
conda install -c conda-forge ecmwf-api-client

It's a good idea to keep various environments for different projects. You can then use conda deactivate/conda activate <name> and install any packages into the correct environment. This also allows you to easily swap between different versions of python, or individual software packages.
Answer: I came across this error when I was accidentally running conda env create -f environment.yaml within another activated conda environment. So, deactivating environment then re-running conda create fixed the issue
conda deactivate
conda env create -f environment.yaml

Answer:
Simply go to Anaconda navigator.
Go to Environments, Select Installed (packages, etc.) and then click the version of Python. Downgrade it to a lower version. In your case Python 3.6
Answer: Don't know if you managed to fix this but in case some others got stuck here is the solution that I found:
Just simply used pip3 inside of conda env. It has installed opencv for python3.6 without any issue:
pip3 install opencv-python


How do I change the structure of node's $content variable?

Question: I create a Content Type and I add to it a field (Embedded Media Field) that has thumbnails of Youtube videos.
Now the thumbnails use each a row on its own. I want to make them show in three columns, like in a grid. I understand i have to create a node-MyContentType.tpl.php . But in this file there is a $content variable that holds the html structure of the content and i can't find a way to change that (i want to remove some divs). Can anyone guide what to search for?
Answer: Creating a template (node-MyContentType.tpl.php) for your content type is certainly helpful to manipulate the display of the entire node, but it sounds like what you're looking for is how to modify individual fields, and these are rendered in a different template.
Drupal uses template files and theme_xxx() functions to display elements on the site, and there is generally one template or theme function for each object (page, node, block, field, etc.). In order to override them, you use a feature called Template Suggestions. These are an alternate template (.tpl.php) file that you have created to override the base or original template file. Read more about these for Drupal 6 or Drupal 7.
The best way to create your own version of a template file is find the original one, copy it into your theme folder (don't modify the original!), and rename it using the "template suggestions" convention mentioned in the links above. In Drupal 6, you have to have both the base template (e.g. node.tpl.php) as well as the renamed one (e.g. node-mytype.tpl.php). In Drupal 7, having the base template in the same folder is not necessary.
In Drupal 6, fields are a part of the CCK module. Here's information on overriding CCK Field templates. The original template content-field.tpl.php is located in the CCK module under cck/theme.
In Drupal 7, fields are a part of the Drupal core code. The original template field.tpl.php is located in modules/field/theme.
Answer: To theme individual content types in different ways, you need to create a file node-[type].tpl.php in your theme's folder, where [type] is the machine readable name of the content type.
$content: Node content, teaser if it is a summary.
Basically you can edit the template file in anyway you, to add the fields you can make the use of $node:
$node(object): The node object. To view all of the properties of a current $node object, put the following line of code in your node.tpl.php: <?php print_r($node); ?>
Also you can check the community docs for overriding the node template files:
https://drupal.org/node/11816
https://api.drupal.org/api/drupal/modules!node!node.tpl.php/6
Theming nodes by content type


How exactly do Bayesians define (or interpret?) probability?

Question: Part of a series of trying to understand Bayesian vs frequentist: 1 2 3 4 5 6 7
I think I get the difference of how Bayesians and frequentists approach choosing between hypotheses, but I'm not quite sure if or how that is supposed to explain to me how they view probability.
From what I understand, according to Wiki, a frequentist "defines" probability as follows:
Given probability space $(\Omega, \mathscr{F}, \mathbb{P})$, $\forall A \in \mathscr{F}$, $\mathbb{P}(A) \approx \frac{n_A}{n_t}$, where $n_t$ is the number of trials conducted and $n_A$ is the number of times A has occurred in those trials.
Furthermore, $\mathbb{P}(A) = \lim_{n_t \to \infty} \frac{n_A}{n_t}$.
Okay, so how do Bayesians define probability? The above seems to be one approach to computing probability of an event in addition to defining a probability.
Bayesians seems to assume a prior probability, conduct some trials and then update their probability, but that doesn't really seem to explain how they define what probability is.
Wiki says 'Bayesian probability is a quantity that we assign for the purpose of representing a state of knowledge, or a state of belief.'
What exactly does that mean? Is state synonymous to degree? For example, Walter's state of belief that a particular coin is fair is represented with the number 0.1 while Jesse's state of belief that the same coin is fair is represented with the number 0.2. Given new information, Walter's state of belief could become 0.96 while Jesse's state of belief could become 0.03. So, initially, Walter was less inclined to believe the coin is fair, but later on Jesse was more inclined to believe the coin is fair?
I'm hoping for something in terms of symbols like the frequentist one above.
Same Wiki page says 'The Bayesian interpretation of probability can be seen as an extension of propositional logic that enables reasoning with hypotheses, i.e., the propositions whose truth or falsity is uncertain.', it seems like Bayesian and frequentist probability are analogous to fuzzy and Boolean logic, respectively.
Comment: Both frequentists and Bayesians use the same definition of probability, namely the one based on Kolmogorov's axioms of probability, i.e. probability as a finite measure. The difference between Bayesians and frequentists is thus not related to the *definition* of probability, but to how they link this concept to data.
Comment: @MichaelM: But see [Do Bayesians accept Kolmogorov axioms?](http://stats.stackexchange.com/q/126056/17230).
Comment: @MichaelM Should I have said 'interpret' rather than 'define' ?
Comment: @BCLC, I gave you kudos for your question, but after not being completely clear on the answer I found the first entry on the "Related" column very useful.
Comment: @AntoniParellada Thanks. [You mean this?](http://stats.stackexchange.com/questions/31867/bayesian-vs-frequentist-interpretations-of-probability). Seen it. Don't know what 'In the Bayesian approach, we interpret probability distributions as quantifying our uncertainty about the world. ' means hence this question. [Or you mean this?](http://stats.stackexchange.com/questions/11769/is-there-more-to-probability-than-bayesianism) How does help this answer my question?
Comment: Yes. That's the link.
Comment: @AntoniParellada Which? :|
Comment: See my answers on related threads:

[Examples of Bayesian and frequentist approaches giving different results (1)](https://stats.stackexchange.com/questions/43471/examples-of-bayesian-and-frequentist-approach-giving-different-answers/506653#506653)

[Examples of Bayesian and frequentist approaches giving different results (2)](https://stats.stackexchange.com/questions/43471/examples-of-bayesian-and-frequentist-approach-giving-different-answers/538616#538616)
Comment: Related threads: [Bayesian vs frequentist interpretations of probability](https://stats.stackexchange.com/questions/31867/bayesian-vs-frequentist-interpretations-of-probability/503079#503079).   [How do Bayesians interpret $P(X=x|\theta=c)$?](https://stats.stackexchange.com/questions/539351/how-do-bayesians-interpret-px-x-theta-c/539352#539352)
Answer: I believe that most 'frequentists' and 'Bayesians' would rigorously define probability in the same way: via Kolmogorov's axioms and measure theory, modulo some issues about finite vs countable additivity, depending on who you're talking to.  So in terms of 'symbols' I reckon you'll likely find more or less the same definition across the board.  Everyone agrees on how probabilities behave.
I would say the primary difference is in the interpretation of what probabilities are.  My (tongue-in-cheek militant Bayesian) preferred interpretation is that probabilities are coherent representations of information about events.
'Coherent' here has a technical meaning: it means that if I represent my information about the world in terms of probabilities and then use those probabilities to size my bets on the occurrence or nonoccurrence of any given event, I am assured that I can not be made a sure loser by agents betting against me.
Note that this involves no notion of 'long-run relative frequency'; indeed, I can coherently represent my information about a one-off event - like the sun exploding tomorrow - via the language of probability.  On the other hand, it seems more difficult (or arguably less natural) to talk about the event "the sun will explode tomorrow" in terms of long-run relative frequency.
For a deep dive on this question I'd refer you to the first chapter of Jay Kadane's excellent (and free) Principles of Uncertainty.
UPDATE: I wrote a relatively informal blog post that illustrates coherence.
Comment: (+1) Very clear exposition. @BCLC: See Savage (1954), *The Foundations of Statistics* for an axiomatic approach. The gist is that if you want to represent degree of belief & insist on comparability (for any statements $A$ & $B$ you can say you believe one more than the other, or both equally) & coherence (as explained above), it turns out you *have* to use a probability - i.e. a real number subjective to Kolmogorov's axioms (bar one, perhaps).
Comment: 'If you are a member of the general public:

The fact that you are seeing this page indicates that the website you just visited is either experiencing problems, or is undergoing routine maintenance.' --> Maybe later then. Thanks
Comment: @BCLC Is that for the PoU link?  It's working for me.
Comment: I'm sure there's some good explanation about how Bayesian probabilities do not allow for dutch books, but I don't immediately see the connection, so I have trouble saying this is a clear explanation of how Bayesians see probability. And further, if the information an agent has betting against you is asymmetric, then you must be able to be made a sure loser? Maybe that question implies what I'm not understanding...
Answer: As already noted by others, there is no specific Bayesian definition of probability. There is only one way of defining probability, i.e. it's a real number assigned to some event by a probability measure, that follows the axioms of probability. If there were different definitions of probability, we wouldn't be able use it consistently, since different people would understand different things behind it.
While there is only one way we define it, there are multiple ways to interpret the probability. Probability is a mathematical concept, not related anyhow to real world (quoting de Finetti, "probability does not exist"). To apply it to real world we need to translate, or interpret, the mathematics into real world happenings. There are multiple different ways to interpret the probability, even different interpretations among Bayesians (check Interpretations of Probability in Stanford Encyclopedia of Philosophy for a review). The one that is most commonly associated with Bayesian statistics is subjectivist view, also known as personalistic probability.
In subjectivist view, probability is a degree of belief, or degree of confirmation. It measures how much someone considers something believable. It can be analyzed, or observed, most clearly in terms of betting behavior (de Finetti, 1937; see also Savage, 1976; Kemeny, 1955):

Let us suppose that an individual is obliged to evaluate the rate $p$
  at which he would be ready to exchange the possession of an arbitrary
  sum $S$ (positive or negative) dependent on the occurrence of a given
  event $E$, for the possession of the sum $pS$; we will say by
  definition that this number $p$ is the measure of the degree of
  probability attributed by the individual considered to the event $E$,
  or, more simply, that $p$ is the probability of $E$ (according to the
  individual considered; this specification can be implicit if there is
  no ambiguity).

Betting is one of the situations where one needs to quantify how "likely" he believes something to be and the measure of such belief is clearly a probability. Translating such belief to numbers, least to measure of belief, i.e. probability.
Bruno de Finetti, one of the major figures among subjectivists, notices that the subjectivist view is coherent with axioms of probability and it needs to follow them:

If we acknowledge only, first that one uncertain event can only appear
  to us (a) equally probable, (b) more probable, or (c) less probable
  then another; second that an uncertain event always seems to us more
  probable then an impossible event and less probable then a necessary
  event; and finally, third that when we judge an event $E'$ more
  probable then event $E$, which is itself more probable then an event
  $E''$, then event $E'$ can only appear more probable then $E''$
  (transitive property), it will suffice to add to there three evidently
  trivial axioms a fourth, itself of purely qualitative nature, in order
  to construct rigorously the whole theory of probability. The fourth axiom
  tells us that
  inequalities are preserved in logical sums: if $E$ is incompatible
  with $E_1$ and with $E_2$, then $E_1 \lor E$ will be more or less
  probable then $E_2 \lor E$, or they will be equally probable,
  according to wherever $E_1$ is more or less probable then $E_2$, or
  they are equally probable. More generally, it may be deduced from this
  that two inequalities, such as
$$ E_1 \text{ is more probable then } E_2,\\ E_1' \text{ is more
 probable then } E_2',$$
can be added to give
$$ E_1 \lor E_1' \text{ is more probable then } E_2 \lor E_2' $$
provided that the events added are incompatible with each other ($E_1$
  with $E_1'$, $E_2$ with $E_2'$).

Similar points are made by multiple different authors, like Kemeny (1955), or Savage (1972), who like de Finetti draw connections between the axioms and subjectivist view of probability. They also show that such measure of belief needs to be consistent with the axioms of probability (so if it looks like a probability and quacks like a probability...). Moreover, Cox (1946) shows that probability can be thought as an extension of formal logic that goes beyond binary true and false, allowing for uncertainties.
As you can see, this has nothing to do with frequencies. Of course, if you observe that nicotine smokers die of cancer more often then non-smokers, rationally you would assume such death to be more believable for a smoker, so frequency interpretation does not contradict the subjectivist view. What makes such interpretation appealing is that it can be applied also to cases that have nothing to do with frequencies (e.g. the probability that Donald Trump wins the 2016 US presidential election, the probability that there are other intelligent lifeforms somewhere in the space besides us etc). When adopting subjectivist view you can consider such cases in probabilistic manner and build statistical models of such scenarios (see example of election forecasting by FiveThirtyEight, that is consistent with thinking about probability as measuring degree of belief based on the available evidence). This makes such interpretation very broad (some say, overly broad), so we can flexibly adapt probabilistic thinking to different problems. Yes, it is subjective, but de Finetti (1931) notices that as frequentist definition is based on multiple unrealistic assumptions, it does not make it more "rational" interpretation.

de Finetti, B. (1937/1980). La Prévision: Ses Lois Logiques, Ses Sources Subjectives. [Foresight. Its Logical Laws, Its Subjective Sources.] Annales de l'Institut Henri Poincaré, 7, 1-68.
Kemeny, J. (1955). Fair Bets and Inductive Probabilities. Journal of Symbolic Logic, 20, 263-273.
Savage, L.J. (1972). The foundations of statistics. Dover.
Cox, R.T. (1946). Probability, frequency and reasonable expectation. American journal of physics, 14(1), 1-13.
de Finetti, B. (1931/1989). 'Probabilism: A critical essay on the theory of probability and on the value of science'. Erkenntnis, 31, 169-223.
Comment: +1 Very nice answer (somehow I didn't see it before), and the references are good.
Answer: I'll try to be incredible clear with my terminology.  As you did, we'll focus on one coin, $X \sim Bernoulli(p)$, so $Pr(X=1) = p$.
Bayesians and frequentists both view $X$ as a random variable and they share the same views about the probability distribution $Pr(X)$.  However, Bayesians also use probability distributions to model their uncertainty about a fixed parameter, in this case $p$.
If we now let $x_1, x_2, \dots \sim Bernoulli(p)$ and define $h_n = \sum_{i=1}^n x_i$, as you pointed out
$$
\lim_{n\rightarrow \infty} \frac{h_n}{n}=  p.
$$
This is relevant because $h_n/n$ is the MLE for $p$.  However notice that for any positive numbers $a,b$ (in fact they don't even need to be positive):
$$
\lim_{n\rightarrow \infty} \frac{h_n+a}{n+a+b}=  p.
$$
One draw back of the estimator $h_n/n$ is that for small $n$ this might be crazy.  The most extreme example of this is when $n = 1$, our estimate of $p$ will be $0$ or $1$.  What if we set $a=b=5$ and use the second estimate.  If we get a $1$ on the first flip our updated estimate is $6/11$, greater than $50\%$ but not as extreme as $1$.
This more restrained estimate can be easily derived by expressing our uncertainty about $p$ in the form of a prior (and eventually posterior) distribution.  If you would like to look up this example in depth this is known as the Beta-Binomial.  It involves putting a Beta prior on the parameter of a Binomial Distribution, and taking the expectation of the resulting posterior.
Comment: So Bayesians interpret probability as the limit of an MLE? Also, is that first limit statement due to $E(X) = P(X=1) = p$ and one of the [laws of large numbers](https://en.wikipedia.org/wiki/Law_of_large_numbers)?
Comment: This does not answer the question asked... This answer is more about using priors and Bayesian inference, not on how probability is defined.
Comment: @Tim I was thinking that that first limit statement is the answer?
Comment: @Tim Maybe you should say 'how probability is [interpreted](http://stats.stackexchange.com/questions/173056/how-exactly-do-bayesians-define-or-interpret-probability/173110#comment326941_173056)'...
Comment: I tried to explain and give an example of the fact that probability is defined the same way but used differently.
Comment: @jlimahaverford but you do not state this in your answer...
Comment: Perhaps I should have emphasized the second paragraph.
Comment: @jlimahaverford 'Perhaps I should have emphasized the second paragraph.' --> What? The second paragraph to me says probability is modelled by probability distributions. :|
Comment: They share the same views about the distribution.  The difference is that they model their uncertainty about the parameter by means of a distribution.
Comment: A comment on the question had already made the point that the definition of probability was the same, so I focused on the way in which they are different.
Comment: @jlimahaverford Bayesians model their uncertainty about probability through probability distribution. Circular?
Comment: You need to really focus on precise terminology.  I never said " Bayesians model their uncertainty about probability through probability distribution."  Even the phrase "uncertainty about probability" doesn't really make sense.  They model their uncertainty about the parameters of one distribution, using another distribution.
Comment: @jlimahaverford Okay so what's what Bayesians do, but how exactly do they see probability (which causes them to do what they do)? 'This does not answer the question asked... This answer is more about using priors and Bayesian inference, not on how probability is defined. –  Tim 6 hours ago'