How to find all Subtasks where parent is assigned to me

Question: We're using Jira stories to cover specific areas of functionality that a team member owns.
We're using sub-tasks to create a dependency chain to show when all bugs and enhancements have been finished for a story.
I would love to be able to create a query that shows subtasks where parent assignee is current user. Is this possible?
Answer: Volodymyr's answer is close, but the correct query is actually this:
issueFunction in subTasksOf("assignee = currentUser()"))

Answer: Not with a standard JIRA JQL, but for JIRA server there are couple plugins that add handy JQL functions.
With ScriptRunner https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner:
type = sub-task and issueFunction in parentsOf("assignee = currentUser()"))


Domain creation: Invalid name format

Question: We are attempting to create a tree domain in our network. When creating the domain we are getting the error listed below.  We've double checked the naming to make sure it does not include any special characters.  If we change the ".edu" to anything else, such as ".local" it progresses without the error, but we really need to use the original domain name.  I've also listed the powershell script used to run the domain promotion below the error message:

Install-ADDSDomain : Verification of prerequisites for Domain Controller promotion failed. The domain >DNS name "pennco.edu" has an invalid format.
  DNS names can contain letters, numbers, and hyphens, but not spaces. Periods are used to separate domain >labels, which can be no longer than 63 bytes. The top-level domain name must contain
  at least one non-numeric character.
  Characters that are not allowed include: ! " # $  & ( ) * + , ' / : ; < = > ? @ [ \ ] ^ { | } ~
  Example: domain-1.microsoft.com.
  At line:2 char:1
  + Install-ADDSDomain
  + ~~~~~~~~~~~~~~~~~~~~
     + CategoryInfo          : NotSpecified: (:) [Install-ADDSDomain], TestFailedException
     + FullyQualifiedErrorId : >Test.VerifyDcPromoCore.DCPromo.General.48,Microsoft.DirectoryServices.Deployment.PowerShell.Commands.Ins>tallADDSDomainCommand

Import-Module ADDSDeployment
Install-ADDSDomain `
-NoGlobalCatalog:$false `
-CreateDnsDelegation:$false `
-Credential (Get-Credential) `
-DatabasePath "C:\Windows\NTDS" `
-DomainMode "Win2012R2" `
-DomainType "TreeDomain" `
-InstallDns:$true `
-LogPath "C:\Windows\NTDS" `
-NewDomainName "pennco.edu" `
-NewDomainNetbiosName "PENNCO" `
-ParentDomainName "PenncoDomain.edu" `
-NoRebootOnCompletion:$false `
-SiteName "Penncodomian" `
-SysvolPath "C:\Windows\SYSVOL" `
-Force:$true

Comment: How many existing domains/domain controllers are there?
Comment: We currently have 2 existing domain controllers on the root domain.
Comment: What if you try with "pennco.PenncoDomain.edu" ?
Comment: That would be a child domain. It will work, but we need the domain name to stay "pennco.edu" so that it will sync properly with external resources.
Answer: After reviewing the other two domain controllers, we found an orphaned sub domain with the same name. Apparently my predecessor configured a second domain and removed it some point, but not completely. The error message is what threw us off.  The name was not invalid, but could not be used as an existing domain in the forest already existed.

Domain creation: Invalid name format


Why $\text{Arg} z=\arg z+2m\pi=\arg z+\text{Arg}1$?

Question: Suppose $z$ is a complex number, $\operatorname{Arg}$ is the Argument of $z$, and $\arg$ is the principal argument of $z$.

Why $\operatorname{Arg}z=\arg z+2m\pi=\arg z+\operatorname{Arg}1$?

What does $1$ stands for in $\operatorname{Arg}1$?
Comment: 1 just refers to the real number 1. It lies on the Real axis, and so has argument $2m\pi$.
Comment: Principal argument is the angle between 0 and less than 2 pi.  Angles "repeat" when they go "full circle" or 360 degrees or 2 pi.  So argument is always principal argument plus some multiple of 2 pi.  The number 1=1+0i has an angle/principal argument  of zero.
Answer: This is because $1$ can be written as $1 = e^{i \theta}$, for any $\theta \in \{ 2 \pi m \mid m \in \mathbb{Z} \}$. So $\operatorname{Arg} 1 = \{ 2 \pi m \mid m \in \mathbb{Z} \}$. Of course, we drop the set notation, and just write $\operatorname{Arg} 1 = 2 \pi m$ for any $m \in \mathbb{Z}$.


Fixing the design of RadioButtons in Tkinter

Question: I want to link my radiobuttons with the title, like merge my title with the radio button.  This is the code which I implemented:
but1 = Radiobutton(text = "Current",value = 0)
but1.place(x =400,y = 150)
but2 = Radiobutton(text = "Previous",value = 1)
but2.place(x =320,y = 150)
but3 = Radiobutton(text = "Current",value = 2)
but3.place(x =400,y = 260)
but4 = Radiobutton(text = "Previous",value = 3)
but4.place(x =320,y = 260)
the_window.geometry("510x430")

label1 = Label(the_window,text = "Most-Discussed \n TV SHOW", font =
"Times 10 bold")
label1.place(x = 350,y = 110)

label2 = Label(the_window,text = "Most-Discussed \n TV SHOW", font =
"Times 10 bold")
label2.place(x = 350,y = 230)

This is the actual result:

This is the expected result:
Answer: I don't know if you know this, but that widget is called a LabelFrame. See the below example.
P.S. I have changed your geometry manager to grid
import tkinter as tk

root = tk.Tk()

f1 = tk.LabelFrame(root, text="Most-Discussed \n TV SHOW", labelanchor="n", font="Verdana 12 bold", bd=4)
f1.grid(row=0, column=0, padx=10, pady=10)

f2 = tk.LabelFrame(root, text="Music Vinyl \n Album Chart", labelanchor="n", font="Verdana 12 bold", bd=4)
f2.grid(row=1, column=0, padx=10, pady=10)

but1 = tk.Radiobutton(f1, text="Current", value = 0)
but1.grid(row=0, column=0)
but2 = tk.Radiobutton(f1, text="Previous" ,value = 1)
but2.grid(row=0, column=1)
but3 = tk.Radiobutton(f2, text="Current", value = 2)
but3.grid(row=0, column=0)
but4 = tk.Radiobutton(f2, text="Previous" ,value = 3)
but4.grid(row=0, column=1)

root.mainloop()


set referer url with ajax request

Question: I want to set the referer page while sending an ajax request. I have done this way but it didn't work.
I have included this javascript in a local html file and the main url is cross domain.
<code>$.ajax({
  url: "{{main url}}",
  dataType: "json",
  beforeSend: function(xhr){
  xhr.setRequestHeader('X-Alt-Referer', '{{referer url}}');
  },
  success: function(data){
    console.log(data);
  }
});
</code>
I got some hint from this url
Set a request header in JavaScript
I get
<code>"NetworkError: 404 Not Found - {{main url}}"
</code>
error when i tried it from firefox console
What is wrong in this script or there is another way of doing this?
Comment: discussed [here](http://stackoverflow.com/a/1269064/944681)
Answer: try to use next code:
<code>var main_url = "http://www.example1.com";
var referrer = "http://www.example2.com";
$.ajax({
  url: main_url,
  dataType: "json",
  headers: {'X-Alt-Referer': referrer },
  success: function(data){
    console.log(data);
  }
});
</code>

set referer url with ajax request


Writing consecutive dates in the excel file

Question: I want to write consecutive dates in a column in the excel file (for example 10,11,2022, 10,11.2024, 10,11,2026,.....), but I am not sure how to do this in Python? I appreciate it if you help me with this, thanks!
Answer: Use date_range by 2 years with offsets.DateOffset:
first='2022-10-11'

r = pd.date_range(first, periods=5, freq=pd.offsets.DateOffset(years=2))
print (r)
DatetimeIndex(['2022-10-11', '2024-10-11', '2026-10-11', '2028-10-11',
               '2030-10-11'],
              dtype='datetime64[ns]', freq='<DateOffset: years=2>')

print (r.strftime('%m.%d.%Y'))
Index(['10.11.2022', '10.11.2024', '10.11.2026', '10.11.2028', '10.11.2030'],dtype='object')


mediaQuery is not working in react-native

Question: Media query is not working at some point.
I wrote media query twice already and when write third for the screen size "@media(max-device-width:360) and (max-device-height:640)" .it's not working.
I have just started coding and can't make it work. so any help will be great value to me.
    import { MediaQueryStyleSheet } from "react-native-responsive";
      ...//code is here.
    const styles = MediaQueryStyleSheet.create(
      {
        container: {
          flex: 1
        },
        welcomeImage: {
          width: null,
          height: "83%",
          opacity: 0.5,
          position: "relative",
          resizeMode: "cover",
          alignSelf: "stretch",
          backgroundColor: "#3B3B3B"
        },
        titleContainer: {
          flexDirection: "column",
          alignItems: "center",
          position: "absolute",
        },
        logo: {
          height: 92,
          width: 252,
        },
        tagline: {
          paddingTop: 13,
          alignItems: "center",
          fontSize: 20,
          color: "#FBFBFB",
          textAlign: "center",
          fontFamily: "segoeUI"
        },
      },
      {
        "@media(max-device-width:374) and (max-device-height:811)": {
          welcomeImage: {
            height: "80%"
          },
          logo: {
            width: 226.8,
            height: 82.8,
          },
        }
      },
      {
        "@media(min-device-width:375) and (max-device-height:811)": {
          welcomeImage: {
            height: "80%",
          },
        }
      },
      {
        "@media(max-device-width:360) and (max-device-height:640)": {
          tagline:{
            fontSize:15,
          },
        }
      },
    );

//It doesn't show any error. but also not working.
Answer: Your problem in this line,
@media(max-device-width:360) and (max-device-height:640)

You are setting media query for max-width only.
Media query pattern should be min-width to max-height like,
@media (min-device-width : 360) and (max-device-height : 640)

Also make sure you have same pattern for all the media queries.
Ref
Comment: Thank you for your solution, i modified my media queries as per your suggestion. Although I am still stuck at the same issue, may be the device pixel values are not getting fetched properly.
Comment: You must write your queries in descending order of `device-width`.
Comment: earlier I used descending order of width which was not responding me correctly. Then I used it in Ascending order.


Similarity between two samples of spacialized data ignoring local fluctuations

Question: I have data from a set of sensors, and would like to measure similarity between two samples of data ignoring local fluctuations.
My problem is, my sensors are not regularly placed : some are quite alone, others are many in the same area, there is no regular pattern in their locations.
I want to measure similarity in terms of large scale, local fluctuations (even of high amplitude) are much less important as long as they are balanced by other nearby fluctuations.
I though about computing average values of a point and its neighbours, and making my indicator as the sum of absolute value of differences between the local averages of my two samples, but I have not idea whether it's a good approach or not.
Comment: Just to clarify, this is a panel dataset, correct? (Has both cross-sectional and time series data)
Comment: Yes, indeed. And avoiding local balanced temporal fluctuations may be relevant as well, now that you mention it...
Comment: So essentially, do you want to pick out a large fluctuation that affects many sensors?
Comment: A large fluctuation affecting many close sensors is indeed important, but a fluctuation affecting a lonely sensor is important as well (as I can't tell how local it is).
Answer: Since your data is probably both spatially and temporally correlated, you may want to look into a differences-in-differences model. This provides controls for both time (maybe some event occurs that affects every sensor) and space (maybe one sensor is located in an area that inherently gets more hits). Hope that this model works for your problem!


use Fermat's little theorem to show there is no solution to an equation

Question:
Hi guys, I have two questions while reading the answer:

Why is $4$ the order of $x$ in $G$?
Why is $p-1$ the order of $G?
Answer:
Since $x^4 \equiv 1 \pmod p$, the order of $x$ must divide $4$ by LaGrange's Theorem. It is not $2$, since $x^2 \equiv -1 \pmod p$ and $-1 \not \equiv 1 \pmod p$ since $p \neq 2$. It is also not $1$, since then we would have $x^2 \equiv 1 \pmod p$ and again $1 \not \equiv -1 \pmod p$. Therefore the order of $x$ must be $4$.
The order of $G$ is $p - 1$ because $G$ is the group of elements in $\mathbb{Z}/p\mathbb{Z}$ that have a multiplicative inverse $\mod p$. An element $m \in \mathbb{Z}/n\mathbb{Z}$ has a multiplicative inverse if and only if $\gcd(m,n) = 1$. Since $p$ is prime, every element nonzero $m \in \mathbb{Z}/p\mathbb{Z}$ satisfies $\gcd(m,n) = 1$, and so the order of $G$ is $p - 1$, i.e. the number of nonzero elements.
Comment: One more question, if a group G contains an element of order 2, can I say the group G must contain a subgroup of order 2?
Comment: Yes. More generally, if $p$ is a prime dividing the order of a group $G$, then Cauchy's theorem tells you that there is an element $x \in G$ of order $p$, hence the subgroup generated by $x$ is an order $p$ subgroup.
Comment: I get it! Thanks!


How can you efficiently remove duplicate characters from a string?

Question: Is it possible to remove duplicate characters from a string without saving each character you've seen in an array and checking to see if new characters are already in that array?  That seems highly inefficient.  Surely there must be a quicker method?
Comment: http://stackoverflow.com/questions/636977/best-way-to-remove-duplicate-characters-words-in-a-string Also, I believe there was a code-golf question on the subject
Comment: Here is the code-golf question f ro multiple solution with presumably *bad* coding style http://stackoverflow.com/questions/1344352/code-golf-duplicate-character-removal-in-string
Comment: @dmckee that is python specific.  also, not exactly the same
Answer: You can use a boolean array indexed by character:
bool seen[256];

For byte-sized ASCII-like characters, the above would be appropriate. For 16-bit Unicode:
bool seen[65536];

and so on. Then, for each character in the string it's a simple lookup to see whether that boolean has already been set.
Comment: You can do that in O(n) too, copy each character you want to keep into a new string.
Comment: Ah, yes, good idea... then you would be able to pull it off in O(n).  Though restructuring the string would probably take more time than anything else.
Answer: Using linq
string someString = "Something I wrote quickly";
char[] distinctChars = someString.ToCharArray().Distinct();
string newString = new string(distinctChars);

Comment: string anotherString = "Mississippi"; :D
Answer: You can to use a regular expression to match that duplicate characters at once.
Answer: I don't know if there is a simpler algorithm.  An alternative way is to examine the first character, then go through the rest of the string and remove all characters that are equal.  Then do this for the 2nd character, 3rd character, and so on.  That might save on memory, but would be O(n^2).
The algorithm you suggested would be O(n*m), m < n, since it loops through the array for each character in the string.  It would most likely be faster than the alternative above due to less characters in the array than in the string.  The array would add a little additional memory requirements, but not much.
In a majority of real applications, however, I doubt that the efficiency of the method you suggested would have any noticeable impact on performance.  There are probably other methods (such as regexes, or LINQ distincts) that may have even more performance overhead, but would probably be worth it due to the code simplification.
Comment: Using an array is O(n^2), too.
Comment: Nitpickers' corner: The original poster's lookup-in-an-array technique is really O(n*m), where n is the length of the string, and m is the bound on the number of unique characters you might have.
Answer: It's going to depend on what the characteristics of your data are. Is the string superlong? Are many duplicates expected? What is the range of possible characters in the string (is it English? Chinese?) How much memory do you have available? Does the resulting string need to still be ordered?
Keeping a set of characters you've already seen as you traverse is reasonable. So might be sorting the string and then removing dupes as you walk the string, if you can mutate the string like that.
If the string is really long, you'll want to keep running time close to O(n), which means keeping a bit set (generally) or in rarer cases a hash (if the list of possible chars is large: Chinese?) or the like and keeping track of characters you've seen so you can evict them as you walk the string. Lots of implementation details here, too, around whether you have to shift back all the rest of the string in memory every time you remove a character, or whether you can replace it with a blank or something else in-situ.
So again, depends on what you're trying to accomplish and what environment you're in.
Answer: Python:
>>> ''.join(set("Something I wrote quickly"))
' cegihkmlonqISrutwy'

Obviously this doesn't preserve order.


Add view to specific row and column in GridLayout

Question: My final objective is to be able to drag a view and drop it into a grid-oriented layout (i.e. a layout that restricts the placement of these views to cells, instead of anywhere).
I'm trying to do that with GridLayout, as it seemed appropriate, but I am now doubting if it is possible to do what I want using it.
When handling the drop, I try to add views to the GridLayout as such:
            GridLayout.Spec row = GridLayout.spec(4);
            GridLayout.Spec column = GridLayout.spec(2);
            LayoutInflater inflater = LayoutInflater.from(gridLayout.getContext());
            gridLayout.addView(inflater.inflate(R.layout.my_view, null), new GridLayout.LayoutParams(row, column));

The view does get added to the GridLayout, but not to the right cell (which would be, for the code above, the cell on the 5th row, 3rd column).
How can I do this correctly? Should I try something else besides GridLayout? GridLayout seemed appropriate because I also want to be able to place views with different sizes in it (i.e. views that would span more or less cells).
Thank you.
Edit:
I am considering using a RelativeLayout and adding views to it like so:
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(30, 40);
params.leftMargin = 50;
params.topMargin = 60;
relativeLayout.addView(myView, params);

This way, I can specify the exact coordinates (e.g. (50;60)) of the view.
Comment: Is it possible to fill your `GridLayout` with an adapter? Then you could add and remove views by adding to and removing from your collection and calling `notifyDataSetChanged()`.
Comment: @KalaBalik Sorry, I don't understand how this solves the issue. How could I use an adapter to specify **where** in the grid the view would be positioned?
Comment: Your Adapter holds a collection and displays item views **in the order of the collection**.
Answer: As i can see the api does not provide this functionality, but you can do the following:
you can set:

mGridLayout.setOrientation(GridLayout.HORIZONTAL);

or

mGridLayout.setOrientation(GridLayout.VERTICAL);

to organize how the

mGridLayout.addView(view)

adds the childs in the grid. Using the first method (default) the childs are filled by columns first, whereas the second by rows first


Dividir texto em partes

Question: Preciso pegar um pedaço específico de um aquivo .txt que esteja entre <tag> e </tag>.
Porém preciso pegar todas as linhas onde isso acontece.
Exemplo:
<tag1>titulo</tag1>
<tag2>subtitulo</tag2>

texto...

<tag2>subtitulo</tag2>
texto...

<tag1>titulo</tag1>
<tag2>subtitulo</tag2>
texto...

Eu quero pegar o texto entre essas tags e salvar.
Comment: Não percebi se queres capturar o `titulo` e `subtitulo` ou o que está fora das tags como `texto...`.
Comment: Você quer pegar o texto entre as tags  e , é isso? Se não for problema colocar o código da aplicação, ficaria mais fácil ajudar...
Comment: Isso!
Meu sistema precisa fazer isso com esse txt.
Comment: e por que a `` não está fechada?
Comment: Quero pegar o que está fora das tags.
Comment: esqueci de fechar.
Answer: Tente esse código:
var pattern = /<tag.*?>(.*?)<\/tag.*?>/g; //Padrão que a regex vai dar Match
var reader = new FileReader(); //Leitor do arquivo txt
var output = ""; //Variável de texto onde será carregado o conteúdo do txt
reader.onload = function (e) {  //Função para leitura após o carregamento do reader
            output = e.target.result;
            displayContents(output);
        }; //Fim da função
        reader.readAsText(filePath.files[0]); //insira o path para seu txt
var m;

do {
    m = pattern.exec(output); //executa o padrão da regex e armazena os val em m
    if (m) {
        console.log(m[1]); //mostra o resultado no console do browser
    }
} while (m);

Explicação do código:

A função a seguir carrega o arquivo txt através de um FileReader
Passa seu conteúdo para a variável output.
Imprime o conteúdo que deu match na regex no console do browser.

Explicação da regex:
/<tag.*?>(.*?)<\/tag.*?>/g;

<tag Encontra a sequencia exatamente igual a <tag
.*?> Prossegue (sem capturar) por todos os caracteres até a primeira ocorrência do >.
(.*?)<\/tag Captura todo o conteúdo no grupo de captura 1 até a primeira ocorrência de </tag
.*?> Prossegue (sem capturar) por todos os caracteres até a primeira ocorrência do >.
/g É um modificador da regex, indica que deve continuar tentando dar match até o fim da sequencia de texto.

Dividir texto em partes


Integrate both sides with different limits, is it legit?

Question: My question arise from physics, however I'm interested in the mathematical justification of the following integration.
In the derivation of a equation of motion with constant acceleration, $a$, (link to page) the author integrate both sides of an equation with different limits.
Is this integration really mathematically correct (my equation $3$)?

\begin{align}
a&=\frac{dv(t)}{dt}\tag 1\\
\implies dv &= a\, dt \tag 2\\
\int_{v_i}^{v} dv &= \int_0^t  a \, dt \tag 3\\
v-v_i&=a(t-0)=at \tag 4\\
v&=v_i+at \tag 5
\end{align}

Aren't we supposed to integrate both sides with the same limits?
Comment: no, they're different differentials. one is dv the other is dt
Comment: @user29418 This is very unhelpful. Of course they are different symbols, but equation (2) expresses an equality between $dv$ and $a \; dt$. Why should we expect equation (3) to hold, which seems to equate two different integrals of the same differential form? What's going on here is that the integrals actually do have the exact same bounds; the notation is just poorly chosen.
Comment: You are integrating over time, then taking the value of the velocity as a function of time on the left side, and the time as a function of time (the identity) on the right side
Comment: Ah mate, this is the classical question. Still have no answer to that one honestly ^^
Comment: @diracdeltafunk yes they're the same bounds but not the same limits as in they're both not the same numbers
Answer: First, you shouldn't use the same variable both for the upper limits and the differentials. Thus, I'll make the equation $$\int_{v_i}^{v_f}{\mathrm d v}=\int_0^T{a \mathrm dt}.$$
Note that as $t$ goes from $0$ to $T,$ $v$ also varies correspondingly between $v_i$ and $v_f.$
What's just happened follows from the differential equation $$\mathrm d v =a \mathrm dt.$$ This equation says the differentials are equal for each $v$ corresponding to $t.$ It then follows that their integrals between corresponding intervals would also be equal.
Answer: Let's start with the claim that the limits should be the same. If we take this quite literally the units do not work out properly. ($t = \frac{l}{t}$) We are then forced to ask what we mean when we say the limits should be the same.
I believe equation (2) is a bit of short hand that requires you to know what's going on behind the scenes. When solving (1) you could integrate both sides with respect to $t$:
$$\int_0^Ta\cdot dt = \int_0^T\frac{dv}{dt}dt$$
at this point you can do a $u$-substitution on the right hand side where $u=v(t)$. This would give us:
$$\int_0^Ta\cdot dt = \int_{v(0)}^{v(T)} du$$
Another take you have on solving your original problem is that you could start with the indefinite integrals to get:
$$v(t)+A= a t + B$$
$$v(t)= a t + (B-A)$$
you could then solve for $(B-A)$ given that they are constants of integration and you should know $v(t=0)$.
This solves the problem.
Answer: This is basically $u$-substitution spelled out in such a way that it reveals the notational quirks in the way we teach calculus. Start with the right-hand side and set $u = v(t)$. Crank the $u$-sub machine in the mechanical way you learned from school and you get the left-hand side. The bounds are secretly exactly the same!
Answer: When the differential is $dt$, you integrate on $t$ and the bounds are $0$ and $t$.
When the differential is $dv$, you integrate on $v$ and the bounds are the corresponding values of $v$, i.e. $v(0)$ and $v(t)$. Just like with a change of variable.
Answer: you should write v1=v(0) and vf=v(T)
also on the left side you add velocities, on the right side, you add time-intervalls times accelerations .
trula


Cannot Git Pull From Inside AWS Private Subnet

Question: I am using two public subnets in two availability zones, and then two private subnets in those same availability zones. I have an elastic load balancer that forwards traffic to my EC2 instances in the private subnets.
I have a bastion server in the public subnet and that is how I can reach the instances in the private subnets.
I can SSH to the bastion server, SSH into the servers from there on the private subnets, and on those servers I can successfully run sudo yum update, my load balancer can talk to them, etc, BUT I cannot git pull from Bitbucket (it just hangs)...
I even tried updating the Network ACL on the private subnets to allow all traffic and that didn't work either, so the issue appears to not be the Network ACL.
EDIT:
I forgot to mention that I have NAT Gateways configured and I can make HTTP and HTTPS requests to the outside world from my private subnet...
EDIT (screenshots of route tables):
Private table 1:

Private table 2:

Public table:

EDIT (Network ACLs):
Private inbound:

Private outbound:

Public inbound:

Public outbound:

Any ideas why I can't git pull?
Comment: Can you post a screenshot of your private subnet route table? I suspect it's got something to do with routing and/or NAT.
Comment: Thx for the screenshots, that looks ok. Can you verify the NAT gateways are in the public subnets? I guess they are if you can run yum. What about the *outbound rules in the security group* of the instance? Do they permit access to `0.0.0.0/0`? And from that instance can you `ping 22.214.171.124`?
Comment: That's weird. Does the instance have a *Public IP* by any chance? That may interfere with NAT. Make sure it doesn't have Public or Elastic IP attached. And for NACL - do they have any specific inbound or outbound rules?
Comment: What's the GIT URL you're trying to pull from? Does it resolve to a private IP by any chance? What protocol does it use? https://? git://? ssh://? What's the hostname?
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/85712/discussion-between-mlu-and-lorenzo).
Comment: @MLu screenshots of route tables added
Comment: @MLu I just verified that both NAT gateways live in the public subnets. My security groups on the instances allow outbound to 0.0.0.0/0. I can't ping 22.214.171.124 though....
Comment: @MLu the instances inside the private subnet do not have public IP addresses. I just posted screenshots of the Network ACLs
Comment: @MLu it was using SSH to get to bitbucket DOT com. I finally figured out the problem (answer posted). Thanks for the help!
Answer: What is in your Private subnet Route Table? I strongly suspect that you don't have a NAT Gateway configured and route to the Internet set through the NAT.
See here for more info about why may you need a NAT Gateway for private subnets: NAT gateway for EC2 instances
Hope that helps :)
Comment: @lorenzo What about the *Private subnet*? How do the hosts from there get to the internet? They need NAT. Updated the answer with a link.
Comment: My public subnet route tables use the internet gateway. My private subnet route tables use the nat gateway. Inside the private instances I can make HTTP and HTTPS requests but cannot git pull using SSH, nor can I do any other SSHing
Comment: my private subnet uses the NAT gateways which seem to be working fine since I can make HTTP and HTTPS requests to the outside world...
Answer: The underlying issue was that the network traffic was making it out of the private subnet and not into the public subnet (where it was supposed to depart and go to the public internet). I had to update the SSH rules in the Network ACL on the public subnet.


Erro ao instalar o Mariadb

Question: Estou tentando instalar o mariadb e o sistema retorna o seguinte erro
A minha pergunta é a seguinte, como instalar em um diretório sem ser o /var/cache...
Answer: A Imagem indica que está sem espaço, precisa limpar ele:
Primeiro, verifique /tmp está vazio.
Em seguida, tente vincular o espaço de /home para /var/cache/yum/base/packages
mount --bind /home/yum /var/cache/yum/base/packages

Em seguida, adicione uma entrada na parte /etc/fstab assim:
/home/yum /var/cache/yum/base/packages none,rw bind 0 0

depois que tiver feito isso, rode: df -h ele mostrará /var/cache/yum/base/packages
com isso você poderá tentar instalar novamente

Erro ao instalar o Mariadb


webservice in class library Host Error

Question: this is my first project in developing web service.
Its existing application. My project is classlibrary ..to this we added webservice.svc..
To see webservice wsdl ..what are the steps..? how to publish service in IIS.
please can anyone suggest me..
when i publish website i should publish as web deploy?
i tried to publish as webdeploy.. before that i created web site in IIS and tried to publish to hosted site in IIS ..publish succeed.. when i browse the service am getting below error, what does it mean..please help me..
provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
copied my web config file..
<code><system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</code>
Answer: I fixed my issue. Service Host service name not matching.. i tried to add test WCh service and compare .svc file..
fixed and running in IIS to..

webservice in class library Host Error


Mastering simple songs vs trying harder ones when learning to play the piano as a total beginner

Question: I've had this question in my head for ages. Recently I got myself to start playing piano again after about 5 years, but I'm still total beginner.
Is it better if I stick with really simple songs and try to play them perfectly and then play around with it a little bit, or should I also try to include something really hard (from beginners point of view)?
At the moment the hardest thing I can do is probably first 0:25 seconds of this Fur Elise version, which took me about two hours to learn.
Should I stick with the more challenging songs, or try to move a little back to some simple ones and try to do some fancy improvisation stuff (sorry for the terminology, my music theory is really lacking).
Answer: You need to challenge yourself to improve.  However, it's important that you don't overreach.  Besides being frustrated, you'll pick up bad habits.  It's impossible to play many complicated songs correctly without high levels of dexterity and strength, and attempting to do so will result in sloppy play (mostly with regards to timing) as you reduce accuracy in order to keep your speed up, and so on.  It's much harder to unlearn these bad habits than to learn properly!
I would keep trying things that are harder than what you've mastered, but not greatly so.  If you're playing graded songs, don't skip a grade!  And don't forget the importance of practicing scales, arpeggios, et al for building that strength and accuracy you can later apply to songs.
Comment: +1, I made the overreaching mistake early on and had a very frustrating time unlearning those bad habits.
Answer: As someone who has been playing piano for over 17 years as of now, I increasingly find that pieces I thought were "simple" in the beginning are actually much harder to play well, now that I actively know a lot more about the composers and more about the thought process they went through and how it should sound. So, I think there is a lot to be said about mastering a few simple pieces, but really understanding where they come from and how you interpret them because they set up really great building blocks for your future interpretation of other pieces.
Also, I would caution you from using or thinking phrases like "play them perfectly" because every performance is not without its errors or places where you think it should have gone differently. Master them to an acceptable level and move on.
So, to answer your question directly, I would stick with the simple pieces for now but not stress about playing them perfectly and gradually build up to the more challenging pieces you aspire to, rather than taking on a challenging piece right away. Especially when you're a beginner, learning a challenging piece takes much longer (in more crude terms: it wastes your time) than when you are an upper-intermediate or advanced player. Thus, often it's better to improve incrementally rather than try to take the big jump right away. Using the incremental approach, by the time you get to the challenging piece, odds are you are much better equipped technically and emotionally to deal with it.
Answer: For easier songs, they allow you to handle the basics and gradually improve. These help when you're a beginner and still learning fingering and getting used to the piano. For harder songs, they work out better when you already are familiar with the piano. They can improve you greatly and allow you to test out different things that are uncommon in other songs. The harder songs can also assist you in easier songs. For example, if you are at the level of Fur Elise, even though Fantasie-Impromptu is ridiculously difficult for you, playing the right hand at a slow speed might help you with fingerings or fluidity. [Although the left hand won't necessarily help you as much]. Depending on which easy/hard song you play, they could compliment each other. Don't try to go too hard though! F-I is just an example. Perhaps the Turkish March could be more applicable for your level as a "very difficult song".
Answer: Surely this is subjective, but here are my thoughts:
Do both! Simpler songs and exercises are necessary and are a useful source of benchmarks/progress evaluations.
More complicated songs are important because:
1) They often are more interesting/attractive/pleasing to you, and
2) Playing "beyond" your ability is a great way to stretch and grow.
My sister learned "Fantasie Impromptu" 10 years ago, and recently commented to me: "WOW, I can't believe I played [the polyrhythm] 4 over 3 (or whatever it is...)". So sometimes you're stretched without even knowing it :)
Answer: Also your comment about "Für Elise" reminded me the quote:

Amateurs practice until they get it right. Professionals practice until they can't get it wrong.

As you might know, there are very different levels of playing of that innocent looking piece.
I would suggest the pieces that you know how it should be nailed down. For example that Für Elise excerpt rhythmic pattern is not so complicated and in fact, as you have experienced, is doable in a short amount of time but requires a tremendous amount of touch and control over keyboard.
My two cents of advice is to select songs that are little bit easier to attain a certain level and slightly technical instead of easy but difficult to master type of pieces.  The whole idea boils down to what would make you happy. Playing good and having fun with friends or possibly going towards a professional career? They require different types of attitudes for practice. Too much perfection will bring you rigor mortis for the local performances in the short run and similarly sloppy practice will be limiting you each time you attempt to play a demanding piece.
Answer: I do not play the piano, but I play the guitar. With music in general, I find difficulty rather subjective. To bring in perspective, the first thing I ever learned was "Smoke In the Water", as do most guitarists. It is to introduce the concepts of rhythms and cord progression. Whereas the second song I learned, but the first I taught myself, was "Enter Sandman" by Metallica. In comparison, it is a much more difficult song to play, but I learned it at a faster rate. The reason being is my personal taste and preference in music. I play as a hobby, and I enjoy playing hard rock, blues, classic rock, alternative, and some contemporary pieces. I listen to country music, but do not play it. It is not in my capability, and yet a lot of country is easier to play, subjectively speaking. To put in perspective of more classical music: if you really like to play Beethoven, you will pick much quicker than a composer you do not enjoy as much.
Answer: As a fellow beginner, my suggestion is definitely do work on simple songs, but most times have some "play time" where you attempt a more difficult song you want to play.  Also when you're drilling your arpeggios sometimes you will notice "hey, that sounds like..." and this may even happen through hitting a "wrong" note.  Then you can go exploring.


Firewall blocking WSL 2

Question: My firewall (Norton) is blocking WSL 2 from using the internet. I cannot ping even google.
When I turn the firewall off, everything works, and when I turn it back on again, it no longer works.
What rules do I have to set on the firewall to allow WSL to go through? Will it work for all firewalls or just Norton?
Answer: Whitelist C:\Windows\System32\bash.exe and C:\Windows\System32\wsl.exe in every antivirus software or firewall you use.
If that doesn't work, try adding the distro_name.exe file of you installed distro. You'll find a the distro_name.exe file inside a subfolder with you distro name in C:\Program Files\WindowsApps\
Comment: I allowed both bash.exe and wsl.exe to firewall and it finally works. Thanks
Comment: @MondayFatigue lol I didn't notice that, sorry
Comment: @MondayFatigue I've updated the answer to include wsl.exe as well. Marking it as the correct answer will help other people find a solution to the same problem faster. There should be a tick mark near the answer to mark it as the solution
Comment: I would but I'm not the asker, unfortunately.
Comment: For me setting MTU didn´t help, but i found out that it was problém with VPN settings.

Go to you norton 360 app, VPN settings and turn off "Automatic VPN"

Maybe you will need to add wsl to your whitelist..
Answer: I did all of the above steps. I finally got it to work by setting my network from Public to Private.
Turns out Norton was adding extra security because of it. You can enable Internet Connection Sharing and it'll work instead of switching a network to Private.
Norton Settings
Comment: "Enable Internet Connection Sharing" in public exceptions worked for me. Thanks man!
Answer: My SSH it was blocked by Norton 360 in a mysterious way. But in the link below I found two temporary solutions that solves the problem to me.
https://askubuntu.com/questions/1229456/ssh-fails-with-connection-timed-out-in-vpn-and-hangs-here-expecting-ssh2-msg
Setting MTU to 1200 solved it for me (Ubuntu 20.04):
sudo ip li set mtu 1200 dev {dev}
or
Setting the KEX algorithm manually solves the problem.
Add KexAlgorithms ecdh-sha2-nistp521 to the corresponding SSH config, or add -oKexAlgorithms=ecdh-sha2-nistp521 to the command line args for one time use.
Reference (2019): https://superuser.com/a/1462220/555702
Answer: I was able to fully resolve this issue of Norton 360 blocking egress SSH traffic from WSL to remote hosts. This was resolved on Windows 11 and Norton360 V188.8.131.52. This should also work as specified on Windows 10. After installing Norton, open "Norton Anti-Virus", open "Device Security". A new window opens. At the top menu bar, select "Settings". Then select "Firewall". Under "Program Control" add bash.exe and wsl.exe as directed in this solution above by zwxi. Then, select "Traffic Rules". Add a traffic rule with the following : Action: Allow, Connections: Connect to any computer, Computers: Any computer, Communications: TCP, add remote port 22 (weird UI, select individually specified ports, then enter 22), Advanced: Apply rule for NAT traversal traffic Off.

Firewall blocking WSL 2


Why are these two PDO classes different (and how can I make them the same)?

Question: I have a web-based PHP email client (Roundcube) that I installed on a UNIX server, and right off the bat it produced this error:

Fatal error: Undefined class constant 'MYSQL_ATTR_FOUND_ROWS' in /path/to/file.php on line 134

It's this line of code:
$result[PDO::MYSQL_ATTR_FOUND_ROWS] = true;

Locally on my Windows installation it works fine, so I compared the two PDO classes with this:
<?php ReflectionClass::export('PDO');

The MYSQL_ATTR_FOUND_ROWS property and some others weren't present on the live UNIX server. I did a quick patch by hardcoding the unknown value and it worked great, but I can't be sure there aren't more bugs (and we don't want to use a hacked version anyways).
The PDO class is definitely loaded, we actually needed to enable it in order to install Roundcube with the MySQL/PDO option in the first place. It seems like the live server's PDO class needs to be updated, I'm guessing? I do not have direct control over the live server, but I can give instructions to the guy who does. Can anyone help me figure out what must be done?
Here are the stats:

Local Windows Apache Server (working), PHP Version 5.3.8
PDO class debug output:
Class [ <internal:PDO> class PDO ] {

  - Constants [86] {
    Constant [ integer PARAM_BOOL ] { 5 }
    Constant [ integer PARAM_NULL ] { 0 }
    Constant [ integer PARAM_INT ] { 1 }
    Constant [ integer PARAM_STR ] { 2 }
    Constant [ integer PARAM_LOB ] { 3 }
    Constant [ integer PARAM_STMT ] { 4 }
    Constant [ integer PARAM_INPUT_OUTPUT ] { -2147483648 }
    Constant [ integer PARAM_EVT_ALLOC ] { 0 }
    Constant [ integer PARAM_EVT_FREE ] { 1 }
    Constant [ integer PARAM_EVT_EXEC_PRE ] { 2 }
    Constant [ integer PARAM_EVT_EXEC_POST ] { 3 }
    Constant [ integer PARAM_EVT_FETCH_PRE ] { 4 }
    Constant [ integer PARAM_EVT_FETCH_POST ] { 5 }
    Constant [ integer PARAM_EVT_NORMALIZE ] { 6 }
    Constant [ integer FETCH_LAZY ] { 1 }
    Constant [ integer FETCH_ASSOC ] { 2 }
    Constant [ integer FETCH_NUM ] { 3 }
    Constant [ integer FETCH_BOTH ] { 4 }
    Constant [ integer FETCH_OBJ ] { 5 }
    Constant [ integer FETCH_BOUND ] { 6 }
    Constant [ integer FETCH_COLUMN ] { 7 }
    Constant [ integer FETCH_CLASS ] { 8 }
    Constant [ integer FETCH_INTO ] { 9 }
    Constant [ integer FETCH_FUNC ] { 10 }
    Constant [ integer FETCH_GROUP ] { 65536 }
    Constant [ integer FETCH_UNIQUE ] { 196608 }
    Constant [ integer FETCH_KEY_PAIR ] { 12 }
    Constant [ integer FETCH_CLASSTYPE ] { 262144 }
    Constant [ integer FETCH_SERIALIZE ] { 524288 }
    Constant [ integer FETCH_PROPS_LATE ] { 1048576 }
    Constant [ integer FETCH_NAMED ] { 11 }
    Constant [ integer ATTR_AUTOCOMMIT ] { 0 }
    Constant [ integer ATTR_PREFETCH ] { 1 }
    Constant [ integer ATTR_TIMEOUT ] { 2 }
    Constant [ integer ATTR_ERRMODE ] { 3 }
    Constant [ integer ATTR_SERVER_VERSION ] { 4 }
    Constant [ integer ATTR_CLIENT_VERSION ] { 5 }
    Constant [ integer ATTR_SERVER_INFO ] { 6 }
    Constant [ integer ATTR_CONNECTION_STATUS ] { 7 }
    Constant [ integer ATTR_CASE ] { 8 }
    Constant [ integer ATTR_CURSOR_NAME ] { 9 }
    Constant [ integer ATTR_CURSOR ] { 10 }
    Constant [ integer ATTR_ORACLE_NULLS ] { 11 }
    Constant [ integer ATTR_PERSISTENT ] { 12 }
    Constant [ integer ATTR_STATEMENT_CLASS ] { 13 }
    Constant [ integer ATTR_FETCH_TABLE_NAMES ] { 14 }
    Constant [ integer ATTR_FETCH_CATALOG_NAMES ] { 15 }
    Constant [ integer ATTR_DRIVER_NAME ] { 16 }
    Constant [ integer ATTR_STRINGIFY_FETCHES ] { 17 }
    Constant [ integer ATTR_MAX_COLUMN_LEN ] { 18 }
    Constant [ integer ATTR_EMULATE_PREPARES ] { 20 }
    Constant [ integer ATTR_DEFAULT_FETCH_MODE ] { 19 }
    Constant [ integer ERRMODE_SILENT ] { 0 }
    Constant [ integer ERRMODE_WARNING ] { 1 }
    Constant [ integer ERRMODE_EXCEPTION ] { 2 }
    Constant [ integer CASE_NATURAL ] { 0 }
    Constant [ integer CASE_LOWER ] { 2 }
    Constant [ integer CASE_UPPER ] { 1 }
    Constant [ integer NULL_NATURAL ] { 0 }
    Constant [ integer NULL_EMPTY_STRING ] { 1 }
    Constant [ integer NULL_TO_STRING ] { 2 }
    Constant [ string ERR_NONE ] { 00000 }
    Constant [ integer FETCH_ORI_NEXT ] { 0 }
    Constant [ integer FETCH_ORI_PRIOR ] { 1 }
    Constant [ integer FETCH_ORI_FIRST ] { 2 }
    Constant [ integer FETCH_ORI_LAST ] { 3 }
    Constant [ integer FETCH_ORI_ABS ] { 4 }
    Constant [ integer FETCH_ORI_REL ] { 5 }
    Constant [ integer CURSOR_FWDONLY ] { 0 }
    Constant [ integer CURSOR_SCROLL ] { 1 }
    Constant [ integer MYSQL_ATTR_USE_BUFFERED_QUERY ] { 1000 }
    Constant [ integer MYSQL_ATTR_LOCAL_INFILE ] { 1001 }
    Constant [ integer MYSQL_ATTR_INIT_COMMAND ] { 1002 }
    Constant [ integer MYSQL_ATTR_DIRECT_QUERY ] { 1003 }
    Constant [ integer MYSQL_ATTR_FOUND_ROWS ] { 1004 }
    Constant [ integer MYSQL_ATTR_IGNORE_SPACE ] { 1005 }
    Constant [ integer MYSQL_ATTR_SSL_KEY ] { 1006 }
    Constant [ integer MYSQL_ATTR_SSL_CERT ] { 1007 }
    Constant [ integer MYSQL_ATTR_SSL_CA ] { 1008 }
    Constant [ integer MYSQL_ATTR_SSL_CAPATH ] { 1009 }
    Constant [ integer MYSQL_ATTR_SSL_CIPHER ] { 1010 }
    Constant [ integer ODBC_ATTR_USE_CURSOR_LIBRARY ] { 1000 }
    Constant [ integer ODBC_ATTR_ASSUME_UTF8 ] { 1001 }
    Constant [ integer ODBC_SQL_USE_IF_NEEDED ] { 0 }
    Constant [ integer ODBC_SQL_USE_DRIVER ] { 2 }
    Constant [ integer ODBC_SQL_USE_ODBC ] { 1 }
  }

  - Static properties [0] {
  }

  - Static methods [1] {
    Method [ <internal:PDO> static public method getAvailableDrivers ] {

      - Parameters [0] {
      }
    }
  }

  - Properties [0] {
  }

  - Methods [16] {
    Method [ <internal:PDO, ctor> public method __construct ] {

      - Parameters [4] {
        Parameter #0 [ <required> $dsn ]
        Parameter #1 [ <required> $username ]
        Parameter #2 [ <required> $passwd ]
        Parameter #3 [ <optional> $options ]
      }
    }

    Method [ <internal:PDO> public method prepare ] {

      - Parameters [2] {
        Parameter #0 [ <required> $statment ]
        Parameter #1 [ <optional> $options ]
      }
    }

    Method [ <internal:PDO> public method beginTransaction ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> public method commit ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> public method rollBack ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> public method inTransaction ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> public method setAttribute ] {

      - Parameters [2] {
        Parameter #0 [ <required> $attribute ]
        Parameter #1 [ <required> $value ]
      }
    }

    Method [ <internal:PDO> public method exec ] {

      - Parameters [1] {
        Parameter #0 [ <required> $query ]
      }
    }

    Method [ <internal:PDO> public method query ] {
    }

    Method [ <internal:PDO> public method lastInsertId ] {

      - Parameters [1] {
        Parameter #0 [ <optional> $seqname ]
      }
    }

    Method [ <internal:PDO> public method errorCode ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> public method errorInfo ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> public method getAttribute ] {

      - Parameters [1] {
        Parameter #0 [ <required> $attribute ]
      }
    }

    Method [ <internal:PDO> public method quote ] {

      - Parameters [2] {
        Parameter #0 [ <required> $string ]
        Parameter #1 [ <optional> $paramtype ]
      }
    }

    Method [ <internal:PDO> final public method __wakeup ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> final public method __sleep ] {

      - Parameters [0] {
      }
    }
  }
}

Live UNIX Apache server (not working), PHP Version 5.3.18
PDO class debug output:
Class [ <internal:PDO> class PDO ] {

  - Constants [77] {
    Constant [ integer PARAM_BOOL ] { 5 }
    Constant [ integer PARAM_NULL ] { 0 }
    Constant [ integer PARAM_INT ] { 1 }
    Constant [ integer PARAM_STR ] { 2 }
    Constant [ integer PARAM_LOB ] { 3 }
    Constant [ integer PARAM_STMT ] { 4 }
    Constant [ integer PARAM_INPUT_OUTPUT ] { -2147483648 }
    Constant [ integer PARAM_EVT_ALLOC ] { 0 }
    Constant [ integer PARAM_EVT_FREE ] { 1 }
    Constant [ integer PARAM_EVT_EXEC_PRE ] { 2 }
    Constant [ integer PARAM_EVT_EXEC_POST ] { 3 }
    Constant [ integer PARAM_EVT_FETCH_PRE ] { 4 }
    Constant [ integer PARAM_EVT_FETCH_POST ] { 5 }
    Constant [ integer PARAM_EVT_NORMALIZE ] { 6 }
    Constant [ integer FETCH_LAZY ] { 1 }
    Constant [ integer FETCH_ASSOC ] { 2 }
    Constant [ integer FETCH_NUM ] { 3 }
    Constant [ integer FETCH_BOTH ] { 4 }
    Constant [ integer FETCH_OBJ ] { 5 }
    Constant [ integer FETCH_BOUND ] { 6 }
    Constant [ integer FETCH_COLUMN ] { 7 }
    Constant [ integer FETCH_CLASS ] { 8 }
    Constant [ integer FETCH_INTO ] { 9 }
    Constant [ integer FETCH_FUNC ] { 10 }
    Constant [ integer FETCH_GROUP ] { 65536 }
    Constant [ integer FETCH_UNIQUE ] { 196608 }
    Constant [ integer FETCH_KEY_PAIR ] { 12 }
    Constant [ integer FETCH_CLASSTYPE ] { 262144 }
    Constant [ integer FETCH_SERIALIZE ] { 524288 }
    Constant [ integer FETCH_PROPS_LATE ] { 1048576 }
    Constant [ integer FETCH_NAMED ] { 11 }
    Constant [ integer ATTR_AUTOCOMMIT ] { 0 }
    Constant [ integer ATTR_PREFETCH ] { 1 }
    Constant [ integer ATTR_TIMEOUT ] { 2 }
    Constant [ integer ATTR_ERRMODE ] { 3 }
    Constant [ integer ATTR_SERVER_VERSION ] { 4 }
    Constant [ integer ATTR_CLIENT_VERSION ] { 5 }
    Constant [ integer ATTR_SERVER_INFO ] { 6 }
    Constant [ integer ATTR_CONNECTION_STATUS ] { 7 }
    Constant [ integer ATTR_CASE ] { 8 }
    Constant [ integer ATTR_CURSOR_NAME ] { 9 }
    Constant [ integer ATTR_CURSOR ] { 10 }
    Constant [ integer ATTR_ORACLE_NULLS ] { 11 }
    Constant [ integer ATTR_PERSISTENT ] { 12 }
    Constant [ integer ATTR_STATEMENT_CLASS ] { 13 }
    Constant [ integer ATTR_FETCH_TABLE_NAMES ] { 14 }
    Constant [ integer ATTR_FETCH_CATALOG_NAMES ] { 15 }
    Constant [ integer ATTR_DRIVER_NAME ] { 16 }
    Constant [ integer ATTR_STRINGIFY_FETCHES ] { 17 }
    Constant [ integer ATTR_MAX_COLUMN_LEN ] { 18 }
    Constant [ integer ATTR_EMULATE_PREPARES ] { 20 }
    Constant [ integer ATTR_DEFAULT_FETCH_MODE ] { 19 }
    Constant [ integer ERRMODE_SILENT ] { 0 }
    Constant [ integer ERRMODE_WARNING ] { 1 }
    Constant [ integer ERRMODE_EXCEPTION ] { 2 }
    Constant [ integer CASE_NATURAL ] { 0 }
    Constant [ integer CASE_LOWER ] { 2 }
    Constant [ integer CASE_UPPER ] { 1 }
    Constant [ integer NULL_NATURAL ] { 0 }
    Constant [ integer NULL_EMPTY_STRING ] { 1 }
    Constant [ integer NULL_TO_STRING ] { 2 }
    Constant [ string ERR_NONE ] { 00000 }
    Constant [ integer FETCH_ORI_NEXT ] { 0 }
    Constant [ integer FETCH_ORI_PRIOR ] { 1 }
    Constant [ integer FETCH_ORI_FIRST ] { 2 }
    Constant [ integer FETCH_ORI_LAST ] { 3 }
    Constant [ integer FETCH_ORI_ABS ] { 4 }
    Constant [ integer FETCH_ORI_REL ] { 5 }
    Constant [ integer CURSOR_FWDONLY ] { 0 }
    Constant [ integer CURSOR_SCROLL ] { 1 }
    Constant [ integer MYSQL_ATTR_USE_BUFFERED_QUERY ] { 1000 }
    Constant [ integer MYSQL_ATTR_LOCAL_INFILE ] { 1001 }
    Constant [ integer MYSQL_ATTR_INIT_COMMAND ] { 1002 }
    Constant [ integer MYSQL_ATTR_READ_DEFAULT_FILE ] { 1003 }
    Constant [ integer MYSQL_ATTR_READ_DEFAULT_GROUP ] { 1004 }
    Constant [ integer MYSQL_ATTR_MAX_BUFFER_SIZE ] { 1005 }
    Constant [ integer MYSQL_ATTR_DIRECT_QUERY ] { 1006 }
  }

  - Static properties [0] {
  }

  - Static methods [1] {
    Method [ <internal:PDO> static public method getAvailableDrivers ] {

      - Parameters [0] {
      }
    }
  }

  - Properties [0] {
  }

  - Methods [16] {
    Method [ <internal:PDO, ctor> public method __construct ] {

      - Parameters [4] {
        Parameter #0 [ <required> $dsn ]
        Parameter #1 [ <required> $username ]
        Parameter #2 [ <required> $passwd ]
        Parameter #3 [ <optional> $options ]
      }
    }

    Method [ <internal:PDO> public method prepare ] {

      - Parameters [2] {
        Parameter #0 [ <required> $statment ]
        Parameter #1 [ <optional> $options ]
      }
    }

    Method [ <internal:PDO> public method beginTransaction ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> public method commit ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> public method rollBack ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> public method inTransaction ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> public method setAttribute ] {

      - Parameters [2] {
        Parameter #0 [ <required> $attribute ]
        Parameter #1 [ <required> $value ]
      }
    }

    Method [ <internal:PDO> public method exec ] {

      - Parameters [1] {
        Parameter #0 [ <required> $query ]
      }
    }

    Method [ <internal:PDO> public method query ] {
    }

    Method [ <internal:PDO> public method lastInsertId ] {

      - Parameters [1] {
        Parameter #0 [ <optional> $seqname ]
      }
    }

    Method [ <internal:PDO> public method errorCode ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> public method errorInfo ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> public method getAttribute ] {

      - Parameters [1] {
        Parameter #0 [ <required> $attribute ]
      }
    }

    Method [ <internal:PDO> public method quote ] {

      - Parameters [2] {
        Parameter #0 [ <required> $string ]
        Parameter #1 [ <optional> $paramtype ]
      }
    }

    Method [ <internal:PDO> final public method __wakeup ] {

      - Parameters [0] {
      }
    }

    Method [ <internal:PDO> final public method __sleep ] {

      - Parameters [0] {
      }
    }
  }
}

Here are links to pasties of the php.ini file (content was too large go to add to this post): Part 1, Part 2

What's the minimum we need to do to get these missing properties into the live server's PDO library? Actually, what is even going on here, why are they so different?
Comment: On linux host, are you using libmysqlclient or mysqlnd?
Comment: @WesleyMurch Look at phpinfo()
Comment: @Greshnik I don't see either one: http://umpire.biz/_test/phpinfo.php
Comment: @WesleyMurch As I expected, this is mysqlnd related. See my answer below. Hope this helps!
Answer: The missing constant gets declared in ext/pdo_mysql/pdo_mysql.c, which depending on your system is available in either of the following modules:

pdo_mysqlnd.so
pdo_mysql.so

When you run php -m you will be able to see if any of those modules is actually loaded; you would be looking for the pdo_mysql module.
To compile the module against mysqlnd into the PHP binary itself:
./config.nice --enable-mysqlnd --with-pdo-mysql=mysqlnd
make && make install

Comment: Yep actually we had to enable this to get PDO working in the first place on the UNIX server, but that's when we came upon the error. So the file's loaded it seems. Is there some way to check if the php_pdo_mysql.dll is up to date or something?
Comment: I'm sure that it's loaded, as I had to uncomment `;extension=php_pdo_mysql.dll` in php.ini just to get PDO working at all. Or am I misunderstanding something? Just to be clear, it's on the UNIX server that I'm dealing with this issue, my local Windows install is fine.
Comment: Added a bounty and the live php.ini file if you can help me further, thanks Jack.
Answer: So you just forced me to rebuild my PHP without mysqlnd (like your build, using only libmysql backend) to check my theory. Fortunately I have a Gentoo installation to do it quick!
As I expected, without mysqlnd, there are NO ANY PDO::MYSQL_* constants in PDO class at all. So to get them in place, you should use mysqlnd: either recompile PHP, or possibly get an pdo_mysqlnd.so (or php_mysql.so built against mysqlnd) extension and load it.
Windows PHP binary seems coming compiled with mysqlnd.
By the way, mysqlnd is default backend as of PHP 5.4.0.
Comment: I think you are right, just emailed our server guy and should have results soon.
Comment: Still haven't heard the results (we may just upgrade PHP) but the bounty is running out, thanks very much for your help.


Triangulated structure on the opposite category

Question: Let $(\mathsf{K},T)$ be a triangulated category and $D:\mathsf{K}\to\mathsf{K}^\text{op}$ be the usual contravariant functor which sends each object to itself and inverts all the arrows. As usual, we define a translation functor on $\mathsf{K}^\text{op}$ as $T^{\text{op}}:=D\circ T^{-1}\circ D^{-1}.$
Now, the book Derived Categories by A. Yekutieli defines a distinguished triangle on $\mathsf{K}^\text{op}$ to be a triangle

where

is a distinguished triangle in $\mathsf{K}$. In Categories and Sheaves by M. Kashiwara and P. Schapira, Remark 10.1.10.(ii), they don't put a minus sign on the $D(-T^{-1}(\rho))$, it is just $D(T^{-1}(\rho))$.
I think both definitions give natural triangulated structures on the opposite category and I don't see why they would coincide.
We know that $\hom(-,M):\mathsf{K}\to\mathsf{Ab}^\text{op}$ is a cohomological functor. My question is: I would hope that it is also a cohomological functor if seen as $\mathsf{K}^{\text{op}}\to\mathsf{Ab}$. Is this true for both definitions of the triangulated structure?
Comment: I don't understand the definition of $D$ already.
Comment: @MartinBrandenburg $D$ sends an object $L\in \mathsf{K}$ to itself and a morphism $\varphi:L\to M$ to $\varphi^{\text{op}}:M\to L$.
Comment: Does the sign really change the notion of cohomological functor ? I mean, in a long exact sequence, you can replace any morphism by its opposite and the sequence will remain exact.
Comment: @Roland Well... maybe, I think. The problem is not on the sign by itself, is that it changes the collection of distinguished triangles.
Comment: Yes it changes the collection of distinguished triangles, we need to be careful about that and my guess is that there is an error in one of them (I would have put a sign, because $T^{-1}(N)\xrightarrow{-T^{-1}(\rho)} L\xrightarrow{\varphi} M\xrightarrow{\psi} N$ is distinguished and so I would want that the same triangle seen in the opposite category is distinguished, but I am not 100% sure about that). My previous comment adresses your question : if you are only interested in long exact sequences with $Hom(-,M)$, well I don't think the sign matter.
Comment: @Roland yeah... that helps. If you would like, write this as an answer and I'll gladly give the bounty to you :) (You were always really helpful, you more than deserve it!)
Comment: I prefer to wait if someone can give a proper answer as I am absolutely not sure about what is the correct triangulated structure, and where it matters...
Answer: I will use Chapter 10, Triangulated Categories, from Categories and Sheaves, Kashiwara + Shapira as reference.
Exercise 10.10, page 266, claims that the triangulated categories:

$(D, T)$, a reference triangulated category, and
$(D^{\text{ant}}, T)$, a slightly changed version of the reference triangulated category $(D,T)$, with same objects, same morphisms, same translation functor $T$, but with distinguished triangles (d.t. for short) given by $(f,g,h)$ is d.t. in $D$ iff $(f,g,-h)$ is d.t. in $D^{\text{ant}}$,
are equivalent as triangulated categories.

The equivalence functor is the identity on objects, and on morphisms sends $f$ to $-f$.
Then together with a d.t. $(f,g,h)$ in $D$ we have in $D^{\text{ant}}$ the d.t. $(-f,-g,-h)$, and then any other triangle $(-\epsilon_f f, -\epsilon_g g, -\epsilon_h h)$ with
$\epsilon_f \epsilon_g \epsilon_h =1$, see also Remark 10.1.10 (page 245).
Use for instance
$\require{AMScd}$
\begin{CD}
X      @>f>> Y       @>g>>  Z       @>h>>  TX   \\
@V1VV        @V-1VV         @V1VV          @V1VV \\
X      @>>-f> Y      @>>-g>  Z      @>>h>  TX   \\
\end{CD}
and the fact that a triangle isomorphic to a d.t. is also a d.t. -
so exactness in $D$ has a corresponding exactness in $D^{\text{ant}}$.
So up to (minus-twist-)equivalence the two definitions of a triangulated structure on the the opposite category coincide.

The question related to the "Hom's", whether they are cohomological functors is, as i understand the question, a corrolary of Proposition 10.1.13 (applied for the opposite structure).
(Note that pairwise $f^*$ and $(-f)^*$ have same kernels and images, and $g_*$ and $(-g)_*$ have same kernels and images, since composition is bilinear in additive categories. So the minus-twist-equivalence does not change the cohomology in the end.)


Visual Studio 2019 Debugger only runs once, requires restart to run again

Question: I'm building a .net core react app. When starting the application in debug mode, I have no problems the first time I run, but if I stop debugging and attempt to run again, visual studio will stop debugging on its own as the web page is loading.
If I restart my computer, I can debug again, but if I stop and start, I experience the same issue. Restarting Visual Studio works occasionally, but it seems like I need to close out all instances of it, wait a few seconds, relaunch, wait for a few seconds after everything finishes loading, and then it will work (again, only once).
I'm assuming there's a process that isn't shutting down properly and is blocking the debugger from fully starting but I can't seem to find it. I am also running visual studio as Admin. Any help would be appreciated.
Comment: Have you checked this question? https://stackoverflow.com/questions/34399839/visual-studio-2015-not-working-after-first-successful-debug
Comment: @chakeda Just went through everything. 1) safemode did not allow me to debug at all. It started and stopped without even a first successful run. 2) there are no W3P processes (or IIS processes) associated with my project. I have a few for some other projects that are on my machine but none for the one that is giving me issues. Even when running in debug there is no W3P process associated with it. 3) Terminate all does not resolve the issue. 4) the suggested edits to the debugging settings did not resolve the issue.
Answer: Ok so it's not a complete answer but I found what seems to be causing the issue. When the debug would fail, the URL briefly changed, showing that chrome was attempting to use the legacy browser support extension. After a bit of googling I learned that this could be caused by enabling "Javascript Debugging for ASP.NET" under Tools>Options>Debugging>General. Disabling this checkbox allows me to run debug without any issues.
Since I don't really care about the javascript debugging, this is a suitable enough answer for me, but if anyone else sees this and knows the answer that would keep javascript debugging enabled, please provide the details in case anyone needs it in the future.
Comment: Only thing that worked for me! Thanks.


Simple arithmetic approximations to categorical analyses

Question: Suppose I have a two by two table:
$$
\begin{array}{c|ccc} & Y & \neg Y & \\ \hline
X & a & b& &\\
\neg X & c & d& &\\
\end{array}
$$
and I am interested in testing the hypothesis that $\mathcal{H}_0: P(Y|X) =P(Y| \neg X)$. I don't need an exact result, and I don't have a calculator.
Are there quick arithmetic approximations to the test-statistic or p-values for common tests of this hypothesis? Pearson Chi-Square independence test, Fisher's Exact Test, exact binomial test, etc.
What about special cases when the distributions have some reasonable assumptions

$Y$ is common in both $X$ and $\neg(X)$ so normal approximations to sample proportions hold
$Y$ is rare in both $X$ and $\neg(X)$ so Poisson approximations to $Y$
$X$ and $\neg X$ is balanced
$X$ is imbalanced by 1/10 or more.
Comment: $\frac {ad-bc}{(a+b)(c+d)(a+c)(b+d)}$. If it >= 3.84, p< 0.05, if >= 6.63 p<0.01.
Comment: @whuber the idea is to use an approximation to get something at least a little computationally easier than finding the exact statistic, even though I agree it can be done with pencil-and-paper. If a decent approximation can be done mentally, all the better (though even that is subject to debate depending on who's reading the question). As an illustration, the approximation $e^x \approx x$ when $|x| < \epsilon$ or $x$ is very small has been useful for both verifying computation and simplifying complex expressions.
Comment: Could you be more specific about what "don't have a calculator" really means?  After all, it's not difficult to compute the chi-squared statistic for this table with pencil and paper or, if you're used to this sort of exercise, in your head.  That reduces the question to finding p-values for a $\chi^2(1)$ statistic.
Answer: Stuart Pocock published an article on this significance test for the analysis of a 1:1 randomization design:
If A is the number of events in Arm A and B is the number of events in Arm B, then the ratio:
$$Z = \frac{A-B}{\sqrt{A+B}}$$
has approximately a Normal 0,1 distribution under the null and can be used to calculate the p-values.


YouTube API - No channel branding settings returned for queries by username

Question: When using the YouTube API v3 to query a channel's branding settings, why are they returned for queries by channel ID, but not for queries by username? The API doesn't return branding settings for channel list queries by username.
If you query for a channel's branding settings by channel ID (e.g., id=UC8-Th83bH_thdKZDJCrn88g), you are returned a complete set of branding settings:
Google API Explorer: https://developers.google.com/youtube/v3/docs/channels/list
Request
GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&id=UC8-Th83bH_thdKZDJCrn88g&key={YOUR_API_KEY}

Response
{
    // ... snip ...
    "items": [
    {
        "kind": "youtube#channel",
        "etag": "\"...\"",
        "id": "UC8-Th83bH_thdKZDJCrn88g",
        "brandingSettings": {
            "channel": {
                "title": "The Tonight Show Starring Jimmy Fallon",
                "description": "Watch The Tonight Show Starring Jimmy Fallon Weeknights 11:35/10:35c\n\nThe Tonight Show Starring Jimmy Fallon features hilarious highlights from the show including: comedy sketches, music parodies, celebrity interviews, ridiculous games, and, of course, Jimmy's Thank You Notes and hashtags! You'll also find behind the scenes videos and other great web exclusives.",
                // all the branding settings are here
            }
        }
    }]
}

If, on the other hand, you send a channel list query for a username (e.g., forUsername=latenight), you get no branding settings at all. The branding settings aren't returned or populated.
Request
GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&forUsername=latenight&key={YOUR_API_KEY}

Response
{
    // ... snip ...
    "items": [
    {
        "kind": "youtube#channel",
        "etag": "\"...\"",
        "id": "UC8-Th83bH_thdKZDJCrn88g"
    }]
}

Answer: I may be wrong, but I believe that, in v3 of the APIs, Channel IDs are the only way to get a full response, as the concept of a "username" doesn't really exist in the same way anymore. That is, newly created YouTube channels are linked to a G+ profile and can have a display name, but there isn't really any YouTube username anymore associated with such a channel.
Because usernames used to exist, though, and many channels are still known by them, the "forUsername" parameter is there to provide you the associated channelID and then issue the request for the branding settings with that.
Now, having said that, it's clear that the language on the API explorer page doesn't reflect that, and perhaps therein lies the problem; I'm taking my inferences from this documentation:
https://developers.google.com/youtube/v3/guides/working_with_channel_ids#v3
and from this bug report:
https://code.google.com/p/gdata-issues/issues/detail?id=4821&q=forUsername&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary
But it's always possible, too, that I'm reading incorrectly and you're actually seeing a new bug. The only way to know for sure would be to file it (or perhaps someone on the team could comment here)?
Comment: Nope, I'd say the guide you linked pretty well covers it, thanks. Somehow my searches just missed it. "*...v3 was designed to treat channels with and without legacy usernames identically, and that means using channel IDs everywhere.*" If a username exists and identifies one or more channels, it doesn't really explain why it shouldn't return the same results, but I see now that's the choice that's been made.


Check if email is digitally signed using VB.Net

Question: I would like to know if it's possible, using VB.Net, to check if an e-mail is digitally signed and who is the issuer of the certificate.
Using Extended MAPI Wrapper and Cryptography I was able to get the smime.p7m attachment from an e-mail and get the certificate information out of it (including the issuer), so it seemed like everything was working. The issue is that if I send an unsigned e-mail and manually attach a smime.p7m file, it will trick the code into thinking that the e-mail is signed.
Does anyone have a solution for this? I can also use other methods like Outlook Interop.
Answer: Outlook Object Model always tries to represent signed and encrypted messages as regular MailItem objects. The MessageClass property will return "IPM.Note". It goes as far as returning a fake IMessage object from the MailItem.MAPIOBJECT property.
If you are using Extended MAPI, you can read the PR_MESSAGE_CLASS property and check if its value corresponds to one of the signed/encrypted message classes (e.g. "IPM.Note.SMIME.MultipartSigned"). Just make sure to unwrap the IMessage object if you are retrieving it from the MailItem.MAPIOBJECT property.
You can also use Redemption (I am its author) and and its RDOEncryptedMessage object - it allows to decrypt an encrypted message using RDOEncryptedMessage.GetDecryptedMessage  message as well as access the certificate properties.
Answer: If you have a truly signed S/MIME message, then the "smime.p7m" attachment will either have a Content-Type value of application/pkcs7-mime; smime-type=signed-data -or- it will have a Content-Type value of application/pkcs7-signature and will be the 2nd child MIME part of a multipart/signed container.
To visualize:
Option 1:
Content-Type: application/pkcs7-mime; smime-type="signed-data"; name="smime.p7m"
Content-Disposition: attachment; filename="smime.p7m"
Content-Transfer-Encoding: base64

Option 2:
Content-Type: multipart/signed; boundary="some-bounary-string"; protocol="application/pkcs7-signature"

--some-boundary-string
Content-Type: text/plain

This is the message content that was signed...

--some-boundary-string
Content-Type: application/pkcs7-signature; name="smime.p7m"
Content-Disposition: attachment; filename="smime.p7m"
Content-Transfer-Encoding: base64

...
--some-boundary-string--

I'm not familiar with the Exchange MAPI wrapper API, but there should be a way to get the Content-Type value. Depending on what that is, you can check for the other attributes I mentioned above to verify if it is actually a signed message or just an attachment.
Note: They can also be application/x-pkcs7-mime and application/x-pkcs7-signature, but other than the leading x- of the MIME subtype, the logic is the same.
Comment: But if I send a signed email and download it's smime.p7m file, it will have all this information that you said, and I can re-attach it to some other e-mail to make the code think that it's signed, I would just have to identify/modify the body part of the smime file (Content-Type: text/html) and keep the same certificate data.
Comment: You're not making any sense. If you take the smime.p7m signature data from 1 message and add it to another message with a different text/html content, then it won't magically become a signed message. It won't even *look* that way unless you create a multipart/signed container that contains the text/html *and* the smime.p7m data with the correct Content-Type (if you try to attach a smime.p7m file using a mail client, it'll have a Content-Type of application/octet-stream, not application/pkcs7-signature - the mail client also won't add it to a multipart/signed, it'll add it to a multipart/mixed)
Comment: Is it possible for someone with my level of knowledge to construct a message that will fool a client or library into thinking that a message *looks* signed when it isn't? Sure, but that's why you implement logic to *verify* the digital signature.


Gradle native c++ non source files resources or assets folder location?

Question: Context: I am primarily a Java developer and I use gradle for all my builds. As a hobby I've been playing around with C/C++ and found that gradle has the ability to build these as well. So instead of learning cmake/make just for some small hobby projects I thought I'd use gradle since I am familiar with it.
Question: How do I define locations for non-source files?
With Java there is a resources folder that you can put things like images, text files, etc... in and gradle will put these in the jar so in your code you can load them with relative paths pretty easily.
src > main > java for source files.
src > main > resources for assets.
Is there an equivalent way to do this for c++ projects?
Also if there is a default folder that would be good to know, but also how to define it in the build.gradle file to a different location would also be appreciated.
For reference here is my simple build file right now:
apply plugin: "cpp"

model {
  components {
    main(NativeExecutableSpec) {
      sources {
        cpp {
          source {
            srcDir "src"
          }
        }
      }
    }
  }
}

In my code I'd like to be able to load an image, for example, with something like:
HoweverYouLoadAnImageInCpp("imageName.png");

While having a simple structure like:
root
--src
--images

If there is no way to currently do this, is there a workaround or a more standard way people do this in C/C++?
Comment: It's not possible in pure C or C++, platforms have answers to this problem, windows for example has the resource file which gets bundled into the built executable. I don't know what equivalent *nix has.
Comment: I hadn't completely considered that it might not be possible to bundle the assets in the executable. So is it common for assets to be stored outside the executable in a separate folder and accessed that way? Maybe copy the assets to a parallel folder in the build output.
Answer: As mentioned in the comments, unlike jars in java, c/c++ does not seem to have a standard way of including assets in the executable. There do seem to be platform specific ways and gradle does seem to have support for Windows resource files, so if that is what you are looking for see the gradle docs.
I prefer not to do any platform specific things though so I thought I'd answer this with what I decided to do in case someone else finds this question with a similar need. If another, better, answer pops up and I notice I will change the selection.
In the end the executable will look for paths relative to where it is executed (from what I can tell at least.) So I just made a copy task to put the assets in a parallel folder.
task copyAssets {
  copy {
    from "."
    into "build/exe/main"
    include "images/**" // This will take the whole images folder from project root
  }
}

build.dependsOn copyAssets

So when I gradle build now it will copy my images folder to the same folder that it builds my 'main' cpp source executable. And in my code I can access those images with:
HoweverYouGetImages("images/imagename.png");

You could of course get more fancy with your task and zip it up or compress your images and decompress on loading in your code.


Titanium/ Appcelerator/ Alloy: Unable to get current location despite success returning true

Question: I am running the following code using the iPhone 4s simulater:
Ti.Geolocation.getCurrentPosition(function(e){
    Ti.API.log(JSON.stringify(e));
});

A formatted version of the output of the above gives the following information:
{
    "code": 0,
    "type":"location",
    "error":"The operation couldn't be completed. (kCLErrorDomain error 0.)",
    "source":{},
    "success":true
}

There seems to be quite contradictory information. It says success is true yet gives an error message.
Furthermore, according to the Location Results Docs, it says that if success is true, it should return a coords field. Yet the above does not have coords on it.
Please also note both of the following returns true so its not a permission issue:
Ti.Geolocation.locationServicesEnabled;
Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS);
Answer: There are 2 things to take notes of:

locationServicesEnabled property for device
hasLocationPermissions method

First of all, you will need to check for 1st property to make sure that the device location is on.
Then you will check for hasLocationPermissions because this can be true even the device location is not on, which I think is your case.
Sample code for this:
var authType = Ti.Geolocation. AUTHORIZATION_ALWAYS;

if (Ti.Geolocation.locationServicesEnabled) {
    if (Ti.Geolocation.hasLocationPermissions(authType)) {
        // voila...
    } else {
        Ti.Geolocation.requestLocationPermissions(authType, function (e) {
            if (e.success) {
                alert('voila...');
            }
        });
    }

} else {
   alert('Please turn on your device's location');
}

Comment: I have edited the question and it shows that `locationServicesEnabled` is true as well. It also does not deal with the fact that `e.success` is `true` yet it gives an error message. This is against what it says on the docs.


joining two tables in SQL based on one common value

Question: I have two tables in my SQL database. I need to create a report that would show me the strStoredAcctID based on lngItemID that I enter. When the search is performed I only know the 41139320 number. I don't know how to combine the two queries based on the information I have.  Here's the query I used.
SELECT  tblItem.lngItemID, tblItem.lngEntitleItemIDRef
FROM tblItem
WHERE   tblItem.lngEntitleItemIDRef = 41139320

SELECT tblStoredValue.lngItemID, tblStoredValue.strStoredAcctID
FROM tblStoredValue
WHERE tblStoredValue.lngItemID = 41886227

Instead of running two, I would like to be able to type in the lngItemID = 41139320 only and receive the strStoredAcctID. Any help is greatly appreciated.
Comment: if you tighten up your query, you might be able to get way with a simple union
Answer: This should do the trick JOIN
SELECT tblStoredValue.strStoredAcctID FROM tblItem
LEFT JOIN tblStoredValue on tblItem.lngItemID=tblStoredValue.lngItemID
WHERE tblItem.lngEntitleItemIDRef = 41139320

Comment: The OP states the desired result is to only get `strStoredAcctID`.
Comment: Easily fixed :)
Answer: Try this, it uses the result set of the first query to filter the data of the referencing query, this is called a subquery - https://learn.microsoft.com/en-us/sql/relational-databases/performance/subqueries?view=sql-server-ver15
SELECT tblStoredValue.lngItemID, tblStoredValue.strStoredAcctID
FROM tblStoredValue
WHERE tblStoredValue.lngItemID IN (
    SELECT tblItem.lngItemID
    FROM tblItem
    WHERE tblItem.lngEntitleItemIDRef = 41139320
)

Comment: Can you please explain why a simple `INNER JOIN` with a `GROUP BY` won't work?
Comment: No ```GROUP BY``` because I'm not sure of the first queries results could have multiple corresponding results for the next query. @devlincarnate Happy for you to show me how you would do it?
Comment: Thank you! I received the following error: "Only one expression can be specified in the select list when the subquery is not introduced with EXISTS."
Comment: Thats fixed now, apologies! try again
Answer: Try this:
SELECT tblStoredValue.strAcctID
FROM tblItem
INNER JOIN tblStoredValue ON tblStoredValue.lgnItemID = tblItem.lgnItemID
WHERE tblItem.lgnEntitleItemIDRef = 41139320

Comment: Thank you! I do get two records when I run the query. One with the strStoredAcctID and the other is NULL. It's honestly fine and I can live with it.


jquery simple pop up not working for some reason

Question: just trying to get this working:

<%= link_to(image_tag('populisto_logo_for_web1.png', :alt => t('application.title')), root_path) %>

<%= link_to "Create Contacts", reviews_path %>

<%= link_to "Your Address Book", resource_home_path(current_resource) %>

Invite Others

<%= link_to "About Us",about_us_path %>

Any ideas? I click the 'Invite Others' button and nothing happens....
Comment: Are you including jQuery?
Answer: Your dom is not ready yeat when you call jquery. change your code to
$(function(){
     $("#coming_soon").click( function()
           {
             alert('Coming soon....');
           }
        );
  });

Comment: Excellent, works perfect. But I think it's great that in Rustkill's answer the whole script part isn't even needed! Thanks again...
Answer: For something as simple as an alert you could just try something like this:
Invite Others

No jQuery required.


Spock - mocking external service

Question: I'm very new in spock framework testing and I didn't find any example where I can find needed information. Therefore, I think the best way is to show an example what I need to have.

e.g. test class in spock:
def "getData" (){ // this is test of getData method from ExternalService
  when:
    Result result = externalService.getData()
  then:
    result.msg = 'SUCCESS'
}

Service Class:
public class ExternalService(){
  private ServiceConnector serviceConnector;

  public Result getData(){
    Result result = serviceConnector.callAndGet();
    prepareInformation(data);
    updateStatuses(data);
    return result;
  }
}

Class Data as a Domain Class:
public class Data {
  private String msg
  private int Id
  // +getters/setters
}

And now I have getData test and would like to mock the only method callAndGet(). It means every time I call callAndGet I need to have object Data with msg SUCCESS but all other methods from getData method should be called normally.
Is it quite understandable? The question is how can we inject/mock the service class ExternalService into the spock test class?
Answer: What you need to do is to mock the ServiceConnector class and pass it via constructor (e.g.). See below:
@Grab('org.spockframework:spock-core:1.0-groovy-2.4')
@Grab('cglib:cglib-nodep:3.1')

import spock.lang.*

class Test extends Specification {
    def 'some spec'() {
        given:
            def serviceConnector = Mock(ServiceConnector) {
                callAndGet() >> new Result(msg: 'SUCCESS')
            }
            def externalService = new ExternalService(serviceConnector)

        when:
            Result result = externalService.getData()

        then:
            result.msg == 'SUCCESS'
    }
}

public class ExternalService {
  private ServiceConnector serviceConnector

  public ExternalService(ServiceConnector serviceConnector) {
      this.serviceConnector = serviceConnector
  }

  public Result getData() {
    Result result = serviceConnector.callAndGet()

    prepareInformation(result)
    updateStatuses(result)
    result
  }

  private void prepareInformation(Result data) {
  }

  private void updateStatuses(Result data) {
  }
}

public class ServiceConnector {
    public Result callAndGet() {

    }
}

public class Result {
    String msg
}

Answer: You shouldn't try to mock "only one method" of your services. It's just a sign of a bad design, your code is not testable. You should better isolate the dependencies of your class with small services and mock this services in an unit test. Then test the upper layer with an integration test and a complete implementation of your dependencies.
In your example, ServiceConnector should be an interface, which can be easily mocked. With this condition, the test can be written as :
def "test a mocked service connector"() {
  given: "a service connector"
    def serviceConnector = Mock(ServiceConnector)

 and: "an external service"
   def externalService = new ExternalService(serviceConnector:serviceConnector)

 when: "Data is loaded"
   def result = externalService.data

 then: "ServiceConnector is called"
   serviceConnector.callAndGet() >> new Result(msg:"SUCCESS")

 and: "Data is mocked"
   result.msg == "SUCCESS"
}

However, if ServiceConnector is a class and you can't change this, you can use a Partial Mock in Spock. This kind of test are hard to maintain, and can have a lot of side effect :
def "test a mocked service connector"() {
  given: "a service connector"
    def serviceConnector = Spy(ServiceConnector) {
      callAndGet() >> new Result(msg:"SUCCESS")
    }

 and: "an external service"
   def externalService = new ExternalService(serviceConnector:serviceConnector)

 when: "Data is loaded"
   def result = externalService.data

 then: "Data is mocked"
   result.msg == "SUCCESS"
}

Spock - mocking external service


What is the most efficient way to automatically create a home folder for a user in Windows 2012 Server R2

Question: i am looking for a more efficient way to automate home folder creations for our users instead of using active directory and right clicking and selecting properties  on the user and manually entering it every time under the "profile Tab".  is there a way using a GPO or do i have to create a powershell script, or is there some type of built in tool on windows server 2012 R2. I would like to Avoid powershell scripting if possible.
Answer: GPO with wildcard redirect.
Check out: https://msdn.microsoft.com/en-us/library/cc786749%28v=ws.10%29.aspx?f=255&MSPPError=-2147217396 which is titled "Configuring Folder Redirection".
https://social.technet.microsoft.com/Forums/windowsserver/en-US/e999e32f-aaf4-4b8b-86e8-a5a2edde3dbb/group-policy-folder-redirection-using-username-variable
explains how you can embedd the username in the GPO so every user gets a separate path. Happens thre is a %username% variable available.


what is the default location where metrics are stored after installing collectd?

Question: I installed Collectd in CentOS 7.2 I followed the link.
http://www.tecmint.com/install-collectd-and-collectd-web-to-monitor-server-resources-in-linux/2/
After I started Collectd from what I read the one of the default metric is CPU. I was not able to find the location where this information is collected.
Thanks
Answer: Collectd provides mechanisms to store those metrics in different ways. One being in RRD files.
If you choose that method, you'd want to enable the plugin rrdtool in /etc/collectd.conf and specifically set the Directory to store those files as well:
LoadPlugin rrdtool

<Plugin rrdtool>
     DataDir "/var/lib/collectd/rrd"
</Plugin>


Jquery onclick event with angular datatable

Question: I have to open a new link whenever a column of datatable is clicked. Here's my datatable code which is fetching data through ajax call-

         Feature
         ID
         Log
         Location

Here's my Jquery Code i was trying -
$('.featuretable tbody').on('click', 'tr', function () {
    console.log(table.row(this).data());
    var data = table.row(this).data();
    alert('You clicked on ' + data[1] + '\'s row');
});

The css file reads-
.Header {
    border-bottom: 2px solid #6f7277;
    padding: 3px 15px;
    text-align: left;
    color: #4b4a4a;
    overflow: hidden;
}

table.featuretable {
    table-layout: fixed;
    width: 100%;
    font-family: Helvetica, Arial, sans-serif;
    margin-top: 20px;
    margin-bottom: 20px;
    border-collapse: collapse;
    border-spacing: 0;
}

table.featuretable td,
th {
    border: 1px solid transparent;
    height: 30px;
    transition: all 0.3s;
    overflow: hidden;
}

table.featuretable th {
    font-weight: bold;
    text-align: center;
    vertical-align: :middle;
}

table.featuretable td {
    text-align: center;
    vertical-align: :middle;
}

table.featuretable tr:nth-child(even) td {
    background: #f3f7fb;
}

table.featuretable tr:nth-child(odd) td {
    background: #ffffff;
}

on click , chrome is giving the error "ReferenceError: table is not defined" . Anyone know how to do this ?
Comment: can you give me some more information about the `table` class you're using? I'm unfamiliar with it.
Comment: I've added the css code now.
Comment: My bad. I was talking about the js `table` class you try to use at `console.log( table.row( this ).data() );`. Is it part of the datatables? Or do you define it earlier?
Comment: Nope. That's the part where i'm wrong. In jquery we usually define (#table).datatable, which then works but In angular all we have to do is say datatable in the table tag. In short, no I haven't defined table class. Table.row is just supposed to be a jquery function.
Comment: Looking at your code, you are referencing "table". Where is this defined? We probably need to see more of your JS code, or make a jsbin/plunkr.
Comment: I think i didn't define it. Should it not reference the table class featuretable? else , could you tell me how to do that ?
Comment: ok, so I have to ask. Why are you trying to mix jQuery and AngularJS? Can't you implement the desired logic within AngularJS? Maybe using a directive?
Answer: Since you are using the angular dataTables directives you should define a dtInstance and work on that instead :
$scope.dtInstance = {}

Then in your jQuery event handler, use dtInstance as the table reference
$('.featuretable tbody').on('click', 'tr', function () {
   var data = $scope.dtInstance.DataTable.row( this ).data();
   alert( 'You clicked on '+data[1]+'\'s row' );
} );


How to show that $Y$(martingale transform) has equal $L_2$ norm to $X$(martingale or supermartingale)?

Question: $\mathbf{Definition}$:
We have that $C$ and $X$ are stochastic processes. The process $(C∘X)$ is martingale transform, where
$$(C∘X)_n:=\sum_{k=1}^n C_k(X_k-X_{k-1})=\sum_{k=1}^nC_kΔΧ_k,$$
when $n\geq1$ and $(C∘X)_0=X_0.$
$\mathbf{Theorem}$:
Let $\mathbf{F}$ be a history, the process $X$ satisfies $X\in \mathbf{F}$ and $C$ is a predictable process.
1)If in addition $0\leq C_n(\omega)\leq K$ and $X$ is a supermartingale, then $Y=(C∘X)$ is a supermartingale.
2) If in addition $|C_n(\omega)|\leq K$ and $X$ is a martingale, then $Y=(C∘X)$ is a martingale.
I want to show that $Y$ and $X$ have equal $L_2$ norm.
I've been studying this .pdf http://math.aalto.fi/teaching/stokanal/lecture2.pdf and i trying to understand how i am going to do that. The only thing that i think will help is that the norm of a martingale is a sub-martingale. But i have no idea how to continue.
Comment: I don't think that $X$ and $Y$ will have the same $L_2$ norm.  If you take $C=2$ then $C$ is clearly predictable and bounded, but $Y_n = 2 X_n$ so $\|Y_n\|_{L_2} = 2 \|X_n\|_{L_2}$
Comment: But $C$ is a stochastic process . Maybe i am missing something.
Comment: Right, I suppose I abused notation there.  I meant if you take $C_n(\omega)=2$ for all $n, \omega$.
Comment: So if your example doesn't violate anything i am guessing that you're correct. So by only taking $C_n(\omega)=1$ for all $n,\omega$ then we will have that $||Y_n||_{L_2}=||X_n||_{L_2}$?
Comment: That would certainly work, but I don't think that's the only way to make it work.  I'm not sure that you need them to have equal $L_2$ norms for the theorem proof, though.  I would try just computing $\mathbb{E}[Y_n | \mathcal{F}_{n-1}]$ and checking the definition of a (super-)martingale.
Comment: Yeah, the proposition doesn't work all the time, so it's not worth it in my opinion to try and find all times that it works. My teacher in college made this proposition but he didn't give us the proof... he just stated it. I'll tell him that the proposition doesn't hold all the time. Thank you very much for helping me by the way!
Answer: So the theorem itself is definitely correct, it's just the part about the $L_2$ norms being equal that doesn't work.  Here is the proof for part i):
We want to show that $Y$ is a super-martingale, so we need to show $\mathbb{E}[|Y_n|] < \infty$ and $\mathbb{E}[Y_n | \mathcal{F}_{n-1}] \le Y_{n-1}$ for all $n$.
First we will show $\mathbb{E}[|Y_n|] < \infty$  (showing this one first because it makes sure that $\mathbb{E}[Y_n|\mathcal{F}_{n-1}]$ is well-defined).  We compute
\begin{align*} \mathbb{E}[|Y_n |]&= \mathbb{E}\left[\left\lvert \sum_{k=1}^n C_k (X_{k}-X_{k-1}) \right\rvert\right] \\
&\le \mathbb{E}\left[ \sum_{k=1}^n |C_k|\cdot |X_{k}-X_{k-1}|\right] \\
&\le \mathbb{E}\left[ \sum_{k=1}^n K|X_{k}-X_{k-1}|\right] \\
&\le \mathbb{E}\left[ \sum_{k=1}^n K (|X_{k}|+|X_{k-1}|) \right] \\
&= \sum_{k=1}^n K (\mathbb{E}[|X_k|] + \mathbb{E}[|X_{k-1}|]) < \infty.
\end{align*}
Now we need to show $\mathbb{E}[Y_n | \mathcal{F}_{n-1}] \le Y_{n-1}$.  We compute
\begin{align*} \mathbb{E}[Y_n | \mathcal{F}_{n-1}] &= \mathbb{E}[Y_{n-1} + C_n(X_n-X_{n-1}) | \mathcal{F}_{n-1}] & \\
&= Y_{n-1} + \mathbb{E}[C_n(X_n - X_{n-1})|\mathcal F_{n-1}] & \\
&= Y_{n-1} + C_n \mathbb{E}[X_n-X_{n-1}|\mathcal{F}_{n-1}] &
\end{align*}
where we were able to pull $C_n$ out of the conditional expectation because $C_n$ is $\mathcal{F}_{n-1}$ measurable.  Now since we were told $X$ is a super-martingale, we know $\mathbb{E}[X_n-X_{n-1}|\mathcal{F}_{n-1}] \le 0$, and since $C_n(\omega) \ge 0$ for all $\omega$ this implies $C_n \mathbb{E}[X_n-X_{n-1}|\mathcal{F}_{n-1}] \le 0$.  Therefore we conclude $$\mathbb{E}[Y_n | \mathcal{F}_{n-1}]  = Y_{n-1} + C_n \mathbb{E}[X_n-X_{n-1}|\mathcal{F}_{n-1}]  \le Y_{n-1},$$
so by the definition of a super-martingale, $Y$ is a super-martingale.
Comment: So for the second part we say that :$$E\left[ (C∘X)_{n+1}-(C∘X)_{n}|\mathcal{F}_n \right]=E\left[C_n(X_{n+1}-X_n)|\mathcal{F}_n\right]=C_n E\left[(X_{n+1}-X_n)|\mathcal{F}_n\right]=0 $$
Comment: That's pretty much it.  Possibly just a typo, but only thing is that it should be $C_{n+1}$ instead of $C_n$ (that's why it's important $C$ is predictable instead of just adapted).
Comment: Yeah that was a typo :D. By the way if you have time do you mind checking my question regarding the $L_2$ norm of $Y$ with  $\textbf {Itô′s isometry}$


Change detection in trending degradation data

Question: I'm working with degradation data and are trying do use change detection methods to detect repairs. Since I'm looking for repairs I'm only interested in positive changes. Between the repairs the data has a negative trend, differing between the periods.
I'm currently applying lowess as a first step since the data is rather noisy. The detection is done by computing the one step gradient and detecting points with a gradient higher than a set limit.
This approach is working relatively well but I would like to compare with some other approaches. Due to the negative trend between repairs I'm not sure which methods are appropriate. Any suggestions would be much appreciated.
An additional note is that repairs have a minimum interval which means after detection there shouldn't be any other detections within a set period. If multiple detections are made some sort of ranking would be suitable. My current idea is the largest gradient but I have a feeling that the performance won't be what I'm looking for.
Comment: Mice? Imputation of missing data.  https://datascienceplus.com/imputing-missing-data-with-r-mice-package/
Answer: Since you expect a trend in you data, Holt-Winters could be a good candidate. There also is an extension that deals with cyclic data (seasonality), triple exponential smoothing.
These models are generalizations of simple, weighted and exponential moving average. They help to filter noisy data and to forecast. For more information see: http://en.wikipedia.org/wiki/Exponential_smoothing
Change detection can be added by checking if the forecast is positive. Time-out periods I would somehow fit in manual.
Comment: I implemented a EWMA instead of the LOWESS and the detected changes are slightly closer to the truth. I still have some false positives and false negataives, which will probably be inevitable.

To clearify what I'm trying to do, the detection of change points is just a step taken to be able to estimate the degradation trends in the periods between repairs. The trends will later be used to predict the date of coming change points.
Answer: The EnvCpt R package can fit changepoint models with trends (and other features such as autocorrelation which can be present in this sort of data).  You can set a minimum segment length which could be equal to the minimum time between repairs (or slightly smaller may give better results), if there are multiple potential candidates for a "repair point" then it will choose the "best" from a statistical criteria optimization perspective.
The code doesn't restrict to negative gradients but you could modify it to do so.
https://cran.r-project.org/web/packages/EnvCpt/index.html