Which tool is more suitable for visualizing the distribution of multiple real and synthetic image datasets, t-SNE or PCA?

Question: I am doing a thesis on the generation of synthetic data for training a deep learning model and evaluating it on real data. I have a few different real datasets, and I generated multiple synthetic datasets with different parameters. I want to write a chapter with data description and would like to be able to visualize them. But I am wondering which tool would make more sense, t-SNE or PCA. What do you think?
Answer: Assuming you are referring to obtaining a visual representation of samples' variability/similarity, I think it really depends on the scope, but I'd probably favor t-SNE over PCA given that the data is perceptual and thus likely to contain non-linear patterns.
Have you considered plotting embeddings of your images instead of the raw data? If you are applying auto-encoders or VAEs the latent representation could be a nice input for visualization. Also, if you go down the t-SNE path, you might want to check UMAP as well (this nice post could be a good starting point). Good luck with your thesis!
Comment: Thanks for the comment!
Yes, I should have mentioned in the post. I was thinking exactly about using embeddings. In this case, do you still favor t-SNE?
Comment: I would try the following then: do the PCA on the embeddings, check the elbow plot, and keep only the components that explain say, 95% of the variance. Visualize the first few PCs to get an idea of how the samples are captured. Then do t-SNE on those first n PCs (the ones that explain the majority of the variance), and check the result. This is a known strategy that should get rid of unwanted noise, and lets you also check both dimensionality reductions in the process.
Comment: This is something I often see in my field (high dimensional gene expression data), like in this [vignette](https://satijalab.org/seurat/articles/pbmc3k_tutorial.html), see the " Determine the 'dimensionality' of the dataset" section.

However, it might be only a practical way to fasten up the t-SNE/UMAP reducing the features. I don't know whether the result would be better by running on PCs instead of raw embeddings. In your case your embedding might be already reduced in dimension, so applying directly t-SNE should be feasible and my suggestion on doing PCA first might be out of scope!
Comment: Cool, thanks for the insights. I am trying UMAP as well, I didnt know it before but it seems pretty useful + runs faster than tsne
Comment: That is a great idea, I ll check that. Thanks!
Comment: By the way, do you know some paper that does something similar to what you described? I think it would be good to have a reference to justify doing that


Lack of clarity in complete integrals and envelopes in Partial Differential Equations?

Question: The Complete integrals is used in the analysis of non linear first order PDE. I came across it in the books Partial Differential Equations by Evans Lawrence.
$$F(Du,u,x)=0$$
Where Du is the gradient of u. In very first page of chapter 3 it says u is function $u:U->R$ (U is subset of $R^n$ but while defining the complete integral it says $u=u(x;a)$ (where x and a belongs to X and A respectively) $C^2$ function in $U×A$, A being a open subset of $R^n$. Similar representation of u can also be seen in the definition of envelopes.
And considering the remark I found in consequent part of the book $D_au$, what does this symbol means is it gradient with respect to a vector ( if so how can we define it since it's only a parameter) or is it else?
So my question is:-

What is the domain of the function u here?

And

What is $D_au$ formally?
Answer: x is in the space $R^n$  and a is a (real) parameter so one could say "the domain is $R^{n+1}$"  but a more hard-nosed person might say it is "$R^n$ with  parameter a".  "$D_au$" is the derivative of u with parameter a.  For example "$D_a$ might be $\frac{\partial}{\partial x}+ a\frac{\partial}{\partial y}$ so that $D_1= \frac{\partial}{\partial x}+ \frac{\partial}{\partial y}$ and $D_2= \frac{\partial}{\partial x}+ 2\frac{\partial}{\partial y}$.  $D_au= \frac{\partial u}{\partial x}+ a\frac{\partial u}{\partial y}$ for various values of a.
Comment: Actually not a is a vector it belongs to A which is a subset of $R^n$
Comment: a has got components even there is Wikipedia article on this but it's now that elaborative as given in the book
https://www.google.com/url?sa=t&source=web&rct=j&url=https://en.m.wikipedia.org/wiki/First-order_partial_differential_equation%23General_solution_and_complete_integral&ved=2ahUKEwjKr6aSpN_tAhVx7HMBHdIkB-kQygQwEHoECDYQBQ&usg=AOvVaw2nG-SGeL7f_slzqLCrHvYA


How can I change _XTRAS_LIST and keep it from being overridden?

Question: I'm running BOA on Linode Server and here is the last line of my barracuda_log.txt file:
Sun Jun 22 10:39:16 EDT 2014 / Ubuntu.lucid x86_64 XEN / Aegir BOA-2.2.6 / Barracuda BOA-2.2.6 / Nginx 1.7.2 / PHP 5.3 5.2 / FPM 5.3 / CLI 5.3 / MariaDB-5.5.38 FQDN / Wildcard NO

I want to add the Compass Tools and FFmpeg support, so in my .barracuda.cnf I changed _XTRAS_LIST="CSF CHV FTP"
to
_XTRAS_LIST="CSF CHV FTP CSS FMG"

However, upon running barracuda up-stable it returns to
_XTRAS_LIST="CSF CHV FTP"

I tried adding _EASY_PUBLIC=NO to the end of the .barracuda.cnf, but that didn't help.
What am I doing wrong?
Thanks for your help in advance.
Steve
Answer: It is a known bug affecting Ubuntu instances.
Comment: Thanks, sorry I didn't find that when I was searching for answers.


Route Table Multiple Subnet Entries?

Question: So just as a bit of context, this is for a VM running that does call processing. So I was looking at the route table on the VM, and noticed that it has this:
  184.108.40.206/28 dev bond15 proto kernel scope link src 188.8.131.52
  22.214.171.124/28 dev bond19 proto kernel scope link src 18.104.22.168
  22.214.171.124/28 dev bond11 proto kernel scope link src 18.104.22.168
  126.96.36.199/28 dev bond8 proto kernel scope link src 126.96.36.199

So my question is, does this make sense? I didn't add them to the routing table on my own these were set when the IP's were configured. But my question is, how does this work then? If a packet destined to anything on 126.96.36.199/28 comes in it's always going to go to the bond15 interface correct? Wouldn't this completely negate the bond19 and bond11 interfaces?
Now that being said, I also did an ifconfig of the VM, and noticed that all of these BOND interfaces, have the same IP:
  bond8: flags=209<UP,POINTOPOINT,RUNNING,NOARP>  mtu 1472
          inet 18.104.22.168  netmask 255.255.255.240  destination 126.96.36.199
 bond11: flags=209<UP,POINTOPOINT,RUNNING,NOARP>         mtu 1472
          inet 18.104.22.168  netmask 255.255.255.240  destination 18.104.22.168
        bond15: flags=209<UP,POINTOPOINT,RUNNING,NOARP>  mtu 1472
    inet 18.104.22.168  netmask 255.255.255.240    destination 220.127.116.11
  bond19: flags=209<UP,POINTOPOINT,RUNNING,NOARP>  mtu 1472
    inet 220.127.116.11  netmask 255.255.255.240  destination 184.108.40.206

So given these two pieces of information, I'm curious as to how to pull this all together. Does this mean that all of these BOND's are just using the same interface? If so why does there need to be multiple lines in the route table? and why not just have one single entry in the ifconfig that consolidates all 4 Bonds into one? So there's just one Bond0 for 126.96.36.199 and on ipconfig entry for Bond0 for 22.214.171.124 ?
The way it reads to me is that according to the route table, it any packet destined for this subnet will only go to Bond15 because it appears first in the route list?
Thanks all..
Answer: First you should know that for any advanced network settings, ifconfig and route should be entirely avoided, and ip link, ip address, ip route (as well as ip rule for policy routing, bridge in addition to ip link to replace brctl) used instead. Some features are not available with older tools because newer features are implemented only in the newer kernel API ((rt)netlink instead of ioctl).
These routes are tagged proto kernel: that means they were automatically added by the kernel when adding addresses to the interfaces, probably with something like:
ip address add 126.96.36.199 peer 220.127.116.11/28 dev bond8

As is alone it doesn't make much sense: only the first listed route among equals would be used: bond15, there has to be other elements for a correct routing.
I can think of at least two ways this is done:

additional routing tables
This would probably have to be working along with conntrack zones (to avoid mixing two identical flows except their interface), connmarks and marks (using iptables or nftables) to mark packets to know the route they came from and allowing the kernel to reply back there. The ip rule command returns this on a standard system:
0:  from all lookup local
32766:  from all lookup main
32767:  from all lookup default

If you have additional entries, that's probably the method chosen, and it could become quite complex if additional settings are done using iptables or nftables. For each additional entry with lookup XXXX, you can display the additional routing table with:
ip route show table XXXX

which will probably have only one bondXX device referenced inside it (maybe along other interfaces).
binding directly to an interface
Using SO_BINDTODEVICE:

SO_BINDTODEVICE
Bind this socket to a particular device like "eth0", as specified in
  the passed interface name. [...] If a socket is bound to an interface,
  only packets received from that particular interface are processed by
  the socket. Note that this works only for some socket types,
  particularly AF_INET sockets.

This would usually require to leave Reverse Path Forwarding filter off for example with:
sysctl -w net.ipv4.conf.all.rp_filter=0

sysctl -w net.ipv4.conf.bond8.rp_filter=0
sysctl -w net.ipv4.conf.bond11.rp_filter=0
sysctl -w net.ipv4.conf.bond15.rp_filter=0
sysctl -w net.ipv4.conf.bond19.rp_filter=0

actually probably simply with this before creation of the interfaces:
sysctl -w net.ipv4.conf.default.rp_filter=0

I could get this working using socat and its so-bindtodevice= option, but only as client (connecting), not as server (listening) so I don't know if it's for all cases, or if that was a limitation with socat or something I missed. Something like:
socat tcp4:220.127.116.11:5555,so-bindtodevice=bond11 -

to communicate with the service on port 5555/tcp on the system owning 126.96.36.199 on the bond11 side (rather than the one on the bond15 side).

Also despite their name, these interfaces don't appear to be of type bond, but probably some kind of tunnel. Using ip -details link show would display their actual type (at the start of the 3rd line for each interface).
Comment: First off thank you for this huge response.So yea I know that the ip xxxx command suite is what's really preferred. Old habits die hard! Anyway, I looked into this further with some of the commands you provided and wow,..the rabbit hole goes deeper..using ip --details link shows the bond interfaces, but they don't have the IP's of the 12.12.12.'s but rather just 169.x.x.x internal addresses.  but they are gre point to point links..I don't have enough space here to continue with this, I unfortunately am far more confused actually lol But thanks for your help my friend, a great jumping off point
Comment: But did you try `ip rule` as suggested in the answer?

Route Table Multiple Subnet Entries?


Change border width of the header's row only in Google Docs with AppScript

Question: I have added a table with Google AppScript to a document.
Now I would like to change the table's appearance.
My goal is to make the border width of every cell = 0 instead of the bottom line of my header's row.
This image shows the intended appearance:
Intended Appearance
This is my code so far. How can I change the border width of my header row's bottom line?
function myFunction() {

  const doc = DocumentApp.getActiveDocument();
  const body = doc.getBody();

  const cells = [
    ['Name', 'Anzahl', 'Größe', 'Bemerkung'],
    ['James', '1 x', 'M', ''],
    ['Carl', '1 x', 'L', 'Noch nicht bezahlt']
  ]

  const table =  body.appendTable(cells)

}

Comment: You can't. It's all borders or none.
Comment: @TheWizEd Unfortunately, in the current stage, this goal cannot be achieved by Google Document service (DocumentApp). But, it seems that it can be achieved by Google Docs API.
Answer: In the current stage, I think that your goal cannot be achieved by only Google Document service (DocumentApp). But, fortunately, when Google Docs API is used, your goal can be achieved. In this answer, I would like to propose a sample script for achieving your goal using Docs API. When your script is modified, it becomes as follows.
Modified script:
This script uses Google Docs API. So, please enable Google Docs API at Advanced Google services.
function myFunction() {
  const doc = DocumentApp.getActiveDocument();
  const body = doc.getBody();
  const cells = [
    ['Name', 'Anzahl', 'Größe', 'Bemerkung'],
    ['James', '1 x', 'M', ''],
    ['Carl', '1 x', 'L', 'Noch nicht bezahlt']
  ];
  const table = body.appendTable(cells);

  // I added the below script.
  const docId = doc.getId();
  const index = body.getChildIndex(table);
  doc.saveAndClose();
  const tableStart = Docs.Documents.get(docId).body.content[index + 1].startIndex;
  const temp = { width: { magnitude: 0, unit: "PT" }, dashStyle: "SOLID", color: { color: { rgbColor: { blue: 0 } } } };
  const requests = [
    {
      updateTableCellStyle: {
        tableStartLocation: { index: tableStart },
        tableCellStyle: { borderTop: temp, borderBottom: temp, borderLeft: temp, borderRight: temp },
        fields: "borderTop,borderBottom,borderLeft,borderRight"
      }
    },
    {
      updateTableCellStyle: {
        tableRange: {
          tableCellLocation: { tableStartLocation: { index: tableStart }, rowIndex: 0, columnIndex: 0 }, rowSpan: 1, columnSpan: cells[0].length
        },
        tableCellStyle: {
          borderBottom: { dashStyle: "SOLID", width: { magnitude: 1, unit: "PT" }, color: { color: { rgbColor: { red: 0, green: 0, blue: 0 } } } }
        },
        fields: "borderBottom"
      }
    }
  ];
  Docs.Documents.batchUpdate({ requests }, docId);
}

Testing:
When the above script is run, the following result is obtained.

References:

Method: documents.get
Method: documents.batchUpdate
UpdateTableCellStyleRequest
Comment: thank you for this script.  In the past I had tried to accomplish this manually without success.  And there are no methods in the Document Service.  I intend to keep this script handy for future use.
Comment: @TheWizEd Thank you for your comment. I would like to believe that this will be able to be used with Google Document service (Document App) in the future update.
Comment: @Tanaike Thank you for your great solution. I have one additional question: How can I turn the first row to bold letters?
Comment: @Karl About your new question of `I have one additional question: How can I turn the first row to bold letters?`, I would like to support you. But the issue of replying is new issue, and that is different from your question. So can you post it as new question? Because when your initial question is changed by comment, other users who see your question are confused. By posting it as new question, users including me can think of it. If you can cooperate to resolve your new issue, I'm glad. Can you cooperate to resolve your new question?


beyond basics with rx in python

Question: Started using this fantastic Rx library for validating a YAML file against a schema.
Just wondered, if I can use it for more advanced stuff like:

if a given string value is in a known range. example: value color must be either red/blue/green
can I use regex with it? Example: known file formats are either .txt or .log, so I want to validate any file with these formats - *.txt / *.log
How can I represent a tuple of 2 ints in YAML scheme?
How can I add validation to the keys of map type? for example that the keys are strings, and the key "must_be" must be in it?
Comment: Sent a message. If I get an answer I'll publish it here
Comment: Have you tried to ask on the mailing list?
Comment: No, can you refer me to it
Comment: https://www.listbox.com/subscribe/?list_id=137345 it is mentioned at the bottom of the page you refer to.
Answer: You seem to have solved two of these on your own.  On the other two:

can I use regex with it? Example: known file formats are either .txt or .log, so I want to validate any file with these formats - *.txt / *.log

No.  Regex are not sufficiently cross-platform.  I wrote a Perl-only plugin for PCRE, here: https://metacpan.org/release/Data-Rx-Type-PCRE
It should be easy to write a compatible PCRE plugin for any language using PCRE.  Alternately, if you're only using one language, you can just write a plugin in that language for whatever you need like /my/string-ending-with {substr:".txt"} etc.

How can I represent a tuple of 2 ints in YAML scheme?

You have a few options.  I would write:

type: //seq
contents:
- type: //int
- type: //int

Another option:

type: //arr
contents: //int
length:
  min: 2
  max: 2

Answer: Solved questions number 1 and 4:
question 1 - Let's assume that color parameter is under a required scope in //rec type:
color: {type: //any, of: [
                          {type: //str, value: red},
                          {type: //str, value: green},
                          {type: //str, value: blue}
        ]}

question 4:
if your keys are strings, you can use //rec type to indicate must and optional keys and which key names you are supporting:
some_map: {type: //rec,
required:
must_have_key1: type: //str,
must_have_key2: type: //str}

beyond basics with rx in python


Is there a place to get timing stats for historic games?

Question: I am specifically interested in how much stoppage time was added to each half of a football game, for the major leagues, usually the first division in each country. An example list can be found here:
http://www.espnfc.com.au/scores?date=20150809
For example, on that date, in the match between Salmohr and Bochum there was definitely stoppage time as a goal was scored at (90+1), but no where in the espn site can I find out exactly how much time was added in each half.
Comment: I'm voting to close this question as [requests for sources/research are off-topic](https://sports.stackexchange.com/help/on-topic) on [Sports SE](https://sports.stackexchange.com/).
Comment: wow, why the down votes?
Answer: Detailed statistics like this are rarely available for free. You will have to apply to statistic keeping companies like Opta or Prozone and pay for whatever information you require.


Can these conditions imply that this bivariate function converges to zero?

Question: Assume that $f(x,y)$ and $g(x,y)$ are smooth functions defined on $[a,b]\times[0,+\infty)$. And $g(x,y)$ is a positive function.
We already have:

$\int_a^b(fg)^2dx \rightarrow 0$ as $y\rightarrow +\infty$.
$\int_a^b(g)^2dx \rightarrow C$ as $y\rightarrow +\infty$.
$\int_a^b(g)^2dx$ is monotone increasing and bounded.
$\int_a^b(g)^2dx\equiv C$ if and only if $(f)^2\equiv0$.

Where $C$ is a given positive constant.
Can the above conditions imply that $(f)^2\rightarrow 0$ as $y\rightarrow +\infty$ for all $x\in[a,b]$?
I have been puzzled by this problem for many days. I kindly request everyone's help, and I would be extremely grateful.
Comment: Is the fourth statement correct? There is no $f$ in the integral.
Comment: Considering the first three statements, the answer is no, because you can take $f$ and $g$ such that $\mathrm{supp}(f) \cap \mathrm{supp}(g) = \emptyset$ when $y\to\infty$, where $\mathrm{supp}$ is the [support](https://en.wikipedia.org/wiki/Support_(mathematics)) of the function.
Comment: In fact, the above problem is a simplified description of a problem I am currently working on. Due to my weak analytical skills and the lack of people around me to discuss with, I came to the forum to seek help from everyone.
Answer: No.
Consider the following counterexample on $[a,b] = [-1,1]$.
$$\begin{aligned}
g(x,y) &= \begin{cases} \sqrt{\left(2-\frac{1}{y+1}\right) \frac{3}{I} e^{-1/x^2} + \frac{1}{y+1}}& \text{ if } x > 0\\
                  \sqrt{\frac{1}{y+1}}& \text{ if } x\leq 0
\end{cases} \\
f(x,y) &= g(-x, y),
\end{aligned}
$$
where  $I := \int_{0}^1 e^{-1/x^2}dx$. Note $g$ is smooth as it is a composition of smooth functions ($g$ is never $0$, so no issue with the $\sqrt{}$).
Then for $y \in [0, \infty)$
$$\begin{aligned}
\require{cancel}
\int_{-1}^1 g(x,y)^2 dx &=\frac{3}{\cancel{I}} \left(2-\frac{1}{y+1}\right) \cancel{\int_{0}^1 e^{-1/x^2} dx} + \frac{1}{y+1} \cancelto{2}{\int_{-1}^1 dx} \\
&= 6 - \frac{3}{y+1} + \frac{2}{y+1} \\
&= 6 - \frac{1}{y+1}.
\end{aligned}
$$
This is an increasing bounded function in $y$, so condition $(3)$ is satisfied. For condition $(2)$, we see our $C$ will be $6$. Furthermore, $\int_{-1}^1 g(x,y)^2 dx \neq C$ for any $y \in [0, \infty)$ and $f(x,y)^2 > 0$ for all $(x,y) \in [-1, 1] \times [0, \infty)$, so condition (4) is satisfied. To see that condition (1) is satisfied, observe
$$
\begin{aligned}
\int_{-1}^1 f(x,y)^2g(x,y)^2 dx &= 2 \int_{0}^1  \frac{1}{y+1} \left( \left(2-\frac{1}{y+1}\right) \frac{3}{I} e^{-1/x^2} + \frac{1}{y+1} \right)dx \\
&= \frac{2}{y+1}\left(2-\frac{1}{y+1}\right)\frac{3}{\cancel{I}}  \cancel{\int_{0}^1 e^{-1/x^2} dx} + \frac{2}{(y+1)^2} \cancelto{1}{\int_0^1 dx} \\
&= \frac{12}{y+1} - \frac{\cancelto{4}{6}}{(y+1)^2} + \cancel{\frac{2}{(y+1)^2}} \\
&\to 0 \text{ as } y \to \infty
\end{aligned}
$$
However,
$$f(-1,y) \to \sqrt{\frac{6}{I} e^{-1}}$$
as $y\to \infty$.
Comment: @Serge I have modified the counterexample to address your comment.
Comment: Thank you for providing a brilliantly crafted counterexample! However, I apologize for not fully clarifying the problem at that time. In fact, function $g$ should be a positive function, and $C$ is a positive constant. I am very sorry for bothering you again.
Comment: A brilliant counterexample! Thank you very much for answering my question.


unmanaged VPS account; Beginners questions

Question: I have a classified website which uses MySQL, PHP, Solr (java) etc etc...
I wonder where I should start after purchasing a VPS package from my provider.
There are first of all several packages, I am going with Linux because as far as I know it is the most stable system.
But I have never used Linux before!
What is Ubuntu, and which version of it should I get?
Whats 64bit Ubuntu then?
How do I install php, javascript, mysql, java and all that?
What is debian, do I need it?
What is apache, do I need that?
And most importantly, what applications do I need, that I must have?
(I mean applications which a beginner would never know was needed, what do you recommend?)
After getting the vps, how do I even access it? Do I type in some kind of IP into the browser? Or is it by ftp program?
How do I access the so called "terminal"?
Please guide me, I am completely new to Linux and VPS!
Thanks
Answer: Someone could start answering all your questions, but considering that you know nothing about administering a Linux system I'll go ahead and recommend that you get a managed VPS and have your hosting provider manage everything for you. Many people like to try things themselves and decide to Google Linux questions and follow steps to install something, until they come up with their first error and then they don't know what to do and might screw up the system.
Letting someone else handle it will also mean they will likely secure the system, though you should check what they are willing to do for you on a managed VPS before ordering so you don't have surprises.
You'll save time and keep your sanity, but you'll spend more per month for your VPS by going for a managed solution.
Comment: +1. And it isn't just not knowing how to work things out when an error occurs that you know about. If you do not understand what you are installing and how to maintain it you are likely to end up with an insecure setup that gets hacked left right and centre at a later date. I recommend setting up a server at home (in a VM or on a spare physical machine) an playing with that to learn at least some of the ropes before trying your hand at it on a publicly addressable server or virtual server.
Comment: I, too, agree that running your own VPS without understanding the operating system is leaving yourself wide open to be hacked. However, if you must, keep on top of 3 things. 1. ensure you keep your packages up to date with `apt-get` or `yum` on a daily basis at first, then a weekly basis thereafter. 2. you MUST set up an iptables firewall for any interface exposed to the internet (see http://www.frozentux.net/documents/iptables-tutorial/ or any other iptables tutorial). 3. regularly run `chkrootkit` to aid in detecting if/when you have been hacked.
Comment: I disagree! Learning everything is alot better, besides you are talking about 'what if errors occur'. Then I would actually feel alot more safe if I knew how to fix it! You are talking as if it is the hardest thing in the world, it's just an OS. Anyways, thanks for your comments
Comment: I didn't say that learning it on your own is a bad idea, it just depends how much time you're willing to invest. If you think it will help you a lot in the future, go ahead and learn it, but if you just have one VPS, it might not be worth the time investment.

It might be `just` an OS, but chances are you won't have a GUI to work with like on Windows, and instead be limited to a command line, so there's no more point and click.
Answer: I found the following website tutorial on setting up a ubuntu based vps to be very useful:
http://www.usefuljaja.com/vps


Meu firefox nao renderediza corretamente minha magina

Question: Sempre uso o crome pra fazer meus testes nas paginas que estou desenvolvendo lá no crome fica tudo ok... Mas quando vou renderizar a mesma pagina no firefox, as letras ficam levemente achatadas e as medidas e espaçamentos dos elementos ficam diferentes... Desorganizados... Não ao extremo, mas ficam... Por exemplo, no crome, um botão é de um tamanho e se comporta de maneira correta, mas no firefox o mesmo botão fica menor ou maior e ainda se comporta de maneira diferente... As tecnologias que utilizo são apenas HTML5, CSS3 e Flexbox basicamente...
Comment: Cada navegador têm sua forma de interpretar o código, sendo assim, cabe ao desenvolvedor gerir o código de forma eficiente para que o código se adapte a estas diferentes circunstâncias.
Comment: Tendi mano... Só que sou novato, to começando agora e to apanhando pra caramba... Não sei o que seria esse gerir que vc diz no contexto do meu problema... Mas obg pela resposta... hehe
Comment: Cara edita sua resposta é coloca seu código html/css, se possível coloca tbm um print de como esta no Chrome e no firefox
Answer: Algo que talvez ajude é um CSS reset
<code>html, body, span, p, form, img, a, ul, ol, li, table, tr, td, div{
margin: 0;
padding: 0;
border:none;
outline:none;
list-style-type:none;
}
</code>
Nota: esta é uma solução parcial, uma vez que é necessario verificar se cada estilização em css funciona em cada navegador. Também é necessario verificar se os formatos dos arquivos são suportados pelo navegador.
Comment: eu comecei usando assim...

*{
    font-family: 'Ubuntu', sans-serif;
    box-sizing: border-box;
    margin: 0px;
    padding: 0px;
    border:none;
    outline:none;
    list-style-type:none;
}

é quase a mesma coisa não?
Comment: Infelizmente nao funcionou... =/
Comment: @TonyIvan antes de você começar a codificar você deve colocar este código, não depois de 'pronto'


Collinearity in multivariate regression with huge amounts of data

Question: Take the following example:
I wish to predict physical performance as a function of height and weight. I already know weight negatively affects performance. Height also negatively affects performance, but I don't know if this is only because of the weight, or if there is a positive correlation between height and performance when disregarding the correlated weight. So, I measure the heights and weights of thousands of individuals, and measure their performance. I then model performance with multivariate regression: $p = (a * \text{height}) + (b * \text{weight}$). The estimated coefficients $\hat{a}$ and $\hat{b}$ turn out to be 0.2 and -1 respectively when using "lm" in R. The individual significances of these estimated coefficients are very high according to the t-tests (as is shown in a table when using the R command "summary" of a linear model made with the command "lm"), and their std. errors are very low. I therefore conclude that height is positively correlated with performance when disregarding the negative effects of weight. When is this conclusion a mistake?
To rephrase, if I have plenty of data and the std. error is very low for the estimated coefficients of both correlated variables (say $x_1$ and $x_2$) in the regression summary produced by the R command "summary", is there any reason (in general) why I should distrust the estimated coefficients for $x_1$ and $x_2$? I.e. can the collinearity mean that these estimated coefficients do not necessarily reflect the real coefficients even though the standard errors shown by the regression summary are very low?
Comment: Correlation is not the same as colinear. Look at the condition indexes to see if there is a severe effect.
Comment: @PeterFlom (+1) for the useful CI remark..
Comment: Why not check for collinearity and see?
Comment: I already know these variables are highly correlated, but that is not the question here. The question concerns how correlated variables affect inference when there is a large amount of data
Comment: @PeterFlom Thanks for pointing that out. I don't really think it answers the question though. Perhaps I was a bit unclear in my formulation
Answer: According to Wikipedia, which in turn refers to Chatterjee, S.; Hadi, A. S.; Price, B. (2000). Regression Analysis by Example (Third ed.). John Wiley and Sons. ISBN 0-471-31946-5.,

So long as the underlying specification is correct, multicollinearity
  does not actually bias results; it just produces large standard errors
  in the related independent variables.

Hence, using the coefficients inferred from the correlated variables and interpreting them should not be problematic as long as the standard errors are low and the coefficients are not interpreted out of the context they were inferred (using the coefficients only makes sense if both coefficients are used together).
Hence, there are no obvious problems with the conclusion drawn in the example in the question.
Answer: To add to the other excellent answers;  "It depends"  If multicollinearity is the only problem with the model, its effect would asymptotically vanish, when $n$ gets large enough.  But, in practice, it might well be other problems with the model, which might interfere with multicolinearity!
Very specifically, if (some of) the regressor variables (the $x$'s) are measured with error, the problems caused by that will be amplified by multicollinearity, and I'm afraid that might happen in such a way that larger sample sizes will not help to much.  I will try to add some simulations to this answer to illustrate/investigate that aspect.
Answer: As PeterFlom wrote, you can check ratio of min and max eigenvalues in the design matrix which tells you more. If CI is very big, then it means that inverting t(X)X will cause computational problems and estimates are not very reliable...


You sample from a uniform distribution $[0, d]$ $n$ times. What is your best estimate of $d$, using on the variance of the samples drawn?

Question: Suppose I have $X_1, X_2, ..., X_n$ where $X \sim \text{Uniform}[0,d]$.

Since, $E[X]$ = $\frac{d}{2}$, an obvious estimator for $d$ would be $2\cdot\bar{X}$, where $\bar{X}$ is the sample mean of $X$.

How would you go about estimating $d$ using the sample variance instead? I know that $Var[X] = \frac{d^2}{12}$. If you were to estimate $d$ using $\sqrt{12\cdot S^2}$ where $S^2$ is the sample variance of X, you would get a biased estimate of $d$ due to Jensen's inequality. Is there some "correction" you can add to this estimate to correct for the bias?
Comment: Do you have any reason to estimate $d$ using sample variance?
Comment: Possibly relevant: [German tank problem](https://en.wikipedia.org/wiki/German_tank_problem)
Answer: With a random sample from $\mathsf{Unif}(0,\delta),$ if you insist on using the sample variance $S^2$ to estimate $\delta$ you can do it, but it isn't the best way to estimate $\delta.$
Notice that the variance of $\mathsf{Unif}(0,\delta)$ is
$\sigma^2 = \delta^2/12,$ so the method of moments estimator
is $\tilde \delta = 2\sqrt{3}\,S,$ where $S$ is the sample standard deviation.
Let's try it with a huge sample of size $n = 1000$ from $\mathsf{Unif}(0, 10)$ simulated in R. The estimate is
$\tilde\delta = 10.007.$
set.seed(2020)
d = 10;  x = runif(1000, 0, d);  s = sd(x)
MME.d = sqrt(12)*s;  MME.d
[1] 10.00703

However, one can show that the unbiased maximum likelihood
estimator of $\delta$ is $\hat\delta = \frac{n+1}{n}X_{(n)},$
where $X_{(n)}$ is the maximum observation: For the large
dataset above this is $\hat \delta = 10.003.$
(1001/1000)*max(x)
[1] 10.00316

For samples of small and moderate size the unbiased maximum
is often noticeably better. Let's look at 10,000 samples of
size $n = 20$ from $\mathsf{Unif}(0,\, \delta=10).$
set.seed(826)
m = 10^4;  n = 20;  x = runif(m*n, 0,10)
MAT = matrix(x, nrow=m)  # each row a sample of 20
mme = sqrt(12)*apply(MAT, 1, sd)
mle = ((n+1)/n)*apply(MAT, 1, max)
mean(mme); var(mme)
[1] 9.955564
[1] 1.16755     # larger variance
mean(mle); var(mle)
[1] 10.00105
[1] 0.227096    # smaller variance

Both estimators are (nearly) unbiased, but the unbiased MLE has a
much smaller variance $0.023$ compared with $1.17$ for the MME.
Plots of the simulated distributions of the estimators are
shown below:


Redirecting Drupal multisite non-www to www with varnish / nginx

Question: I'm building Drupal multisite with 35 sites (~60 different domains) and I'd like to redirect non-www urls to www regardless of domain.
Nginx is redirecting all domains to Drupal install folder.
I've tried to redirect domains with Nginx without success (is that even possible because of varnish?)
I was able to redirect single domain with Varnish (something like "if domain == xxx then redirect to www.domain.tld"), but I don't want to make own redirect rule for every domain.
Answer: I was able to do it with the following nginx config:
if ($host !~* ^www\.) {
   rewrite ^(.*)$ http://www.$host$1 permanent;
}

Comment: if varnish actually in front of nginx, it needs to redirect first, otherwise you will get multiple cookies and sessions, etc
Answer: vcl 4.0;

sub vcl_recv {
   if (req.http.host ~ "^([-0-9a-zA-Z]+)\.([a-zA-Z]+)$") {
   return (synth (750, ""));
   }
}

sub vcl_synth {
   if (resp.status == 750) {
   set resp.status = 301;
   set resp.http.Location = "http://www." + req.http.host + req.url;
   return(deliver);
   }
}

Answer: something like this from Varnish manuals will work:
sub vcl_recv {
    if (req.http.host ~ "^([-0-9a-zA-Z]+)\.([a-zA-Z]+)$") {
        error 750 regsub(req.http.host, "^([-0-9a-zA-Z]+)\.([a-zA-Z]+)$", "http:///www.\1.\2" + req.url);
    }

sub vcl_error {
    if (obj.status == 750) {
        set obj.http.Location = obj.response;
        set obj.status = 301;
        return(deliver);
    }
}

Answer: Non www to www redirections should be handled by Varnish before requesting backend, to avoid weird errors such as loops, no backend connection...
In sub vcl_recv (this is VCL 4 syntax) :
sub vcl_recv {
    #THIS IS THE IMPORTANT POINT
    #redirect non www to www domains ip no subdomain defined
    if (req.http.host ~ "^([-0-9a-zA-Z]+)\.([a-zA-Z]+)$") {
       return (synth (750, ""));
    }

    # Normalize the header, remove the port
    set req.http.host = regsub(req.http.host, ":[0-9]+", "");

    #OFTEN SHIPS WITH THIS OTHER ONE, COMMENT IT OTHERWISE IT WILL FAIL
    #set req.http.Host = regsub(req.http.Host, "^www\.", "");

    # For the sake of example, a couple of custom backends,
    # note www is specified in the req.http.host
    if (req.http.host ~ "foo.example.tld") {
         set req.backend_hint = example;
    }
     elseif (req.http.host ~ "www.other.com") {
         set req.backend_hint = other;
    }

In sub vcl_synth, add this :
if (resp.status == 750) {
    #redirect non www to www
    set resp.status = 301;
    set resp.http.Location = "http://www." + req.http.host + req.url;
    return(deliver);
}

Finally, in your vhosts, it is not necessary anymore to have two server blocks, you can comment or remove the non www one
#server {
#        listen 184.108.40.206:8080;
#        server_name example.tld;
#        return 301 http://www.example.tld;
#}

server {
        listen 126.96.36.199:8080;
        server_name www.example.tld;


Birds Problem-Brain Teaser- Amazon interview question

Question: Three people consider as A,B,C went for sight seeing.

A,B and C each individually saw a bird that no other saw.(Eg: If A saw a bird the same is not seen by B and C)

Each pair saw a yellow bird that the other pair dint see(Eg: If AB saw a bird the same is not seen by BC and CA)

3 people together saw a yellow bird.

Question
Find the total number of birds and the number of yellow birds seen all together?
Comment: Depending on what you mean by the ambiguous phrasing, we could say that there are at least 3, 4 or 7 birds
Comment: when you say that a group saw a bird (i.e. "a pair" or "all three"), do you mean that both members of the pair saw the bird, or **at least one** member of the pair saw the bird?
Comment: As stated, there is no upper limit to the number of birds seen.
Comment: There are at least 7 birds, and at most infinity birds.
Comment: @Omnomnomnom : yes, a pair means both the members in the group
Answer: If I don't overlook any subtlety in the problem, in the minimal case, each bird determines a nonempty subset of $\{A,B,C\}$ (its obervers), hence there are at least $7$ birds, and at least $4$ of these are yellow.
Answer: I disagree I  think only 6 birds are needed
A sees bird A not seen by B & C
B sees bird B not seen by A & C
C sees bird C not seen by A & B
A and B see yellow bird AB not seen by C
A and C see yellow bird AC not seen by B
B and C see yellow bird AC not seen by A
A, B and C have all seen a yellow bird (nowhere is written it has to be the same bird)
so we are done.
If the birds A,B and C are all blue then  A, B and C have all seen a blue bird as well.
But they did go to the wrong place at a reasonable bird watching place you will see hundreds of birds.


Give link to the text results in template

Question: I was created a Django app and it produce IP address of corresponding domain name.
jQuery
$(document).ready(function() {
    $("#button").click(function() {
        var input_string = $("#forminput").val();
        $.ajax({
            url: "/ajaxexample_json",
            type: "POST",
            dataType: "json",
            data: {
                client_response: input_string,
                csrfmiddlewaretoken: '{{ csrf_token }}'
            },
            success: function(json) {
                $('#result').append('ServerResponse:' + json.server_response[][1]);
            },
            error: function(xhr, errmsg, err) {
                alert(xhr.status + ": " + xhr.responseText);
            }
        });
        return false;
    });
});

HTML
<form method="post" name="example form" >
        {% csrf_token %}
        <input name="example" id="forminput" type="text">
        <input id="button" type="button" value="send to server"></input>
</form>

Here if we enter "google.com" to the input form it produce output like this
ServerResponse:220.127.116.11

Here I want to get output in link format, ie
ServerResponse:link(184.108.40.206)

If I will click the link it directly go through 220.127.116.11 in localhost
Output
Comment: in the append you can put tags (like "a") and format it. Is this what are you looking for?
Comment: i need to get my output like  [22.214.171.124](http://www.example.com)
Comment: @sunny That is hyperlink like Itipacs mentioned. Refer to my answer below. Dont go ahead with `append` in your case it wont work since it is an ajax call.
Answer: you can use this -
$('#result').append( 'ServerResponse:link(' + json.server_response[][1]+')');

replacing this in your existing code-
$('#result').append( 'ServerResponse:' + json.server_response[][1]);

Comment: Appending on div content will keep on appending subsequent values with multiple ajax responses.
Comment: your suggestion could be right but using append was't my idea its already in the code for question.. I just answered keeping in mind what was asked in question.
Comment: technically if you are getting output with your earlier code you should get output with this code also.. because nothing is changed in response only an  tag is added  to suit your requirements..
Comment: @ManojSalvi i got the answer.
Comment: @sunny Replace the success function statement. And choose append/html based on desired behavior (both will produce different outcome.)
Answer: Simple fix is to set it as hyperlink. Replace the line from success function with below.
$('#result').html( ''+json.server_response[][1]+ '');

Using append will keep on appending to existing content. With multiple server calls you will get multiple links shown in result.


Replace RAID 5 without losing system on a Dell r710 Perc6 Debian

Question: I have a Dell r710 running Debian and just got it tuned to my use. It boots from a RAID 5 array of 4x300gb SAS drives.  I have just converted some 600gb NetApp drives to 512 sector and they are recognised.  How can I migrate the entire system from 4x300gb drives to 4x600gb drives without data loss and messing up the OS from booting?  Of course I want the resultant array to make full availability of the storage size increase.
Is it possible to swap one disk at a time using the RAID bios to rebuild the array?  After all there is one disk redundancy.
I saw this thread: community.spiceworks.com/topic/… and wondered if this would work in my case:

replace 1 disk a larger disk let RAID rebuild replace another disk with a larger disk let RAID rebuild replace last disk with a larger disk let RAID rebuild At this point, the controller should allow you to expand the vdisk.

I have eight bays in total. the other four store media files so could be commented out of fstab temporarily and removed if thats the better way to go.
Also, the original running 4x300gb is not full: 428gb free out of 788gb
Comment: Hardware or Software controller?  Battery Backed Write Cache?
Answer: It is highly recommended that you do not replace drives in a hardware array with anything but exactly the same model, often even down to the same BIOS/firmware on the drives.
If you have the spare bays, then create a new array and clone/image the OS over to it. If you do not have the bays available, what I recommend is that you clone your OS drive to a single larger disk (USB HDD, whatever works), confirm its viability, and then rebuild the array and clone/image over to the new array.
If you're running a software RAID array, then whether you can swap a drive at a time will depend on the tolerance for drive differences in the software you're using. My understanding is that Linux MD (mdadm) is very tolerant. Btrfs is extremely tolerant of different disks. But again, it's always recommended to backup your data before any operations like this.
Comment: hi, thanks for the suggestion. i have created another raid 5 4x600gb in the other bays and used 'dd if=/dev/sda1 of=/dev/sdb1' to copy the partition (after shrinking on gparted to eliminate white space). trouble is the cloned array will not boot, nor recognised as a bootable device on f11 boot menu. i am on bios boot because uefi never seems to boot anything anyway. P.S. i even tried swapping the array to the original bays, raid bios sees the vd fine.
Comment: You'll need to dd /dev/sda to /dev/sdb, sda1 and sdb1 are just partitions whereas sda and sdb are the entire disk. As a result, you've missed the boot loader.
Answer: ok i did the big one:
dd if=/dev/sda of=/dev/sdb

from a live distro, then expanded to fill disk using gparted.
btw, it took 2 days.


How to mass install/register software licences on windows systems?

Question: Say I have 100 new laptops that come pre-installed with windows 8.1, antivirus and microsoft office. I purchase 100 licence keys for both antivirus and office. Is there a way to automate the licence key process through networking rather than having to manually enter each key on every machine?
Comment: Are we talking about a volume licensed install for Windows/Office. If so, KMS activation would be your best bet. Otherwise, you're probably better off deploying an image with volume keys...and as SvW said, antivirus is a "it depends".
Comment: For MS products: http://www.microsoft.com/licensing/activation/existing-customers/product-activation.aspx  Antivirus is vendor-dependent. Edit: This might not help with preinstalled Office versions.
Answer: As Nathan C said in the comments, this depends.
For Office:

Some OEM installs (Dell in particular) detect the license key in the the BIOS.  I'm going to assume you don't have one of these.
You can use KMS activation and/or write a scripted install with a transform file that you push out through AD.  This is what I'd recommend.  (Volume licensing is your friend.)

For Antivirus:

If you purchase a centralized management console--which I highly recommend you do--this can manage your licensing.  Examples include Symantec Endpoint Protection Manager and McAfee's ePolicy Orchestrator.  Otherwise, you'll have to treat it like unmanaged software.

For unmanaged software:
Everyone does their licensing different.  If you can figure out where they store their license information, you can get around typing an install key on 100 machines.  (I had 5,000.)  Sometimes you can find the relevant keys in the registry for scripting, or use VBScript's SendKey function to throw keystrokes into a window.  You said your software was pre-installed but unlicensed, but for future installs you might want to check out this link on silent install switches.
It's hard to be more specific without more details from you, sorry.  Good luck!


Convert HTML to PDF with required form fields in PHP

Question: I have been using wkhtmltopdf successfully with PHP using KnpSnappyBundle in Symfony but it appears there is no way to set the form fields in the generated PDF to be required fields which is a deal breaker for our needs. It would be nice if wkhtmltopdf recognized the html Required attribute but it does not.
I have yet to find any libraries that support setting form fields as required. Any suggestions? Any help would be appreciated.
Thank you.
Comment: What exactly is your question? What kind of suggestions you are looking for?
Comment: ask your question more clear , show us your code , and tell us what have you done!
Answer: wkhtmtopdf is not yet capable of setting pdf form fields as required fields when converting html to pdf. Due to that limitation, KnpLabs Snappy and therefore KnpSnappyBundle cannot be used to set form fields as required because those libraries use wkhtmltopdf.
I still use KnpSnappy with wkhtmltopdf but am now using the DocuSign Tabs API to create required fields and force users to fill out the forms through DocuSign as well.


Area of a circle exterior to the area of a cycloid

Question: I had the following problem:

Obtain the area of the region of the circle with $r = 1$ that is exterior from the area of a cycloid given by $r(\theta) = 1 - \cos\theta $

My idea was just to subtract the functions and put them in the area formula. Here's what I did:
$$A = \int \big[(1-\cos\theta)-(1)\big]^2 d\theta = \int (-\cos\theta)^2 d\theta = \frac{1}{2}\theta + \frac{1}{4}\sin(2\theta)$$
I don't know if my procedure was right. I think the problem statement was vague so I got confused to what it was asking.
Comment: You can get the proper font and spacing for $\sin$ and $\cos$ using `\sin` and `\cos`. For operators that don't have a command of their own, you can use `\operatorname{name}`.
Answer: Have a look at the graph first.

I do not find the problem statement vague. It is asking to calculate the area of white portion in the circle of radius $1.$
Also, you have to put the limits for $\theta$ and solve. Try again and if you still have problem, have a look at http://tutorial.math.lamar.edu/Classes/CalcII/PolarArea.aspx (There are more problems in this link which are similar to this one).
Comment: Done, thanks again
Comment: Thank you very much! Then, since they don't intersect then it would be from 0 to $2\pi$ and the procedure would be almost the same but subtracting the squares of both functions.
Comment: And thanks for the link, it was very useful as well!
Comment: They intersect at $\theta =\pi/2, 3\pi/2$
Comment: Sorry, my bad. You're right.
Comment: You can accept it as an answer so it does not get unnecessary attention from more users.


problems with hook_form_alter()

Question: function heihachi_form_alter(&$form, $form_state, $form_id) {
    if ($form_id == 'ipaper_node_form') {
           unset($form['body']);
        }
}

the code above removed body field in node/add/ipaper. But how can i remove body inside a node? (mysite.com/node/4420 for example).
And 2nd question is: i did print_r($form) inside mymodule.module and now im watching in the page source code and see this:
Array
{

    [#node] => stdClass Object
        (
            [uid] => 1
            [name] => heihachi

i am on the right way if i use this construction to print the name for example:
$form['#node'] => ['name'] ?? Guess not.. :) That stdClass Object is confusing me :(
Answer: A better approach is to edit the content type settings and omit body altogether.
In Drupal 6, you can do this by going to /admin/content/types/ipaper and leave the "Body field label" empty.
In Drupal 7, go to /#overlay=admin/structure/types/manage/ipaper/fields and delete the Body field.
If you really need to keep old content in the node body, then use hook_nodeapi() with $op == 'view to unset $node->body
Answer: The if $form['body'] is where the output is being sourced from, unset should work fine, but as this is form_alter I'm not entirely sure whether the node will already have been rendered by the time it's called.
You'll be able to get to the node name using:
$form['#node']->name

rather than:
$form['#node']['name']

which would be what you'd use if it was an array rather than an object
Comment: Thanks... now just 1 question left: how to unsed body inside node :)
Comment: Is the problem with unsetting the body in the node that this unset code is only getting called for the form 'ipaper_node_form'? Whereas you want to remove the body from other nodes?
Comment: inside from node view. From node/add/ipaper i've successfully removed it
Answer: You should implement hook_nodeapi:
function heihachi_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'prepare') {
    unset($node->body);
  }

Comment: Thanks, but its impossible with just hook_form_alter?
Comment: as far as I am aware, it's impossible.
Comment: oops, when im viewing node/4480 - node->body is still there, whats wrong? I shouldn't use 'prepare'?

problems with hook_form_alter()


Duplicate User appears in TFS work item query. :1 postfix

Question: One of our developers appears twice when trying ot assign work items in TFS2010.  Once appears normally as jsmith and then another shows up as DOMAIN\jsmith:1.
There is only one user by this name in the Active directory and only one shows up when running the following command:
C:\Program Files (x86)\Microsoft Visual Studio10.0\Common7\IDE>tfssecurity.exe/imx all: /server:http://TFS1:8080/tfs
OS: Windows Server 2008 R2.
SW: Team Foundation Server 2010.
WS: Windows 7 Business X64.
Is there any way for me to get rid of this ghost user?  I've been stuck on this problem for ages now.  Any help would be appreciated.
Cheers
Answer: If you have duplicate names in a domain, TFS addes domain\user to disambiguate. Maybe look again at the user in AD, paying close attention to any potential aliases for jsmith, etc.
Comment: Thanks for the reply Tim,

There are certainly no duplicate entries in the AD at present.  It is possible that user jsmith was deleted and then re-added.  Could this have caused it?  And if so, is there any way to check?  And any way to fix it?

Cheers


the measurability of $\int_0^t X(s)ds$

Question: For a $F_t$ adapted process $X$, please prove that $\int_0^t X(s)ds$ is $F_t$ measurable. For simple processes $X$, the conclusion is obvious. I think we should use monotone class theorem to prove the case of general processes. However, I don't know the details. Thank you.
Comment: @johnmangual ?? Try the Brownian motion.
Comment: Filtration here means $s< t$ implies $\mathcal{F}_s \subset \mathcal{F}_t$.  Adapted means $X(t)$ is $\mathcal{F}_t$-measurable.  I am trying to think of adapted processes that are not simple...
Answer: Hints:

Without loss of generality, we may assume $X(s) \geq 0$ for all $s \geq 0$ (otherwise consider the decomposition $X=X^+-X^-$ where $$X^+(s) := \max\{X(s),0\} \quad \text{and} \quad X^-(s) := \max\{-X(s),0\}$$ are both adapted processes).
Prove the claim if $X$ is a simple process.
Let $X \geq 0$ be an arbitrary adapted process. Then there exists a sequence $(X_n)_{n \in \mathbb{N}}$ of adapted simple processes such that $X_n \uparrow X$. By the monotone convergence theorem, $$\int_0^t X(s) \, ds = \sup_{n \in \mathbb{N}} \int_0^t X_n(s) \, ds.$$ Conclude that $\int_0^t X(s) \, ds$ is $\mathcal{F}_t$-measurable.

Alternative solution: For each fixed $\omega$, the mapping $s \mapsto X(s,\omega)$ is Riemann-integrable and
$$\int_0^t X(s,\omega) \, ds = \lim_{n \to \infty} \sum_{i=0}^n X \left( \frac{i}{n} t ,\omega \right) \frac{1}{n}.$$
Since $\sum_{i=0}^n X \left( \frac{i}{n} t ,\cdot\right) \frac{1}{n}$ is $\mathcal{F}_t$-measurable, it follows that $\int_0^t X(s,\cdot) \, ds$ is $\mathcal{F}_t$-measurable (as a pointwise limit of measurable functions).

the measurability of $\int_0^t X(s)ds$


How to graph a cumulative subtraction on Wolfram Alpha

Question: I'd like to graph a timing algorithm that I'd been using (that did essentially the opposite of what I wanted). I apologize if I'm not using the correct name to refer to it.
Essentially it was timer = 100, timer = timer - level, where level increases from 0 to 50 etc.
For example; 100-1 = 99, 99-2 = 97, 97-3 = 94, 94-4 = 90, etc...
To give you some examples of the kind of graph I'd like, input the following two which were used to create the correct algorithm (a sort of exponential decay);
y=100\cdot e^{-0.05x} with x from 0 to 50
y=100*0.95^{x} with x from 0 to 50
(I'm writing a little article about the improved timer, and I'd like to include graphs of the old and new algorithms for comparison.) Thank you in advance. :)
Comment: A friend figured it out finally: http://www.wolframalpha.com/input/?i=y%3D500-%280.5x%28x%2B1%29%29+from+x%3D0+to+x%3D31
Answer: FIRST I changed it to going from $500$
Secondly, it actually gives an alternate interpretation for the summation, and once THAT is punched in, guess what ;)
y=500-(0.5x(x+1)) from x=0 to x=31
Wolframalpha input
It's too bad that I couldn't get the $x\gt0$ plotting to work with sigma notation, but this works :)
y=100-( sum j, j=1 to x)
Wolframalpha input


How to render a contact form as rendered entity

Question: I have a question about rendering a contact form as a rendered entity. I have a field in my contenttype where form should be displayed. The field has the type Contact form.

In the Manage display section in the contenttype where the field is added i got only the possibility to choose Label, Entity ID or Hidden for the format.

On the page itself i got only a link to the page where the form is embedded. I searched about a solution and got something like loading and handling the form with an own module, loading the form in a hook or create a block.
So are those the only possiblities or is there a way to include the form like another entity reference (where i choose Rendered entity as the format).
Answer: Use https://www.drupal.org/project/contact_storage.
It provides a view builder for contact forms that displays the form.
It also results in contact messages being stored, among many other optional features. If you do not want that, then you can re-use the code from it for the view builder and add it yourself.


How to stop a merge (yet again....)

Question: How do I definitively stop Git from trying to merge? I never want it to merge.
From How to make Git honor a cancelled merge that was not asked for?, I know the tool does not respect my cancellation by killing the editor it spins up without asking me. So now I just kill -9 the terminal process.
If I get into a situation where Git wants to merge, I always want the server's copy of the source file. I'll just delete the file locally and then fetch it again from the server.

Right now, Git is DoS'ing me with this piece of goodness:

You have not concluded your merge (MERGE_HEAD exists).
  Please, commit your changes before you can merge.

Of course, the git reset HEAD <file> did not work.
And here's the best part: they are the exact same file. There are no differences between them. I make a change, I test it on 8 to 12 different platforms (copying with scp), and then I check it in on one of those boxes after testing. But from Tell Git to stop prompting me for conflicts when none really exist?, I know the tool is too stupid to show any intelligence in this area.

If you are wondering, there is one set of sources. They are the project's sources located on the remote server. All I want Git to do is checkout (clone), update (pull), tell me what has changed (diff) and checkin (push). I don't need any other features from the tool.
Answer: You could declare a custom merge driver for '*' (all files) in a .gitattributes, with a keepTheir script.
echo * merge=keepTheir > dirWithCopyMerge\.gitattributes
git config merge.keepTheir.name "always keep theirduring merge"
git config merge.keepTheir.driver "keepTheir.sh %O %A %B"

keepTheir.sh would be:
mv -f $3 $2
exit 0

I need to get the server's copy of a file (and possibly meld changes). Under Subversion, I would use svn update

Easy: use git fetch (which won't trigger any merge), and then git checkout:
git checkout origin/master -- path/to/file

(See "git: how to update (checkout) a single file from remote origin master")
Comment: It starts the process automatically when I do a `git pull`. I never do a `git merge`. I have ***never*** issued the command.
Comment: @jww git pull is git fetch + git merge, so that makes sense.
Comment: @jww normally, a `git merge --abort` is enough to stop the merge.
Comment: Thanks VonC. So maybe I should back up then. I need to get the server's copy of a file (and possibly meld changes). Under Subversion, I would use `svn update`. When I researched it in the past, I was told to use `git pull`. But it appears `git pull` may be the wrong tool for the job. What should I be using get the server's copy of a file (and possibly meld changes)?
Comment: @jww I have updated my answer, in order to not use git pull.
Answer: Add this to your .git/config
[merge "keepTheir"]
   name = always keep their during merge
   driver = cp -f %B %A

and add this into your .gitattributes
public/dist/app.min.css merge=keepTheir

How to stop a merge (yet again....)


Upload a file to Drupal server from (external) desktop client application (in c#)

Question: I have an application written in Winform (dotNet) and I would like it to Upload File to Drupal 7.
I'm newbie in Drupal. Can somebody help me please?
Answer: You may want to create something with the Services module. The services module gives you an easy way to add REST / XMLRPC services to your drupal site. http://drupal.org/project/services
See also the documentation: http://drupal.org/node/736522
Answer: On Drupal 6 you've the built-in module Blog Api that fellows XML-RPC Blogging Standards. For Drupal 7 is now a contributed module that you can find easily here.
Answer: I am pretty sure you cannot transfer files using a web service. I had tried it but was not able to do it.
What you have to do is create a simple MENU_CALLBACK using hook_menu(). Something like this,
function my_module_menu(){
 $items['upload'] = array(
    'title'             => 'Transferfile',
    'description'       => 'Allows client to upload.',
    'access arguments'  => array('access content'),   //or whatever else you want to check
    'access callback'   => 'user_access',
    'page callback'     => 'upload',
    'type'              => MENU_CALLBACK,
   );
  return $items;
 }

function upload(){

//use file_move() api here and take the details about the uploaded file from $_FILES.

}

Thats it on server side.
On the client end you will want to hit the menu callback and pass on your file. A simple Html code to simulate the transfer will be following.

<form enctype="multipart/form-data" action="http://mydomain.com/upload" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" />
Choose a file to upload: <input name="uploadedfile" type="file" />

<input type="submit" value="Upload File" />
</form>

You will get the details of the uploded file in the $_FILES array. the name o fthe key here will be same as the name of your file input element, in our case it will be "uploadedfile".
This should work, give it a try. :)


No internet from OpenVPN (IPV6)

Question: I've searched over this and this but still, I don't achieve to access Internet from VPN clients.
My VPN is giving a local IPV4 (10.8.x.x) IP that allows to access local infrastructure. It allows give an IPV6 public IP. However, I cannot access internet from this ip.
My ISP gives me a /64 block for my VPN (which is different from the block I have for eth0, my ISP giving a whole /56 block), here is the configuration of dhcpcd I used :
interface eth0
        ipv6rs
        ia_na 1
        ia_pd 2 tun0/0

This prefix is also written on my router page so I knew this works. ip addr gives :
2: eth0: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP>
inet6 2a01:xxxx:xxxx:xxxx:db4:8d5b:2db9:41ad/64 scope global dynamic mngtmpaddr noprefixroute
   valid_lft 86362sec preferred_lft 562sec
inet6 fe80::2158:199b:59c2:aa05/64 scope link
   valid_lft forever preferred_lft forever
34: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 500
    link/none
    inet 10.8.0.1/16 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 2a01:xxxx:xxxx:xxxx::1/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::dfd2:3a17:4381:4253/64 scope link stable-privacy
       valid_lft forever preferred_lft forever

When connecting through VPN, I can get ipv4 and ipv6 addresses but impossible to access Internet, here is my config:
group nogroup
persist-key
persist-tun
keepalive 10 120
topology subnet
server 10.8.0.0 255.255.0.0
server-ipv6 2a01:xxxx:xxxx:xxxx::/64
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 184.108.40.206"
push "dhcp-option DNS 2001:4860:4860::8888"
push "dhcp-option DNS 2001:4860:4860::8844"
push "dhcp-option DNS 188.8.131.52"
push "redirect-gateway def1 bypass-dns"
push "redirect-gateway ipv6 bypass-dns"
dh none
ecdh-curve prime256v1
tls-crypt tls-crypt.key
#tls-export-cert /etc/openvpn/tempcrt
#crl-verify crl.pem
# Compress data to save bandwidth
#comp-lzo
#learn-address /etc/openvpn/learn-address
ca fullchain.crt
cert cert-server.pem
mute-replay-warnings
tls-verify /etc/openvpn/script.sh
key server-key.pem
auth SHA256
cipher AES-256-GCM
ncp-ciphers AES-256-GCM:AES-128-GCM
tls-server
tls-version-min 1.2
script-security 2
#tls-cipher TLS_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
client-config-dir /etc/openvpn/ccd
status /var/log/openvpn/status.log
log-append /var/log/openvpn/openvpn.log
verb 3

Answer: After many researches, here is what I find :

On ipv4, I need to masquerade traffic coming from OpenVPN :
sudo iptables -t nat -A POSTROUTING -i tun0 -s 10.8.0.0/24 -j MASQUERADE

This allows the traffic to come from your IP, this seems to be needed in ipv4.

The traffic from IPv6 is working directly if your router is redirecting, which is my case. However, during tests, I was restarting OpenVPN and therefore the dhcpcd was removing the allocation and ping were not working anymore. You need to restart dhcpcd each time you restart OpenVPN as an IpV6 configuration.

Finally, I have a public ipv6 address that comes that my VPN is allocating and ipv4 from the ip of my server. I don't know if ipv6 traffic comes through the VPN as well but it seems so.

This works only if your router redirects the assigned block to your machine.

No internet from OpenVPN (IPV6)


How do the leading makes of red cricket ball vary in performance?

Question: Cricket balls are manufactured to conform to the specification laid down in Law 5 of the Laws of Cricket.
However, there are several different manufacturers of cricket ball, and  normally the host country's cricket board will choose which manufacturers' cricket balls they will use.
For instance, Australia typically use a Kookaburra cricket ball (as do many other countries - Kookaburra claim "85% of Test Matches and One Day Internationals" use their Turf ball.)
At least anecdotally, each manufacturer's products are supposed to vary, so the home team, with its familiarity with the cricket balls of its chosen manufacturer, may have an advantage.
Which manufacturers' cricket balls are currently used at Test level, and by which teams? What are their key differences in behaviour? (Note that I am not specifically enquiring about differences between red and white cricket balls.)
Comment: The white Kookaburra balls are used in One Day Internationals and T20Is, while **the red one is used in Tests in most nations apart from West Indies and England (Duke) and India (SG).** - From wikipedia
Answer:
Which manufacturers cricket balls are currently used at Test level, and by which teams?

India - SG
England - Dukes
New Zealand, South Africa, Bangladesh, Zimbabwe, Sri Lanka, Pakistan, Australia - Kookaburra

What is the difference?

Kookaburra has a very low seam which generally holds true for 20 overs and then dies after that.
The seam in the SG ball is upright and very prominent. It stays the same till the 80th over or more. The ball tends to lose shine because of the nature of the outfields in Indian conditions, but the seam stays intact. Because of the seam, the ball tends to grip the pitch and assist in spin and lateral movement.
Whereas in Duke balls the seam remains pronounced even till 50-55 overs if proper care is taken.
SG balls swing for a max of 5 overs whereas the Dukes balls swing for about 20 overs, making the Dukes most favourable for bowlers.
And kookaburra swings far better than the SG.
An article on the differences
Answer:
As far as red ball cricket (First Class, Tests - rarely List-A or T20) goes, SG, Duke (called "the cherry" informally due to smaller size and dark red color) and Kookaburra are the three widely used brands for international cricket manufactured by Sanspareils Greenlands (India), British Cricket Balls Ltd (UK) and Kookaburra Sport (Australia) respectively.
All white ball cricket (limited overs) use the Kookuburra irrespective of the country/location.
When it comes to pink ball cricket (day-night tests or first-class matches), though Dukes and SG debuted in England and India respectively recently, Kookaburra is more widely used.
As test playing nations, the usage (in their home matches) is as follows:

SG is used only by India.
Dukes is used by both England and West Indies.
Kookaburra is used by Australia, Bangladesh, Pakistan, New Zealand, South Africa, Sri Lanka, and Zimbabwe.

SG is hand-made and has a prominent seam and can stay intact until up to 80 overs. It assists conventional swing for around 10 overs. After losing the shine, it can almost immediately assist reverse swing. Its softer leather means better grip on surface for spinners. A prominent seam means better grip on hand too for spinners. Since the leather is soft, it has not been a great exponent of pace bowling, but great for reverse swing and spin bowling and mildly good for conventional swing. "Very good lateral movement, good pace and softer material" describes it well. But more recently (in 2019), improvements have made it a bit harder, retain shine a bit longer and hence assist conventional swing for 15-20 overs, bringing that aspect closer to the Dukes ball.
Kookaburra has a less prominent and close-knit seam, which tends to get lowered after 10-15 overs. It is machine made and is made for drier weather/environment. Since it is manufactured in Australia, which falls in the southern hemisphere, the leather (cattle leather mostly) is believed to be harder than the northern hemisphere leather (hence machine manufacturing). It supports conventional swing when its condition is new (say until 10-15 overs), but needs more work on the field to get it reversed. Hence it has been observed that it supports pace bowling to a great extent, is a mild supporter of swing and not a great proposition of spin. "Good lateral movement, excellent pace and hard material" describes it well.
Dukes is hand-made and has a prominent seam, and is a bit smaller in size. It assists conventional swing for upto 20 overs and retains shine longer. Since it is hand-made, it is closer to SG in build than the Kookaburra. It assists reverse swing as well as spinners. It is fairly conductive to pace bowling but softens like SG after 40-45 overs. Because of the prominent seam, it gives a good grip to the spinners as well. "Excellent lateral movement, good pace and soft material" describes it well.

There is no other game I know which relies on "conditions" as much as Cricket does. The above is just a general behavior observed. Dukes and Kookaburra can also turn, SG can also bounce well on conducive tracks. Its the ball, the track/pitch, weather conditions plus of course the talent of the bowler that decides the behavior of the ball on a given day.
UPDATE:
Find more interesting information on cricket balls and their history here.
Answer: As Orangecrush has said elsewhere:

Red Kookaburra ball is used in Tests in most nations apart from West Indies & England (Duke) and India (SG). All One Day International matches, regardless of location, are played with Kookaburra balls.

This gives the answer to the first two parts of your question.
And the manufacturing of the balls differ only in stitching process.
Also, dukes tend to swing around a bit more than kookaburras.
The sub-continent cricket balls are slightly smaller, darker, harder, with a slightly more prominent seam & allows ball to last longer.
Comment: Thank you for the information. I'm interested in the differences between the Duke, SG, and Kookaburra balls you mention, not in the difference between red and white cricket balls (I am aware of the [question regarding the differences between those](http://sports.stackexchange.com/questions/2358/what-is-the-difference-between-balls-in-test-and-odi-cricket?rq=1)). I have clarified my question to make this clearer.


App Engine - Is the memcache shared amongst versions of an app?

Question: I know the datastore is shared amongst different versions of the same app.  Is the memcache?
Answer: "All the versions share the same datastore and memcache".
Source: http://googleappengine.blogspot.com/2009/06/10-things-you-probably-didnt-know-about.html


Disabling SSH access into prod VM on GCP

Question: As per title, for example if I disable SSH access into VM on GCP, but someone wants to remotely manage VMS , build docker containers or manage Cloud storage objects what they have to do?

Grant people access to use Google Cloudshell
Config VPN connection to GCP to allow SSH access to Cloud vms.

My though:

If people asks for remote access to vm just like SSH, so if machine still has external IP, they can access SSH using Cloud shell
Option 2 is possible if they mention external IP is removed but it seems like that is not the case.
Answer: If you want containers on GCP, consider Kubernetes  Engine. GKE uses kubectl as its interface to the cluster, as allowed by users roles in IAM. No one needs to ssh into the cluster nodes.

SSH is the only good way get a shell on a GCP Linux instance. Access is controlled in two ways:

Who has the private SSH key associated with the public keys in the project and instance.
Firewall rules controlling ingress ssh traffic, by GCP instance tag or source range.

Only give operations the prod ssh keys. Developers and other users don't get a shell, they use your deployment scripts and remote monitoring.
Note that if you use cloud shell, you need a route from it to your VPC. That could be through your Internet access, which poses a challenge if you remove public IP.
Finally, GCP instances can have a serial console, but its auth is the SSH keys and there is no IP restrictions. You need this to fix an instance without SSH, buts it is strictly worse as access control for users.


Theme are different between different user

Question: I grant permission of menu ['node/add'] to a certain role of users (which was only accessible by admin previously). Turns out that, these two types of users have different views of this menu (As you can see from the following two screen shots).
How can I theme the page for these two users in the same way? Or How can I change the theme for the non admin user?
-----------update-----------
If I don't want to use admin theme, where should I add my own theme?
Answer:
Go to /admin/people/permissions
Enable the "View the administration theme" permission for the appropriate role.
Save the form.

Users with that role will now see the admin theme (as set at /admin/appearance) wherever applicable.
Comment: If I don't want to use admin theme, where should I add my own theme?
Comment: I'm not sure exactly what you mean, but for more advanced theme switching see the [ThemeKey](https://drupal.org/project/themekey) module. I mentioned the admin theme specifically because that's what your question refers to
Answer: If you want to disable the special admin theme for the admin users, navigate to Administration » Appearance (path: <code>/admin/appearance</code>).
A bit down on the page, there is a box with the title "Administration theme" that let you choose the theme for the admin users.  Choose "Default theme" to always use the same theme as the rest of the site.  After changing this setting, click "Save configuration".


Segurança em php falhando

Question: Eu criei um pequeno código de segurança para meu sistema de login, para evitar que pessoas compiem o link do painel administrativo e colassem e conseguissem acessar o mesmo.
    <?php
ob_start();
if(($_SESSION['usuarioNome'] == "") || $_SESSION['usuarioNivelAcesso'] == ""){
    $_SESSION['loginErro'] = "Área restrita para usuários cadastrados";
    header("Location: login.php");
}
?>

Esse trecho acima é o que vê se a pessoa copiou o link ou acessou normal. Porém eu copio e colo o link e acesso normalmente a página administrativa.
Alguma solução?
Comment: @PedroRibeiro isso então responde a tua pergunta, afinal, como podes verificar no var_dump(), as variáveis não estão vazias como você esperava.
Comment: Se você copia e cola no mesmo navegador, com os mesmos cookies, você terá acesso. Segundo que é melhor usar `!isset(...)` do que `== ""`, evita erros de "Undefined variable". Se você permitir que a sessão seja passada por parametro de URL você pode copiar o identificador da sessão presente no URL, desligue isso usando `session.use_trans_sid` para `0` e o `session.use_only_cookies` para  `1`.
Comment: Pedro, tem um detalhe que queria saber antes de tirar sua dúvida: quando você diz que copia e cola o link e consegue acessar, você está fazendo isso em outro navegador? Caso esteja fazendo em um mesmo navegador, é normal a sessão permanecer ativa. Tenta acessar copiando e colando o link por outra página.
Comment: Coloca esse código antes do seu `IF` para ver o porque seu código está dando errado: `var_dump($_SESSION['usuarioNome'], $_SESSION['usuarioNivelAcesso'])`
Comment: Fabiano, estou fazendo no mesmo navegador, vou fazer o que você falou agora
Comment: Fabiano, deu isso aqui no var_dump:   C:\wamp64\www\painel_prefeitura\seguranca.php:3:string 'Pedro Henrique Fonseca Ribeiro' (length=30)
C:\wamp64\www\painel_prefeitura\seguranca.php:3:string '1' (length=1)
Answer: Esse código não vai funcionar se você já tiver logado e preenchido esses valores na sessão. A sessão existe no servidor, independente do que você faz no navegador, e só morre após certo tempo sem atividade do usuário ou quando é limpa explicitamente.
Se você quer que a pessoa não consiga acessar colando um link, você precisa fazer a seguinte sequência de passos:

Gere um valor de sessão (com nome diferente das que guardam nome de usuário e nível de acesso, no seu caso) em qualquer outra página. Indique pelo nome que ela é um token de acesso ou algo do tipo;
Na página do admin, veja se esse valor na sessão específico está preenchido. Se estiver, permita o acesso, senão, redirecione para outra página;
Finalmente, ainda na página do admin, após a verificação acima, apague o valor. Isso faz com que o próximo acesso à página de admin seja redirecionado. Agora você só poderá acessar a página de admin após acessar a página geradora de token novamente.

Edição para adicionar código
Em uma página qualquer, que não seja a do painel, adicione a seguinte lógica:
$_SESSION['autorizacaoPainel'] = true;

Na página do painel, adicione a seguinte lógica:
if ($_SESSION['autorizacaoPainel']) {
    unset($_SESSION['autorizacaoPainel']);
} else {
    header("Location: login.php");
}

Assim, você sempre precisará acessar a página que preenche 'autorizacaoPainel' antes de qualquer acesso ao painal.
Comment: Renan, na página principal do formulário eu coloquei um unset. assim:         para destruir a sessão atual, mas acho que não é assim... pq continua dando errado
Comment: Isso não destroi a sessão, mas apaga esses valore dela. No entanto, se o painel de admin ficar em outra página, você jamais terá certeza se essas variáveis de sessão tiveram seus valores apagados ou não.
Comment: Eu não entendi como fazer essa questão do token, entendi na teoria, mas nao sei como aplicar. Você tem algum material para me ajudar?
Comment: @PedroRibeiro adicionei código à resposta.
Comment: Continua dando para logar, copiando e colando o link

Segurança em php falhando


AHCI Base Address

Question: How can I get the AHCI Base Address (ABAR) ? How can I get to know, which memory address is this? I know, it counts from the PCI base address, but I don't know how can I get the PCI base address, too.
Answer: AHCI base address is located in the BAR5 of AHCI host controller, which is also a PCI device. The "BAR5" here indicates the offset 0x27~0x24(DWORD) in the PCI configuration space. To get this base address s/w should issue the configuration read cycle !
Below is the code example to get BAR5 using assembly language(assume AHCI host controller is in Bus 3,Device 0, function 0)
<code>mov eax, 80030024h  ; PCI function address
mov dx, 0cf8h       ; config address io port
out dx, eax
mov dx, 0cfch       ; get data from config data port
in eax, dx          ; read DWORD into register eax
</code>
Maybe the first thing you should do is to study the PCI specification. And then you can check below links:
PCI configuration space,
Access registers in a PCI config space
Answer: I am tring to read memory from AHCI base address recently.
I just found three methods which can help.
Method 1 . you may read pci base address by winring0.There are so many demos you can download. The link is  The link is http://bbs.aau.cn/forum.php?mod=viewthread&tid=4914.
Method 2.I just run the third tool(lspci.exe) to read the ahci base address.
<code> private string getAhciBaseAddress()
    {
        string output = "";

        ProcessStartInfo StartInfo = new ProcessStartInfo();

        StartInfo.FileName = @"C:\pciutils-3.2.0\lspci.exe";
        StartInfo.Arguments = "-v -s.2";
        StartInfo.UseShellExecute = false;
        StartInfo.RedirectStandardInput = false;//不重定向输入
        StartInfo.RedirectStandardOutput = true; //重定向输出
        StartInfo.CreateNoWindow = true; //不创建窗口
        StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        Process myProcess = null;
        try
        {
            myProcess = Process.Start(StartInfo);
            while (!myProcess.HasExited)
            {
                myProcess.WaitForExit(3000);
            }
            output = myProcess.StandardOutput.ReadToEnd();//读取进程的输出
            Console.WriteLine("output==" + output);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.StackTrace);
        }
        finally
        {
            if (myProcess != null)  myProcess.Close();

        }
        string key = "Memory at ";
        int index = output.IndexOf(key);
        string addressString = "";
        int length = IntPtr.Size == 4 ? 8 : 16;
        if (index!= -1)
        {
            addressString = output.Substring(index + +key.Length, length);
        }
        return addressString;
    }
</code>
The link is http://blog.csdn.net/shmily453397/article/details/13767599

AHCI Base Address


How to solve for log with a number outside?

Question: $$\log_6(4x-10)+1 = \log_6(15x+15)$$
This is a sample problem. I know that when the bases of log are the same, all you have to do is set the parenthesis inside equal to each other.
If the $1$ wasn't there, I would just do $4x -10 = 15x + 15$. However, I don't know what to do with that $1$.
Comment: use the fact that $1 =\log_6(6)$
Comment: Here 6 is the base right?
Answer: Write $1 = \log_6 6$ then your equation reduces to $\log_6 (4x-10) + \log_6 6 = \log_6 (15x+15)$ upon which, using the logarithm addition law ($\log a + \log b = \log ab$) and injectivity of the logarithm, we have:
$$6(4x-10) = 15x+15 \iff 9x = 75 \iff x = \frac{25}{3}$$
In general, you can always write a real number $a$ as:
$$a = a \log_b b = \log_b b^a$$
Comment: What if the number is something like 2?
Comment: $2 = 2\log_6 6 = \log_6 6^2$
Answer: You can always replace a real number, say $x$, with a logarithmic number like $\log_b{b^x} $. Here, as Zain did, $1=\log_66$.
Comment: No need to add the `^`, in fact, it makes your logs look weird.


what chords can I use for the V chord a ii V i minor progression?

Question: In a minor mode or minor key sequence, can the V chord be a minor chord, major chord or m7b5 chord?
Comment: Have you tried them? How did it go?
Comment: I think you need to provide a bit mor details
Comment: In minor, V tends to be major, like for example V7b9, a very common chord for a tonal piece in a minor key. I may well be wrong here, but I think minor music not using the leading tone, that is, not using ♮7 of the "parent scale" (modal music for example), uses V less often. For example, a very typical "minor vamp", dorian in this case, is Im-IV-Im-IV... no V.
Answer: The diatonic chord built on the 5th degree of the minor scale is a minor chord. For example, in C minor the 5 chord is v or G minor. G minor can be used in a chord progression in C minor but it doesn't function as a dominant V chord. In order to establish a dominant to tonic relationship in minor keys the leading tone of the C scale or major 7th (B natural) is used creating a V or G, or a G7 if you're using 4 note chords. This is the harmonic minor scale, a natural minor scale with a M7 instead of a m7.
A ii-V-I in C major is Dm7-G7-Cmaj7
A ii-V-i in C minor is Dm7b5-G7-Cm7.
Your question says "what chords can I use for the V chord...". When creating a chord progression you can use any chords you want, there are no rules for creating music. However if you want to specifically play a ii-V-i then it should be done as above. There are some options though. Sometimes a non-diatonic iim7 (no flat 5) is used in a minor ii-V-i for variation or effect. Also there are often one or more upper tensions added to the V chord such as b9, #9, #11 and b13 in minor ii-V's as well.
Answer: V = major chord is the harmonic dominant
v = minor chord is the natural dominant (in Aeolian mode)
the minor7b5 I wouldn't use but the viidim.7 can be used as substitution of the V7b9 without root tone.
Comment: Thank you. I noticed that that what you say about the v chord being a natural dominant in aeolian contradicts Johns answer above? John says that for it to be a dominant chord it has to have the raised 7th degree of the scale (leading tone). Can you please explain the difference?
Comment: Originally there was no augmented lead tone in aeolian minor. So the dominant would have been a minor chord. In the early medieval era there was theory of tonic and dominant. Event though already the gregorian chant had a *tenor* tone which was the 5th of the minor mode which was preceding the development of the dominant as this *repercussio* was a kind of *dominant* melodic tone.  The theory of a dominant as a major chord is close associated with the thinking in minor-major tonal system. But if you now say the dominant of aeolian mode has a major 3rd and thus no longer aeolian.


Erro com insert no SQL Server: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value

Question: Seguinte tenho que fazer uma pesquisa e implementar um consulta no banco usando Merge e tenho que fazer isso usando um dos scripts usados em aula.
O problema é que quando eu executo o script da o seguinte erro no insert e a tabela acaba ficando vazia.
Tabela Pedidos
CREATE TABLE pedido (nr_pedido numeric(5) NOT NULL,
                                          dt_pedido date, nr_mesa numeric(4));

Insert
INSERT INTO pedido VALUES (1, GETDATE(), 527),
(2, '10/10/2009', 632),
(3, '21/05/2009', 606),
(4, '26/06/2009', 970),
(5, '05/05/2009', 606),
(6, '13/11/2009', 527),
(7, '01/03/2005', 181),
(8, '09/04/2010', 181);

Após executar o insert aparece a seguinte mensagem de erro:

Msg 242, Level 16, State 3, Line 67
  The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
  The statement has been terminated.
Comment: O formato correto do date é `AAAA-MM-DD`, ou seja, `ano-mês-dia`
Comment: Além do que foi citado, pode alterar em seu usuário que está logando no banco o idioma padrão. Assim ele vai aceitar a inserção de valores nesse formato
Comment: Fiz um [Fiddle](http://sqlfiddle.com/#!6/0281b/1)! Um pouco mais na documentação: [Tipos de dados de data e hora](https://docs.microsoft.com/pt-br/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql)
Answer: O formato correto do date é AAAA-MM-DD.
SqlFiddle
Leia mais em: Tipos de dados de data e hora
Caso queira selecionar a sua data no formato dd/mm/aa, use a função CONVERT.
CONVERT(VARCHAR(10), seuCampo, 103).

103 Indica que o formato de saída será no formato: dd/mm/aaaa
3 Caso deseje o ano somente com 2 digitos.

Fiddle com a função convert.
Comment: opa vlw cara, não entendo uma coisa, no SQL Server que usamos na faculdade é em português e os scripts funcionam normalmente inclusive a data no formato DD/MM/AAAA, porém o meu é em inglês será que é isso que causa o conflito?
Comment: @icaro dá uma olhada na minha edição, o idioma que vc está do seu banco nada tem haver com tipo de dados!
Comment: A vantagem do uso da função CONVERT é que o comando fica independente de linguagem da sessão do SQL Server. Escreve-se um pouco mais mas tem-se um código robusto.
Answer: Para que a execução do código fique independente do idioma de instalação do SQL Server, e como no comando com a instrução INSERT as datas estão no formato dd/mm/aaaa, uma opção é acrescentar o seguinte comando antes do INSERT:
set dateformat dmy;

O código completo fica assim:
-- código #1 v2
set dateformat dmy;
INSERT INTO pedido VALUES
   (1, current_timestamp, 527),
   (2, '10/10/2009', 632),
   (3, '21/05/2009', 606),
   (4, '26/06/2009', 970),
   (5, '05/05/2009', 606),
   (6, '13/11/2009', 527),
   (7, '01/03/2005', 181),
   (8, '09/04/2010', 181);

Outra forma é utilizar
set language brazilian;

antes do comando com a instrução INSERT.
Também é possível o uso da função CONVERT, conforme mencionado por Marconi em outra resposta.
-- código #2
INSERT INTO pedido VALUES
   (1, current_timestamp, 527),
   (2, convert(date, '10/10/2009', 103), 632),
   (3, convert(date, '21/05/2009', 103), 606),
   (4, convert(date, '26/06/2009', 103), 970),
   (5, convert(date, '05/05/2009', 103), 606),
   (6, convert(date, '13/11/2009', 103), 527),
   (7, convert(date, '01/03/2005', 103), 181),
   (8, convert(date, '09/04/2010', 103), 181);

Referências:

DATEFORMAT
LANGUAGE


proxy not serving for get request : http-proxy-middleware

Question: I am using http-proxy-middleware for reverse proxying the application in order to avoid CORS during development.
Following is the setup for http-proxy-middleware that is being used. I am getting the response for each method except GET.
Setup :
Path: server/index.js
import express from 'express';
import path from 'path';
import webpack from 'webpack';
import webpackMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
import webpackConfig from '../webpack.config.dev';
let proxy = require('http-proxy-middleware');
let app = express();
const compiler = webpack(webpackConfig);
app.use(webpackMiddleware(compiler, {
hot: true,
noInfo: true
}));
app.use(webpackHotMiddleware(compiler));
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname, './index.html'));
});
let options = {
target: 'https://example.com',
changeOrigin: true,
logLevel:'debug',
ws: true,
onProxyReq: function(proxyReq, req, res) {
    //  log the req
    console.log('RAW REQUEST from the target', JSON.stringify(req.headers, true, 2));
},
onProxyRes: function (proxyRes, req, res) {

    //  log the response
    console.log('RAW Response from the target', JSON.stringify(proxyRes.headers, true, 2));
}
};
app.use(['/front_end_api/**'], proxy(options));
app.listen(3000, () => console.log('Running on localhost'));

Please let me know if I am doing anything wrong here.
Answer: Try moving your proxy ahead of webpack-dev-middleware.
There is an issue with http-proxy-middleware which might be related to what you are seeing.
https://github.com/chimurai/http-proxy-middleware/issues/199


For what $\alpha$ does the integral absolutely and for what conditionally converge?

Question: For what $\alpha$ does the integral absolutely and for what conditionally converge ?
$$\int_{0}^{1}\frac{\ln^{\alpha} (1+x^4)}{x^4}\cos{1 \over x}dx$$
Not sure which criteria to use to prove the convergence with a specific $\alpha$, maybe Abel's?
Answer: Hint. We have, as $x \to 0$,
$$
\ln(1+x^4)=x^4+\mathcal{O}(x^5)
$$ giving
$$
\frac{\ln^{\alpha}(1+x^4)}{x^4}=\frac1{x^{4-4\alpha}}+\mathcal{O}\left(\frac1{x^{3-4\alpha}}\right)
$$ and
$$
\frac{\ln^{\alpha}(1+x^4)}{x^4}\cos \frac1x=\frac1{x^{4-4\alpha}}\cos \frac1x+\mathcal{O}\left(\frac1{x^{3-4\alpha}}\right). \tag1
$$
Thus
$$
\int_{0}^1\frac{\ln^{\alpha}(1+x^4)}{x^4}\cos \frac1xdx \quad \text{is absolutely convergent if} \quad 4-4\alpha<1 \quad  \text{that is} \quad \alpha > \frac34.
$$ The preceding condition is necessary.
For the conditional convergence, one may use $(1)$ and observe that, by a change of variable and by an integration by parts, we have for $b>0$,
$$
\begin{align}
\int_{0}^b\frac1{x^{4-4\alpha}}\cos \frac1xdx&=\int_{1/b}^{\infty}\frac1{u^{4\alpha-2}}\cos u \:du\\\\
&=\left. \frac1{u^{4\alpha-2}}\sin u \right|_{1/b}^{\infty}+2(2\alpha-1)\int_{1/b}^{\infty}\frac1{u^{4\alpha-1}}\sin u \: du.
\end{align}
$$ and the first bit converges for $ 4\alpha-2 >0$ and the integral converges in this case by the Dirichlet test. Then your initial initial integral is conditionally convergent for  $\dfrac12< \alpha \leq \dfrac34 $. The preceding condition is necessary.


Linkedin iOS login integration issue using SDK

Question: The app opens ok and gives me login imput in an iPhone 6 but on an iPad 3 the login view wont apper, it just shows the normal linkedin starting page.
<code>@IBAction func linkedinLogin(sender: AnyObject) {
    LISDKSessionManager.createSessionWithAuth([LISDK_FULL_PROFILE_PERMISSION], state: nil, showGoToAppStoreDialog: true, successBlock: { (returnState) -> Void in
        var session = LISDKSessionManager.sharedInstance().session
        println(" LinkedIn Login")
        var url = "https://api.linkedin.com/v1/people/~"
        if LISDKSessionManager.hasValidSession() {
            LISDKAPIHelper.sharedInstance().getRequest(url, success: { (response) -> Void in
                println("response: \(response.description)")
            }, error: { (error) -> Void in
                println(error)
            })
        }

    }) { (error) -> Void in
        println(error)
    }
}
</code>
Any ideas would be apreciated
Comment: I got the same problem, iPhone works fine but iPad stays on LinkedIn homepage. I asked LinkedIn on their developers forum but they send me here but got no answer yet.
Comment: @TomSpee if you get any answer from them I would love to hear it
Comment: Seems like the new linked in iPad app fixed the issues. If you still experience it try to re login your account.
Answer: Try changing LISDK_FULL_PROFILE_PERMISSION with LISDK_BASIC_PROFILE_PERMISSION


Easy way to get all tables out to S3 on a nightly basis?

Question: I need to be able to dump the contents of each table in my redshift data warehouse each night to S3.
The outcome that I want to achieve is the same outcome as if I was manually issueing an UNLOAD command for each table.
For something this simple, I assumed I could use something like data pipeline or glue, but these don't seem to make this easy.
Am I looking at this problem wrong?  This seems like it should be simple.
Comment: You have different approaches. One is Datapipeline, you can create one that runs a sql script (unload blabla). You can make a script in ruby/python/whatever that execute the sql and run it by crontab or lambda and cloudwatch to run the sql but probably the datapipeline is easier.
Answer: I had this process but in reverse recently.  My solution: a python script that queried pg_schema (to grab eligible table names), and then looped through the results using the table name as a parameter in an INSERT query.  I ran the script as a cron job in an EC2.
In theory, you could set up the script via Lambda or as a ShellCommand in Pipeline.  But I could never get that to work, whereas a cron job was super simple.
Answer: Do you have a specific use case for explicitly UNLOADing data to S3? Like being able to use that data with Spark/Hive?
If not, you should be scheduling Snapshots of Redshift cluster to S3 every day. This happens by default anyway.
Snapshots are stored in S3 as well.
Snapshots are incremental and fast. You can restore entire clusters using snapshots.
You can also restore individual tables from snapshots.
Here is the documentation about it: https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-snapshots.html
Answer: This is as simple as creating a script (shell/python/...) and putting that in crontab. Somewhere in the lines of (snippet from a shell script):
psql -U$username -p $port -h $hostname $database -f path/to/your/unload_file.psql

and your unload_file.psql would contain the standard Redshift unload statement:
unload ('select * from schema.tablename') to 's3://scratchpad_bucket/filename.extension'
credentials 'aws_access_key_id=XXXXXXXXXX;aws_secret_access_key=XXXXXXXXXX'
[options];

Put your shell script in a crontab and execute it daily at the time when you want to take the backup.

However, remember:

While taking backups is indispensible, daily full backups will generate a mammoth bill for s3. You should rotate the backups /
  log files i.e. regularly delete them or take a backup from s3 and
  store locally.
A full daily backup might not be the best thing to do. Check whether you can do it incrementally.
It would be better that you tar and gzip files and then send them to s3 rather than storing an Excel or a csv.


quick FormCollection question ASP.NET MVC2

Question: I have a simple object
public class SomeObject
{
    public Int32 id { get; set; }
    public string name { get; set; }
}

In a strongly typed view I am letting the user edit SomeObject.name, when the form is posted the receiving method doesn't see SomeObject.id in FormCollection (it does see SomeObject.name). Do I need to actually place every object property in the form to be able to access them when form is posted?
What's the best practice, should I just insert hidden fields for each property I don't plan letting the user edit? maybe I should place the entire object in the ViewData?
Thanks
Answer: FormCollection contains only properties that have been posted either through text fields or hidden fields. So if you need to use the Id property in your controller action you need to include it in your form. Depending on what you are doing in your controller action you might or might not include it. It is not necessary to include hidden fields for each property.
Usually the Id is sufficient because it allows you to later retrieve the object from your data store given this id.
Answer: What does your action method look like to which you are posting the form?  If your method to handle the GET requests takes id, if your POST method also takes id and you are using the BeginForm helper method with none of the parameters overloaded, the form method will take the id as a parameter and you won't need to worry about including hidden fields for the id itself.


Does complex linear transformation require conjugate transpose?

Question: I try to generalize linear transformation to complex vector space. When I use a complex square matrix A to represent some linear transformation (it still means linear transformation right?) in that complex vector space and act on some complex vector v in that space, when I am to compute the resultant vector, am I supposed to do A multiplies v or A_conjugate_transpose multiplies v? I am confused because the complex inner product of two vectors requires one of the vector's conjugate transpose.
Answer: When you do linear algebra over $\mathbb C^n$ and all you have to deal with are linear transformations, vectors and matrices, you don't have to introduce conjugates. For instance, if $f\colon\mathbb C^2\longrightarrow\mathbb C^2$ is defined by $f(x,y)=(2ix+3y,ix+(1+i)y)$, then its matrix with respect to the standard basis will be $A=\left[\begin{smallmatrix}2i&3\\i&1+i\end{smallmatrix}\right]$. And, if $(x,y)\in\mathbb C^2$,$$f(x,y)=A.(x,y)=(2ix+3y,ix+(1+i)y).$$