"content: attr" não valida no W3C

Question: Como resolver esse erro na linha table td:before {content: attr(db); que faz com o que não valide no W3C?
<!DOCTYPE html>

Nome
Data de Nasc.
Salário
Cargo

Adão
01/01/1980
R$ 1.250,00
Auxiliar de produção

Eva
01/01/1980
R$ 2.500,00
Gerente

Comment: Rose eu entendi agora você trocou por isto `{content: "NOME: ";}`, mas entenda isto `{content: "NOME: ";}` é diferente disto `{content: attr(db);}`, é totalmente possivel validar o `{content: attr(db);}` em http://www.css-validator.org como eu disse na resposta, mas se o alternativo lhe resolveu ok. :)
Comment: Que bom que você gostou das respostas! A melhor forma de agradecer quem te ajudou é assinalando a melhor resposta como aceita e votando em todas que te ajudaram. Assim você garante que quem escreveu a resposta receba algo em troca, além de tornar o site mais limpo e útil pra todo mundo.
Answer: Vou arriscar a dizer que há um erro no Validador, pois as documentações (W3C, CDN Mozila, CND Mozila, W3Schools), dão vastos exemplos de como usar o attr em content, e estes exemplos não validam, pode testar. Então vai a dica comenta a linha /{content: attr(db);/ e valida, vai dar certo (levando em consideração o erro do validador).
Para fazer de acordo com os padrões HTML 4, o elemento td não possuí atributo db (vide Documentação), utilize então o abbr (vide Documentação) no lugar do db.
content: attr(abbr);

Adão

Em resumo, comente a linha valide e seja feliz, pois nem a documentação da organização que valida está válida :).
Para HTML 5 use a dica do Afonso abaixo:
Comment: Ta certo valeu a dica.. já consegui resolver de outra maneira no <td coloquei um class="c1" e no style .c1::before {content: "NOME: ";} fiz uma modificações e agora esta como eu queria um CSS nível 3 ! sem erros de validação.
Answer: O erro do validador é justamente com o atributo db, porém não existe nenhum erro nesse código CSS.
A ressalva está, justamente, nos atributos db e abbr. O atributo db não existe, e para esses casos o padrão orienta que se use o prefixo data-, ou seja, o atributo deveria ser escrito como data-db. Através deste prefixo podemos escrever qualquer atributo que não esteja na especificação do HTML.
Além disso, o abbr sugerido em outra resposta não faz mais parte da especificação e não deve mais ser utilizado. Está obsoleto desde a versão 5 do HTML (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td).
Comment: O erro não é no atributo db, é do validador mesmo.
Answer: Realmente existe um problema é na hora de validar pelo https://jigsaw.w3.org/css-validator ele mostra este erro:

Value Error : content Parse Error attr(db)

Como na imagem:

O valor attr no content: não era suportado até algum tempo, mas hoje já é parte do CSS3, então se trata de um BUG https://github.com/w3c/css-validator/issues/24
No entanto se tentar validar em http://www.css-validator.org/ ele funciona normalmente (selecione em More Options > Profile : a opção CSS level 3, porque senão ele vai usar a versão 2.1) ele irá validar normalmente, veja o resultado:

Considerações sobre o HTML

não use abbr=, ele está em desuso no html5.
O atributo db é invalido.
Ao invés de db="" use o atributo data- que é especifico pra este tipo de tarefa.

Agora informações adicionais:

Falta as tags ,  e <title> se não ele não valida

HTML e CSS validos
<!DOCTYPE html>

        <title>Exemplo</title>

        Nome
        Data de Nasc.
        Salário
        Cargo

    Adão
    01/01/1980
    R$ 1.250,00
    Auxiliar de produção

    Eva
    01/01/1980
    R$ 2.500,00
    Gerente

Validado 100% em:

https://validator.w3.org/#validate_by_input
http://www.css-validator.org/

Dicas:

Realmente é bom validar o CSS e o HTML, mas não é tão importante assim, tem coisas como esta que funcionam mas não validam, então prefira apenas se importar se o CSS funciona em todos navegadores que deseja, mesmo que não valide.
Estão aparecendo muitas novas funcionalidade no CSS, nem tudo estará listado no validador e podem aparecer estes falsos problemas.

Resumindo, tente validar o que der, mas se algo falhar não se prenda tanto a isto, desde que funcione em todos navegadores que seus clientes usam (de preferencia os mais modernos) então estará tudo bem.

"content: attr" não valida no W3C


Do we have $(g \wedge g)^g = 0$?

Question: Let $g$ be a simple Lie algebra. Let $(g \wedge g)^g = \{a \wedge b \in g \wedge g: x.(a \wedge b) = [x,a] \wedge b + a \wedge [x,b] = 0\}$ be the set of $g$ invariants under the adjoint action.  Do we have $(g \wedge g)^g = 0$? If $g$ is a semisimple Lie algebra (respectively any Lie algebra), do we have $(g \wedge g)^g = 0$? Any help will be greatly appreciated!
Answer: Edit: I am sorry, I was not careful with my first answer, which was wrongly suggesting that the question was about the second Lie algebra cohomology of ${\mathfrak g}$.
The Killing form identifies ${\mathfrak g}\wedge{\mathfrak g}$ with skew-symmetric bilinear forms $\mu: {\mathfrak g}\otimes{\mathfrak g}\to {\mathbb k}$; such a form is ${\mathfrak g}$-invariant precisely if it is associative in that $\mu([X,Y],Z)=\mu(X,[Y,Z])$. Now such associative forms correspond to ${\mathfrak g}$-module homomorphisms ${\mathfrak g}\to{\mathfrak g}^{\ast}$, and by the assumption that $\mathfrak g$ - hence also its dual - are simple ${\mathfrak g}$-modules, such are unique up to scalar. Now, the Killing form is one such morphism, and its associated form is symmetric; consequently, any associative form on ${\mathfrak g}$ must be symmetric, and we conclude that $({\mathfrak g}\wedge {\mathfrak g})^{\mathfrak g} = 0$.
Remark: Is there a way to deduce the symmetry of associative forms without considering the Killing form?
Comment: thank you very much. Why the problem transforms into finding certain invariant skew-symmetric forms on $\mathfrak{g}$?
Comment: in the case that $g$ is a semisimple Lie algebra, we also have $(g \wedge g)^g = 0$. Is this correct? I searched on google and only find [Whitehead's Lemma](https://en.wikipedia.org/wiki/Whitehead%27s_lemma_(Lie_algebras)). What is the statement of the Whitehead Theorems? Thank you very much.
Comment: @LJR I was wrong with my first answer, see the corrected version.
Comment: @LJR: You're welcome! I hope everything's clear now.

Do we have $(g \wedge g)^g = 0$?


Weird behavior of Non-Lebesgue measurable subset of the Smith–Volterra–Cantor set and pointwise convergence of a sequence of simple functions

Question: I came across this (seemingly?) weird behavior of a sequence of simple functions:
Let $E$ be the Smith–Volterra–Cantor set and $m: \operatorname{Leb}(\Bbb{R}) \to [0, \infty]$ the Lebesgue-measure. Now, because $m(E) > 0$, there exists a non-measurable subset $F$ of $E$.
Using the notation for the construction process of the Cantor set used here, we see that if $x \in E$, then
$$
\{x\} = \bigcap_{j=1}^\infty I_{j,k(x,j)}
$$
for some sequence $(k(x,j))_{j \in \Bbb{N}}$ depending on $x$.
Now, we can write the set $F$ as
$$
F = \bigcup_{x \in F} \bigcap_{j=1}^\infty I_{j,k(x,j)}\,.
$$
Define a sequence of sets $(F_m)_{m \in \Bbb{N}}$ by
$$
F_m = \bigcup_{x \in F} \bigcap_{j=1}^m I_{j,k(x,j)}\,.
$$
and a sequence of functions $(f_m)_{m \in \Bbb{N}}$ by $f_m(x) = \chi_{F_m}(x)\,,$
where $\chi_{F_m}$ is the characteristic function of $F_m$.
If $m$ is fixed, there are only a finite amount of intervals $I_{j,k(x,j)}$, $1 \leq j \leq m$. This means that $F_m$ is a finite union of finite intersections of closed intervals, hence closed. So the functions $f_m$ are measurable.
Now, my intuition says that $f_m \to \chi_F$ pointwise, but this is impossible since $\chi_F$ is not measurable function.
My question is why $f_m \not \to \chi_F$? Is there some insight into this? Or are non-measurable sets just weird? Do I have a mistake somewhere?
Some notes: If $x \in F$, then $x \in F_m$ for all $m$, hence $f_m|_F \to \chi_F|_F$. So $f_m|_{F^c} \not \to \chi_F|_{F^c}$.
Because $\chi_F$ is $0$ on $F^c$, there must exist a point $ x \in F^c$ s.t. $f_m(x) \not \to 0$. So for all $n_0 \geq 1$ there exists $n \geq n_0$ s.t. $f_n(x) = 1$ which just means that $x \in F_n$. So no matter how far in the sequence we go, $x$ belongs to some $F_n$. Because $F_{n+1} \subset F_n$, this means that $x$ belongs to $F_n$ for all $n$?
The set $F$ can't be closed, so it has a limit point in $F^c$...
Comment: I am somewhat hesitant to accept your initial formula; a little more caution might be good there. That said, I think you are on the right track. In particular I think you will find that $\overline{F} \cap F^c = \partial F \cap F^c$ has positive outer measure.
Answer: Since $F$ can't be closed, it has a limit point in $F^c$.
Because $E$ is closed and $F \subset E$, the limit point of $F$ must be in $E \cap F^c$. Now let $x$ be this limit point. Since $x \in E$, we can write
$$
\{x\} = \bigcap_{j=1}^\infty I_{j, k(x,j)}
$$
where $(k(x,j))_{j \in \mathbb{N}}$ is some sequence. Since $x$ is a limit point of $F$, for all $n$ there exists $y_n \in F$ such that
$$
\{y_n\} = \bigcap_{j=1}^\infty I_{j, k(y_n,j)}
$$
and $|x-y_n| < 1/n$. This then implies that
\begin{align}
x \in \bigcap_{j=1}^{r_n} I_{j, k(y_n,j)}
\end{align}
for some $r_n$. Choose one such sequence $(r_n)$. Now it suffices to show that $r_n \to \infty$, because from this it follows that $f_m(x) = 1$ for all $m$ even though $x \notin F$.
Now if $(r_n)$ was bounded, after some index $n_0$ the "route" of $x$, defined by the sequence $k(x,j)$, would differ from the "routes" of all $y \in F$ defined by the sequences $k(y,j)$ after $j \geq n_0$. This then means that for all $j \geq n_0$ and $y \in F$ we have $$|x-y| \geq d(\{x\}, I_{j, k(y,j)}) > 0\,,$$
since $x \notin I_{j, k(y,j)}$ and the distance between different intervals $I_{j,a}$ and $I_{j,b}$ is always positive.  Now this inequality means that $x$ is not a limit point of $F$. This is a contradiction and thus $r_n \to \infty$. So $\lim_{m \to \infty} f_m(x) = 1 \neq \chi_{F}(x)$. This means that the pointwise convergence $f_m \to \chi_F$ fails at every limit point of $F$ that is not contained in $F$.


Recommended tools for benchmarking Ruby and Perl

Question: I want to compare the execution time for mathematical equations for different dynamic, interpreted programming languages like Ruby, Perl, and Python.
In Python, there is the convenient timeit module, which allows me to time, where I can simply time for, e.g., a least squares fit (python_lstsqr(x,y)) via
min(timeit.Timer('python_lstsqr(x, y)',
            'from __main__ import python_lstsqr, x, y')\
                                        .repeat(repeat=3, number=1000))

(here the best of 3 repetitions and 1000 loops per repetition)
Are there equivalents in Perl and Ruby?
Answer: Good old time ?
For Perl, you can use built-in Benchmark or Time::Stopwatch.
For Ruby, the built-in benchmark is good enough.


Scale a highly transactional SQL server

Question: I'm looking to upgrade one of my site servers. The site currently executes around 20m sql queries a day and this is growing quite fast. Right now IO throughput is a real issue, so my idea is to move various databases onto their own disk pairs. My idea is to do something like this:
Config
Disk 1 & Disk 2 / Raid 5,6 or 10 (SAS or SSD) - database 1
Disk 3 & Disk 4 / Raid 5,6 or 10 (SAS or SSD) - database 2
Disk 5 & Disk 6 / Raid 5,6 or 10 (SAS or SSD) - database 3
Disk 7 (SSD) - Transaction Logs
Disk 8 (SSD) - Transaction Logs
My experience is lacking here, so got a few questions:
1)  Firstly, does the above look stupid?
2)  Is there anything I should look out for in the RAID controller, eg. Bandwidth throughput when using SSD?
3)  Are all SSD disks created equal? I've picked up threads saying that certain types are substandard?
4) I'm assuming that for simple two disk mirrors any of those RAID levels will be ok? Bad assumption?
5) Any other tweaks to make this config better?
My site is highly transactional, but the databases aren't that big, only a couple of gigs currently. So my major scaling requirement is IO, not size.. I'll be throwing a lot of RAM at the box as well to put more indexes in memory etc..
Thanks
Dave
Comment: How have you determined you have a disk IO problem?
Comment: Hi SuperCoolMoss, have a large proportion of writelog waits in SQL as well as other IO related waits. And can see that the disks are pretty much maxed out by looking at the relevant IO related performance counters directly on the server.
Comment: What are your io requirements? Are your databases mostly read or write?  How large is your database? How much ram do you have? What is your page live expectancy?
Comment: Hi mrdenny, I can provide all that info but I didn't want to increase the scope of the question too much. 128Gb RAM, all indexes fully in RAM. More Read than Write (about 10:1). I'm guessing with the higher read RAID 10 will be better as reads will be distributed..?
Comment: With all the data in memory already why are you trying to increase the throughput on the disks?  You shouldn't be hitting the disks very hard if at all.  What's the Page Life Expectancy perfmon counter show?  What's the current seconds per read and seconds per write perfmon counters show?
Comment: Hi, all writes will hit the disk, only reads can be serviced entirely from memory. The app is highly transactional, hence lot's of reads and writes..
Comment: Writes are written the transaction log, then flushed to disk upon checkpoint.  Writes aren't written to the data files as they come in.
Comment: Correct, but I think that's not really relevant. Most of our transactions affect single rows. So each update/insert/delete is effectively checkpointed directly after it occurs. In effect each write affects both the transaction log, the data files, and the index files as they occur. But, I think we're getting a little off-topic here...
Comment: Nope, checkpoints only happen about once a minute, at which point the writes are flushed from the write buffer and the transaction log to disk.  The only way that the write buffer would be flushed to disk faster than that would be if the write buffer filled, then SQL would flush the disk.  I'm trying to make sure that you actually need faster disks.
Comment: Hmmm, I never knew that.. I thought checkpoint occurred after each commit..? Thanks, appreciate the info..
Comment: No problem, it's a common misunderstanding.
Answer: No, all SSD's are not equal.  The Intel G2 are quite good, and the Crucial RealSSD are good.  However, the best performance is from the SSD cards that plug into PCI Express slots.  The best of those currently have 1.4 TB/second (sequential) throughput.
The common denominator is random write throughput.  This is best measured by running the Microsoft SQLIO utility.
You may want to go even further and put (some) indexes on a separate file group that are on an SSD.  This may not necessarily help update performance, but would help query performance.  Some queries may never hit the database, only the index(es).
Don't forget TempDB, if you have procedures or queries that use that.
Comment: Thanks Greg, that's a great suggestion..! I've never thought of putting indexes on to their own SSD disks. That would be great for some of the indexes that get updated a lot..

Scale a highly transactional SQL server


How do I solve these bijections?

Question: Let $f$ be a bijection from a set $A$ to a set $B$. The inverse of $f$, noted $f^{-1}$ is the function that assigns to an element $b \in B$ the unique element $a \in A$ such that $f(a)=b$. Hence $f^{-1}(b) = a$ when $f(a) = b$.
Let $f$ be a bijection from a set $A$ to a set $B$. Let $S$ and $T$ be two subsets of $A$.
a)  Show that  $f(S∪T)=f(S)∪f(T)$
b)  Show that  $f(S∩T)⊂f(S)∩f(T)$
c)  Show that  $f^-1(S∪T)=f^{-1}(S)∪f^{-1}(T)$
Answer: 1) Suppose $y\in f(S\cup T)$ $\Rightarrow$ $\exists x\in S\cup T$ such that $f(x)=y$. Thus either $x\in S$ and/or $x\in T$. In either case, $f(x)\in f(S)\cup f(T)$, thus proving $f(S\cup T)\subset f(S)\cup f(T)$. On the other hand, suppose $y\in f(S)\cup f(T)$, then either $\in f(S)$ and/or $y\in f(T)$. In either case $\exists x\in S$ and/or $T$ such that $f(x)=y$, thus implying $f(x)\in f(S\cup t)$.  Hence $f(S\cup T)=f(S)\cup f(T)$.

Let $y\in f(S\cap T)$, thus $\exists x\in S\cap T$ such that $f(x)=y$. So $f(x)\in f(S)\cap f(T)$ $\Rightarrow f(S\cap T)\subset f(S)\cap f(T)$.

3.If you've really understood above two points then it's time to do 3rd on your own.
P.S.-Since you are new to MSE, hence I answered your question. But you should try to show some of your own effort while posting a question.
Answer: Hint:

$f(S \cup T) := \{f(a) \in B ;\, a \in S \cup T\}= \{f(a) \in B ;\, a \in S \text{ or } a \in T\} = \ldots$
$\ldots$

How do I solve these bijections?


Como fazer um switch em Ruby?

Question: Como posso fazer um switch em Ruby?
Comment: Poderia apresentar algum esforço de pesquisa.
Comment: Vários exemplos: http://stackoverflow.com/questions/948135/how-can-i-write-a-switch-statement-in-ruby
Comment: Não sei porque tem gente dando down vote para a pergunta da @mayra. É uma dúvida que muitos iniciantes tem, e pode ser útil para bastante gente, pois pra quem vem de outras linguagens é bem diferente.
Answer: Neste caso o Ruby utliza a estrutura case...when
case objeto
when 1
  puts "Seu número é 1"
when 2..10
  puts "Seu número está entre 2 e 10"
when 11,13,17,19
  puts "é um número primo entre 10 e 20"
when String
  puts "é uma String"
else
  puts "Qualquer outra coisa."
end

Você pode criar essa estrutura sem parâmentro também
case
when objeto < 10
  puts "Menor que 10"
when objeto == 10
  puts "Igual a 10"
when (10..20) === b
  puts "Alguma coisa entre 10 e 20"
end

E também o Ruby interpreta todo tipo de instrução como o case when/ if else enfim... Ou seja:
    objeto = 1
    variable_to_return = case objeto
                           when 1
                             10
                           else
                             'UAHEUHAUEHUAEHUAE sou uma String!'
                         end
   puts variable_to_return  # => 10

Comment: Obrigada Luiz Carvalho

Como fazer um switch em Ruby?


Address parser in spark scala

Question: I have a csv file containing addressId and address of the customers as below

addressId
address

ADD001
"123, Maccolm Street, Copenhagen, Denmark"

ADD002
"384, East Avenue Street, New York, USA

I want to parse the address column to get number, street, city and country. I am given initial code to build on to get the necessary output
object Address extends App {

  val spark = SparkSession.builder().master("local[*]").appName("CustomerAddress").getOrCreate()

  import spark.implicits._

  Logger.getRootLogger.setLevel(Level.WARN)

  case class AddressRawData(
                             addressId: String,
                             address: String
                           )

  case class AddressData(
                          addressId: String,
                          address: String,
                          number: Option[Int],
                          road: Option[String],
                          city: Option[String],
                          country: Option[String]
                        )

 def addressParser(unparsedAddress: Seq[AddressData]): Seq[AddressData] = {
    unparsedAddress.map(address => {
      val split = address.address.split(", ")

      address.copy(
        number = Some(split(0).toInt),
        road = Some(split(1)),
        city = Some(split(2)),
        country = Some(split(3))
      )
    }
    )
  }
  val addressDF: DataFrame = spark.read.option("header", "true").csv("src/main/resources/address_data.csv")

  val addressDS: Dataset[AddressRawData] = addressDF.as[AddressRawData]
}

I assume that I need to use addressParser function to parse my addressDS information. However, the parameter to the function is of type Seq. I am not sure how should I convert addressDS as an input to function to parse the raw data. some form of guidance to solve this is appreciated.
Comment: can you provide an answer to the question please if it was solved
Answer: def addressParser(addressId: String, customerId: String, address: String): AddressData = {
    val split = address.split(", ")
    AddressData(addressId, customerId, address, Some(split(0).toInt), Some(split(1)), Some(split(2)), Some(split(3)))
  }

  spark.udf.register("addressParserUDF", addressParser _)

  val groupedAddressDataDS = addressDF
    .selectExpr("customerId", "addressParserUDF(addressId, customerId, address) as parsedAddress")
    .groupBy("customerId")
    .agg(Map("parsedAddress" -> "collect_set"))
    .withColumnRenamed("collect_set(parsedAddress)", "address")
    .select($"customerId", $"address")

  // Join customerAccountDS and groupedAddressDataDS by customerId
  val customerDocumentDS = customerAccountDS
    .join(groupedAddressDataDS, Seq("customerId"), "left_outer")
    .selectExpr("customerId", "forename", "surname", "accounts", "address")
    .as[CustomerDocument]

You need to define the addressParser method to include addressId, customerId along with the address. Then register the addressParser function as a UDF and use it to parse the address, addressId and customerId which should give you the ideal output

Address parser in spark scala


Age stratified analysis in R

Question: I am working on a project for which I need to do age stratified analysis for age of onset, age at last visit to the hospital and age at death. Our collaborator wants me to create an "Age stratified table per status (1,2,3)  stratified by cohort". What does she actually mean and how do I do this in R?
    tt <- structure(list(iid = structure(c(`4367` = 41L, `15178` = 31L,
`803` = 33L, `7231` = 44L, `3314` = 99L, `6567` = 3L, `11534` = 37L,
`11544` = 38L, `5371` = 87L, `15551` = 55L, `15391` = 45L, `14921` = 17L,
`15665` = 65L, `14068` = 49L, `9859` = 5L, `9353` = 86L, `7324` = 47L,
`10566` = 9L, `6686` = 19L, `12009` = 70L, `14927` = 18L, `14565` = 79L,
`5654` = 95L, `13417` = 94L, `6817` = 23L, `3028` = 52L, `4108` = 20L,
`17234` = 84L, `8051` = 74L, `13970` = 43L, `17705` = 64L, `12823` = 50L,
`5180` = 27L, `12413` = 22L, `4861` = 73L, `16204` = 92L, `17781` = 72L,
`8091` = 76L, `13260` = 78L, `16577` = 30L, `2947` = 40L, `12549` = 29L,
`6698` = 21L, `1921` = 90L, `16931` = 63L, `1715` = 77L, `13552` = 12L,
`233` = 67L, `14184` = 57L, `8058` = 75L, `14137` = 51L, `2311` = 24L,
`5323` = 82L, `4644` = 39L, `6574` = 4L, `17585` = 35L, `16978` = 66L,
`13097` = 68L, `1034` = 46L, `17359` = 93L, `11186` = 11L, `16289` = 96L,
`3544` = 56L, `17221` = 80L, `17241` = 85L, `15320` = 42L, `10361` = 8L,
`1179` = 53L, `14696` = 89L, `14240` = 61L, `13281` = 81L, `188` = 60L,
`8918` = 48L, `4295` = 100L, `13565` = 14L, `9686` = 1L, `7499` = 54L,
`9813` = 2L, `13569` = 16L, `8581` = 13L, `11029` = 10L, `16300` = 97L,
`12477` = 25L, `9374` = 88L, `9036` = 59L, `13522` = 98L, `10031` = 7L,
`821` = 34L, `10016` = 6L, `11970` = 69L, `6923` = 26L, `13808` = 32L,
`9402` = 91L, `14592` = 83L, `8781` = 36L, `2527` = 28L, `4597` = 15L,
`4885` = 62L, `1247` = 58L, `5828` = 71L), .Label = c("09AD15049",
"09AD16760", "09AD16914_NACC082679", "09AD16934_NACC444662",
"09AD17380", "09AD18901", "09AD18925", "09AD19739", "09AD20369",
"10AD23300", "27564", "NACC006109", "NACC006368", "NACC017525",
"NACC022113", "NACC024542", "NACC025848", "NACC031468", "NACC035702_08AD11678",
"NACC038726", "NACC039815_09AD14641", "NACC079667", "NACC105660_08AD11689",
"NACC119655", "NACC135096", "NACC151854_08AD7757", "NACC171578",
"NACC183751", "NACC191953", "NACC193689", "NACC195165", "NACC209283",
"NACC224051", "NACC234892", "NACC246522", "NACC250984", "NACC256669",
"NACC266210", "NACC286235", "NACC293642", "NACC302216", "NACC306292",
"NACC322567", "NACC333589_09AD13683", "NACC347611", "NACC358132",
"NACC380482_08AD8144", "NACC386821", "NACC392815", "NACC417504",
"NACC448017", "NACC456139", "NACC459177", "NACC466486_08AD10812",
"NACC472939", "NACC483309", "NACC484535", "NACC492224", "NACC510923",
"NACC512892", "NACC514998", "NACC522588", "NACC522704", "NACC529473",
"NACC553874", "NACC575784", "NACC618811", "NACC636234", "NACC670026",
"NACC708345", "NACC717532", "NACC722553", "NACC726530", "NACC735204_08AD11164",
"NACC737878_08AD11016", "NACC752488_08AD7749", "NACC753447",
"NACC770057", "NACC780374", "NACC788939", "NACC794979", "NACC795252",
"NACC795728", "NACC799353", "NACC804511", "NACC842938", "NACC843642",
"NACC864182", "NACC864553", "NACC889512", "NACC893727", "NACC896900",
"NACC898988", "NACC907646", "NACC956562", "NACC963831", "NACC971672",
"NACC982981", "NACC984280", "NACC992021"), class = "factor"),
    cohort = structure(c(`4367` = 2L, `15178` = 8L, `803` = 12L,
    `7231` = 1L, `3314` = 2L, `6567` = 1L, `11534` = 5L, `11544` = 5L,
    `5371` = 2L, `15551` = 8L, `15391` = 8L, `14921` = 8L, `15665` = 8L,
    `14068` = 7L, `9859` = 4L, `9353` = 3L, `7324` = 1L, `10566` = 4L,
    `6686` = 1L, `12009` = 5L, `14927` = 8L, `14565` = 7L, `5654` = 2L,
    `13417` = 6L, `6817` = 1L, `3028` = 2L, `4108` = 2L, `17234` = 9L,
    `8051` = 1L, `13970` = 7L, `17705` = 10L, `12823` = 6L, `5180` = 2L,
    `12413` = 6L, `4861` = 2L, `16204` = 8L, `17781` = 10L, `8091` = 1L,
    `13260` = 6L, `16577` = 9L, `2947` = 2L, `12549` = 6L, `6698` = 1L,
    `1921` = 12L, `16931` = 9L, `1715` = 12L, `13552` = 7L, `233` = 11L,
    `14184` = 7L, `8058` = 1L, `14137` = 7L, `2311` = 2L, `5323` = 2L,
    `4644` = 2L, `6574` = 1L, `17585` = 10L, `16978` = 9L, `13097` = 6L,
    `1034` = 12L, `17359` = 9L, `11186` = 4L, `16289` = 8L, `3544` = 2L,
    `17221` = 9L, `17241` = 9L, `15320` = 8L, `10361` = 4L, `1179` = 12L,
    `14696` = 7L, `14240` = 7L, `13281` = 6L, `188` = 11L, `8918` = 3L,
    `4295` = 2L, `13565` = 7L, `9686` = 4L, `7499` = 1L, `9813` = 4L,
    `13569` = 7L, `8581` = 3L, `11029` = 4L, `16300` = 8L, `12477` = 6L,
    `9374` = 3L, `9036` = 3L, `13522` = 6L, `10031` = 4L, `821` = 12L,
    `10016` = 4L, `11970` = 5L, `6923` = 1L, `13808` = 7L, `9402` = 3L,
    `14592` = 7L, `8781` = 3L, `2527` = 2L, `4597` = 2L, `4885` = 2L,
    `1247` = 12L, `5828` = 2L), .Label = c("ADC1", "ADC10_caucasian",
    "ADC2", "ADC3", "ADC4", "ADC5", "ADC6", "ADC7", "ADC8", "ADC8_hispanic",
    "ADC9_AA", "ADC9_caucasian"), class = "factor"), merged_id = structure(c(`4367` = 21L,
    `15178` = 86L, `803` = 1L, `7231` = 37L, `3314` = 17L, `6567` = 31L,
    `11534` = 59L, `11544` = 60L, `5371` = 28L, `15551` = 89L,
    `15391` = 88L, `14921` = 84L, `15665` = 90L, `14068` = 77L,
    `9859` = 52L, `9353` = 47L, `7324` = 38L, `10566` = 56L,
    `6686` = 33L, `12009` = 62L, `14927` = 85L, `14565` = 81L,
    `5654` = 29L, `13417` = 70L, `6817` = 35L, `3028` = 16L,
    `4108` = 19L, `17234` = 98L, `8051` = 40L, `13970` = 76L,
    `17705` = 8L, `12823` = 66L, `5180` = 26L, `12413` = 63L,
    `4861` = 24L, `16204` = 91L, `17781` = 10L, `8091` = 42L,
    `13260` = 68L, `16577` = 94L, `2947` = 15L, `12549` = 65L,
    `6698` = 34L, `1921` = 12L, `16931` = 95L, `1715` = 11L,
    `13552` = 72L, `233` = 9L, `14184` = 79L, `8058` = 41L, `14137` = 78L,
    `2311` = 13L, `5323` = 27L, `4644` = 23L, `6574` = 32L, `17585` = 3L,
    `16978` = 96L, `13097` = 67L, `1034` = 4L, `17359` = 100L,
    `11186` = 58L, `16289` = 92L, `3544` = 18L, `17221` = 97L,
    `17241` = 99L, `15320` = 87L, `10361` = 55L, `1179` = 5L,
    `14696` = 83L, `14240` = 80L, `13281` = 69L, `188` = 7L,
    `8918` = 45L, `4295` = 20L, `13565` = 73L, `9686` = 50L,
    `7499` = 39L, `9813` = 51L, `13569` = 74L, `8581` = 43L,
    `11029` = 57L, `16300` = 93L, `12477` = 64L, `9374` = 48L,
    `9036` = 46L, `13522` = 71L, `10031` = 54L, `821` = 2L, `10016` = 53L,
    `11970` = 61L, `6923` = 36L, `13808` = 75L, `9402` = 49L,
    `14592` = 82L, `8781` = 44L, `2527` = 14L, `4597` = 22L,
    `4885` = 25L, `1247` = 6L, `5828` = 30L), .Label = c("0_NACC224051",
    "0_NACC234892", "0_NACC246522", "0_NACC358132", "0_NACC459177",
    "0_NACC492224", "0_NACC512892", "0_NACC529473", "0_NACC618811",
    "0_NACC722553", "0_NACC753447", "0_NACC889512", "1191_NACC119655",
    "1377_NACC183751", "1735_NACC293642", "1805_NACC456139",
    "2057_NACC984280", "2274_NACC483309", "2793_NACC038726",
    "2965_NACC992021", "3028_NACC302216", "3239_NACC022113",
    "3281_NACC286235", "3480_NACC726530", "3501_NACC522588",
    "443_NACC171578", "566_NACC795252", "604_NACC843642", "842_NACC956562",
    "993_NACC717532", "ADC1_09AD16914_NACC082679_09AD16914_NACC082679",
    "ADC1_09AD16934_NACC444662_09AD16934_NACC444662", "ADC1_NACC035702_08AD11678_NACC035702_08AD11678",
    "ADC1_NACC039815_09AD14641_NACC039815_09AD14641", "ADC1_NACC105660_08AD11689_NACC105660_08AD11689",
    "ADC1_NACC151854_08AD7757_NACC151854_08AD7757", "ADC1_NACC333589_09AD13683_NACC333589_09AD13683",
    "ADC1_NACC380482_08AD8144_NACC380482_08AD8144", "ADC1_NACC466486_08AD10812_NACC466486_08AD10812",
    "ADC1_NACC735204_08AD11164_NACC735204_08AD11164", "ADC1_NACC737878_08AD11016_NACC737878_08AD11016",
    "ADC1_NACC752488_08AD7749_NACC752488_08AD7749", "ADC2_NACC006368_NACC006368",
    "ADC2_NACC250984_NACC250984", "ADC2_NACC386821_NACC386821",
    "ADC2_NACC510923_NACC510923", "ADC2_NACC842938_NACC842938",
    "ADC2_NACC864182_NACC864182", "ADC2_NACC893727_NACC893727",
    "ADC3_09AD15049_09AD15049", "ADC3_09AD16760_09AD16760", "ADC3_09AD17380_09AD17380",
    "ADC3_09AD18901_09AD18901", "ADC3_09AD18925_09AD18925", "ADC3_09AD19739_09AD19739",
    "ADC3_09AD20369_09AD20369", "ADC3_10AD23300_10AD23300", "ADC3_27564_27564",
    "ADC4_NACC256669_NACC256669", "ADC4_NACC266210_NACC266210",
    "ADC4_NACC670026_NACC670026", "ADC4_NACC708345_NACC708345",
    "ADC5_NACC079667_NACC079667", "ADC5_NACC135096_NACC135096",
    "ADC5_NACC191953_NACC191953", "ADC5_NACC417504_NACC417504",
    "ADC5_NACC636234_NACC636234", "ADC5_NACC770057_NACC770057",
    "ADC5_NACC794979_NACC794979", "ADC5_NACC907646_NACC907646",
    "ADC5_NACC982981_NACC982981", "ADC6_NACC006109_NACC006109",
    "ADC6_NACC017525_NACC017525", "ADC6_NACC024542_NACC024542",
    "ADC6_NACC209283_NACC209283", "ADC6_NACC322567_NACC322567",
    "ADC6_NACC392815_NACC392815", "ADC6_NACC448017_NACC448017",
    "ADC6_NACC484535_NACC484535", "ADC6_NACC514998_NACC514998",
    "ADC6_NACC780374_NACC780374", "ADC6_NACC795728_NACC795728",
    "ADC6_NACC864553_NACC864553", "ADC7_NACC025848_NACC025848",
    "ADC7_NACC031468_NACC031468", "ADC7_NACC195165_NACC195165",
    "ADC7_NACC306292_NACC306292", "ADC7_NACC347611_NACC347611",
    "ADC7_NACC472939_NACC472939", "ADC7_NACC553874_NACC553874",
    "ADC7_NACC896900_NACC896900", "ADC7_NACC963831_NACC963831",
    "ADC7_NACC971672_NACC971672", "ADC8_NACC193689_NACC193689",
    "ADC8_NACC522704_NACC522704", "ADC8_NACC575784_NACC575784",
    "ADC8_NACC788939_NACC788939", "ADC8_NACC799353_NACC799353",
    "ADC8_NACC804511_NACC804511", "ADC8_NACC898988_NACC898988"
    ), class = "factor"), omit = structure(c(`4367` = 1L, `15178` = 1L,
    `803` = 1L, `7231` = 1L, `3314` = 1L, `6567` = 2L, `11534` = 1L,
    `11544` = 2L, `5371` = 1L, `15551` = 1L, `15391` = 1L, `14921` = 1L,
    `15665` = 1L, `14068` = 2L, `9859` = 1L, `9353` = 1L, `7324` = 1L,
    `10566` = 1L, `6686` = 1L, `12009` = 2L, `14927` = 1L, `14565` = 2L,
    `5654` = 1L, `13417` = 1L, `6817` = 1L, `3028` = 1L, `4108` = 2L,
    `17234` = 1L, `8051` = 1L, `13970` = 2L, `17705` = 1L, `12823` = 2L,
    `5180` = 2L, `12413` = 2L, `4861` = 1L, `16204` = 1L, `17781` = 1L,
    `8091` = 1L, `13260` = 1L, `16577` = 1L, `2947` = 1L, `12549` = 1L,
    `6698` = 1L, `1921` = 1L, `16931` = 1L, `1715` = 1L, `13552` = 2L,
    `233` = 1L, `14184` = 2L, `8058` = 1L, `14137` = 1L, `2311` = 2L,
    `5323` = 1L, `4644` = 1L, `6574` = 1L, `17585` = 1L, `16978` = 1L,
    `13097` = 1L, `1034` = 1L, `17359` = 1L, `11186` = 2L, `16289` = 1L,
    `3544` = 1L, `17221` = 1L, `17241` = 1L, `15320` = 1L, `10361` = 1L,
    `1179` = 1L, `14696` = 1L, `14240` = 1L, `13281` = 1L, `188` = 1L,
    `8918` = 1L, `4295` = 1L, `13565` = 2L, `9686` = 1L, `7499` = 1L,
    `9813` = 1L, `13569` = 1L, `8581` = 1L, `11029` = 1L, `16300` = 1L,
    `12477` = 1L, `9374` = 1L, `9036` = 2L, `13522` = 2L, `10031` = 1L,
    `821` = 1L, `10016` = 1L, `11970` = 1L, `6923` = 2L, `13808` = 2L,
    `9402` = 1L, `14592` = 2L, `8781` = 1L, `2527` = 1L, `4597` = 1L,
    `4885` = 1L, `1247` = 1L, `5828` = 1L), .Label = c("0", "1"
    ), class = "factor"), sex = structure(c(2L, 2L, 2L, 2L, 1L,
    NA, 1L, NA, 2L, 2L, 1L, 2L, 2L, NA, 1L, 1L, 1L, 2L, 1L, NA,
    1L, NA, 1L, 1L, 1L, 1L, 1L, 1L, 2L, NA, 2L, NA, 1L, NA, 2L,
    2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, NA, 2L, NA, 1L,
    2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, NA, 1L, 2L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, NA, 1L, 1L, 1L, 1L, 1L,
    2L, 2L, 2L, 1L, NA, NA, 1L, 1L, 1L, 2L, NA, NA, 1L, NA, 2L,
    1L, 2L, 2L, 2L, 1L), .Label = c(" 1", " 2", "-9"), class = "factor"),
    status = structure(c(3L, 1L, 2L, 2L, 3L, NA, 2L, NA, 2L,
    2L, 1L, 2L, 1L, NA, 2L, 2L, 2L, 2L, 2L, NA, 2L, NA, 3L, 1L,
    2L, 2L, 3L, 1L, 2L, NA, 2L, NA, 1L, NA, 2L, 1L, 1L, 2L, 2L,
    2L, 3L, 1L, 2L, 2L, 2L, 1L, NA, 1L, NA, 2L, 1L, 2L, 3L, 1L,
    1L, 1L, 1L, 1L, 2L, 2L, NA, 1L, 3L, 2L, 1L, 1L, 2L, 2L, 1L,
    1L, 1L, 1L, 1L, 3L, NA, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L,
    NA, NA, 2L, 1L, 1L, 2L, NA, NA, 2L, NA, 2L, 3L, 1L, 1L, 1L,
    2L), .Label = c(" 1", " 2", " 3", "-9"), class = "factor"),
    age_at_onset = structure(c(`4367` = 22L, `15178` = NA, `803` = 4L,
    `7231` = 12L, `3314` = 23L, `6567` = NA, `11534` = 11L, `11544` = NA,
    `5371` = 1L, `15551` = 12L, `15391` = NA, `14921` = 5L, `15665` = NA,
    `14068` = NA, `9859` = 7L, `9353` = 16L, `7324` = 7L, `10566` = NA,
    `6686` = 6L, `12009` = NA, `14927` = 3L, `14565` = NA, `5654` = 24L,
    `13417` = NA, `6817` = 3L, `3028` = 2L, `4108` = 21L, `17234` = NA,
    `8051` = 14L, `13970` = NA, `17705` = 14L, `12823` = NA,
    `5180` = NA, `12413` = NA, `4861` = 21L, `16204` = NA, `17781` = NA,
    `8091` = 25L, `13260` = 20L, `16577` = 9L, `2947` = 6L, `12549` = NA,
    `6698` = NA, `1921` = 5L, `16931` = 10L, `1715` = NA, `13552` = NA,
    `233` = NA, `14184` = NA, `8058` = NA, `14137` = NA, `2311` = 17L,
    `5323` = 22L, `4644` = NA, `6574` = NA, `17585` = NA, `16978` = NA,
    `13097` = NA, `1034` = 20L, `17359` = 13L, `11186` = NA,
    `16289` = NA, `3544` = 17L, `17221` = 16L, `17241` = NA,
    `15320` = NA, `10361` = 19L, `1179` = 23L, `14696` = NA,
    `14240` = NA, `13281` = NA, `188` = NA, `8918` = NA, `4295` = 8L,
    `13565` = NA, `9686` = 11L, `7499` = 19L, `9813` = 9L, `13569` = 15L,
    `8581` = NA, `11029` = 23L, `16300` = NA, `12477` = NA, `9374` = NA,
    `9036` = NA, `13522` = NA, `10031` = 7L, `821` = NA, `10016` = NA,
    `11970` = 14L, `6923` = NA, `13808` = NA, `9402` = 18L, `14592` = NA,
    `8781` = NA, `2527` = 11L, `4597` = NA, `4885` = NA, `1247` = NA,
    `5828` = 23L), .Label = c("54", "58", "60", "61", "63", "64",
    "65", "66", "67", "68", "69", "70", "71", "72", "74", "75",
    "76", "77", "78", "79", "80", "81", "84", "88", "90"), class = "factor"),
    age_last_visit = structure(c(`4367` = 25L, `15178` = 13L,
    `803` = 5L, `7231` = NA, `3314` = 29L, `6567` = NA, `11534` = 17L,
    `11544` = NA, `5371` = 8L, `15551` = 22L, `15391` = 21L,
    `14921` = 5L, `15665` = 13L, `14068` = NA, `9859` = NA, `9353` = 29L,
    `7324` = NA, `10566` = 26L, `6686` = NA, `12009` = NA, `14927` = 4L,
    `14565` = NA, `5654` = 32L, `13417` = 3L, `6817` = NA, `3028` = 5L,
    `4108` = 25L, `17234` = 14L, `8051` = NA, `13970` = NA, `17705` = 20L,
    `12823` = NA, `5180` = 26L, `12413` = NA, `4861` = 24L, `16204` = 1L,
    `17781` = 9L, `8091` = NA, `13260` = 30L, `16577` = 12L,
    `2947` = 12L, `12549` = 12L, `6698` = NA, `1921` = 10L, `16931` = 9L,
    `1715` = 10L, `13552` = NA, `233` = 15L, `14184` = NA, `8058` = NA,
    `14137` = 8L, `2311` = 28L, `5323` = 31L, `4644` = 21L, `6574` = 2L,
    `17585` = 6L, `16978` = 8L, `13097` = 13L, `1034` = 23L,
    `17359` = 16L, `11186` = NA, `16289` = 12L, `3544` = 26L,
    `17221` = 22L, `17241` = 21L, `15320` = 14L, `10361` = NA,
    `1179` = 25L, `14696` = 17L, `14240` = 7L, `13281` = 21L,
    `188` = 11L, `8918` = 21L, `4295` = 12L, `13565` = NA, `9686` = NA,
    `7499` = NA, `9813` = NA, `13569` = 19L, `8581` = 14L, `11029` = 27L,
    `16300` = 19L, `12477` = 8L, `9374` = 19L, `9036` = NA, `13522` = NA,
    `10031` = 16L, `821` = 18L, `10016` = 5L, `11970` = 16L,
    `6923` = NA, `13808` = NA, `9402` = 28L, `14592` = NA, `8781` = 26L,
    `2527` = 13L, `4597` = 6L, `4885` = 12L, `1247` = 11L, `5828` = 33L
    ), .Label = c("61", "62", "63", "64", "65", "66", "67", "68",
    "69", "70", "71", "72", "73", "74", "75", "76", "77", "78",
    "79", "80", "81", "82", "83", "84", "85", "86", "87", "88",
    "89", "90", "91", "93", "95"), class = "factor"), age_at_death = structure(c(`4367` = NA,
    `15178` = NA, `803` = NA, `7231` = 4L, `3314` = NA, `6567` = NA,
    `11534` = NA, `11544` = NA, `5371` = 2L, `15551` = NA, `15391` = NA,
    `14921` = NA, `15665` = NA, `14068` = NA, `9859` = 6L, `9353` = NA,
    `7324` = 8L, `10566` = NA, `6686` = 13L, `12009` = NA, `14927` = NA,
    `14565` = NA, `5654` = 14L, `13417` = NA, `6817` = 9L, `3028` = 1L,
    `4108` = 12L, `17234` = NA, `8051` = 5L, `13970` = NA, `17705` = NA,
    `12823` = NA, `5180` = NA, `12413` = NA, `4861` = NA, `16204` = NA,
    `17781` = NA, `8091` = 14L, `13260` = NA, `16577` = 6L, `2947` = NA,
    `12549` = NA, `6698` = 10L, `1921` = 3L, `16931` = NA, `1715` = NA,
    `13552` = NA, `233` = NA, `14184` = NA, `8058` = 3L, `14137` = NA,
    `2311` = NA, `5323` = 15L, `4644` = NA, `6574` = NA, `17585` = NA,
    `16978` = NA, `13097` = NA, `1034` = NA, `17359` = 9L, `11186` = NA,
    `16289` = NA, `3544` = NA, `17221` = NA, `17241` = NA, `15320` = NA,
    `10361` = 11L, `1179` = 13L, `14696` = NA, `14240` = NA,
    `13281` = NA, `188` = NA, `8918` = NA, `4295` = NA, `13565` = NA,
    `9686` = 11L, `7499` = 11L, `9813` = 8L, `13569` = NA, `8581` = NA,
    `11029` = NA, `16300` = NA, `12477` = NA, `9374` = NA, `9036` = NA,
    `13522` = NA, `10031` = NA, `821` = NA, `10016` = NA, `11970` = NA,
    `6923` = NA, `13808` = NA, `9402` = NA, `14592` = NA, `8781` = NA,
    `2527` = 7L, `4597` = NA, `4885` = NA, `1247` = NA, `5828` = NA
    ), .Label = c("67", "68", "70", "71", "72", "73", "74", "75",
    "77", "78", "84", "85", "86", "93", "94"), class = "factor")), row.names = c("4367",
"15178", "803", "7231", "3314", "6567", "11534", "11544", "5371",
"15551", "15391", "14921", "15665", "14068", "9859", "9353",
"7324", "10566", "6686", "12009", "14927", "14565", "5654", "13417",
"6817", "3028", "4108", "17234", "8051", "13970", "17705", "12823",
"5180", "12413", "4861", "16204", "17781", "8091", "13260", "16577",
"2947", "12549", "6698", "1921", "16931", "1715", "13552", "233",
"14184", "8058", "14137", "2311", "5323", "4644", "6574", "17585",
"16978", "13097", "1034", "17359", "11186", "16289", "3544",
"17221", "17241", "15320", "10361", "1179", "14696", "14240",
"13281", "188", "8918", "4295", "13565", "9686", "7499", "9813",
"13569", "8581", "11029", "16300", "12477", "9374", "9036", "13522",
"10031", "821", "10016", "11970", "6923", "13808", "9402", "14592",
"8781", "2527", "4597", "4885", "1247", "5828"), class = "data.frame")

Answer: This might be better answered in stackoverflow, but I'm guessing you are more concerned with answering what they mean by stratify yes?
I'm guessing they want you to create age groups and then you'll have multi dimensional tables from this. One table for each group you stratify by.
Here's how to create age groups in decades. Not the most elegant solution, but it will do. I just assumed you wanted age_last_visit
tt$age_last_visit<- as.numeric(as.character(tt$age_last_visit))
tt$Age_decades<- cut(tt$age_last_visit, breaks = c(seq(0, 100, by = 10), Inf))
tt$Age_decades_numeric <-ifelse(tt$Age_decades=="(10,20]",1, ifelse(tt$Age_decades== "(20,30]" ,2,ifelse(tt$Age_decades=="(30,40]",3, ifelse(tt$Age_decades== "(40,50]", 4, ifelse(tt$Age_decades== "(50,60]", 5, ifelse(tt$Age_decades=="(60,70]", 6, ifelse(tt$Age_decades== "(70,80]", 7, ifelse(tt$Age_decades=="(80,90]",8,NA))))))))

Then stratify with this
table(tt$Age_decades, tt$cohort, tt$status)

I recommend making the splits on the variable with the fewest levels/values it can take which is status in this case. If you want more elegant tables I highly recommend the table1 package in R. Very high quality html tables

Age stratified analysis in R


Ubercart product quantity count in product view page show as smsung 2/10 sold?

Question: I added a product and say it has count of ten(of that product), If one is bought, then I want to show in the product view page out of 10/1 sold like that.
Is there any contributed modules available, or custom way to do it? I can add the quantity as field in the product content type, but what do I do after that?
Comment: @Ram, Check my answer in this question http://drupal.stackexchange.com/questions/94204/how-to-configure-stock-module-in-ubercart-and-know-how-many-products-sold-out-of/94206#94206
Comment: check this http://drupal.stackexchange.com/questions/75002/how-to-check-the-stock-count-of-an-ubercart-node
Comment: @Bala: what i want is to do is while adding a product, if enter 10 as the product count, if two are sold of tat products, i want the result to be as 8/2sold like tat in the product view page. I dont know how what your referred answer will help my question. I have not installed any stock module. Clear me if i am wrong.
Comment: Check this http://stackoverflow.com/questions/4601667/how-to-show-available-stock-quantity-in-ubercart and http://www.ubercart.org/forum/support/5643/stock_level_product_detail_page
Comment: If you want to do it with custom code, then you just create one more custom talbe like tbl_product_stock. There you keep the product quantity. Then the you decrement the value of quantity at each product checkout.
Comment: @Bala: I enabled the stock module, where should i  add the stock value?
Comment: @Bala: but how will i know how much product currently it has been sold ?
Comment: @Ram I'm also trying to search for you since yesterday, once I found it I will let you know
Comment: @Bala: Also there is a issue w.r.t auction where after some one wins auction, only sell price gets added to the ubercart. Since i am already using this module, i am just want to stick with it and resolve or make it work ? any ideas will be helpful.
Answer: This is not an answer, but you can find the stock level using the below code, just put in the node.tpl.php, and print the var $stock_html in a proper place, probably in node-product.tpl.php <?php print $stock_html ?>  .
<?php
if ($node->type == 'product') {
  $arr_sku = uc_stock_skus($node->nid);
  $stock_html .='
';
  foreach($arr_sku as $sku){
    $stocklevel = uc_stock_level($sku);
    if ($stocklevel) {
      if ($stocklevel < 1) {
        $stocklevel = ''.$stocklevel.'';
      }
      $stock_html .='
'.$sku.'	:  '.$stocklevel.'
';
    }
  }
  $stock_html .='
';
}
?>

or you can try this http://www.ubercart.org/comment/60577
Comment: source http://www.ubercart.org/forum/support/4037/stock_level_product_page
Comment: uc_stock_skus is a drupal5 function.
Comment: @Ram try to convert this function for drupal 7, since no other way to find the proper one.
Comment: This is just printing the stock level, but i want to print also how many has been already purchased.
Comment: I just have a doubt. Why is tat fetaure of stock is coming only while editing a product, not while adding a product?
Answer: Code snippets to display total and sold item from stock:
$output = '';

$array_sku = uc_product_get_models($node->nid, FALSE);

foreach ($array_sku as $sku) {
    $stock_level = uc_stock_level($sku);

    $stock_counts = db_select('uc_order_products', 'up')
                    ->fields('up', array('nid','qty'))
                    ->condition('up.model', $sku, '=')
                    ->execute()
                    ->fetchAll();

    $quantity_count = 0;

    if(isset($stock_counts))  {
        foreach($stock_counts as $stock_count ) {
            $quantity_count += $stock_count->qty;
        }
    }

    $total = $stock_level +  $quantity_count;

    if($total == 0){
        $total = 1;
    }

    $output .= $total . " / " . $quantity_count . " Sold out";
  }

 print $output;

Kindly see that above code will be check stock level for each different SKU of the product. If there is attribute of the product and each attribute has different SKU, then it will display the stock for each sKU of the product.
It will work perfect in fresh "Ubercart" installation with "stock" configuration.
You can add this code in node--product.tpl.php file in your theme directory.
Comment: Actually there is a bug in this code, i found out. The issue was this is only chekcing row count of the nid and no quantity check. So for a record if i order 3 of that products , still row count wil be only one not three... I am updating the answer.
Comment: I have posted the answer. You can update your answer too. i am not going to un-check your answer, so better you update your answer
Answer:          <?php
                $array_sku = uc_product_get_models($node->nid, FALSE);
                foreach ($array_sku as $sku) {
                    $stock_level = uc_stock_level($sku);
                    //$stock_count = db_select('uc_order_products', 'up')->fields('up', array('nid'))->condition('up.model', $sku, '=')->execute()->rowCount();

                    $stock_counts = db_select('uc_order_products', 'up')
                                    ->fields('up', array('nid','qty'))
                                    ->condition('up.model', $sku, '=')
                                    ->execute()
                                    ->fetchAll();
                    $quantity_count = 0;
                    if(isset($stock_counts))
                    {
                        foreach($stock_counts as $stock_count )
                        {
                            $quantity_count += $stock_count->qty;
                        }
                    }
                    $total = $stock_level +  $quantity_count;
                    if($total == 0){
                        $total = 1;
                    }
                    $output .= $total . " / " . $quantity_count . " Sold out";
                }
          ?>

This will output exact stock level and sold level of the product.


Iterating over a Database

Question: I want to iterate over a list.
def Alle_Eintraege_Anzeigen():
    for Text in Schluesselanlegen.select():
        print (str(Text.Schluessel))
    for Text in Schluesselanlegen.select():
        print (str(Text.Schwierigkeitsgrad))
    for Date in Schluesselanlegen.select():
        print (str(Date.Oeffnungsdatum))

At the end it should look like this:
1|Schluessel1|2|23.01.2017
2|Schluessel2|3|24.01.2017

How can i do it ?
is something in my order wrong ?
Thanks for help.
Answer: You may try to print once per line
def Alle_Eintraege_Anzeigen():
    for Text in Schluesselanlegen.select():
        print (str(Text.Schluessel))+'|'+(str(Text.Schwierigkeitsgrad))+'|'+(str(Date.Oeffnungsdatum))

Also, you might want to keep a counter variable to print the line number
def Alle_Eintraege_Anzeigen():
    lineNumber = 1
    for Text in Schluesselanlegen.select():
        print (str(lineNumber))+'|'+(str(Text.Schluessel))+'|'+(str(Text.Schwierigkeitsgrad))+'|'+(str(Date.Oeffnungsdatum))
        lineNumber += 1

(I assumed you literally wanted to print the pipe characters)

Iterating over a Database


Block internet access to OpenVPN clients once connected to the VPN - Access server in AWS

Question: I have an OpenVPN access server running in AWS - the instance is built using the official AMI from the marketplace. There is a requirement to block the internet access for all clients once they are connected to VPN. Means, once connected, they should only be routed to the VPC networks.
How can I achieve this:
1) without Making any changes in the client side config
2) without making any changes in the OS level routes in access server (if no other choice, can explore this)
Split tunneling is not an option, blocking the internet access of the access server is also not an option in this case.
Thanks in advance.
Answer: Push the default route to the clients via the VPN to the AWS host (add push "redirect-gateway def1" to your server.conf file).
Then set the firewall on the AWS host to only allow access to subnet you want clients to have access.
Comment: If the host do not have a route to the internet, how can the clients connect to it ?
Comment: The VPN server host still has a route to the internet, It is just choosing not to route packets that come in over the VPN out to the internet
Answer: This OpenVPN config results in clients using conventional routing for the rest of Internet packets but then routing all business-related traffic (in this case, 10.8.0.0/24), through the actual VPN.
I've managed to put together this server.conf. I pasted all the file and commented all the lines I changed or added, and also because of order.
port 1194
proto udp6
dev tun
user nobody
group nogroup
persist-key
persist-tun
keepalive 10 120
topology subnet
server 10.8.0.0 255.255.255.0
client-to-client  # Otherwise, clients may not be able to connect but to the server.
push "route 10.8.0.0 255.255.255.255 10.8.0.1 1"  # Push default VPN route for
                                                  #  redirecting internal traffic
                                                  #  only
# push "route <network_ip> <netmask> <gateway, normally, the server> <priority>"
ifconfig-pool-persist ipp.txt
#push "dhcp-option DNS 220.127.116.11"  # Comment out so clients won't get DNS config
                                 # changed.
#push "dhcp-option DNS 126.96.36.199"  # Ditto
#push "redirect-gateway def1 bypass-dhcp"  # Comment out so clients won't get
                                           #  their default routing changed,
                                           #  thus redirecting even Internet
                                           #  packets.
server-ipv6 fd42:42:42:42::/112
tun-ipv6
push tun-ipv6
#push "route-ipv6 2000::/3"  # Disable Internet IPv6 addresses routing
#push "redirect-gateway ipv6"  # So no IPv6 routing override.
dh none
ecdh-curve prime256v1
tls-crypt tls-crypt.key
crl-verify crl.pem
ca ca.crt
cert server_P0QFYDE85qRItX6k.crt
key server_P0QFYDE85qRItX6k.key
auth SHA256
cipher AES-128-GCM
ncp-ciphers AES-128-GCM
tls-server
tls-version-min 1.2
tls-cipher TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
client-config-dir /etc/openvpn/ccd
status /var/log/openvpn/status.log
verb 3

Comment: As it's currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Comment: Of course it isn't suitable. Thanks for the feedback. I might only have the configs necessary for redirecting private traffic, but I thought it was a good idea to paste all the file and comment added or changed lines.
Comment: Do you think it's any clearer now?


Regular expression to match url patterns

Question: I want to create a function which would validate possible url patterns in my CMS. The possible patterns:
9-naberanie-cistej-hmoty
demonize-p18
maximizing-your-prohormone-cycle-34

link pattern

CATEGORY_ID-CATEGORY_URL

link pattern

PRODUCT_URL-pPRODUCT_ID

link pattern

ARTICLE_URL-ARTICLE_ID

Is it possible to validate it via regular expression ? I was thinking about exploding the stuff but it would take more steps if there is regexp for this which I could use it would b e great. I am not familiar with regexp so thanks for any help
Code:
$category = "9-naberanie-cistej-hmoty";
preg_match("([0-9]+)-([A-Za-z-]+)", $category);

When I run this code I get

Message: preg_match(): Unknown modifier '-'
Comment: Certainly that is possible. But please note that SO is _not_ a free coding service. We are here to help you _with your own code_. You are not here to do your work for you. So start out yourself, implement what you need. Then, if you run into an issue you cannot solve or understand yourself in your own code, _then_ is the time to come here and ask by posting your code and pointing out the issue in a precise and specific manner.
Comment: well could you at least provide me with link where I can find some patterns and how to start?
Comment: There are endless tutorials about regular expressions to be found on google.
Comment: well I figured something out. I have working regex ([0-9]+)-([A-Za-z-]+) but if I put this as pattern to preg_replace I get unknown modifier '-' how can I fix this
Comment: Please add such additional details into the question itself, do not post them in comments. There is an `edit` link below your question. _Use it._
Comment: And please post the whole php row, not just the pattern.
Comment: Please read the documentation of the functions you use. You forgot to enclose your pattern into bounding characters. It should be something like `preg_match('|([0-9]+)-([A-Za-z-]+)|', $category);`. (note the additional `|` characters enclosing the pattern)
Comment: Thanks got all 3 regex wasnt that hard after all I posted it as answer
Answer: Ok, great that you yourself gave a pretty good answer after you started thinking about your question!
I only made some small modifications. Not to answer your question, YOU DID, but to point out that you should anchor your expressions to the start and end of the subjects by adding a preceding ^ and a trailing $...
Also a closing php tag rarely is a good idea...
<?php
$category = "9-naberanie-cistej-hmoty";
$product  = "demonize-p18";
$article  = "maximizing-your-prohormone-cycle-34";

preg_match('/^([0-9]+)-([A-Za-z-]+)$/', $category, $matches);
preg_match('/^([A-Za-z-]+)-p([0-9]+)$/', $product, $matches);
preg_match('/^([A-Za-z-]+)-([0-9]+)$/', $article, $matches);

Comment: thanks, edited it in my code. well it was just a snip from my code so wanted to make just example. but thanks anyway.
Answer: Well thanks to arkascha I worked on the answer :)
Here is the code:
<?php
$category = "9-naberanie-cistej-hmoty";
$product  = "demonize-p18";
$article  = "maximizing-your-prohormone-cycle-34";

preg_match("/([0-9]+)-([A-Za-z-]+)/", $category, $matches);
preg_match("/([A-Za-z-]+)-p([0-9]+)/", $product, $matches);
preg_match("/([A-Za-z-]+)-([0-9]+)/", $article, $matches);
?>


Does it make sense to regress the residuals with rep(0, N) vector?

Question: I need to use Breusch-Pagan test, to check whether two series are homoscedastic.
First I calculate the residuals of two lists of prices after [...] and then I test residuals for homoscedasticity. My doubt is, does it make sense to regress the residuals with a rep(0, N) line?
I thought of it because the residuals should be 0 (to have a perfect fit) so i think it makes sense to regress the residuals with a 0,0,0,0,0 etc etc line, what do you think?
The only problem that if I use bptest(residuals ~ rep(0,500)) I get a NA
Comment: The Breusch-Pagan test is clearly described in the [Wikipedia article](http://en.wikipedia.org/wiki/Breusch%E2%80%93Pagan_test): you regress the squared residuals against the original (independent) variables.  What, then, are you trying to ask about rep(0,N)?  Because it never makes sense to regress *anything* against a constant value such as 0 (except as a complicated way to compute an arithmetic mean), I am wondering whether this question correctly communicates what you want to ask.
Answer: I don't see any way this makes sense as it stands.
Residuals from a linear regression should already have mean 0, and 500 zeros certainly do, so the regression is left trying to figure out "how many times zero is the best linear predictor of the residuals?".
Anything times zero is zero, so no multiple of 0 could achieve anything at all toward getting us closer to any residual value. Such a predictor can never achieve anything with ordinary regression residuals.
Your regression estimator will be 0/0 ... which is why you're getting NA.
I, too, wonder if you may have mistyped something in your question. If not, it simply makes no sense at all.
To quote Mr Babbage, "I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question"
There's nothing to be gained here, it's not a meaningful activity.


Decomposing Sheaves into a direct sum

Question: I have two questions about sheaves inspired by representation theory:

Is there a theorem that tells me when a sheaf of vector spaces can be decomposed into the direct sum of two "smaller" sheaves?
Let's call a sheaf of vector spaces "irreducible" if it cannot be decomposed into a direct sum of smaller sheaves. Is there a theory that tells us how sheaves are composed into these smaller "irreducible" components? For example, is such a decomposition unique, are there criteria for telling what components a sheaf has, etc.
Comment: This is somewhat misguided. Have you thought about the analogous questions for, say, modules over a ring?
Comment: I picked vector spaces specifically to avoid the situation where there is a subobject, but no "complementary subobject", so to speak. Yuan's answer says that it still doesn't work.
Answer: What you call irreducibility is usually called indecomposability; irreducibility is the stronger condition that an object (in an abelian category, say) has no nontrivial subobjects.
The analogy to the representation theory of, say, finite groups fails in an important respect: categories of sheaves of vector spaces are almost never semisimple. That is, objects almost never decompose into direct sums of irreducible objects. Instead, one must solve extension problems, the solution to which can be expressed in terms of the Ext functor. People usually first encounter this sort of issue in module theory.
For example, the category of locally constant sheaves of vector spaces on $S^1$ is equivalent to the category of representations of the fundamental group $\mathbb{Z}$. This is not a semisimple category: there is a representation
$$\mathbb{Z} \ni n \mapsto \left[ \begin{array}{cc} 1 & n \\\ 0 & 1 \end{array} \right]$$
which is indecomposable but not irreducible. It is a nontrivial extension of the trivial representation by the trivial representation.
The idea in the representation theory of finite groups to try to understand all representations in terms of irreducible representations just doesn't work in general. Sheaves of vector spaces is a huge category, and trying to understand every object in it is hopeless. This isn't a category you try to understand all the objects in, it's a convenient starting point from which you can do other things.
Comment: Thank you. I'm disappointed on the one hand, but there is interesting mathematics here.

Decomposing Sheaves into a direct sum


Find a specific critical point from set of equations for $f(x,y) = xy(12-3x-4y)$

Question: I'm having trouble finding a specific critical point from set of equations for $f(x,y) = xy(12-3x-4y)$. In particular it is the critical point $(\frac{4}{3},1)$
Calculating the first order derivatives for $x$ and $y$ we get the set of equations:
$$\partial_{x}f = y(12-6x-4y) = 0 \\ \partial_{y}f = x(12-3x-8y) = 0$$
Could somebody assist me in solving for this specific critical point?
Answer: Obviously $(x,y)=(0,0)$ its a critical point, so, suppose that $x\neq0$ and that $y\neq0$. Hence,
$$y(12-6x-4y)=0 \textrm{ implies } 12-6x-4y=0$$
and similarly $12-3x-8y=0$ from the second equation. It follows that the unique solution to the system of equations
$$\left\{\begin{align}
-6x-4y&=-12 \\
-3x-8y&=-12
\end{align}\right.$$
is $(x,y) = \big(\tfrac43,1\big)$.
Comment: Thank you sir....
Answer: Here is a stream plot:

$$(0,3), (4/3,1), (4,0), (0,0)$$ marked, each of which you can analyze for the value of the derivatives (and second derivatives).
Comment: @dc3rd:  Copy your plot to your computer clipboard, then while writing/editing your solution click on the "insert graphics" icon and paste...  (Oh... and thanks for your compliment... but I sometimes need a break from my current very big writing project, and solving such math problems is a wonderful and relaxing diversion...)
Comment: quick question. How do you embed graphics such as this into solutions. Also thank you for taking the time to produce this. Shocked (and honored) that a man of such high accomplishments still has time for us meagre plebs of the math world...


Meaning of exception in C# app: "Not a legal OleAut date"?

Question: Does anyone know what this means. Getting this in C# winforms applications:

Not a legal OleAut date
Comment: Can you post the code that is causing this?
Answer: It means that somewhere in the program is attempting to convert to or from an OLE Automation Date outside the valid range 1-January-4713 BC to 31-December-9999 AD. It might have slipped through because OLE Automation Dates are represented as a double.
Start by looking for any uses of the methods:
DateTime.FromOADate
DateTime.ToOADate
Answer: An OADate is represented as a double value whose value is the number of days from midnight on 30 december 1899 (negative values representing earlier dates).
This exception is thrown when trying to convert a value that is outside the valid range of Ole Automation dates to/from a .NET DateTime value (methods DateTime.FromOADate and DateTime.ToOADate - which are also used implicitly for COM Interop).
I believe to be valid for conversion to an OADate the .NET DateTime value needs to be strictly greater than 01/01/0100.
To convert from OADate to a .NET DateTime value, the double value needs to be strictly greater than -657435 (= 01/01/0100) and strictly less than 2958466.0 (01/01/10000).
Answer: It means you provided an invalid date somewhere, attempting to convert to or from an OLE Automation date outside the valid range 1-January-4713 BC to 31-December-9999 AD.  A possible cause is that it might have slipped through because OLE Automation Dates are represented as a double.
Comment: It's an obvious question, I don't know how one could be more helpful if the OP won't provide any details.
Comment: Isn't that a little too obvious an answer?
Comment: Agreed. We can't help more without further details like code.
Answer: I've used:
try
{
    if (folderItem.ModifyDate.Year != 1899)
    {
        this.FileModifiedDate = folderItem.ModifyDate.ToShortDateString() +
            " " +
            folderItem.ModifyDate.ToLongTimeString();
    }
}
//we need this because it throws an exception if it's an invalid date...
catch (ArgumentException) { }

to deal with the same problem I'm having. It throws the exception when we check the year in my case. Doing nothing on an invalid date is exactly the behavior I want, so this hack works.
Answer: What I found was that a column with a large row_id '257381195' was attempting to be read by Excel as a Date.  What I ended up doing was altering that column's data to a string by preceding the row_id with a single quote.  This resolved my issue.  Hope this helps.
Answer: I had the same problem. When trying to parse date from cell.
When converting string to double, the decimal separator was ignored because of my localization.
So the cell value string:"123456,78" was converted to double:12345678 instead of double:123456.78 (made-up example value used)
Here is my snippet that fixed the issue:
if (double.TryParse(
    s: cell.CellValue.InnerText,
    style: NumberStyles.Number,
    provider: CultureInfo.InvariantCulture,
    result: out double oaDateValue))
{
  DateTime parsedDateTime = DateTime.FromOADate(oaDateValue);
  // DateTime was parsed successfully.
}
else
{
  // DateTime failed to parse.
}

The important part here is CultureInfo.InvariantCulture. This makes sure that if that cell has a decimal separator . or , it will be detected and parsed properly.
If you still get the error make sure that cell.CellValue.InnerText is an actual value and not a reference to SharedStringTable. If that's the case you can use this helper extension method that will help extract the value from SharedStringTable:
private static string GetCellValue(this Cell cell, SharedStringTable sharedStringTable)
{
    if (cell.DataType == null || !cell.DataType.HasValue)
    {
        return cell.CellValue != null
            ? cell.CellValue.InnerText
            : String.Empty;
    }
    else if (cell.DataType.Value == CellValues.SharedString)
    {
        return sharedStringTable
            .ElementAt(int.Parse(cell.CellValue.InnerText)).InnerText;
    }

    return cell.CellValue.InnerText;
}

Now you can use cell.GetValue(sharedStringTable) to get the actual string value.


Relative efficiency of Wilcoxon signed rank in small samples

Question: I have seen in published literature (and posted on here) that the asymptotic relative efficiency of the Wilcoxon signed rank test is at least 0.864 when compared to the t test. I have also heard that this only applies to large samples, although some books don't mentioning this (what's with that?).
Anyway, my question is, how small do things need to get before the above paragraph no longer applies?
In my case I have 4 pairs of data. If all assumptions hold, I know I have at least 90% power to detect an effect size of 2SD under the paired t test if I use an alpha of 0.1 and have moderately correlated data. However, I would like to use the Wilcoxon signed rank test due to the small sample size and inability to check assumptions but I'm concerned the test will have too little power if I do. Thanks!
Comment: "Asymptotic" anything in "small samples" does not make sense: it's a contradiction in terms.  I suspect you are asking for the actual relative efficiency in small samples, period. The answer depends on the underlying distributions you are comparing and so will be complicated unless you have two specific distributions in mind. Many people choose the Normal for reference, but that might not necessarily be right for your applications.
Comment: What's "moderately correlated data"?
Comment: Note that your above 90% power will be at the normal, not at the distribution where ARE is 0.864. As such the calculation should be done at the normal.
Comment: Yes I am looking for relative efficiency in small samples. Thanks for pointing that out. I want to know what is the worst I could do power-wise. I don't really have any underlying distributions in mind but if I were to use the normal, as you suggest, how would I proceed? I know that it will also depend on how correlated the data is.
Comment: @ Glen_b: You're right, I should specify what I was thinking by moderate correlation. I was thinking of a correlation of at least 0.4. So how then would I do the calculation? ALso, in terms of my original question about comparing efficiency of the two tests at small sample sizes, I did a bit of research on this topic. A couple of sources indicated that the answer is not completely clear in smaller samples but the Wilcoxon test performs reasonably well. Maybe I will just have to live with that type of answer for now.
Comment: @Jimj It's quite possible to make some progress. In the normal case (and for a couple of other distributions) there are some results for the signed-rank test (at least for larger samples), and more generally one can always simulate. I plan to illustrate the simulation approach but I wanted to see whether there were explicit small sample results first.
Comment: Just to confirm so the comment about the intention to do so is not left hanging there -- I did simulate, as indicated in the updated answer.
Answer: Klotz looked at small sample power of the signed rank test compared to the one sample $t$ in the normal case.
[Klotz, J. (1963) "Small Sample Power and Efficiency for the One Sample Wilcoxon and Normal Scores Tests" The Annals of Mathematical Statistics, Vol. 34, No. 2, pp. 624-632]
At $n=10$ and $\alpha$ near $0.1$ (exact $\alpha$s aren't achievable of course, unless you go the randomization route, which most people avoid in use, and I think with reason) the relative efficiency to the $t$ at the normal tends to be quite close to the ARE there (0.955), though how close depends (it varies with the mean shift and at smaller $\alpha$, the efficiency will be lower). At smaller sample sizes than 10 the efficiency is generally (a little) higher.
At $n=5$ and $n=6$ (both with $\alpha$ close to 0.05), the efficiency was around 0.97 or higher.
So, broadly speaking ... the ARE at the normal is an underestimate of the relative efficiency in the small sample case, as long as $\alpha$ isn't small. I believe that for a two-tailed test with $n=4$ your smallest achievable $\alpha$ is 0.125. At that exact significance level and sample size, I think the relative efficiency to the $t$ will be similarly high (perhaps still around the 0.97-0.98 or higher) in the area where the power is interesting.
I should probably come back and talk about how to do a simulation, which is relatively straightforward.
Edit:
I've just done a simulation at the 0.125 level (because it's achievable at this sample size); it looks like - across a range of differences in mean, the typical efficiency is a bit lower, for $n=4$, more around 0.95-0.97 or so - similar to the asymptotic value.

Update
Here's a plot of the power (2 sided) for the t-test (computed by power.t.test) in normal samples, and simulated power for the Wilcoxon signed rank test - 40000 simulations per point, with the t-test as a control variate. The uncertainty in the position of the dots is less than a pixel:

To make this answer more complete I should actually look at the behavior for the case for which the ARE actually is 0.864 (the beta(2,2)).


JQGRID mudar a cor da linha ou dos dados caso o retorno esteja NULL ou Branco

Question: Teria como eu condicionar uma cor diferente se uma coluna estiver em branco no GRID? Algo como:
if Loja ="", cor da linha vermelha
<code> $table.jqGrid({
        url: url,
        datatype: 'json',
        mtype: 'GET',
        postData: {
            representante: function () { return jQuery("#representante option:selected").val(); },
            vendedor: function () { return jQuery("#vendedor option:selected").val(); },
            nome: function () { return jQuery("#nome").val(); }
        },
       colModel: [
           { label: 'RECNO', name: 'RECNO', width: 80 },
           { label: 'Cliente', name: 'CLIENTE', width: 80 },
            { label: 'Loja', name: 'A1_LOJA', width: 80 },
            { label: 'Nome', name: 'A1_NOME', width: 350 },
            { label: 'CNPJ', name: 'A1_CGC', width: 120 },
            { label: 'Municipio', name: 'A1_MUN', width: 150 },
            { label: 'Telefone', name: 'A1_TEL', width: 80 },

        ],
         viewrecords: true,
            rowNum: 20,
            rowList: [20, 40, 100],
            height: "auto",
            //height: 400,
            emptyrecords: "Nenhum Cliente",
            loadtext: "Buscando e carregando...",
            //rowNum: 20,
            pager: "#jqGridPager",
            loadonce: true

    });
</code>
A imagem mostrada, teria que vir com a segunda linha vermelha. Ja que trouxe os dois campos em branco.
Answer: A quem possa interessar, acrescente no evento loadComplete e coloque sua condição, pegando a linha e mudando a sua caracteristica
<code> loadComplete: function() {
             var rowIDs = jQuery("#jqGrid").getDataIDs();   //busca ids das linhas do grid

             for (var i = 0; i < rowIDs.length; i++) {     //entra nas linhas
                 var rowData = $("#jqGrid").jqGrid('getRowData', rowIDs[i]);
                 //verifica se o campo está vazio (coloque sua condição)
                 if (rowData["A1_LOJA"] == "") {
                        console.log("recno: ", rowData["RECNO"]);
                        // Muda a cor da Linha
                        $(this).jqGrid('setRowData', rowIDs[i], false, {background:'#ee993d', color:'#fff'});
                 }
             }
          },
</code>


MFMessageComposeViewController shows blank white screen in iOS7

Question: there's a problem when I try to send a large recipients list (e.g more than 40) using MFMessageComposeViewController. In iOS7, it will show a blank white screen for 20s or more before displaying the SMS compose view. This does not occur for iOS5 and iOS6.
Below is the existing code that I'm using,
NSArray * recipients;

for (NSIndexPath * index in selectedRows)
{
   NSDictionary *dictionary = [data objectAtIndex:index.row];
   NSString *phoneNum =  [dictionary objectForKey:@"contactNum"];
   recipients = [NSArray arrayWithObjects:phoneNum, nil]];
}

MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];

if([MFMessageComposeViewController canSendText])
{
    controller.body = bodyOfMessage;
    controller.recipients = recipients;
    controller.messageComposeDelegate = self ;
    controller.wantsFullScreenLayout = NO;
    [(id)_delegate presentModalViewController:controller animated:YES];
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
}

Below are the output message that I received when I try to send to many.
timed out waiting for fence barrier from com.apple.mobilesms.compose
Received memory warning.
Received memory warning.
Received memory warning.
Received memory warning.
Received memory warning.
Received memory warning.
Received memory warning.
Received memory warning.
Received memory warning.

Comment: I have the same issue.
I've opened a bug report in bugreport.apple.com with id #14994563
after two days an Apple Engineering ask me for a console log, i've attached it, but, for now nothing happened. I've wrote many thread in apple developer forum without find any solution ... today i wrote to tim cook ..
Comment: I'm having the same problem with my shipped app. Seems OK below 30 or so contacts, but gets progressively longer delay above that. 86 didnt return at all! Best guess is this relates to the way that contacts are now coloured according to the method that will be used to send them. On iPad you now get a bunch of spinners appearing against each contact as it works out whether they are known to iMessage. I'm not sure if this was a late addition to iOS7, but I didn't spot this stuff here in the betas.
Comment: It's a weird bug. Out of 4 iPhone5 devices that I have tested, 2 experienced this problem while the other 2 display the SMS compose view immediately. I'm puzzled.
Comment: LDWP- are you saying the same code consistently worked with the same size group on some devices and not others?

One user reported different results according to whether MMS was enabled, could that be the difference between devices?
Comment: Peter Johnson - I have tested and it's working on devices running beta iOS7. Devices that were upgraded to the latest iOS7 from iTunes have this problem. I have also tested by toggling the MSS enabled settings but problem still exists.
Comment: There's a big thread on Apple forums about this. This is an iOS 7 bug introduced after the GM build and is still there in iOS 7.0.2. Apple is however aware of this and looking into fixing it.
Comment: The problem has been resolved in iOS 7.0.3.
Comment: Still getting this error in iOS 12.0.
Answer: I had a similar problem where I got the message in the console "

timed out waiting for fence barrier from com.apple.mobilesms.compose

The problem was that I tried in my app to add the number as a string, but because of the localization request, I have put it in a form:NSArray *recipents = @[NSLocalizedString(@"numberForRegistrationViaSms", @"")];
and
[messageController setRecipients:@[recipents]];

That didn't work for some reason but, when I put just simply, [messageController setRecipients:@[@"123456789"]];, the SMS composer appears without any problem.
Answer: I to had the same problem then figured
controller.recipients = // should always be an array of strings.
Make sure the phone numbers you send to controller.recipients are NSString.
Answer: I think I maybe resolve this:
//must initiate new NSString object

NSString *phoneStr = [NSString stringWithFormat:@"%@",... ];

MFMessageComposeViewController *aCtrl = [[MFMessageComposeViewController alloc] init];
aCtrl.recipients                      = @[phoneStr];
...

Then OK.
Answer: I had same problem.

timed out waiting for fence barrier from com.apple.mobilesms.compose

Message Cancelled

Instead of this:
    NSString *phoneNumber = @"888888888";
    [picker setRecipients:@[phoneNumber]];

Try this:
    NSString *phoneNumber = person.phoneNumber;
    [picker setRecipients:@[[NSString stringWithFormat:@"%@", phoneNumber]]];

This worked for me.
Answer: The problem has been resolved in iOS 7.0.3.
Comment: Also get this on 8.1.1. Yay apple!
Comment: Just had  timed out waiting for fence barrier from com.apple.mobilesms.compose appear on 7.0.4
Comment: Problem is also in 8.0.2 version
Comment: Problem also exists in iOS 8.3 .


Best way to plot a 4 dimensional meshgrid

Question: I have $4$ variables $X$, $Y$, $Z$ and $C$, and I want to plot these on a graph. Usually I would just plot the surface $X$, $Y$, $Z$ and then use color to represent the $4$th dimension, as shown bellow:

However, my $X$, $Y$, and $Z$ co-ordinates make up a $3$-dimensional meshgrid, so when I do the $4$ dimensional plot it is hard to see what is going on, as shown below:

$X$, $Y$ and $Z$ represent spatial dimensions and $C$ represents a value that depends on its place its $3$-dimensional space. I need $X$, $Y$, and $Z$ to be shown in all places because these are the independent variables. In this simplified version of my function, $C=X+Y+Z$. I want to be able to pick any $3$ numbers for $X$, $Y$, and $Z$, and then look at my graph, and be able to get a good idea of what $C$ is. You can sort of do this with this current graph but it is hard to use.
What I want to know is: Is there a better way to plot this information? For example, is there a different co-ordinate system I could use that would be better? Or is there a way I could represent the 3 spatial dimensions so they look like a curved surface, but still include every point?
To reiterate that last question: Is there a way to represent every point in $3$ dimensions within $0 \leq X,Y,Z \leq 10$, all on one surface?
Thanks!
Comment: I suppose it is fine to post it on mathematica.se.com as well. Perhaps you could slightly rephrase it to emphasize that (on that website at least) you are looking for visualization methods in Mathematica. By the way, some useful links: [Visualizing 4D functions](http://mathematica.stackexchange.com/questions/19575/what-are-the-possible-ways-of-visualizing-a-4d-function-in-mathematica) and [3D heatmaps](http://mathematica.stackexchange.com/questions/17260/3d-heatmap-density-plot).
Comment: And to think that I already had trouble with a $3$-dimensional plot... (which I solved with a $2$-dimensional plot with colors). But seriously, I don't think there's a simple way to do what you want.
Comment: If you are not restricted to static images, you could make a dynamic plot that you can move around, to see depth in your image. But if you want to put it in a paper or something, that wouldn't work.
Comment: (You might also want to try [mathematica.stackexchange.com](http://mathematica.stackexchange.com/) if you happen to be making such plots in Mathematica. Maybe they have some good suggestions.)
Comment: I'm not restricted to static images, the graphs shown can be moved around, however even with this, it is still hard (but not impossible) to get a good estimate of C just by looking at the x, y and z position.
Comment: @TMM Do you think it will be okay if I post on that site and leave this question up? Stack exchange usually discourage posting the same question on multiple sites, but in this case it does seem useful. If not I'd rather leave the question on this site. As I'm asking more about an abstract mathematical idea, instead of how to implement it. If anyone can give me an idea I will probably _(Hopefully)_ be able to implement it for myself.
Comment: I'm thinking if I split the graph up into two separate graphs I should be able to achieve my aims, but I cannot think exactly how I should do it.
Comment: See : https:twitter.com/4DGeometry Delivers anything and everything you might want to know about 4-dimensional geometry. [enter image description here](https://i.stack.imgur.com/fBnse.jpg)
Answer: Great question OP! I just wanted to add my contribution here. It might be too late, however, I think it is worthwhile to post anyway.
I created a program for this a while back for a multivariable calculus course I was teaching and figured I would include it here.
My approach is to use a scatterplot, but I made some changes to really make the graphics pop.
Specifically, I included a function to remove a portion of the Alpha channel range from the colormap to make portions of the range transparent. This is controlled by the function f_AlphaControl in the code below.
The function I used in the demo is the function $$f(x,y,z)=xyz e^{-(x^2+y^2+z^2)}$$
It has 4 local max and 4 local min, all of which are visualized in the plots below. I think the results speak for themselves so please take a look at them and let me know what you think .
2700 points:

1000000 points:

This code allows for creation of isovolume renders that rival Mayavi and/or OpenGL but without all of the effort. I have similar routines coded up in Mayavi, however, since OP just asked about matplotlib, I wanted to show how powerful it can be.
<code>import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm

from matplotlib.colors import ListedColormap

## The following code creates the figure plotting function
def MakePlot(xx,yy,zz,ww,cmapO=cm.jet):
    ##Create Custom Colormap with Alpha varying depending on the functions behavior.
    ## This produces very nice isovolume plots similar to Mayavi and OpenCV

    ##Preallocate new colormap
    my_cmapN=cmapO(np.arange(cmapO.N))

    #set Alpha of new colormap to be small in the middle of the colormap range using a bump function
    # this can be changed to emphasize different areas of the range that are of interest.
    nA=cmapO.N
    xA=np.linspace(-1,1,nA)
    epsilon=5 #Width of range to exclude from alpha channel
    x_0=0#Center of range to exclude from alpha channel

    def f_AlphaControl(x):
        u=(x-x_0)/epsilon
        return 1-np.exp(-u**2/(1-u**2))*(np.abs(u)<1.)

    yA=f_AlphaControl(xA)
    plt.plot(xA,f_AlphaControl(xA))
    plt.xlim([-1,1])
    plt.ylim([0,1])

    my_cmapN[:,-1]=yA

    fig = plt.figure(dpi=200)

    # Create new colormap
    my_cmap = ListedColormap(my_cmapN)

    plt.style.use('dark_background')
    fig = plt.figure(dpi=200)
    ax = fig.add_subplot(projection='3d')
    points=ax.scatter(xx,yy,zz,c=ww,cmap=my_cmap)
    cbar=fig.colorbar(points)
    # cbar.solids.set_rasterized(True)

    cbar.set_alpha(1)
    cbar.draw_all()

    ## Make Title for plot
    ax.set_title(r'Plot of $f:\mathbb{R}^3\rightarrow \mathbb{R}$'+'\n'+r'$w=f(x,y,z)$')

    ##Plot x, y, and z axis useful for visual referencing when viewing the plot
    eps=.3
    tt=np.linspace(-(1+eps)*L,(1+eps)*L,2)
    ax.plot(tt,0*tt,0*tt,c='magenta',linewidth=2);
    ax.plot(0*tt,tt,0*tt,c='magenta',linewidth=2);
    ax.plot(0*tt,0*tt,tt,c='magenta',linewidth=2)

    ## Set viewing angle
    xang=-76;pang=12;
    ax.view_init(pang, xang)

    # Set axis limits
    ax.set_xlim([-(1+eps)*L,(1+eps)*L]);ax.set_ylim([-(1+eps)*L,(1+eps)*L]);ax.set_zlim([-(1+eps)*L,(1+eps)*L]);

    #Set axis labels
    ax.set_xlabel('$x$');ax.set_ylabel('$y$');ax.set_zlabel('$z$')
    plt.savefig("ScatterPlotVaryingAlpha.png",dpi=200)

if __name__ == "__main__":

    #Set Plot Grid

    L=1.5
    x_C=0.0;y_C=0.0;z_C=0.0;
    # Set XYZ Plotting Grid
    a1=x_C-L;b1=x_C+L;
    a2=y_C-L;b2=y_C+L;
    a3=z_C-L;b3=z_C+L;

    n=100;
    NT=n**3

    ##The following if statement determines whether you want to use a random grid R=1
    ## or a uniform grid R=0

    grid_flag=1

    if grid_flag==1:
       ## Random Grid
       xx=np.random.uniform(a1,b1,NT);
       yy=np.random.uniform(a2,b2,NT);
       zz=np.random.uniform(a3,b3,NT)
    else:
        ## Even Grid
        x = np.linspace(a1,b1,n);
        y = np.linspace(a2,b2,n);
        z = np.linspace(a3,b3,n);

        X, Y, Z = np.meshgrid(x, y, z, indexing='ij', sparse=False)

        xx=X.reshape(X.size);yy=Y.reshape(Y.size);zz=Z.reshape(Z.size);

    ## The following code defines the function of 3 variables that we wish to visualize
    ## This can be replaced with the flattened data array that you wish to plot

    def f(x,y,z):
        return x*y*z*np.exp(-(x**2+y**2+z**2))

    ww=f(xx,yy,zz)
    ww[np.isinf(ww)]=np.nan

    MakePlot(xx,yy,zz,ww)
    plt.show()

</code>
from matplotlib.colors import ListedColormap
Comment: I originally asked this question as I wanted to include an image like this in my university dissertation 8 years ago, so it's a little late, but it's certainly a worthwhile post! :P I really like the idea of making portions of the range transparent. I will definitely consider this if I need to make an image like this in the future.

It will be great for things like radiation fields around an object.
Answer: You could try plotting the 3rd dimension with color and the 4th dimension with the saturation/brightness of that color?
Comment: (Or more like tints and shades of that color)


Raft algorithm leader election when there is a partition

Question: Let's say you have three servers A, B and C
There is a network partition between A and C.
During leader election the following steps might happen:
a) A encounters a timeout and start a new election with term 1. B responds to the vote request and A becomes the leader.
b) After some time C starts a new election with term 1, but since B already voted for A for term 1, it refuses to vote for C and the leader election for C fails due to timeout.
c) Another timeout for C occurs and it starts a leader election for term 2. In this case B accepts C as a leader since it has a higher term and C becomes the leader.
d) Similarly later A starts and election for term 3 and the leadership alternates between A and C.
Wouldn't this stall progress? Am I missing something here?
Answer: If A can reach B and C can reach B then A and C are not in a network partition.
If a node or a group of nodes is unreachable from another node or a group of nodes, then there is a network partition between those two nodes/groups of nodes.


why am I getting a "single value for column cannot be determined" error when using the "EARLIER" function?

Question: I'm getting the "a single value for column cannot be determined" error in Power BI when using the EARLIER function.
I've tried using code from this post: Getting the PERCENTRANK.INC in PowerPIvot/DAX
I've also googled the EARLIER function plus other methods to avoid blanks, hoping this was the cause. Still get the error.
Finally, I tried the original solution in the post above; still get the same error:
RankAwards = RANKX('HRO_Table_current','HRO_Table_current'[HM31_AWARD_AMOUNT])

AwardsPercRank =
COUNTROWS (
    FILTER (
        'HRO_Table_current',
        'HRO_Table_current'[HM31_AWARD_AMOUNT]
            < EARLIER ( 'HRO_Table_current'[HM31_AWARD_AMOUNT] )
            && ISBLANK ( 'HRO_Table_current'[HM31_AWARD_AMOUNT] ) = FALSE ()
    )
)
    / (
        COUNTROWS (
            FILTER (
                'HRO_Table_current',
                ISBLANK ( 'HRO_Table_current'[HM31_AWARD_AMOUNT] ) = FALSE ()
            )
        ) - 1
    )

Expected Results: similar to what one would get using PERCENTRANK in Excel.
Actual Results: error mentioned before "a single value for column cannot be determined"
Comment: Is "AwardsPercRank" a measure or a calculated column?
Comment: It's a calculated column.
Answer: Give this one try
RankAwards = RANKX('HRO_Table_current','HRO_Table_current'[HM31_AWARD_AMOUNT])

VAR FIRTVALOR =

CALCULATE(
  COUNTROWS(HRO_Table_current);
  HRO_Table_current[HM31_AWARD_AMOUNT]< EARLIER(HRO_Table_current[HM31_AWARD_AMOUNT]);
  ISBLANK (HRO_Table_current[HM31_AWARD_AMOUNT] ) = FALSE ()
        )

VAR SECONDVALOR=
      CALCULATE(
          COUNTROWS(HRO_Table_current);
          ISBLANK(HRO_Table_current[HM31_AWARD_AMOUNT]) = FALSE()
               )

RETURN((FIRTVALOR / SECONDVALOR)-1)

What are you trying to do with RANKX, i think the 2nd valor most be an expression, i'm not sure what you're trying to do with RANKX statement.


PyOpenGL Constant Size 2D Labels for 3D Objects

Question: I'm trying to make labels for some 3d objects, with an icon/triangle to show you where the object is, plus some text describing what the object is.
Essentially, I want to 1. display text using pyopengl and 2. have the text + icon stay at a constant size on the screen that can 3. still move around the screen.
(I looked around a bit and looked at orthographic projections, but I'm not sure that's what I should be using...)
I have not used opengl very much at all, so this might be a dumb question!
Any help is much appreciate.
Answer: A nice start would be to store your icon + text inside a quad.
There are plenty of good tutorials on "font rendering" which will help you to create the desired quad.
You can load your icon inside a openGL texture, once done you will have to create your quad and associate a vertex and fragment shader to it. The difficult part will be to set a fixed position to your quad, that won't be linked to your 3D scene.
In video-games when you want to draw the ui, or the hud (healthbar, minimap), you draw them at the end on top off everything. Thoose elements don't need the mvp matrices, or projection matrices you might be familiar with. All the magic will appen in the vertex shader, he will be responsible to to set the position of all your elements, the output of the vertex shader should be in the [-1, 1] range for all coordinates:

-1 -> left, top, near
1 -> right, bottom, far

We call this space ndc see diagram https://antongerdelan.net/opengl/raycasting.html
Your job will be to output values in this range. If you want your quad to be half the size of the width and a quarter of the height, centered in the middle, you can store this information in the vertices you sent to your shader.
GLfloat vertices[] = {-0.5, -0.25, 0, // bottom left corner
                      -0.5,  0.25, 0, // top left corner
                       0.5,  0.25, 0, // top right corner
                       0.5, -0.25, 0}; // bottom right corner

vertex shader, people might use pixel size quads with a ortho projection
in vec3 pos;
in vec2 uv;

out fuv;

void main()
{
    //glm::mat4 translation = uTranslation might need to mvoe the quad on screen at runtime
    gl_Position = vec4(pos.x, pos.y, -1.0, 1.0); //set it to near plane -1
    fuv = uv;
}

fragment shader
in vec2 fuv;
out vec4 color;

uniform sampler2D renderedTexture;

void main(){
    color = texture(renderedTexture, fuv);
}


Phase shifting a signal

Question: I have a signal of the form $s(t)=A(t) \sum cos(\omega_i(t)t +\phi_0) + n(t)$, where $n$ is gaussian noise.
Now I want to phase shift this to $A(t) \sum cos(\omega_i(t)t)$ and I am at a loss on how to do this. During lectures / courses I've always done phase shifts simply by multiplying with $e^{i\phi_0}$ (signal is of the form $e^{ix}$).
Is there any way to do this? I'm asking because I am interested in cross-correlating two signals.
Edit: Posted this on signal processing stackexchange
Comment: The expression that is your goal contains no explicitly random terms.  Have you perhaps forgotten an additive random term, as in the original expression, or do you intend one of the other parameters such as $A(t)$ or $\omega_i(t)$ to be random?
Answer: White noise stays white noise when phase shifted, since it's stationary. Therefore, shifting $s(t)$ (the noisy signal) is equivalent to shifting $s(t) - n(t)$ (the signal without the noise).
In other words: $e^{i \phi_0} n(t)$ is still gaussian noise and you should just ignore the noise while shifting. Probably your teacher wanted you to realize that.
(By the way: this question is probably more related to signal processing than stats and there is a dedicated stackexchange for that on https://dsp.stackexchange.com/)
Comment: Hi Denwid, thanks for the reply! The problem with the phase shift is that I have the signal in real space (so the signal is not in the form of $\sum e^{i\omega_i t+a}$, so I can't phase shift the signal simply by using $e^{i\phi_0}((A(t) \sum cos(\omega_i(t) t+a))-n(t))$. The total signal is the only thing I have so I also can't just transform $cos(x) \rightarrow e^{ix}$. Should I try e.g. transforming the whole signal to frequency space and operate there?
Do you know of a way to move the question to the other forum? Or shall I delete it and move it there?
Comment: I made a post here: http://dsp.stackexchange.com/questions/29671/phase-shifting-a-noisy-signal

Phase shifting a signal


Acoustics of woodwinds with centered mouthpieces/openings

Question: Common woodwind instruments, as you know, are blown into from one of the two ends; the acoustic studies for air columns mainly center around these. But I am attempting to understand the acoustics of a woodwind instrument in which one does not blow into one of the ends but rather into a hole in the center, like the Chinese Koudi instrument.
In order to begin attempting to understand the acoustics of such an instrument, I need to know the fundamental frequency of the instrument. So let us say we only have the two open ends, and the hole you blow into (e.g. no tone holes). My first question is: What frequency would resonate based on the length of the instrument (also disregarding end correction for now)?
With that question answered (hopefully), let's say we covered one of the endholes with the blow hole and the other end hole still open, and still lacking tone holes. What frequency would resonate then, and how would it compare to the frequency from the first question?
Comment: You don't blow into one end of a western transverse flute either, but the two "halves" of the pipe are of different lengths, and one is closed at the end. The acoustics of the flute have been extensively researched - http://newt.phys.unsw.edu.au/music/flute/ is a good place to start. You may want to contact them directly about the Koudi - if anybody has published anything on its acoustics, they will probably know about it.
Comment: @alephzero Oh I've been on that website you've linked there many times, which is where I gained most of my minimal acoustic knowledge, so it won't help me further (especially how they in fact treat the flute as being blown into from one end). I would love to contact them, but I wonder how quickly they would reply back, because I don't want to wait three months for an answer, though that's just me being selfish.
Answer:
So let us say we only have the two open ends, and the hole you blow into (e.g. no tone holes). My first question is: What frequency would resonate based on the length of the instrument (also disregarding end correction for now)?

I believe this would behave as a regular tube open at both ends, but unable to resonate the fundamental, or in fact any odd harmonic, due to the open hole in the center.  The embouchure hole would be acting like a permanent octave key.  So I think the true fundamental wavelength would be twice the length of the instrument, but since you only have even harmonics it would be functionally the same as having the fundamental be simply the length of the instrument.

With that question answered (hopefully), let's say we covered one of the endholes with the blow hole and the other end hole still open, and still lacking tone holes. What frequency would resonate then, and how would it compare to the frequency from the first question?

If my thinking above is correct, then I think this would behave as a regular tube closed at one end, with fundamental wavelength 4x the length of the instrument.  The embouchure hole being in the center doesn't disrupt the fundamental in this case.  So compared to the first instrument, I think it would sound 2 octaves lower.
Comment: How about someone buys a hunk of 1/4" ID tubing and builds a few of these to see what happens?


What's the fastest grand slam tennis singles won

Question: I'd like to know what's the fastest total time of all the matches played by any male and female tennis grand slam champion for the entirety of a single tournament. In other words, what's the shortest duration of play time spent by any male and female grand slam champion over the course of all their matches? To make things even, each champion must have played all 7 matches of the major tournament.
Please provide the champion's name, the year and the tournament of the happening, as well as the time taken to win the major.
Comment: I literally spent years developing a fantasy tennis game a few years ago and have devoted hundreds of hours to scouring the internet for good sources of thorough tennis match data. I think I know what I'm talking about when it comes to what kind of tennis match data is easily found or not.
Comment: I doubt the data to support such a question is easily found, and even then, I doubt it has been compiled and sorted in such a way to show the shortest duration of play by a major champion. This just isn't a very important statistic to keep a record of across all time. It's usually only mentioned by broadcasters during the later rounds of the tournament and is likely considered disposable data. Good luck in your search.
Comment: @fedorqui I disagree. As jamauss mentioned such data is not easily found. I'm not talking about the number of games played to win the championship, but the total time taken. Let me know why you think the question doesn't show enough research effort. Your comment also implies that the data should be found somewhat easily doing some research, so I'm interested to see some sources.
Comment: @fedorqui thumbs up for the link. The whole point of this site is to post questions which the answers cannot be found within a reasonable amount of time. So it's implicitly implied that the OP of any decent question couldn't find the answer. That's why I don't see why any user should say they couldn't find the answer to the question no matter how long they spent looking for it.
Comment: Downvote. _This question does not show any research effort_.
Comment: Yes, the question is clear but does not show any research effort. If you tried and could not find any, say so! Otherwise this looks like a "make my homework, please" :) https://github.com/JeffSackmann/tennis_atp has the info about duration of the matches on some years and tournaments.
Answer: For male players (only champions that played 7 full matches (no retirements or walkovers) are considered). data is by Jeff Sackmann, but it's not entirely complete. Time (last column) is in minutes.
<code>tourney_date,tourney_name,winner_name,fulltime
2006-06-26,Wimbledon,Roger Federer,729
2003-06-23,Wimbledon,Roger Federer,745
1996-06-24,Wimbledon,Richard Krajicek,748
2004-06-21,Wimbledon,Roger Federer,753
2004-01-19,Australian Open,Roger Federer,780
1996-05-27,Roland Garros,Yevgeny Kafelnikov,786
2007-01-15,Australian Open,Roger Federer,799
1997-06-23,Wimbledon,Pete Sampras,804
1998-06-22,Wimbledon,Pete Sampras,820
2005-06-20,Wimbledon,Roger Federer,822
</code>