Expectations of cosine under von Mises distribution

Question: I'm trying to work out the expectations of a few functions under the von Mises distribution:
$
p(\theta \mid \mu, \kappa) = \frac{1}{2\pi I_0(\kappa)}
\exp\left\{
 \kappa \cos \left( \theta - \mu \right)
\right\}
$
Specifically, for known $\mu$ and $\kappa$,
$
\mathbb{E} \left( \cos\tfrac{\theta}{2} \right) =
 \frac{1}{2\pi I_0(\kappa)} \int_0^{2\pi}
 \cos\tfrac{\theta}{2} \exp\left\{
 \kappa \cos \left( \theta - \mu \right)
\right\} d\theta = ?
$
However, my bag of tricks for integrals is fairly small, and I've hit
a kind of brick wall.
Ultimately, I'm looking for expressions for $\mathbb{E}(\cos\theta/2)$,
$\mathbb{E}(\sin\theta/2)$, $\mathbb{E}(\cos^2\theta/2)$, and
$\mathbb{E}(\sin^2\theta/2)$ for a given $\mu$,$\kappa$.
Is there a good lit. source (or trick) for integrals of this type?
Thanks!
Comment: Most of these integral a will be related to Bessel function derivatives. You can standardize your integrals by using half angle formulas and then thinking about writing them as derivatives in $\kappa$ of Bessel functions. A good place to look is an integral handbook: http://people.math.sfu.ca/~cbm/aands/page_376.htm
Comment: Also see the moment calculations here: https://en.m.wikipedia.org/wiki/Von_Mises_distribution
Comment: Thanks @AlexR. Since posting, I've been able to get a bit further by shifting the integration limits by $-\mu$, then using trig idents to break apart the leading cosine. In particular, this seems to lead to modified Bessel functions in the $\cos^2$ and $\sin^2$ cases. Yet to crack the first two though...
Answer: Ok, after a weekend of wine, cheese and brain-bashing, I solved the integrals. For the sake of posterity:
$
\left\langle \cos(\theta/2) \right\rangle =
 \frac{1}{\sqrt{2 \pi \kappa} I_0(\kappa)} \left[
 e^{ \kappa} \cos(\mu/2) \;
  \mathrm{erf} \left( \sqrt{2 \kappa} \sin(\mu/2) \right) -
 e^{-\kappa} \sin(\mu/2) \;
  \mathrm{erfi} \left( \sqrt{2 \kappa} \cos(\mu/2) \right)
 \right]
$
$
\left\langle \sin(\theta/2) \right\rangle =
 \frac{1}{\sqrt{2 \pi \kappa} I_0(\kappa)} \left[
 e^{ \kappa} \sin(\mu/2) \;
  \mathrm{erf} \left( \sqrt{2 \kappa} \sin(\mu/2) \right) +
 e^{-\kappa} \cos(\mu/2) \;
  \mathrm{erfi} \left( \sqrt{2 \kappa} \cos(\mu/2) \right)
 \right]
$
$
\left\langle \cos^2(\theta/2) \right\rangle =
\frac{1}{2} \left[
 1 + \frac{I_1(\kappa)}{I_0(\kappa)} \cos \mu \right]
$
$
\left\langle \sin^2(\theta/2) \right\rangle =
\frac{1}{2} \left[
 1 - \frac{I_1(\kappa)}{I_0(\kappa)} \cos \mu \right]
$
And one more, because why not...
$
\left\langle \cos(\theta/2) \sin(\theta/2) \right\rangle =
 \frac{1}{2} \frac{I_1(\kappa)}{I_0(\kappa)} \sin \mu
$
The one trick I hadn't tried prior to posting was the ticket: let $x = \theta - \mu$ and then use trig identities to simplify the expressions into known integrals.
Comment: The 'trick' is a recommended path, hence my upgrade.


Why $\left(\frac{\partial x}{\partial y}\right)_z=-\left(\frac{\partial x}{\partial z}\right)_y \left(\frac{\partial z}{\partial y}\right)_x$?

Question: I was reading a statistical mechanics book, the author use: $\left(\frac{\partial x}{\partial y}\right)_z=-\left(\frac{\partial x}{\partial z}\right)_y \left(\frac{\partial z}{\partial y}\right)_x$ so I'm trying to prove this, but I'm stuck. I'm using the theorem:
$dF=\frac{\partial F}{\partial x}dx+\frac{\partial F}{\partial y}dy+ \frac{\partial F}{\partial z}dz=0$
with $dz=\left(\frac{\partial z}{\partial x}\right)_y dx +\left(\frac{\partial z}{\partial y}\right)_xdy$
if $z$ is constant then $dz=0$ then $\left(\frac{\partial z}{\partial x}\right)_y dx =-\left(\frac{\partial z}{\partial y}\right)_xdy$ so I get:
$\frac{\partial F}{\partial x}dx+\frac{\partial F}{\partial y}dy=0$
but this result doesn't lead me to anything
Comment: Welcome to MSE. Your question is phrased as an isolated problem, without any further information or context. This does not match [many users' quality standards](http://goo.gl/mLWc8), so it may attract downvotes, or closed. To prevent that, please [edit] the question. [This](http://goo.gl/PlJyVQ) will help you recognise and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers.
Answer: In physics notation, you can write $dz=\left ( \frac{\partial z}{\partial x} \right )_y dx + \left ( \frac{\partial z}{\partial y} \right )_x dy=0$ (so you're holding $z$ fixed). Then solving for $dx$ you get $dx=-\frac{\left ( \frac{\partial z}{\partial y} \right )_x dy}{\left ( \frac{\partial z}{\partial x} \right )_y}$. Finally divide by $dy$, and interpret the result as holding $z$ fixed, giving $\left ( \frac{\partial x}{\partial y} \right )_z = -\frac{\left ( \frac{\partial z}{\partial y} \right )_x}{\left ( \frac{\partial z}{\partial x} \right )_y}$.
Finally to convert this to the form you wrote you apply the inverse function theorem in the denominator to get $\left ( \frac{\partial z}{\partial x} \right )_y = \left ( \left ( \frac{\partial x}{\partial z} \right )_y \right )^{-1}$.
In math notation you introduce a parametrized path $(x(t),y(t),f(x(t),y(t)))$ and check that $\frac{df}{dt}=\frac{\partial f}{\partial x} \frac{dx}{dt} + \frac{\partial f}{\partial y} \frac{dy}{dt}$, so if this is to be zero then $\frac{\frac{dx}{dt}}{\frac{dy}{dt}}=-\frac{\frac{\partial f}{\partial y}}{\frac{\partial f}{\partial x}}$. Then you use the inverse function theorem in the same way.
Comment: thank u very much


Module not found: can't resolve' redux-thunk ' error I have tried the solutions but it does not happen.What is the solution?

Question: I tried all the commands for redux but it doesn't work:how do you think the solution is. These are the commands I tried
yarn add react-redux
yarn add reduxjs / Redux-thunk#master
npm install --save Redux react-redux
npm install redux -- save
npm i redux -- save
yarn add redux-thunk

index.jsx
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import {createStore, applyMiddleware,compose} from 'redux';
import rootReducer from './store/reducers/rootReducer';
import {Provider} from 'react-redux';
import thunk from 'redux-thunk';
import {reduxFirestore,getFirestore} from 'redux-firestore'
import {reactReduxFirebase,getFirebase} from 'react-redux-firebase'
import fbConfig from './config/fbConfig';

const store=createStore(rootReducer,
    compose(
        applyMiddleware(thunk.withExtraArgument({getFirebase,getFirestore})),
        reduxFirestore(fbConfig),
        reactReduxFirebase(fbConfig)
    ));

ReactDOM.render(<Provider store={store}><App /></Provider>, document.getElementById('root'));

package.json
{
  "name": "omaga-yazilim",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^npm i --save react-router4.2.4",
    "@testing-library/react": "^9.4.0",
    "@testing-library/user-event": "^7.2.1",
    "firebase": "^7.8.1",
    "jest-leak-detector": "^25.1.0",
    "moment": "^2.22.2",
    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "react-redux": "^7.1.3",
    "react-redux-firebase": "^3.1.1",
    "react-router": "^4.4.0-beta.8",
    "react-router-dom": "^4.4.0-beta.6",
    "react-scripts": "^2.1.1",
    "redux": "^4.0.5",
    "redux-firestore": "^0.12.0",
    "redux-thunk": "reduxjs/redux-thunk#master",
    "start": "webpack-dev-server --mode development"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Comment: Is there any specific reason why you are using the **master** branch from **redux-thunk**?
Comment: Also you have `start` script as a dependency. That needs to be removed. And the version `@testing-library/jest-dom` is an npm command instead of an actual version.
Answer: I faced the same problem but I run the command line:

npm install --save redux-thunk
Answer: The simplest solution is to use our new official Redux Toolkit package.  The configureStore function will automatically set up the store correctly, including adding the thunk middleware by default.  Given that you're trying to use React-Redux-Firebase, you can do that by using the getDefaultMiddleware API:
const store = configureStore({
    reducer: rootReducer,
    middleware: [...getDefaultMiddleware({
        thunk: {
            extraArgument: {getFirebase,getFirestore}
        }
    })],
    enhancers: [reduxFirestore(fbConfig), reactReduxFirebase(fbConfig)]
})

Comment: I did what you said, he didn't give the thunk error, but Module not found: can't resolve gave the 'react-redux' error.
Answer: I had a similar issue with this and this is how i resolved it:
Stop the server:Ctrl C in terminal.
Open package.json and manually add:
"redux-thunk": "^2.3.0",

then in the terminal cd into the project and install redux thunk:
yarn add redux-thunk

restart the server:
yarn start

More details about redux thunk can be found on this link:
ReduxThunk-Github
Answer: I also had the same issue...and this is how I resolved it...
Stop the server Ctrl + C
open package.json
and remove the available redux-thunk version and replace like below...
"redux-thunk": "^2.3.0",

and then go to terminal and install the redux-thunk using following command...
npm install redux-thunk

and then start the server
npm start


Consultar os nomes dos pilotos patrocinados por uma Equipe

Question: Quero consultar pilotos patrocinados pela equipe 'A'
Estou fazendo assim:
SELECT piloto.nome AS NomePiloto
FROM equipe
INNER JOIN piloto
ON equipe.idequipe = piloto.idequipe
INNER JOIN patrocinador
ON patrocinador.idpat = equipe.idpat
WHERE patrocinador.nome = 'A'

Mas, não está retornando nada, onde estou errando?
O modelo é este:
Comment: qual o erro que retorna? o `idpat`, `idequipe` e `nome` estão realmente escritos assim no banco? na imagem que você apresentou, estão como `ID_PAT`, `NOME_E` e `NOME_P`.
Comment: Nas ligações para estar tudo OK, mas o problema poderá estar nos dados. Tem a certeza que tem pilotos associados a equipas e equipas patrocinadas com o nome "A"?
Answer: Como você quer os nomes dos pilotos, melhor usar como tabela principal a pilotos, assim facilita montar a query.
SELECT pi.nome as piloto, eq.nome_e as equipe, pt.nome_p as patrocinador
FROM piloto pi
LEFT JOIN equipe eq ON eq.id_equipe = pi.id_equipe
LEFT JOIN patrocinador pt ON pt.id_pat = eq.id_pat
WHERE pt.nome_p LIKE 'A%'

Usei o LIKE assim trará todos que começam com a letra A.


Rogers-Ramanujan continued fraction in terms of Jacobi theta functions?

Question: The Rogers-Ramanujan cfrac is,
$$r = r(\tau)= \cfrac{q^{1/5}}{1+\cfrac{q}{1+\cfrac{q^2}{1+\ddots}}}$$
If $q = \exp(2\pi i \tau)$, then it is known that,
$$\frac{1}{r}-r =\frac{\eta(\tau/5)}{\eta(5\tau)}+1\tag1$$
$$\frac{1}{r^5}-r^5 =\left(\frac{\eta(\tau)}{\eta(5\tau)}\right)^6+11\tag2$$
with the Dedekind eta function, $\eta(\tau)$.
Q: Is there a similar simple identity known using ratios of the Jacobi theta functions $\vartheta_n(0,q)$?

$\color{brown}{Edit}$: In response to a comment, here are some details. Suppose we don't know $(2)$. One way to find such relations is to use known identities. Given the j-function $j(\tau)$, we have,
$$j(\tau)=-\frac{(r^{20} - 228r^{15} + 494r^{10} + 228r^5 + 1)^3}{r^5(r^{10} + 11r^5 - 1)^5}\tag3$$
$$j(\tau)=\frac{(5x^2+10x+1)^3}{x^5}\tag4$$
where $x = \left(\frac{\eta(\tau)}{\sqrt{5}\,\eta(5\tau)}\right)^6$. Equate $(3),\,(4)$,
$$-\frac{(r^{20} - 228r^{15} + 494r^{10} + 228r^5 + 1)^3}{r^5(r^{10} + 11r^5 - 1)^5} = \frac{(5x^2+10x+1)^3}{x^5}\tag5$$
and using symbolic software like Mathematica to factor $(5)$, we find one factor is given by,
$$\frac{1}{r^5}-r^5 =125x+11\tag6$$
and it only takes minor tweaking to make $(6)$ have the form of $(2)$. Thus, all we need is to express $j(\tau)$ not by an eta quotient $x$, but by a theta quotient $y=\left(\frac{\vartheta_n(0,q)}{\vartheta_n(0,q^5)}\right)^k$ so that,
$$j(\tau) = \frac{f_1(y)}{f_2(y)}\tag7$$
is a ratio of polynomials in $y$.
$\color{brown}{P.S.}$ The motivation for this is that the general quintic is solvable by the Rogers-Ramanujan cfrac via the eta quotient above as described in this post.
Comment: From another source, we have $$\frac{1}{r^5}-r^5 = \Big(\frac{ \vartheta_2(0,q)\,\vartheta_3(0,q)\, \vartheta_4(0,q)  }{\vartheta_2(0,q^5)\,\vartheta_3(0,q^5)\, \vartheta_4(0,q^5) }\Big)^2+11$$ but I find this is cheating a little bit.
Comment: Using basic identities, one can deduce a family of formulae for the RRCF like
$$r(\tau) = \frac
{\vartheta_1\!\left(\frac{\pi}{5}\middle|\tau'\right)}
{\vartheta_1\!\left(\frac{2\pi}{5}\middle|\tau'\right)}
= \frac
{\vartheta_2(0\mid \tau')\,\vartheta_3(0\mid\tau')\,\vartheta_4(0\mid\tau')}
{2\,\vartheta_2\!\left(\frac{\pi}{5}\middle|\tau'\right)
\vartheta_3\!\left(\frac{\pi}{5}\middle|\tau'\right)
\vartheta_4\!\left(\frac{\pi}{5}\middle|\tau'\right)}$$
where $\tau'=-(5\tau)^{-1}$.
Unfortunately, the question requires thetanulls exclusively. Sigh.
Comment: @Nicco: Thanks. Right now, I can do so using the complete elliptic integral $K(k)$ and the Dedekind eta function, via $R(q)$. I'm trying to adapt the method to the Jacobi theta.
Comment: The answer is in W.Duke's paper ***continued fractions and modular functions***,equation (4.9)
Comment: @Nicco: Thanks. By the way, can you ask a question on the forum how to solve the _Brioschi quintic_ using elliptic functions? (I have an answer that may be useful to you and others interested, and is the reason for this theta function post.)
Comment: @ Tito PiezasIII :I have asked the question [here](http://math.stackexchange.com/questions/1425349/different-ways-of-solving-the-brioschi-quintic-in-terms-of-elliptic-functions)
Comment: @ Tito PiezasIII:it looks awesome,though
Comment: The derivative of the theta function $$\theta_1(0,q)$$ is known to satisfy the identity $$\theta_1(0,q)\prime=\theta_2(0,q)\,\theta_3(0,q)\,\theta_4(0,q)$$
Comment: @Nicco: Very interesting. This would then imply $\theta_1(0,q)' = 2\eta^3(\tau)$. Substituting this into the identity, one recovers $$\frac{1}{r^5}-r^5 = \Big(\frac{\eta(\tau)}{\eta(5\tau)}\Big)^6+11$$
Comment: Another way to express $\eta$ in terms of Jacobi theta functions is eq. $(20)$ at [Mathworld](http://mathworld.wolfram.com/DedekindEtaFunction.html). This is not a nullvalue however.
Comment: @ccorn: Or from [this](https://en.wikipedia.org/wiki/Theta_function#Relations_to_Dedekind_eta_function).
Comment: Could you concretize what you are asking for? The question is interesting, but currently it is not clear to me what a valid answer would be. It seems you might be satisfied with an algebraic equation for $r$ with coefficients in terms of thetanulls. You have already given some. I have inspected your Brioschi quintic post, but to adapt the method to thetanulls one can go directly via $\eta$, that is, the $2\eta^3$ as a product of thetanulls, as already mentioned. Do you expect something drastically simpler? Whatever reformulation we can come up with, it would at best be equivalent, I'm afraid.
Comment: @ccorn: I have clarified the question. If you know of a formula for the j-function in terms of a theta quotient in just ***one*** thetanull $\frac{\vartheta_n(0,q)}{\vartheta_n(0,q^5)}$, then that can lead me to an answer.
Comment: Thanks for the clarification. My gut feeling is that such a thing should exist. Thinking...
Comment: @ccorn: Thanks to your prodding, I found what I was looking for. :) Kindly see answer below.
Comment: I have asked a question which assumes $(6)$ and proves $(3),(4)$ based on it. I also provide an answer based on modular equations. See [this question](https://math.stackexchange.com/q/4000258/72031).
Answer: Motivated by ccorns's comment, I decided to re-visit this question. After some effort, I found what I was looking for. The Rogers-Ramanujan cfrac is,
$$r = r(\tau)= \cfrac{q^{1/5}}{1+\cfrac{q}{1+\cfrac{q^2}{1+\ddots}}}$$
where $q = \exp(2\pi i \tau)$. It turns out we have the nice relations,
$$\begin{aligned}\frac{1}{r^5}-r^5
&=\,u^3+11\\
&= \frac{v(v-5)^2}{(v-1)^2}+11
\end{aligned}$$
where the three roots of the cubic in $u$ are eta quotients,
$$u_n = \left(\frac{\eta(\tau')}{\eta(5\tau')}\right)^2$$
with $\tau'=\tau+n$, while the three roots of the cubic in $v$ are theta quotients,
$$v_n = \left(\frac{\vartheta_{n+2}(0,p)}{\vartheta_{n+2}(0,p^5)}\right)^2$$
for the nome $p = e^{\pi i \tau}$ and for $n=0,1,2$.
Comment: Nice indeed. If there were a 2nd volume of Whittaker & Watson, this one would make it to the legendary "Shew that..." exercises.
Answer: Given the Jacobi theta function
$$
\vartheta_4(u,q)=1+2\sum^{\infty}_{n=1}(-1)^nq^{n^2}\cos(2nu)
$$
I. Define the Rogers-Ramanujan as
$$
R(q)=\frac{q^{1/5}}{1+}\frac{q}{1+}\frac{q^2}{1+}\frac{q^3}{1+}\ldots\textrm{, }\;|q|<1
$$
then
$$
R(e^{-x})=e^{-x/5}\frac{\vartheta_4(3ix/4,\,e^{-5x/2})}{\vartheta_4(ix/4,\,e^{-5x/2})}\textrm{, }\;x>0
$$
II. Define the Ramanujan-Gordon-Gollniz as
$$
H(q)=\frac{q^{1/2}}{1+q+}\frac{q^2}{1+q^3+}\frac{q^4}{1+q^5+}\frac{q^6}{1+q^7+}\ldots\textrm{, }\;|q|<1
$$
then
$$
H(e^{-x})=e^{-x/2}\frac{\vartheta_4(3ix/2,\,e^{-4x})}{\vartheta_4(ix/2,\,e^{-4x})}\textrm{, }\;x>0
$$
Comment: +1 This is very nice. I tested it with _Mathematica_ and they equate. Do you know if the _cubic cfrac_ and the _octic cfrac_ can be similarly expressed in terms of theta quotients?
Comment: Can you look at this [MO post](http://mathoverflow.net/a/259342/12905) about $x^5+y^5 = 1$? There are some functions $a,b,c,d$ there and the ratio $a/b$ can be expressed by Jacobi theta functions. Can you check if we can do so for the ratio $d/b$ as well?
Answer: I'm sorry about the octic cfrac. Yes it seems to be non trivial. In Berndt's book (see: B.C. Berndt. "Ramanujan Notebooks III". Springer Verlag, New York (1991), In chapter 19 Entry 1) one can find the expansion
$$
M(q)=\tfrac{1}{2}\,q^{1/8}\frac{\sum^{\infty}_{n=-\infty}q^{n^2/2+n/2}}{\sum^{\infty}_{n=-\infty}q^{n^2}}=\frac{q^{1/8}}{1+}\frac{q}{1+q+}\frac{q^2}{1+q^2+}\frac{q^3}{1+q^3+}\ldots
$$
Hence if $|q|<1$ and
$$
\vartheta_3(z,q):=\sum^{\infty}_{n=-\infty}q^{n^2}e^{2niz}
$$
For $x>0$ we have
$$
M(e^{-x})=\tfrac{1}{2}\,e^{-x/8}\frac{\vartheta_3(ix/4,e^{-x/2})}{\vartheta_3(0,e^{-x})}
$$
Equivalently, let $q = e^{2\pi i z}$, then
$$M(q) = \tfrac{1}{2}\,q^{1/8} \frac{\vartheta_3\big(i\ln(q^{1/4}),q^{1/2}\big)}{\vartheta_3(0,q)}=\frac{\eta(z)\,\eta^2(4z)}{\eta^3(2z)}$$
where $\eta(z)$ is the Dedekind eta function.
Comment: I've added some info to connect it to the $\eta(z)$ function.
Answer: For the cubic $V(q)$ cfrac is
$$
V(q):=\frac{q^{1/3}}{1+}\frac{q+q^2}{1+}\frac{q^2+q^4}{1+}\frac{q^3+q^6}{1+}\ldots\textrm{, }|q|<1
$$
and
$$
V(e^{-x})=e^{-x/3}\frac{\vartheta_4(ix/4,e^{-3x})}{\vartheta_4(0,e^{-3x})}\textrm{, }x>0
$$
See more formulas in https://arxiv.org/pdf/1107.2393v2.pdf
Comment: +1 Great! Now all that is missing is Ramanujan's octic cfrac
Comment: The octic cfrac of Ramanujan is just the "elementary" continued fraction of Euler and can be evaluated (with theta functions) in a very simply way.
Comment: Kindly include so this list will be complete.
Answer: Set $T=\sqrt{1-8V(q)^3}$, $q=e^{-\pi\sqrt{r}}$, $r>0$, then
$$
k_r^2=\frac{(1-T)(3+T)^3}{(1+T)(3-T)^3}
$$
where $k_r$ is the elliptic singular modulus. (see https://arxiv.org/pdf/1008.1304v2.pdf)


How to mass delete some lines of htmls in a directory

Question: I think someone here can help me out of the trouble I'm facing.
I got my sites DDOSed and all the html files in my site were added 7 lines of codes at the end of the files. I downloaded all the contaminated files and would like to remove all those bad codes. But the task was overwhelmed. There are 400+ htmls.
So I would ask those gurus, is there any method that I can bulk delete the last 7 lines? I tried notepad++ and other apps but failed to find a better way.
PS. the HTMLS spread in different directory.
Comment: First, you need to fix the underlying security hole.
Comment: Use regex or juste simple replace in notepad++ or coda , and replace all lines in a folder
Answer: Lots of people seem to be using PowerShell for tasks like this these days.
Test this before you run it, but I think this is what you're looking for:
<code>gci c:/USE_REAL_FOLDER_NAME_HERE/ | % {
    $path = $_
    $file = gc $_
    $file[0..($file.length-7)] | % {$_.trimstart()} | out-file $path
}
</code>


How to add directions with a link to a webform in Drupal 7

Question: I'm creating forms with the webform module. I'd like to add 'directions for filling out the form at the top of the form. I'd like those directions to include a link to another form if users clicked the wrong form.
This seems like it should be simple to do, but I can't figure out how to do it. When I add the directions with the link in a  and put that at the top I get the link but no paragraphs, just one long running line of text, no matter how I split it up in the editor window. If I use a  field, not only does it look ugly (even when disabled), because it has a white background on a gray background site, but it displays the link as html code etc..
I have wysiwyg enabled on my site and it shows up in other places but not on these editor windows so I can't use that (or select filtered html/full as those options also aren't available) in those data types I tried.
Anyone know a way to do this?
Answer: I'd recommend creating a custom module and using hook_form_alter() as shown in this example.
You can add a form element of type #markup to add custom html in your form. And set the #weight to a low number, <code>-50</code> for instance, for your markup element to show at the top.
Answer: It sounds like you may have editor limitations on that content type. Other than that make sure you are adding your directions to the 'body' field.
When editing the webform go to the 'edit' tab adjacent (where you set the title) the body field should have a switch. If that was not present, you need to check your editor module settings. Sometimes called profiles depends which one you use.
I recall one of them required that each content type had to be picked in the editor settings.


Calculate averages over row-specific time interval in R

Question: I have a data frame with prey items, the day they were brought and their estimated weight. Some rows have NA for estimated weight and I would like to extrapolate a rough estimate by averaging the weight of the same type of prey item over a period of 3 days, being the day before the prey delivery, the same day and the day after. How should I do that? Also, the data is grouped by nest IDs. MRE:
example_data <- structure(list(broodID = structure(c(7L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L,
8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L), .Label = c("2018_1", "2019_3",
"2020_10", "2020_11", "2020_12", "2020_2", "2020_5", "2020_8",
"2020_9"), class = "factor"), date = structure(c(18469, 17743,
17724, 17730, 17731, 17739, 17723, 17724, 17738, 17738, 17739,
17739, 17742, 17735, 17724, 17730, 17732, 17745, 17737, 17751,
17725, 17725, 17725, 17725, 17726, 17729, 17723, 17730, 18104,
18104, 18102, 18102, 18103, 18098, 18098, 18100, 18462, 18462,
18470, 18459, 18459, 18471, 18473, 18463, 18463, 18474, 18493,
18479, 18473, 18471, 18471, 18475, 18475, 18472, 18472, 18474,
18411, 18411, 18462, 18462, 18461, 18462, 18470, 18464, 18449,
18453, 18452, 18452, 18448, 18456, 18464, 18464, 18450, 18450,
18471, 18471, 18451, 18460, 18470, 18460, 18456, 18456, 18473,
18473, 18447, 18447, 18471, 18447, 18452, 18452, 18450, 18456,
18459, 18488, 18464, 18451, 18458, 18455, 18469, 18453, 18461,
18461, 18468, 18466, 18458, 18458, 18449, 18450, 18450, 18476,
18482, 18454, 18454, 18458, 18458, 18470, 18452, 18453, 18453,
18448, 18448, 18457, 18457, 18467, 18467, 18472, 18472, 18455,
18457, 18457, 18461, 18461, 18465, 18465, 18453, 18453, 18458,
18466, 18466, 18475, 18452, 18452, 18459, 18456, 18456, 18456,
18458, 18458, 18456, 18456, 18450, 18450, 18465, 18452, 18461,
18461, 18456, 18464, 18459), class = "Date"), PreyGroup = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "bird", class = "factor"),
    weightcalc = c(10, 5, 10, 10, 10, 10, 15, 15, 15, 15, 15,
    15, 15, 20, 25, 25, 25, 25, 25, 40, 45, 45, 45, 45, NA, NA,
    NA, NA, 10, 10, 15, 15, 20, 25, NA, 20, 15, 15, 20, 20, 20,
    20, 35, 45, 45, 50, 120, 15, 20, 20, 20, 20, 20, 25, 35,
    45, 45, NA, 6, 6, 7, 8, 10, 12, 12, 12, 14, 14, 15, 15, 15,
    15, 15, 15, 20, 20, 20, 25, 25, 35, 40, 40, 55, 55, 60, 60,
    70, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 15, 15, 20, 50,
    50, NA, 6, 8, 8, 10, 10, 10, 15, 15, 15, 15, 15, 15, 15,
    15, 15, 15, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
    20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 35, 35, 35, 35,
    40, 40, 45, 45, 45, 45, 70, NA, NA, NA, NA, NA, NA)), class = "data.frame", row.names = c("1",
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
"14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24",
"25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35",
"36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46",
"47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57",
"58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68",
"69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79",
"80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90",
"91", "92", "93", "94", "95", "96", "97", "98", "99", "100",
"101", "102", "103", "104", "105", "106", "107", "108", "109",
"110", "111", "112", "113", "114", "115", "116", "117", "118",
"119", "120", "121", "122", "123", "124", "125", "126", "127",
"128", "129", "130", "131", "132", "133", "134", "135", "136",
"137", "138", "139", "140", "141", "142", "143", "144", "145",
"146", "147", "148", "149", "150", "151", "152", "153", "154",
"155", "156", "157", "158", "159"))

Comment: Please submit a [Minimal Reproducible Example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with usable data, not an image.
Comment: Sorry, I added now the dput code but somehow it only keeps only the first row in the code section. Does it work anyway?
Answer: You could first create a new variable with a moving average of the weightcalc variable. The rollmean function from the zoo package can help you do that. Make sure you look at ?rollmean to know the options (the align and k arguments are especially important for you):
library(zoo)
rollmean(c(1, 2, 3, 3, 4, NA, 6, 7, 7), k=3, na.rm=TRUE)
#> [1] 2.000000 2.666667 3.333333 3.500000 5.000000 6.500000 6.666667

Apply the rollmean within groups using dplyr's group_by and mutate function:
library(dplyr)
library(zoo)

dat = dataset %>%
  arrange(PreyGroup, date) %>%
  group_by(PreyGroup) %>%
  mutate(weightcalc_ma = rollmean(weightcalc, k=4, fill=NA, na.rm=TRUE),
         weightcalc_new = ifelse(is.na(weightcalc), weightcalc_ma, weightcalc))

dat
#> # A tibble: 159 x 6
#> # Groups:   PreyGroup [1]
#>    broodID date       PreyGroup weightcalc weightcalc_ma weightcalc_new
#>    <fct>   <date>     <fct>          <dbl>         <dbl>          <dbl>
#>  1 2018_1  2018-07-11 bird              15          NA             15
#>  2 2018_1  2018-07-11 bird              NA          13.3           13.3
#>  3 2018_1  2018-07-12 bird              10          16.7           10
#>  4 2018_1  2018-07-12 bird              15          23.8           15
#>  5 2018_1  2018-07-12 bird              25          32.5           25
#>  6 2018_1  2018-07-13 bird              45          40             45
#>  7 2018_1  2018-07-13 bird              45          45             45
#>  8 2018_1  2018-07-13 bird              45          45             45
#>  9 2018_1  2018-07-13 bird              45          45             45
#> 10 2018_1  2018-07-14 bird              NA          27.5           27.5
#> # … with 149 more rows

Alternatively, you could use the data.table package:
library(data.table)
dat = data.table(dataset, key=c("PreyGroup", "date"))[
      , weightcalc_ma := rollmean(weightcalc, k=4, fill=NA, na.rm=TRUE),
        by="PreyGroup"][
      , weightcalc_new := ifelse(is.na(weightcalc), weightcalc_ma, weightcalc),
        by="PreyGroup"]


Colocar setas para mudar por cima do carrossel

Question: Boas,
Eu precisava de colocar as setas do meu carrossel que servem para mudar de imagem por cima do carrossel desta forma:

Eu ja usei o z-index e tentei mudar os display mas não fica em cima da imagem.
Aqui vai o meu codigo:

var slideIndex = 1;
showDivs(slideIndex);

function plusDivs(n) {
  showDivs(slideIndex += n);
}

function showDivs(n) {
  var i;
  var x = document.getElementsByClassName("mySlides");
  if (n > x.length) {slideIndex = 1}
  if (n < 1) {slideIndex = x.length}
  for (i = 0; i < x.length; i++) {
    x[i].style.display = "none";
  }
  x[slideIndex-1].style.display = "block";
}
.mySlides {
    display: none;
    width: 100%;
}

.botao {
    z-index: 2;
    position: inherit;
    display:
}

.slideshow {
    z-index: -1;
}
<!DOCTYPE html>

<title>Rio Lis</title>
<link rel="stylesheet" type="text/css" href="./style.css">
<link rel="stylesheet" type="text/css" href="./normalize.css">

      <button class="botaoesquerda botao" onclick="plusDivs(-1)">❮</button>
      <button class="botaodireira botao" onclick="plusDivs(1)">❯</button>

Answer: Cara um opção é colocar position:relative no container do slider e usar position:absolute nos btns para poder alinhar com top/left/right

Veja o resultado

var slideIndex = 1;
showDivs(slideIndex);

function plusDivs(n) {
  showDivs(slideIndex += n);
}

function showDivs(n) {
  var i;
  var x = document.getElementsByClassName("mySlides");
  if (n > x.length) {
    slideIndex = 1
  }
  if (n < 1) {
    slideIndex = x.length
  }
  for (i = 0; i < x.length; i++) {
    x[i].style.display = "none";
  }
  x[slideIndex - 1].style.display = "block";
}
.mySlides {
  display: none;
  width: 100%;
}

.botao {
  z-index: 2;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 30px;
}

.botaodireira {
  left: auto;
  right: 30px;
}

.slideshow {
  /* z-index: -1; */
  position: relative;
}

  <button class="botaoesquerda botao" onclick="plusDivs(-1)">❮</button>
  <button class="botaodireira botao" onclick="plusDivs(1)">❯</button>

OBS: se vc colocar z-index:-1 no container do slider vc não vai conseguir clicar nos botões que estão dentro desse container. Na verdade não vi necessidade de usar esse  z-index:-1 então  deixei comentado no CSS
Answer: Todos os elementos são ou "posicionados" ou "estáticos". Posicionados são todos que possuem position: relative, absolute etc (qualquer position exceto static). Elementos sem uma position declarada ou com position: static serão estáticos e seguirão o fluxo da página.
Sabendo disso, perceba que itens posicionados sempre estarão "na frente" dos itens estáticos. O z-index tem por objetivo apenas ordenar itens posicionados. Ele de nada serve para itens estáticos.
No seu caso, os botões herdaram a posição estática do slideshow, e portanto foram empurrados para baixo, seguindo o fluxo da página. A forma mais simples de lidar com isso é dar-lhes position: absolute, e não se esqueça de dar ao slideshow position: relative para ancoragem.
Compreender o posicionamento é vital para um web developer, portanto, não deixe de ler sobre o assunto.


How to properly handle const char* in c++

Question: bool check(const char* pass);

Does const mean that I cannot modify char* inside the function?
Does char* c has any function like contains(char c) which checks if the char is inside char*?
How to get to 4th character in the char*?
Is there any function which gives the length of that char*. Beside checking where is '\0'?
Comment: A `char*` does not "contain" characters. It does not have a string "inside" it, and it does not have a length. It points to a character, which may or may not be the first character of a nul-terminated string. The nul-terminated string contains characters and has a length.
Comment: Answer to 4 is a big fat **NO**. That is one of the many reasons you shold be using `std:string` not `char*`. You could carry on making life difficult for yourself or you could take the advice of experienced programmers. If you have some trouble using `std::string` then ask about how to use it properly, it will be worth it in the end.
Comment: Const protects his left side, unless there is nothing to his
left and only then it protects his right side
Answer: Use std::string instead.

No, it means you can't modify the chars.
char* is a pointer, it doesn't have any functions. You can look up strchr.
pass[3]
strlen, but it checks for '\0' internally.
Comment: "You can look up `strstr`, but it doesn't take a single char as parameter" -- or look up `strchr`, which does take a single character (it takes it as an `int` rather than a `char`).
Comment: Ad2. I am asking about any static or non static funtion which can check if char* type object contains certain character
Comment: @SteveJessop didn't know that existed.
Comment: @Luchian: we'll make C programmer of you yet  ;-) If you like `strchr` then `strrchr` will blow your mind (especially the first time you typo one for the other)


Upload of large files using azure-sdk-for-java with limited heap

Question: We are developing document microservice that needs to use Azure as a storage for file content. Azure Block Blob seemed like a reasonable choice. Document service has heap limited to 512MB (-Xmx512m).
I was not successful getting streaming file upload with limited heap to work using azure-storage-blob:12.10.0-beta.1 (also tested on 12.9.0).
Following approaches were attempted:

Copy-paste from the documentation using BlockBlobClient

BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient("file").getBlockBlobClient();

File file = new File("file");

try (InputStream dataStream = new FileInputStream(file)) {
  blockBlobClient.upload(dataStream, file.length(), true /* overwrite file */);
}

Result: java.io.IOException: mark/reset not supported - SDK tries to use mark/reset even though file input stream reports this feature as not supported.

Adding BufferedInputStream to mitigate mark/reset issue (per advice):

BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient("file").getBlockBlobClient();

File file = new File("file");

try (InputStream dataStream = new BufferedInputStream(new FileInputStream(file))) {
  blockBlobClient.upload(dataStream, file.length(), true /* overwrite file */);
}

Result: java.lang.OutOfMemoryError: Java heap space. I assume that SDK attempted to load all 1.17GB of file content into memory.

Replacing BlockBlobClient with BlobClient and removing heap size limitation (-Xmx512m):

BlobClient blobClient = blobContainerClient.getBlobClient("file");

File file = new File("file");

try (InputStream dataStream = new FileInputStream(file)) {
  blobClient.upload(dataStream, file.length(), true /* overwrite file */);
}

Result: 1.5GB of heap memory used, all file content is loaded into memory + some buffering on the side of Reactor
Heap usage from VisualVM

Switch to streaming via BlobOutputStream:

long blockSize = DataSize.ofMegabytes(4L).toBytes();

BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient("file").getBlockBlobClient();

// create / erase blob
blockBlobClient.commitBlockList(List.of(), true);

BlockBlobOutputStreamOptions options = (new BlockBlobOutputStreamOptions()).setParallelTransferOptions(
  (new ParallelTransferOptions()).setBlockSizeLong(blockSize).setMaxConcurrency(1).setMaxSingleUploadSizeLong(blockSize));

try (InputStream is = new FileInputStream("file")) {
  try (OutputStream os = blockBlobClient.getBlobOutputStream(options)) {
    IOUtils.copy(is, os); // uses 8KB buffer
  }
}

Result: file is corrupted during upload. Azure web portal shows 1.09GB instead of expected 1.17GB. Manual download of the file from Azure web portal confirms that file content was corrupted during upload. Memory footprint decreased significantly, but file corruption is a showstopper.
Problem: cannot come up with a working upload / download solution with small memory footprint
Any help would be greatly appreciated!
Comment: "file is corrupted during upload. Azure web portal shows 1.09GB instead of expected 1.17GB", could it be that Azure web portal shows [Gibibyte / GiB](https://en.wikipedia.org/wiki/Byte#Multiple-byte_units) (i.e. 1024³ bytes) instead of Gigabyte (i.e. 1000³ bytes)? Because 1.17 GB ≈ 1.09 GiB. (Though if you confirmed locally that the uploaded file is corrupt, then that might not be the answer)
Comment: @Marcono1234 yes, I verified that byte size for original and uploaded files are the same. So by all means you are right. However, the file itself is corrupted (e.g uploaded image has 60% of grey pixels, uploaded video is not playable).

I used this fragment to verify that byte size is the same (as well as checking it manually via download & compare):
`log.info("EXPECTED SIZE: {}; ACTUAL SIZE: {}", image.length(), blockBlobClient.getProperties().getBlobSize());`

Created this query in GitHub for sanity check: https://github.com/Azure/azure-sdk-for-java/issues/18295
Answer: Pls try the code below to upload/download big files, I have tested on my side using a .zip file with size about 1.1 GB
For uploading files:
public static void uploadFilesByChunk() {
                String connString = "<conn str>";
                String containerName = "<container name>";
                String blobName = "UploadOne.zip";
                String filePath = "D:/temp/" + blobName;

                BlobServiceClient client = new BlobServiceClientBuilder().connectionString(connString).buildClient();
                BlobClient blobClient = client.getBlobContainerClient(containerName).getBlobClient(blobName);
                long blockSize = 2 * 1024 * 1024; //2MB
                ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions()
                                .setBlockSizeLong(blockSize).setMaxConcurrency(2)
                                .setProgressReceiver(new ProgressReceiver() {
                                        @Override
                                        public void reportProgress(long bytesTransferred) {
                                                System.out.println("uploaded:" + bytesTransferred);
                                        }
                                });

                BlobHttpHeaders headers = new BlobHttpHeaders().setContentLanguage("en-US").setContentType("binary");

                blobClient.uploadFromFile(filePath, parallelTransferOptions, headers, null, AccessTier.HOT,
                                new BlobRequestConditions(), Duration.ofMinutes(30));
        }

Memory footprint:

For downloading files:
public static void downLoadFilesByChunk() {
                String connString = "<conn str>";
                String containerName = "<container name>";
                String blobName = "UploadOne.zip";

                String filePath = "D:/temp/" + "DownloadOne.zip";

                BlobServiceClient client = new BlobServiceClientBuilder().connectionString(connString).buildClient();
                BlobClient blobClient = client.getBlobContainerClient(containerName).getBlobClient(blobName);
                long blockSize = 2 * 1024 * 1024;
                com.azure.storage.common.ParallelTransferOptions parallelTransferOptions = new com.azure.storage.common.ParallelTransferOptions()
                                .setBlockSizeLong(blockSize).setMaxConcurrency(2)
                                .setProgressReceiver(new com.azure.storage.common.ProgressReceiver() {
                                        @Override
                                        public void reportProgress(long bytesTransferred) {
                                                System.out.println("dowloaded:" + bytesTransferred);
                                        }
                                });

                BlobDownloadToFileOptions options = new BlobDownloadToFileOptions(filePath)
                                .setParallelTransferOptions(parallelTransferOptions);
                blobClient.downloadToFileWithResponse(options, Duration.ofMinutes(30), null);
        }

Memory footprint:

Result:
Comment: Thank you for the quick response! I tried your approach and it worked great. Here's [screenshot](https://user-images.githubusercontent.com/76443987/102862430-c393cc80-4439-11eb-8eb2-62528ef47951.png) of heap usage during upload / download.  I believe, that file usage allows Azure SDK to skip quite a few copying / buffering steps. File is not corrupted. The only little inconvenience is that we receive our data from the network in the form of `InputStream` and would have to write it to a temporary file in order to leverage `uploadFromFile` API
Comment: by the way, I noticed that only 6 files are uploaded / downloaded in parallel. If I work with more than 6 files in parallel, the rest is waiting for the first 6 to complete. Do you happen to know if there is a setting to control this?
Comment: My assumption that there is some hidden limitation of up to 6 files uploaded / downloaded concurrently was preposterous as I discovered that it was due to Google Chrome settings - I was using Swagger to call upload / download endpoints (Chrome has a limit of 6 connections per host name, and a max of 10 connections)
Comment: @white-sagittarius, Thanks for this tips, I am not so familiar about it before
Comment: @StanleyGong What does `setMaxConcurrency` do here ?


Reverse dns returns a different host each time

Question: So, randomly I happened to ping abc.com and found this fascinating:
<code>$ ping abc.com
PING abc.com (18.104.22.168) 56(84) bytes of data.
64 bytes from m.abc.com (184.108.40.206): icmp_req=1 ttl=237 time=90.3 ms
64 bytes from tdl.disneyuniversity.com (22.214.171.124): icmp_req=2 ttl=237 time=89.8 ms
64 bytes from preschooltime.go.com (22.214.171.124): icmp_req=3 ttl=237 time=95.1 ms
64 bytes from futbolpicante.espnfc.com (22.214.171.124): icmp_req=4 ttl=237 time=98.6 ms
64 bytes from www.worldofcars.go.com (220.127.116.11): icmp_req=5 ttl=237 time=86.9 ms
64 bytes from www.verizon.bravesweepstakes.com (220.127.116.11): icmp_req=6 ttl=237 time=87.9 ms
64 bytes from www.directv.bravesweepstakes.com (220.127.116.11): icmp_req=7 ttl=237 time=87.9 ms
64 bytes from manup.abc.com (188.8.131.52): icmp_req=8 ttl=237 time=88.8 ms
64 bytes from m.onemoredisneyday.com (188.8.131.52): icmp_req=9 ttl=237 time=87.5 ms
64 bytes from finance.abc30.com (126.96.36.199): icmp_req=10 ttl=237 time=87.9 ms
64 bytes from finance.abc13.com (18.104.22.168): icmp_req=11 ttl=237 time=88.0 ms
...
</code>
In a way it seems similar to load balancing used in forward DNS, except I don't understand how this would be useful.
Is there any practical reason for this or just a consequence of these sites all being hosted behind the same IP address?
Comment: Isn't that forward DNS?  Reverse would be if you searched by IP.  It doesn't happen when I ping them now.  I get the same result repeatedly.  Perhaps this has something to do with the way their DNS wildcard works?
Answer: nslookup 18.104.22.168 shows up witn bunch of non-authoritative answers for different domain names. But my ping doesn't change dynamically as yours.
Answer: It really looks someone just being funny, or server misconfigured or something like that. There are actually that many reverse records.
btw. i suspect this IP might be used to distribute spam and these hostnames are there to confuse filters. (but that is a wild guess)
see:
<code>$ dig 250.132.181.199.in-addr.arpa -t PTR
;; Truncated, retrying in TCP mode.

; <<>> DiG 9.7.3 <<>> 250.132.181.199.in-addr.arpa -t PTR
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33536
;; flags: qr rd ra; QUERY: 1, ANSWER: 195, AUTHORITY: 4, ADDITIONAL: 2

;; QUESTION SECTION:
;250.132.181.199.in-addr.arpa.  IN      PTR

;; ANSWER SECTION:
250.132.181.199.in-addr.arpa. 180 IN    PTR     m.nightofjoy.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     m.disneyworld.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     m.mustdodisney.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     m.disneytheforce.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     m.onemoredisneyday.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     s.espnradio.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     fb.steelgetsreal.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     my.abcnews.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     qa.watchdisneyxd.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     qa.watchabcfamily.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     qa.watchdisneyjunior.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     qa.watchdisneychannel.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     uk.disneycareers.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     abc.abcnews.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     cdn.musiclounge.abc.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     fdj.espnfc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     fdj.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     gma.abcnews.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     hdf.espnfc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     hub.disneyuniversity.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     itm.abc.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     lnb.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     sam.abcnews.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     tdl.disneyuniversity.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     ugc.lionking.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     ugc.marypoppins.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     ugv.abcnews.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     vpd.disneycruise.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     w88.m.fwfest.waltdisneyworld.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.abc.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.att.bravesweepstakes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.cox.bravesweepstakes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.ttdl.disneyuniversity.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.enter.bravesweepstakes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.espnfc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.abcnews.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.charter.bravesweepstakes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.directv.bravesweepstakes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.verizon.bravesweepstakes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.mediacom.bravesweepstakes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.adventure.bravesweepstakes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.disneyhome.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.worldofcars.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.disneycasting.net.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.donovandecker.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.disneyroommate.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.disneycampusrep.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.disneycollateral.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.disneyinternsinfo.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.missiontimekeeper.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.disneycastingscout.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.disneyimaginations.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.disneyprogramsblog.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.wdwcollegeprogramecard.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.wdwcollegeprogramecard2.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     www.disneyinternationalepresentation.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     1ext.doit.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     25th.disneystore.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     beta.xgames.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     blog.disneyxd.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     bmoc.abc7chicago.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     doit.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     live.dadt.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     live.espnfc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     play.toontown.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     prod.waltdisneystudios.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     ugv2.abc.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     blogs.abcnews.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     cards.babyzone.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     email.doit.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     email.disneymovieclub.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     espn3.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     games.soapnet.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     manup.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     panam.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     castle.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     comedy.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     espnrf.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     hdfmas.espnfc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     health.abcnews.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     mobile.abcfamily.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     oscars.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     photos.kaboose.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     photos.babyzone.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     search.abc.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     search.video.movies.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     temail.disneymovieclub.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     tienda.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     topics.abcnews.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     velti2.disneylandsummer.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     workit.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     999test.abcnews.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     account.toontown.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     casting.disneyparks.jobs.
250.132.181.199.in-addr.arpa. 180 IN    PTR     catalog.disneyuniversity.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     clarity.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     culture.disneyuniversity.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     finance.6abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     finance.abc7.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     finance.abc11.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     finance.abc13.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     finance.abc30.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     finance.7online.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     finance.abc7news.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     finance.abc7chicago.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     hotseat.abc.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     missing.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     playdom.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     preview.mydisneyphotopass.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     revenge.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     scandal.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     scrumtv.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     search2.spanish.disneylandsummer.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     theview.abc.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     topics2.abcnews.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     uplayit.abc7chicago.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     developu.disneyuniversity.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneyhd.tv.
250.132.181.199.in-addr.arpa. 180 IN    PTR     polo2011.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     theriver.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     whereami.doit.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     abccomedy.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     helpoffer.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     rugby2011.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     shelterme.6abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     stagepass.abc.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     tenis2011.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     themiddle.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     trongames.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     cougartown.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     devicedata.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneytime.disneyparks.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneyvisa.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     experience.disneydestinations.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     happyrides.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     portfolios.abcnews.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     storefront.abcnews.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     bodyofproof.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     copavirtual.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     desafioeuro.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneyparks.jobs.
250.132.181.199.in-addr.arpa. 180 IN    PTR     familytools.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     glass-house.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     hipcricket2.spanish.disneylandsummer.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     klubpenguin.de.
250.132.181.199.in-addr.arpa. 180 IN    PTR     klubpinguin.de.
250.132.181.199.in-addr.arpa. 180 IN    PTR     musiclounge.abc.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     preolimpico.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     radiodisney.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     suburgatory.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     weatherblog.abc13.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     abcdotcomedy.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     euroquiniela.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     happyendings.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     modernfamily.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     sendtofriend.abcnews.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     desafiofutmex.espnfc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     dimgpressroom.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneypackage.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneystudios.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     futbolpicante.espnfc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     golesdeeuropa.espnfc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     onceuponatime.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     preschooltime.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     rincontecnico.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     yourcommunity.6abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     desafiopremier.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     phineasandferb.disneymags.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneyparksblog.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneyvisaperks.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     elmejorejemplar.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     lastmanstanding.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     monstroussummer.disneyparks.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     the-glass-house.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneyconnection.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     avalanchesoftware.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     celebritywifeswap.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneyhumanrights.org.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneysecondscreen.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     watchdisneychannel.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     hablemosdefutbolmas.espndeportes.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     mickeystrickortreat.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneylearningstudio.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     shanghaidisneyresort.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneystarbuckssurvey.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneyworldsvacations.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     wheelchairrentaldisney.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     hyperionbooksforchildren.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     disneyparksstarbuckssurvey.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     m.abc.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     m.test.doit.go.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     m.fwfest.waltdisneyworld.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     m.abcfamily.com.
250.132.181.199.in-addr.arpa. 180 IN    PTR     m.bostonmed.abcnews.go.com.

;; AUTHORITY SECTION:
132.181.199.in-addr.arpa. 180   IN      NS      sens01.dig.com.
132.181.199.in-addr.arpa. 180   IN      NS      orns01.dig.com.
132.181.199.in-addr.arpa. 180   IN      NS      sens02.dig.com.
132.181.199.in-addr.arpa. 180   IN      NS      orns02.dig.com.

;; ADDITIONAL SECTION:
orns01.dig.com.         257     IN      A       184.108.40.206
sens02.dig.com.         242     IN      A       184.108.40.206

;; Query time: 7 msec
;; SERVER: 192.168.0.1#53(192.168.0.1)
;; WHEN: Fri Apr 19 23:24:14 2013
;; MSG SIZE  rcvd: 5471
</code>
Answer: This is used for "forward-confirmed reverse DNS." From Wikipedia

A FCrDNS verification can create a weak form of authentication that
  there is a valid relationship between the owner of a domain name and
  the owner of the network that has been given an IP address. While
  weak, this authentication is strong enough that it can be used for
  whitelisting purposes because spammers and phishers can not usually
  by-pass this verification when they use zombie computers for mail
  spoofing. That is, the reverse DNS might verify, but it will usually
  be part of an other domain than the claimed domain name.

However, I know of no application that actually looks at more than 1 PTR RR. It could be that Disney has some services that look at more than 1 PTR RR.


Disable cache on back navigation ASP.NET Core for js script tags

Question: I have a script that is runtime generated, it contains translations for some labels. Its purpose is to expose translations to AngularJS.
app.MapWhen(current => current.Request.Path.StartsWithSegments(path),
        mapped => mapped.UseMiddleware<ClientResourcesMiddleware>(options)
    );

The script is loaded in the layout:

In the middleware:
public async Task Invoke(HttpContext context, IRequestCultureFeature requestCultureFeature)
{
    string script = _cache.GetOrAddValue(
       $"ClientResources|{_options.ResourceType.FullName}|{requestCulture.Name}",
       () => CreateScript(requestCulture));

    context.Response.Headers["Cache-Control"] = "no-cache";

    await context.Response.WriteAsync(script, Encoding.UTF8);
}

Another option is to use DateTime.Now.Ticks, this will make the file to reload everytime.


Get data from local storage (SD card) of onvif camera

Question: I'm developing a WPF application for Onvif Camera. By following the Onvif SDK I have successfully to connect the camera to get video stream and control ptz...
Now I want to work with the SD card, the local storage on camera, but I'm have no information about that.
Anybody can give me idea how to use Onvif library to connect to the SD card and get recorded data from that.
Thanks for your help.
Answer: From here: http://www.onvif.org/onvif/ver10/recording.wsdl
You need to call: GetRecordingJobs
Find the recording job.
From here: http://www.onvif.org/ver10/replay.wsdl
You need to call: GetReplayUri
Comment: @ChirsWard: Yes. I've already read them from Onvif spec. So Do I have to implement SOAP web service for my app?. Whether it is available in Onvif library? If it is then I just add referrence and use it like a session dll that is Getprofile, GetProfileConfiguration...
Comment: I'm not sure what is available in the Onvif SDK as I have never used it. You will need to implement the recording and replay SOAP web services directly or indirectly in order to make the appropriate calls.
Comment: This will not download the recording. This will replay it in realtime, which means that if one is trying to get 1 hour of a recording it will take 1 hour to stream it and save the stream somewhere. The needed approach would be to download the footage, which should be possible via `http://www.onvif.org/ver10/recording/wsdl/ExportRecordedData`.
Answer: I am not sure this fits perfectly for your need, but I think it may help you. This code can be used to connect to an Onvif IP camera and to record the stream into MPEG4 format. By using this code, the recording files will be stored automatically on the computer.
namespace Basic_CameraViewer
{
    public partial class MainWindow : Window
    {
        private VideoViewerWPF _videoViewerWpf;

        private BitmapSourceProvider _provider;

        private IIPCamera _ipCamera;

        private WebCamera _webCamera;

        private MediaConnector _connector;

        private MPEG4Recorder _recorder;

        private IVideoSender _videoSender;

        public MainWindow()
        {
            InitializeComponent();

            _connector = new MediaConnector();

            _provider = new BitmapSourceProvider();

            SetVideoViewer();
        }

        private void SetVideoViewer()
        {
            _videoViewerWpf = new VideoViewerWPF
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                Background = Brushes.Black
            };
            CameraBox.Children.Add(_videoViewerWpf);

            _videoViewerWpf.SetImageProvider(_provider);
        }

        private void ConnectIPCamera_Click(object sender, RoutedEventArgs e)
        {
            var host = HostTextBox.Text;
            var user = UserTextBox.Text;
            var pass = Password.Password;

            _ipCamera = IPCameraFactory.GetCamera(host, user, pass);
            if (_ipCamera == null) return;
            _connector.Connect(_ipCamera.VideoChannel, _provider);

            _videoSender = _ipCamera.VideoChannel;
            _ipCamera.Start();
            _videoViewerWpf.Start();
        }

        private void DisconnectIPCamera_Click(object sender, RoutedEventArgs e)
        {
            _videoViewerWpf.Stop();

            _ipCamera.Disconnect();
            _ipCamera.Dispose();

            _connector.Disconnect(_ipCamera.VideoChannel, _provider);
        }

        private void StartCapture_Click(object sender, RoutedEventArgs e)
        {

            if (_videoSender == null) return;
            var date = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" +
                        DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second;

            var currentpath = AppDomain.CurrentDomain.BaseDirectory + date + ".mpeg4";

            _recorder = new MPEG4Recorder(currentpath);
            _recorder.MultiplexFinished += _recorder_MultiplexFinished;

            _connector.Connect(_videoSender, _recorder.VideoRecorder);
        }

        void _recorder_MultiplexFinished(object sender, Ozeki.VoIP.VoIPEventArgs<bool> e)
        {
            _recorder.MultiplexFinished -= _recorder_MultiplexFinished;
            _recorder.Dispose();
        }

        private void StopCapture_Click(object sender, RoutedEventArgs e)
        {
            if (_videoSender == null) return;
            _connector.Disconnect(_videoSender, _recorder.VideoRecorder);
            _recorder.Multiplex();
        }
    }
}

Here you can find a video explanation on how to implement video recording.
Answer: You should be able to copy video from the SD Card to a network storage using http://www.onvif.org/onvif/ver10/recording.wsdl and the ExportRecordedData() method.


Owl Carousel width issues when first load

Question: i'm using owl carousel. this is my script:
<code>$("#owl-demo").owlCarousel({
  items : 3
});
</code>
i want the container show 3 images. But, here is the picture when first load

but when i resize the browser, although just a little bit, size of images change to actual size and setting that i want

So, the problem is images preview when i load browser for the first time.
Why this is happening? i think the issues about size of my browser
Comment: I had the same issue time ago, and was because I changed CSS in the items, especially positions and display. Try changing to defaults.
Comment: i didn't change anything. i got from this link http://owlgraphic.com/owlcarousel/demos/itemsCustom.html
Comment: [FIXED] my items in div which it didn't active (im using tab panel). http://stackoverflow.com/questions/27006239/owl-carousel-image-not-right-size-at-first?rq=1
Answer: I fixed this problem when I measured the width of the owl-stage container in a working state. And then set the values in the styles like:
<code>#photo-gallery .owl-stage {
  min-width: 10317px;
}
</code>
My JS:
<code>$(document).ready(function(){
      $('.owl-carousel').owlCarousel({
        center: true,
        loop:true,
        margin:20,
        autoWidth: true,
        responsive:{
            0:{
                items: 1,
                autoWidth: false
            },
            908:{
                items: 1,
                autoWidth: true
            },
            1236:{
                items: 3
            }
        }
      });
    });
</code>


Deferred Annuities

Question: A debt of 8000 is to be amortized  by equal monthly payments starting at the end of one year and ending at the end of 2 years if money is worth 9% every month, find each payment.
So I was thinking this is a deferred annuity but instead of find the future value we are finding the annuity.
Plugging in my equation
n+d = 2 years which is 24 payments
Future value = 8000
 AM i doing it right?
$Annuity$ = $\frac{8000}{\frac{1+\left(\frac{0.09}{12}\right)^{24}}{\frac{0.09}{12}}-{\frac{1+\left(\frac{0.09}{12}\right)^{12}}{\frac{0.09}{12}}}}$
Comment: You want $\left(1+{.09\over12}\right)^{24}$ for example.  You've got the left parentheses in the wrong place.
Comment: Are you still interested in an answer?
Answer: $i=0.09/12$, $v=\frac{1}{1 +i} $, $L=8000$
$$
A=\frac{L}{v^{12}\times\frac{1-v^{12}}{i}  }
$$

Deferred Annuities


Function as a member "variable" in class

Question: I was thinking about how to improve my simple calculator using some advanced techniques. I came to question, is there some way to create a class with function you could define per instance:
class Function
{
public:
    Function(function);
    ~Function();

private:
    function;
};

So for example you create an instance
Function divide(int x / int y); //For example

I hope you understand the question.
EDIT:
So I studied the void (*foo)(int) method. It could be used. But the initial idea was to create a generic function that holds the function itself in it. Not just a pointer to a function defined outside. So you could do something like this:
int main() {

//Define the functions
Function divide( X / Y ); //Divide
Function sum( X + Y ); //Sum

//Ask the user what function to call and ask him to enter variables x and y

//User chooses divide and enters x, y
cout << divide.calculate(x, y) << endl;

return 0;
}

Answer:
@Chris Drew pointed out:
Sure, your Function can store a std::function<int(int, int)> and then you can construct Function with a lambda: e.g: Function divide([](int x,int y){return x / y;}); But then I'm not sure what your Function offers that you can't just do with std::function.
It answers my question, unfortunately my question was put on hold so I cannot mark the question resolved.
Comment: possible duplicate of [Should I use std::function or a function pointer in C++?](http://stackoverflow.com/questions/25848690/should-i-use-stdfunction-or-a-function-pointer-in-c)
Comment: `std::function` may help also for binery function.
Comment: You mean something like a function pointer: `int (*function)(int,int))`?
Comment: What's your intention? Could you provide more examples?
Comment: @πάνταῥεῖ yes something like this
Comment: Sure, your `Function` can store a `std::function` and then you can construct `Function` with a lambda: e.g: `Function divide([](int x,int y){return x / y;});` But then I'm not sure what your `Function` offers that you can't just do with `std::function`.
Comment: @ChrisDrew Well that explains how to do it. Thanks! Could you write an answer so I can mark it as resolved?
Comment: @BBPP20Development I'd love to but your question is "on hold" because it was deemed to be unclear what you were asking. Perhaps now that you have added an edit explaining your intentions it will be reopened.
Comment: @ChrisDrew I already edited it several times. Shame. I will mention the answer in my next edit.
Answer: Sure, your Function can store a std::function<int(int, int)> and then you can construct Function with a lambda:
#include <functional>
#include <iostream>

class Function {
  std::function<int(int, int)> function;
public:
  Function(std::function<int(int, int)> f) : function(std::move(f)){};
  int calculate(int x, int y){ return function(x, y); }
};

int main() {
  Function divide([](int x, int y){ return x / y; });
  std::cout << divide.calculate(4, 2) << "\n";
}

Live demo.
But then, as it stands, I'm not sure what Function offers that you can't do with a std::function directly:
#include <functional>
#include <iostream>

using Function = std::function<int(int, int)>;

int main() {
  Function divide([](int x, int y){ return x / y; });
  std::cout << divide(4, 2) << "\n";
}

Live demo.
Comment: Using function<> as member has the advantage of polymorphic behavior by switching the function of the same interface but with different implementation (could be at construction time, or at runtime).  For example draw() from a shape object.  the shape could be triangle or circle.  This happens in my design in certain projects (you don't want to start a new derived class, just want to use a different method)


Heartbleed: What if OpenSSL has been patched but SSL certs not yet rekeyed?

Question: Does anyone know what entry point a hacker could have if a sever's OpenSSL has been patched but a site's SSL certs have not yet been rekeyed?
Thanks!
Comment: This question is not a duplicate as it addresses a different aspect of the Heartbleed security: Could an attacker gain access to your server after you patched OpenSSL BUT have not yet re-keyed your SSL certs.
Comment: Or is an attacker limited to man-in-the-middle attack (i.e. by capturing user creds when they login on the sebsite), but not able to access the server itself?
Answer: If the remote attacker was able to retrieve you private key before you patched, then they can decrypt all any previous communication that has been performed if you didn't use perfect forward secrecy and perform man-in-the middle attacks.  Intercepting and possibly modifying existing communications.  They could have also captured credentials needed to remotely access and modify your system, or your user's accounts.
If you are lucky and nobody used this bug to collect your keys or anything else while you were vulnerable, you would theoretically be fine.
Comment: @Honey Yes, it does.  That's why this one's so bad.
Comment: Anything that could potentially be in the process memory linking to OpenSSL could have been leaked.   This may include your admin credentials, it may include many other things.
Comment: @Honey Heartbleed doesn't allow direct access to control the system, it "bleeds" out information contained within the affected system.  The attacker doesn't gain access to your system through the bug itself.  Rather they are able to read information that could allow them to gain access to your system, or other sensitive information. Anything that's in your server's RAM.  That could be credentials, keys, bank account numbers, anything.  So, if keys are one thing that gets out then your encryption is toast (for example).
Comment: Thanks for your answer Zoredache. Could you please explain what you mean by "They could have also captured credentials needed to remotely access and modify your system". You mean they could access my server the way one has access using SSH? Or do you mean they could login as admin on a website and have access to only the website files?
Comment: But what if the server's OpenSSL has been patched, but ONLY the SSL cert not rekeyed? Could they still gain access to the server? That's why this question is different to the one quoted as possible duplicate, in that there is only one vulnerability (the old SSL keys, not OpenSSL).
Comment: **I think you missed the second paragraph of my answer.**  The heartbleed bug has existed for over two years.  If someone knew about the vulnerability two years ago they could have collected anything and everything in memory.  If they were able to get admin credentials or the key for your system before you patched your system, then you are screwed.  The secrets have already been lost.  Sure nobody can get them now that you are patched, but that may be too late.  Patching is only good enough if no secrets were lost before patching.  But there are no logs, so how can you know that you are safe?
Comment: Hi @Zoredache, even if a system is compromised, the attacker can only gain access to the HTTPS website but not the physical server itself right? Sorry if this is a noob question... I'm still trying to understand the implications of Heartbleed. For one, I'm not sure when someone says the attacker can access your "system", does it mean the attacker can access the server the way someone uses SSH/FTP or just the website itself (i.e. they did not gain access to the physical files on the server). Thanks for your patience!
Comment: Thank you @squillman. "Anything that's in your server's RAM" doesn't include the server's SSH or FTP login creds used by the system admin right? Or does it (shock horror)?


How can I join selected columns of multiple csv files into one data frame? Jupyter

Question: I am slightly confused because the following seems to work:
raw_data_df = pd.DataFrame()

temp = pd.read_csv('/Users/bob/desktop/Research_data/tobii/42r-export.csv', sep = ',', encoding = 'latin-1')
raw_data_df['1'] = temp['Gaze point X']
raw_data_df['2'] = temp['Gaze point Y']

However the following does not work:
for i in files:
  temp = pd.read_csv(path + i , sep = ',', encoding = 'latin-1')
  print(temp['Gaze point X'])
  raw_data_df[i+"x"] = temp['Gaze point X']
  raw_data_df[i+"y"] = temp['Gaze point Y']

where files is
path = "/Users/bob/desktop/Research_data/tobii/"
files = [f for f in listdir(path) if isfile(join(path,f))]

Instead of returning a pandas data frame where column names are i+"x" or  i+"y" i get a list of lists.
here is a sample of what is outputted with raw_data_df
132660     857
132661     846
Name: Gaze point X, Length: 132662, dtype: int64
0      1206
1      1204
2      1205
3      1205

How can I join selected columns of multiple csv files into one data frame?
Comment: What becomes a list of lists?
Comment: I return the data frame and it is in some sort of list of all the columns
Answer: I don't think there's any need to initialise an empty dataframe. You can iterate over your files, load only the columns you need (using usecols), and then concatenate all dataframes at the end.
Furthermore, when concatenating path artifacts, use os.path.join.
import os

cols = ['Gaze point X', 'Gaze point Y']

df_list = []
for f in files:
    temp = pd.read_csv(
         os.path.join(path, f), sep=',', encoding='latin-1', usecols=cols
    )
    temp.columns = [f + i for i in ['x', 'y']]
    df_list.append(temp)

Now, just concatenate the dataframes with pd.concat.
df = pd.concat(df_list, axis=1)

Answer: sorry there was a ds.store file inside the files I was searching that was throughing everything off. I just deleted it and it is working.
Answer: Building on @COLDSPEED's solution, you could use a list comprehension:
def rename_cols(df, f):
    df.columns = [f + i for i in ['x', 'y']]
    return df

df = pd.concat([rename_cols(pd.read_csv(os.path.join(path, f),
                sep=',', encoding='latin-1', usecols=cols), f) for f in files],
                ignore_index=True)


Multiple regression with class probabilities

Question: I'm given a list of class probabilities $(p_1, p_2, \ldots, p_c)$ (which sum to 1) for each sample. Now, I'd like to replicate this with a model (supervised learning).
How can I approach this?
I could use a separate regression model for each of $p_1, \dots, p_{c-1}$. But the probabilities might exceed 1 and also the models are independent, which both loses information.
I could use a classification method where I try to predict probabilities for classes. But then the input for each sample is a single class (the largest class probability). Here I'm losing the details of the given probabilities.
The goal is actually to closely match the given class probabilities.
Anything more direct and appropriate?
Comment: can you be more specific? What are the features that according to them your samples are classified?
Comment: The features are real numbers which I will create by feature engineering.
Answer: ok there is a very simple way of doing this, although not neccesary the best way of doing it. It all depends on the problem you trying to solve. If we're allowed to assume that the features are uncorrelated or independent from each other. The posterior of being in a class $c$ is equal to:
\begin{equation}
p(c | F_1, F_2, ..., F_n) = p(c) \times \frac{\prod_{i=1}^{n} p(F_i|c)}
{\sum_{c'} \prod_{k=1}^n p(F_k| c')}
\end{equation}
This model is what it's referred to as Naive Bayes method, where features are assumed to be independent from each other. If your information gives no preference toward any classes, then just set the prior probability $p(c)$ to a simple uniform probability.
To learn this model, there are many packages, such as http://www-users.cs.york.ac.uk/~jc/teaching/arin/R_practical/.


Conteúdo oculto é ruim para acessibilidade?

Question: Tenho uma tabela com três colunas, uma para "Espécie", uma para "Quantidade" e uma para opções. O campo quantidade pode ser alterado quando for clicado no botão alterar, sendo o botão alterar ocultado para aparecer o botão salvar.

    ....

       Espécie 1

          10
          <input type="text" id="txtQtde_1" value"10" class="form-control hide">

         <button type="button" value="1" class="btn">Alterar</button>
         <button type="button" id="btnSalvar_1" value="1" class="btn hide">Salvar</button>

Esse tipo de prática de ocultar/mostrar elementos com CSS pode ser ruim no que diz a respeito a acessibilidade por exemplo pra usuários cegos?
Answer: Elementos ocultos (style="display:none;" e <input type="hidden">) não são lidos pelos leitores de tela como NVDA e JAWS, os leitores de tela ignoram esses tipos de elementos.


What level of rigor is needed to determine relative importance?

Question: I'm performing dominance analysis (using domir) not to predict/forecast but only to report on the relative importance of a set of independent variables. Do I still need to analyze with split datasets (train and test) and make sure that relative importance is stable over multiple random splits?
Answer: Dominance analysis is, in my view, an extension of the underlying model that adds information about predictive utility.  If the underlying model is stable as determined by whichever means the analyst finds defensible, then I don't see a good reason to attempt to assess the stability of the dominance analysis based on that model.
I would then recommend assessing stability on, for example, the lm()/linear regression model results directly.  If they appear to be sufficiently stable and seems reasonable to proceed with, then a dominance analysis using that linear model is justified.
Again, a dominance analysis provides more information about predictive utility of predictors related to a pre-selected model.  I see applying training-testing/cross-validation methods as a model selection step and better applied to a model and not a dominance analysis on which it is based.


What's the point of interval inversion?

Question: The rules for inverting intervals are well documented (for example on Wikipedia), but I'm having a hard time figuring out why this operation is of interest:
How does interval inversion help us in understanding or creating music?
Answer: In addition to Dom's great answer, there's a very famous compositional technique known as invertible counterpoint. In short, invertible counterpoint switches the register of two (or more) independent voices such that the voice that was on top is now on the bottom and the voice that was on bottom is now on top.
Now let's remember that, from a standpoint of strict counterpoint, a perfect fifth is consonant and a perfect fourth is dissonant. As such we need to have an awareness of how intervals invert so that if we write a counterpoint that will eventually be inverted, we make sure to treat particular intervals carefully so that their inverted versions also follow all rules of consonance and dissonance.
Comment: Good point. Not only that, but common-practice counterpoint allows consecutive [perfect] fourths but prohibits consecutive [perfect] fifths.
Answer: The simple explanation is that inverse intervals are another way to view the distance starting at a different point You can go up to a note or down to a note which gives different interval sizes, but they are related. Where you see this concept most is looking at vertical harmony especially chords.
To keep it simple, we'll just look at the notes C and G. When you are talking about intervals the default is to assume upward and C up to G would be a perfect 5th. However when looking at C down to G, the interval would only be a perfect 4th. The distance is different because we are taking a different path. This is also why G up to C would be a perfect 4th and G down to C would be a perfect 5th.
Again if you looked at a harmonic structure containing C G and C like below, you would have both intervals and on the staff you could see the difference in staff space between the inverse intervals.
X:1
L:1/1
M:
K:C
V:1 clef=treble
[C G]  | [G c]  | [C G c]
%

Answer: @Dom and @Richard gave great answers. In fact you can sort of combine them and look into imitative counterpoint and fugue where the "entries" of imitative counterpoint can occur at the fifth above and the fourth below. The musical importance of the voices entering at those points of inversion above and below is it keeps clear what key the music is in by highlighting the tonic/dominant relationship.
I can add another musical aspect of inversion. Some inversions procedures can sort of "flip" musical qualities.
A C major chord is a major third (M3) and a minor third (m3) above a root C M3↑ E m3↑ G.

We can invert that. But first we need a point from which to invert - this is an important aspect of inverting, inversion can happen from different points.
Inverting the C major chord from the C root we will invert/reverse the added intervals - add a M3 below and then a m3 below the root C M3↓ Ab m3↓ F

A major chord inverts to a minor chord!

If we start on G the inversion give us a Cm chord...

A similar thing happens if you invert the whole and half step direction of a major scale starting on G. It will produce the minor scale...

Some chord are symmetrical when inverted. Ex. if you invert a diminished seventh chord at the root, you get the same chord, enharmonically respelled...

Other chords change quality when inverted, like a dominant-seventh chord from a major key inverted at the tonic becomes a half-diminished seventh chord from the parallel minor key...

...help us in understanding or creating music?

I'm not sure if awareness of these inversions helps much. Apparently they figure large in Riemannian theory. Personally I don't buy into the idea that the minor scale is derived from a major scale inverted at the fifth. I don't think that fits into any acoustical phenomena nor what I understand of ancient music theory & history. But these inversion can be observed - if not necessarily heard - and they come up in music theory discussions from time to time.
Answer: Ascending melodies sound different to descending ones. The inversions of chords (achieved through changing the intervals) sound different. It's not surprising that the inversion of intervals gets attention: music is all about sound.

What's the point of interval inversion?


How to get different image styles in the same view?

Question: I'am a newbie, and I want to make a simple view with an image field (in article nodes), that looks like this layout :

And for this, I don't want to use CSS rules to resize the view rows images, for two reasons :

I am using bootstrap grid, and I don't want to deal with relative heights, since images in articles have various sizes, so I prefer that this view do the image resizing for me.
I want to learn this view trick without relaying on CSS tricks.

I tried different tricks, like:

importing the image filed twice, making each one in different image style, rewriting them (displaying them conditionaly) based on "view result counter", but putting a condion like {% if counter == 1 %} or like {% if counter == '1' %} don't work (i think it still an open issue).
I tried also making some theme preprocess or theme hook altering to force a different image style for the first iteration.

I'm so frustrated because of such an easy task that looks so hard to me.
Any help?
Answer: The Twig Tweak can help you.
Firstly, you should write a specific condition for check if the image is first.
<code>{% if loop.index == 1 %}
</code>
Inside condition you need to fetch an uri to the image and apply the Image Style Filter.


jQuery .get for non https, in a userscript

Question: I made a script on my website that accesses a table on a different website. However, the other website is HTTP so chrome is telling me "This request has been blocked; the content must be served over HTTPS."
<code>$.get('http://www.kanjidamage.com/kanji', null, function searchKD () { /*function*/ });
</code>
So what I'm asking is: how can I access elements on a different website even if it's not HTTPS.
Answer: You have this tagged as tampermonkey.  If that is the case, use it.
Tampermonkey allows one to bypass "mixed active content" restrictions by using GM_xmlhttpRequestDoc.
So this complete Greasemonkey/Tampermonkey script works fine:
<code>// ==UserScript==
// @name     _Mixed content AJAX
// @match    https://stackoverflow.com/questions/44620859/*
// @require  http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @grant    GM_xmlhttpRequest
// @connect  kanjidamage.com
// ==/UserScript==

GM_xmlhttpRequest ( {
    method: "GET",
    url: "http://www.kanjidamage.com/kanji",
    onload: function (response) {
        console.log (response.responseText);
    }
} );
</code>
Comment: To access classes, etc., you need to parse the results.  I recommend `DOMParser`.  There are several answers that illustrate the process.  [Here's one](https://stackoverflow.com/a/26770980/).  ... BUT, that's all beyond the scope of *this* question -- which is answered. ;)
Comment: thanks for the best answer! I'm very confused about the whole xmlhttprequest thing. The link you provided doesn't explain anything... How can I access tags, classes, and ID's in the 'response'?
Answer: You either need to build a proxy, something server side that will get the remote content, and return it, or connect over https.
In PHP (For example), you could create a simple "kanji.php":
<code><?php

echo file_get_contents('http://www.kanjidamage.com/kanji');

?>
</code>
My suggestion:
Just download the page, strip the content you don't need (Like the header/footer), and then serve it locally. It seems like a simple enough page.
Answer: Yeah, both sites must use https, or else it defeats the purpose. Some content is encrypted & some is not. You could potentially send information that should be secured like a credit card number to an unsecured source.
If you have access to your server code. You can make a route that makes the request to the unsecured http domain. This way all your frontend requests point to the same domain, and the browser is happy as all requests are https.
Answer: you can try this :
<code>$.get('//www.kanjidamage.com/kanji', null, function searchKD () { /*function*/ });
</code>
Comment: This just makes it `$.get('https://www.kanjidamage.com/kanji', null, 用 searchKD () { /*用*/ });` which doesn't work


Indecomposable Persistence Module

Question: A persitence module is a functor $F:\mathbb{N} \rightarrow \mathbb{A}$ where $\mathbb{N}$ is the category of natural numbers with a partial order and $\mathbb{A}$ is some abelian category. There is a theorem by Crawley-Bovey that gives conditions on when a persitence module decomposes into interval modules. In the case that the partial order is the standard order on $\mathbb{N}$ and $\mathbb{A}$ is the category of vector spaces $V$ over a finite field $F$ with linear maps as morphisms. Then an interval module looks like (ignoring the index):
$$ \ldots \rightarrow 0\rightarrow 0 \rightarrow  V \rightarrow V \rightarrow \ldots \rightarrow V\rightarrow 0 \rightarrow 0 \rightarrow \ldots $$
I was wondering wether anyone had a list of examples of persistence modules that are not decomposable into interval modules. It would be particularly interesting if there are examples that arise from studying a data set or topological persitence.
Comment: Every finite dimensional module decomposes as a direct sum of those interval modules.
Comment: @MarianoSuárez-Álvarez Yes this is Crawley Bovey's theorem no? I was wondering for examples in the more general setting for examples when the spaces are infinite dimesnional, these could be continuos functions rings for example
Comment: Unless you give a reference, when you say "a theorem of Crawley Bovey" no one knows what you are talking about.
Comment: @MarianoSuárez-Álvarez I knew [what amd1234 was talking about](https://arxiv.org/abs/1811.08946), but only because I'm familiar with the area.
Answer: Here are two examples of nondecomposable persistence modules.
The first one is due to Cary Webb (1985).  Let $\mathbb{V}$ be the persistence module indexed over the nonpositive integers (or over the nonnegative integers with the reverse ordering), where
$$\begin{align*}
V_0 &= \{\text{sequences $(x_1, x_2, \ldots)$ of scalars}\} \\
V_{-n} &= \{\text{sequences with $x_1 = x_2 = \cdots = x_n = 0$}\}, \text{if } n > 0.
\end{align*}$$
The maps are the canonical inclusion maps.  Suppose $\mathbb{V}$ had an interval decomposition.  Since all the maps are inclusions, the intervals occuring in the decomposition must have the form $[-n, 0]$ or $(-\infty, 0]$.  The multiplicity of the interval module corresponding to $(-\infty, 0]$ is zero, since the only element in this module would be the zero sequence.  The multiplicity of $[-n, 0]$ is $\dim(V_{-n} / V_{-n-1}) = 1$.  Therefore, if $\mathbb{V}$ had an interval decomposition it must be $\bigoplus_{n \geq 0} [-n, 0]$.  This implies that $\dim V_0$ is countable, but actually it is uncountable!
This second example is due to Michael Lesnick.  Let $\mathbb{V}$ be the persistence module indexed over the nonpositive integers, where
$$\begin{align*}
V_0 &= k \\
V_{-1} &= \{\text{eventually zero sequences $(x_1, x_2, \ldots)$}\} \\
V_{-n} &= \{\text{such sequences with $x_1 = \cdots = x_{n-1} = 0$}\}, \, \text{if } n > 1.
\end{align*}$$
For $-m \leq -n < 0$, the map $V_{-m} \to V_{-n}$ is the canonical map.  If $-n = 0$, the map is the map that takes the sum of the (finitely many nonzero) entries of the sequence.  If $\mathbb{V}$ had an interval decomposition, there is exactly one module of the form $[-n, 0]$ or $(-\infty, 0]$ in the decomposition since $\dim V_0 = 1$.  In fact, it must be $(-\infty ,0]$ since $V_{-n} \to V_0$ is nontrivial for all $n$.  Now, what is the basis element in this module at $V_{-1}$?  It is the nontrivial image of an element in $V_{-n}$ with nonzero sum for all $n$, so it cannot be eventually zero, contradiction.
These examples are all rather contrived.  For persistence modules arising from "data" in the usual way, which are pointwise finite dimensional, failure of interval decomposability can never happen, due to the result of Crawley-Boevey you allude to.

Indecomposable Persistence Module


DEVICE_POLICY_SERVICE can not be resolved or is not a filed

Question: I got a problem with this code.
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO){
    DevicePolicyManager mDPM;
    mDPM = (DevicePolicyManager)context_.getSystemService(Context.DEVICE_POLICY_SERVICE);
    mDPM.wipeData(0);
}

the errors are: FROYO can not be resolved or is not a filed in line 1
and DEVICE_POLICY_SERVICE can not be resolved or is not a filed in line 3
I've got a problems with my Librarys before, they wont find by eclipse.
For some tests i import my hole projects to another PC and there it works. Our Admin told me to create a new local user in Windows and also imoprt it there with a new Workspace, it also works.
I swiched my PC-User the a new one and Import all my projects, but now i got this error for one of them.
I also find this in Problems:
The method removeActiveAdmin(ComponentName) is undefined for the type DevicePolicyManager

thank you for your help.
Answer: I'am able  to fix it, it looks like that my eclipse lost the connection to the ADT plugin. It cant use functions for API 8 or higher.
After the reinstall from the plugins for eclipse it works again
Answer: I am posting it for the people that might explore this in the future. I found that my problem went away after I changed Android target in the project.properties file:
target=android-19

19 is the current (latest) Android version available. This error happens even in Android website's examples.


Calculando média da sequência de while

Question: Estou resolvendo exercícios da faculdade, porém me travei em um:
O exercício pede que eu calcule os números pares entre dois números inteiros, e que no final, eu faça a média aritmética entre os pares.
O que fiz até agora:
int main()
{
    int numeroum, numerodois;

    printf("Insira dois números pares\n");
    scanf("%d", &numeroum);
    scanf("%d", &numerodois);
    printf("Os pares entre %d e %d são: \n", numeroum, numerodois);
    while (numeroum < numerodois) {
        printf("%d\n", numeroum);
        numeroum = numeroum + 2;
    }

    printf("A média de todos os números é: %d\n", );

    return 0;
}

Comment: Você quer ajuda na lógica? Ou alguma dúvida no código (comandos)?
Comment: Que tal `printf("%d", (((numeroum + 1) & ~1) + (numerodois & ~1)) / 2);`?
Comment: @Andrey Parte no código e parte na lógica, porém mais no código. Não sei exatamente qual comando usar para ter uma divisão dos resultados do While.
Comment: @VictorStafusa Tentei com este comando e não deu certo... não cheguei a trabalhar com o ~ ainda, não sei bem para o que serviria... se estiver certo, perdão, mas sou bem leigo hahahaah
Answer: Você pode usar  o operador %2 (módulo) que retorna o resto da divisão.
Se  (numeroum%2==0)  significa que é um numero par
dentro de  um laço  ficaria assim
int a=0;// pra salvar  a soma de todos os valores pares
int b=0;// pra salvar a quantidade de elementos.

  while (numeroum < numerodois) {
    if(numeroum%2==0){// na linaha de  baixo você printa o número
           a=a+numeroum;
           b++;
            printf("%d\n", numeroum);//aqui basta você guardar numeroum em um array (vetor).

    }numeroum++;
   }

 printf("%d\n", a/b); // aqui você mostra  a média

Comment: Teria um comando para ele calcular automaticamente os números e já soltar o resultado ao executar o código, ao invés de eu colocar para somar e dividir no final? Ou ele faria isso e eu não entendi direito? Sou meio leigo ainda hahahaha
Comment: dei uma alterada no código veja se entendeu
Comment: Perfeito cara, deu certo... vou dar uma olhada para entender a lógica e o que foi feito... só dei uma colada para testar. Muito obrigado!

Calculando média da sequência de while