text:
Q: What does the basis of the null space of the constraint matrix of a flow problem look like? Consider a directed graph $G=(V,\mathbb{A})$ and a set of flow constraints of the following form:
$$ \sum_{(u,v)\in\mathbb{A}}x_{u,v} - \sum_{(v,u)\in \mathbb{A}}x_{v,u} = 0   \forall v \in V$$
where $x \in \mathbb{R}^{\mathbb{A}}$.
Consider $A \in \mathbb{\{0,-1,1\}}^{|V|\times |\mathbb{A}|}$ to be the  matrix representing the aforementioned constraints and $N_{A} = \{ y : Ay = 0 \}$ to be its null space.
What does a basis of this null space look like?
Edit: Fixed errors pointed out by Peter Heinig.

A: An illustrated example right-away
Not to immediately bore you with lengthy preliminary remarks, let me begin with an illustration which, in a sense, already is an answer in itself. Here is an example that such a basis can look very different from the familiar spanning-tree-bases, and still be highly structured:

(source: [H2014; p. 83], color added, and some notation in [H2014] not needed here removed)
Figure 1. This is an example of a representation of the flow on the left-hand side in terms of a basis consisting of Hamilton-flows only.
  The left-hand flow is not a Hamilton flow (since vertices $3$ and $5$ are not in the support of the flow). Since 'flow' is just another term for 'element of the null space of the constraint matrix of a flow problem', this is an example of exactly the kind the OP was asking for: the basis of the 'constraint matrix' of a flow problem (better called: incidence matrix) can look very special, in particular, they can look very different from the familiar spanning tree bases, i.e. bases obtained from choosing a spanning tree and adding missing edges one by one.

The relevant directed graph here is represented by each of the nine undirected graphs underlying the pictures (the graph is the same everywhere), the edge-directions are not drawn but defined by letting any undirected edge $\{i,j\}$ with $i<j$ (natural order) represent the directed edge $(i,j)$.
(In other words, direct each edge from the smaller to the larger vertex.)
On the left-hand side of the equation, the thick black lines with the white inlays represent a flow, i.e., in your notation, an element of $N_A$, with a support equal to a 'circuit'; this circuit is not a 'Hamilton-circuit', because  two vertices are not used by the circuit. (Incidentally, the circuit on the left-hand side is a so-called *fundamental circuit, i.e. it can be constructed by choosing a suitable spanning tree, and then adding one more edge not in the tree.)
On the right-hand side, you see the eight elements of a Hamilton-basis (explained below) among the many bases of $N_A = Z_1(G)$, together with the unique integer coefficients which make the eight Hamilton-flows add-up to the given non-Hamilton-flow.
The basis you see in Figure 1 is a basis each of whose eight elements has its support equal to a Hamilton-circuit of $G$. (This is called a 'Hamilton-basis'). This is in some sense an answer to how these bases
can 'look like'. (An important point is that the above example looks very different from the so-called fundamental cycles that a commentator  mentioned at 2017-08-23 22:50:19Z in this thread.)
You can check (in Figure 1) that 'on' each particular edge the relevant calculation works out to the value given on the left-hand side. A remarkable feature are the small magnitudes of the $\mathbb{Z}$-valued coefficients in the linear combination (all coefficients have absolute value at most $2$). In my experience, it is relatively easy in a moderately dense graph to find a Hamilton-circuit-supported basis by choosing rank-many Hamilton-flows randomly, but it is not easy to find a Hamilton-basis such that the coefficients in the (unique) linear combination representing a given flow are all small. The small coefficients are not a purposeless gimmick: to write the  proof in [H2014] for general $n$, it was (at least pragmatically) necessary to keep the coefficients small and reasonably structured; otherwise the  proof would have been unmanageably complicated (in [H2014], a Hamilton-basis is given which is structured enough to carry out the proof for general $n$ without even having to resort to induction, and this basis was not found by randomly mining the available Hamilton-bases, rather by a rather tedious mixture of machine-experimentation and human intuition).
To give an explicit example, on e.g. the directed edge $(1,10)$, the relevant calculation works out to (note that blue coefficients match Figure 1)
$\small 0= \color{blue}{(+)} \cdot 0 {\ \scriptsize\text{+}\ }  \color{blue}{0} \cdot (+) {\ \scriptsize\text{+}\ }  \color{blue}{(-)} \cdot (+) {\ \scriptsize\text{+}\ } \color{blue}{(+2)} \cdot (+) {\ \scriptsize\text{+}\ }  \color{blue}{(-2)} \cdot (+) {\ \scriptsize\text{+}\ }  \color{blue}{(-2)} \cdot 0 {\ \scriptsize\text{+}\ }  \color{blue}{(+2)} \cdot 0 {\ \scriptsize\text{+}\ }  \color{blue}{(+1)} \cdot (+)$
$=$
$\small 0 {\ \scriptsize\text{+}\ } 0 {\ \scriptsize\text{+}\ } (-) {\ \scriptsize\text{+}\ } (+2) {\ \scriptsize\text{+}\ } (-2) {\ \scriptsize\text{+}\ } 0 {\ \scriptsize\text{+}\ } 0 {\ \scriptsize\text{+}\ } (+)$
$=$
$\small (-) {\ \scriptsize\text{+}\ } (+)$
$=$
$\small 0$
where $-:=-1$ and $+:=+1$ and the second factors correspond to the flows given by the black lines, the inlays indicating the direction of the respective flow.
Needless to say, since this is a basis, the $\mathbb{Z}$-linear representation of the non-Hamilton-flow in terms of the eight Hamilton-flows, more precisely, the coefficient vector $(1,0,-1,2,-2,-2,2,1)\in\mathbb{Z}^8$ is the only one among the infinitely-many in $\mathbb{Z}^8$.
Six preliminary remarks on the syntax of the OP
Remark 0 I think the form of the OP (its title included) should be improved.
Instead of rewriting it from scratch, I will leave the question untouched and instead offer an equivalent formulation of the question here:
My suggestion of an equivalent reformulation of the title of the OP: what structural results are known about elements of the kernel of the incidence matrix of a directed graph? ${}\hspace{79pt}$ (e.0)
My suggestion of an equivalent reformulation of the OP: what is known about how to describe the null space of the signed incidence matrix of a specified finite directed graph in  combinatorial/structural/graph-theoretic terms? ${}\hspace{256pt}$ (e.1)
I think that (e.0) is equivalent to the title, and (e.1) is equivalent to the OP.  The alternative formulations are better because 'incidence matrix' is a more usual and neutral technical term than 'constraint matrix', which belongs to the rather specialized context of combinatorial optimization.
Remark 1  To say "set of flow constraints"  and "constraint matrix" is misleading, or at least the wrong emphasis, since this "constraint matrix" is determined by the given digraph alone, not by the constraints; that is, your matrix $A$ is independent of the values $x_{u,v}$ in the OP. I therefore recommend to not call $A$ a 'constraint matrix'.

*

*in your OP, you use 'constraint' in a slightly
unusual sense: you don't use it to mean some kind of capacity or costs
specified for the edges, but rather you simply mean the usual
flow condition.

Remark 2 For simplicity, in this answer I simply assume that

in the OP, "directed graph" means 'oriented graph'='digraph without any 2-cycles'='1-dimensional finite abstract simplicial complex'.

This implies: in this answer, no multiple edges whatsoever are allowed, not even 2-cycles(=antiparallel arcs) are allowed, which are allowed in digraphs.
Remark 3 I hope you don't mind a nitpick and piece of good advice: while I am well aware that,
especially in applied mathematics, sets of matrices tend to be written in the form

$(\text{codomain of the linear map described by the matrix})^{(\text{finite cardinal})\times(\text{finite cardinal})}$,

this is only seemingly natural, and I would like to  recommend to simply write your matrix as

$\{0,-1,+1\}^{V\times\mathbb{A}}$

instead of the unnecessarily complicated $\{0,-1,+1\}^{\lvert V\rvert\times\lvert\mathbb{A}\rvert}$, which in particular involves the concept of cardinal numbers, which is quite irrelevant to the problem. My recommendation is to simply to label rows and colums by the very things whose relation to one another the matrix is meant to express, unless there is some compelling reason to label the entries by numbers. (And here there is no such reason). This is actually simpler, since then you do not need a total ordering, with numerical labels, on the sets indexing the rows and columns.
Remark 4 A more important criticism: the OP has "$N_A = \{y\colon Ay = 0 \}$" as the definition of the null space, which is simply undefined: it was not specified which module the vector $y$ is supposed to come from. In other words, if $R$ is a commutative ring (as such, it automatically contains $\{0,-1,1\}$), and if $M$ and $N$ are suitable free finite-rank $R$-modules, and if $f_A\colon M\rightarrow N$ is the linear map defined by $A$, then $N_A = \ker(f_A)$, and yet the OP has not specified what the domain $M$ is supposed to be.
One could interpret the appearance of $\mathbb{R}$ in the OP to mean that the asker is only interested in the linear map $\mathbb{R}^{\mathbb{A}}\xrightarrow[]{v\mapsto Av}\mathbb{R}^V$, whereupon e.g. the (problem) below would be moot (since then we would only be dealing with vector spaces), yet it is not completely clear to me that the OP is only interested in real numbers. I recommend to also study the case of integer coefficients; this case is arguably simpler as far as the underlying set-theoretic foundations are concerned, and it is both mathematically more interesting and relevant to some applications.
Remark 5 Permit me to end these syntactical remarks with some carping and cavilling at grammatical minutiae: the OP contains the grammatically correct, but misplaced and unintentionally-funny formulation "Consider $\{y\colon Ay=0\}$ [...] to be its null space." The trouble is that there is nothing to willfully "consider" here: the set defined by the OP already is the null space.
Answer to what seems to be the substance of the OP.
The right setting for your question is the usual linear algebra over principal ideal domains; the question then is a question  about the cycle group of a 1-dimensional finite abstract simplicial complex.
I think that a relevant answer to your question is:

Let $G$ denote the undirected graph whose $\{0,1\}$-valued incidence matrix is obtained by forgetting all signs in your matrix $A$. Then the kernel of your matrix $A$  is just the flow lattice of $G$, and it is fair to say that no general theorem about the structure of the set of all $\mathbb{Z}$-bases of a graph is known, and, sadly, probably no noteworthy such general theorem exists .

The flow lattice(terminology) is the same as the cycle group $Z_1(G)=Z_1(G;\mathbb{Z})$ in the sense of classical simplicial homology, in the familiar sense usual at least since Seifert and Threfall's 1934 textbook. It has been generalized to the notion of the flow lattice of an oriented matroid.
I think that currently the best, and sadly perhaps the only, general structural statement relevant to your question is:

Proposition. Every basis of your $N_A$ (and, notably,  regardless of the ring or field of coefficients that you use), has the property that every element of the basis has its support equal to a union of graph-theoretic circuits. Somewhat conversely, if $H\subseteq G$ is any subgraph wich is a union of circuits, then there exists a flow $f\in Z_1(G)$ with $\mathrm{Supp}(f) = E(H)$. $\hspace{40pt}$     (circuit-union)

This is well-known, easily proved, and almost obvious. Perhaps the most interesting aspect of it (strictly speaking this is irrelevant to your question) is that this generalizes to arbitrary finite regular matroids: cf. Lemma 9 in [Y. Su, D.G. Wagner, The lattice of integer flows of a regular matroid. Journal of Combinatorial Theory, Series B 100 (2010) 691–70]. (Incidentally, beware that in that article, 'circuit' means the matroid-theoretic notion, not 'graph-theoretic circuit'='2-regular connected graph').
One should certainly also point out to you that:

if $S$ is a rank-sized generating set of a finitely-generated abelian group $A$, then $S$ is a basis of $A$

and hence

whatever set $S$ of $\mathbb{Z}$-generating set of the abelian group $Z_1(G)$ you choose (and such sets can look very unstructured), and if $\lvert S\rvert = \lvert E(G)\rvert - \lvert V(G)\rvert + 1$, then $S$ is a basis of $Z_1(G)$ (which I take to be equal to 'your' null space of $N_A$).

Furthermore, to the question

What's so good about spanning tree bases, i.e. what mathematical reasons are there to give so much prominence to spanning tree bases for $N_A$?

I personally would not have anything better to say than that these bases are the most well-studied and traditional ones, which is not a mathematical reason at all. In particular, the choice of what spanning tree to use to construct a basis is highly arbitrary (typically, the number of spanning trees is exponential in the order of the graph); also, the bases thus obtained are not known to have any noteworthy mathematical quality. In particular, spanning tree bases for $N_A$ tend to contain rather 'long' cycles, which in some contexts can be disadvantageous (think e.g. of fault-tolerance of the basis: if there are many 'long' basis-elements, they are more prone to get damaged).
If the above has not made it clear enough yet, let me spell out explicitly that

A basis of your $N_A$ need not consist of circuit-supported flows only (and probably most bases don't).

(The statistical conjecture just made has not been proved as far as I know.)
Moreover,

I think there does not exist a 'canonical' basis of $N_A$, in any sense deserving the (undefined) term 'canonical'

An open research problem.
The OP clarified their question in a somwewhat unclear comment at Aug 16 '17 at 11:37:

"All incidence vectors of cycles are in the kernel. Also all incidence vectors of cycles that "disregard orientation" are in the kernel if we swap some one entries for -1, to obtain a cycle with correct orientation. I assume they span the whole kernel. There are cases however when we can construct simple cycles from other simple cycles. So we wouldn't get a basis but just a generating set."

It take this to mean:

The signed incidence vector of any oriented circuit is in the kernel. Also, the incidence vector of any flow obtained from an undirected cycle by choosing any of its two orientations is in the cycle. The set of all such flows spans the whole kernel. However, in all but the trivial cases, this set is not a basis but just a generating set.

and that is obviously true.
The OP also remarks in a comment

So we wouldn't get a basis but just a generating set.

which seems to suggest that theh OP may also be interested in knowing more about how generating sets and bases of the flow lattice $Z_1(G)$ are related.
There is an interesting open problem about the relationship between generating sets and bases of $N_A$. This, to the best of my knowledge, is still an open research problem (I find it somewhat deplorable that this 'basic' question seems to be open---of course, it is somewhat undefined):

Research problem. Find an appreciable graph-theoretic/combinatorial/topological characterization of the class of all finite undirected simple graphs $G$ with the property that each generating set of the free finitely-generated abelian group $Z_1(G)$ contains a $\mathbb{Z}$-module basis of $Z_1(G)$.

Hopefully needless to say: for free modules, and even for free $\mathbb{Z}$-modules (= free abelian groups), it is not true4 that every generating set contains a basis, so the above problem is not moot.
I feel duty-bound to have to tell you upfront that even though your question shows some interest in this subject matter, and even though I personally think this is an interesting and open problem, you should not spend your time working on it, for two reasons: (0) it is quite possible that an appreciable answer simply does not exist, (1) in my experience, no one finds the question interesting, sadly.
I have a few conjectures with regard to the above problem, maybe even suitable for an MO question of its own. And yet I think better not to mention them here, if only not to bias anyone trying to solve the problem.
The problem is open, does not require much mathematical knowledge, and is also amenable to computational experimentation. Since you say you are interested in computing, this might be a plus.
Of course, the problem is a rather open-ended and aesthetic problem, in that "appreciable graph-theoretic/combinatorial/topological characterization" is not a mathematically defined term.
A generating set of $N_A$ not containing any basis
Quite unbelievably (since for other modules than $Z_1(G)$, such questions have been studied in detail, cf. e.g. [M2007a][M2007b][MS2012]) the first example of a generating set of $Z_1(G)$ not containing any basis was given in [H2014; Section 1.2.1]. (I would appreciate being shown an earlier publication containing such an example, or even a mention of its existence; I have searched much for this much, in vain.) This example is this:

Figure 2. The elements of the generating set of $N_A$ are represented by the thick black lines,
  with the white inlays indicating the direction of the respective flow. Each of the seven
  flows in the generating set has its support equal to a graph-theoretic circuit. The underlying
  graph is the wheel-graph. Its flow-lattice $N_A$
  has $\mathbb{Z}$-rank equal to $12-7+1=6$, hence a basis must have six elements only. The
  generating set show has $7>6$ elements, and it can be checked by explicity computations of the
  relevant Smith normal forms that leaving out any one of the seven
  flows in the generating set results in a non-basis, more precisely, a $\mathbb{Z}$-linearly
  independent subset of $N_A$ which generates a subgroup of index larger than one. The large gray arrows indicate the directed edges.
(source: [H2014; p. 4])

The example in Figure 2 sheds on your question, in the sense that the set of all bases of $N_A$ is mysterious and ill-understood, even for rather structured graphsf. E.g., the example in Figure 2 shows that

in general one cannot find all generating sets of $N_A=Z_1(G)$ by first finding all bases and then taking supersets thereof (as one could if one was facing a vector space).

The above, strangely enough, seems not to have been known before [H2014]. Of course, for modules in general, this is a very well-known fact, but for modules of the special form $Z_1(G)$ with $G$ a finite simple undirected graph, this seems not to have been known before, and questions remain.
A theorem about Hamilton-bases for $N_A=Z_1(G)$.
In [H2014], the following was proved, which can be seen as another variation on the theme that the bases for $N_A$ oftentimes can look very different from the familiar spanning-tree-bases:

Theorem. For every $\gamma>0$ there exists $n_0\in\omega$ such that if $n_0\leq n\equiv 3\quad(\text{mod $8$})$, then every finite simple undirected graph $G$ with $n$ vertices and minimum vertex degree at least $(\frac12+\gamma)n$ has the property that the free $\mathbb{Z}$-module $Z_1(G)$ admits a basis consisting only of flows whose support equals a Hamilton-circuit of $G$.

It is almost unimaginable that for the other congruence classes  $n_0\leq n\equiv 1\quad(\text{mod $8$})$, $n_0\leq n\equiv 5\quad(\text{mod $8$})$, $n_0\leq n\equiv 7\quad(\text{mod $8$})$ (note that it is necessary for such a result that $n$ be odd), the analogous statement is true, too, but this is not proved. Somewhat interestingly, the only known method for proving such a result depends, simultaneously in a boring yet delicate way, on the remainder of $n$ modulo $8$. With the current methods, it seems that one would basically have to carry out a sizeable part of the proof in [H2014] four times over in order to prove it for every $n_0\leq n\equiv 1\quad(\text{mod $2$})$.
It is probably much more difficult, and perhaps impossible, to get rid of the lower bound $n_0$ (which is super-exponentially large in $\frac{1}{\gamma}$); new methods would be needed, and it seems unlikely that this will ever be done.
Further literature references that the OP may be interested in.

*

*The newest news on $N_A$ as an object in its own right is the preprint [DG2016] of Dancso and Garoufalidis.

*A recommendable survey on computational problems related to $N_A$ is

F. Berger, P. Gritzmann, S. de Vries, Minimum Cycle Bases and Their Applications. Springer, LNCS, volume 5515

*

*More on optimization problems related to the OP's question (e.g., finding bases of $N_A$ having small total length of supports of the flows in the basis) can be found in :

*

*A talk by Jeff Erickson [8]

*An article by Jeff Erickson [9]

*Franziska Berger, Minimum Cycle Bases in Graphs. Berichte aus der Mathematik. Shaker. 2004. ISBN 9783832229863. 181 pages

If you would like to read something reasonably self-contained and textbook-like, and are willing to read a French text, then

[L2012]  Francis Lazarus, Topologie Combinatoire et Algorithmique. Notes de Cours. GIPSA-lab. Grenoble. 2012

seems extremely relevant to your question: in a sense, Lazarus's text has just the right emphasis for (what I read into) your question: Lazarus in particular places emphasis on graph-homology with real-valued coefficients.
In particular, Lazarus in the proof of "Proposition 1.1.9" gives a separate argument for why any spanning-tree-obtained set of fundamental cycles is a generating set. To be honest, the author does not really emphasize the fundamental $\mathbb{Z}$-coefficient case, rather does the proof in the context of $\mathbb{R}$-coefficients. In particular, Chapter 2 of Lazarus' text seems extremely relevant to your question. It is concerned with calculating 'good' (in some specified sense) bases of $N_A = Z_1(G)$.
Chapter 3 then broaches the topic of integer coefficients. Chapter 7 treats optimization questions, that you might be particularly interested in.
Footnotes.
(terminology) While the 'flow lattice' is indeed isomorphic to the usual cycle group of $G$ qua simplicial complex, as an abstract abelian group, the term 'cycle group' seems the wrong emphasis, in particular in view of results such as Su and Wagner's on characterizing circuit-supported elements of the flow lattice via the bilinear form on $Z_1(G)$. These are metric, not purely group-theoretic considerations.The lattice $Z_1(G)$ is less interesting as an abstract abelian group, more interesting as a concrete lattice $\subset\mathbb{R}^{   \lvert E(G)\rvert - \lvert V(G) \rvert + 1    }$. Insisting that $Z_1(G) \simeq N_A = \ker (\mathbb{Z}^{\mathbb{A}}\xrightarrow[]{v\mapsto Av}\mathbb{Z}^V) $. Viewing $Z_1(G)$ as a concrete discrete subgroup of $\mathbb{R}^{   \lvert E(G)\rvert - \lvert V(G) \rvert + 1    }$ provides additional structure, and in the case of the flow-lattice, such additional structure can be used in at least three ways:

*

*The lattice-viewpoint makes it possible to improve the obvious and hackneyed statement 'the orientations of the edge do not matter since the cycle groups are all the same': with the metric point of view, one can use the additional structure to make a stronger statement: not only are all the lattices $Z_1(G)$ obtained by flipping orientations isomorphic as abstract abelian groups, they are even isometric as lattices $\subset$ $\mathbb{R}^{   \lvert E(G)\rvert - \lvert V(G) \rvert + 1    }$ w.r.t the standard inner product (see [SW2010; p. 692).

*The lattice-viewpoint has been put to use by Su and Wagner in [SW2010] to give a metric characterization of circuit-supported elements of $N_A$.

*The lattice-viewpoint has been put to use by Amini in [A2010] to formulate a theorem on Voronoi cells: the abstract abelian group would not enable such results.

Glossary.

*

*'circuit' = '2-regular simple undirected graph', more usually called 'cycles', which is however a less suitable term than the more distinctive 'cycle' in contexts in which $Z_1(G)$ plays a role, since the latter's elements are usually called 'cycles' too. Moreover, the use of 'circuit' in graph theory, though unusual nowadays, is not unheard of: Tutte uses 'circuit'  in [T1956], A. Bondy uses 'circuit' in Chapter I.1 of [B1995],
[DG2016]  use 'circuit' as opposed to 'cycle', too.

*'lattice' = lattice as in lattice, not as in lattice, an unfortunate terminological clash of mathematical English, a clash especially acute in the title of Amini's preprint (where 'lattice-in-the-number-theoretic-sense' occurs side by side with 'poset')

*'simple flow' = 'flow in the digraph whose support is a circuit and whose values all have absolute value one' (i.e., arguably the simplest flow one can think of, bar the zero flow; cf. [SW2010])

*'spanning-tree basis' = 'the set of elements of $Z_1(G)$ obtained after arbitrarily selecting a spanning tree $T$ of $G$, then (one after another) adding-in an edge of $G$ not in $T$, arbitrarily choosing one of the two orientations of the unique so-called fundamental circuit obtained, and adding the 'simple flow' corresponding to said oriented circuit to the nascent set of flows'
References.
[T1956] W. T. Tutte, A class of abelian groups. Canadian Journal of Mathematics. 1956
[BHN1997] Roland Bacher, Pierre de la Harpe, Tatiana Nagnibeda, The lattice of integral flows and the lattice of integral cuts on a finite graph. Bulletin de la Société mathématique de France 125, fascicule 2 (1997), 167-198
[N2004]  Robert Nickel, Das Flussgitter affiner Punktkonfigurationen. Talk. 2004
[NH2007]  Robert Nickel, Winfried Hochstättler, The flow lattice of oriented matroids. Contrib. Discrete Math. 2(1). 2007
[M2007a]  Jacques Martinet, Bases of minimal vectors in lattices. I., Archiv der Mathematik, Arch. Math. 89, No. 5, 404-410 (2007)
[M2007b]  Jacques Martinet, Bases of minimal vectors in lattices. II., Archiv der Mathematik, Arch. Math. 89, No. 6, 541-551 (2007)
[BJG2009]  Jørgen Bang-Jensen, Gregory Gutin, Digraphs. Second Edition. Springer. 2009
[SW2010]  Yi Su, David G. Wagner, The lattice of integer flows of a regular matroid. Journal of Combinatorial Theory, Series B 100 (2010) 691–703
[A2010]  Omid Amini, Lattice of Integer Flows and Poset of Strongly Connected Orientations. arXiv:1007.2456
[L2012]  Francis Lazarus, Topologie Combinatoire et Algorithmique. Notes de Cours. GIPSA-lab. Grenoble. 2012
[MS2012] Jacques Martinet, Achill Schürmann,Bases of minimal vectors in lattices. III. Int. J. Number Theory 8, No. 2, 551-567 (2012)
[D2013]  Zsuzsanna Dancso, Bipartite algebras and a categorification of the flow lattice of graphs. Talk. 2013
[H2014]  Peter Heinig, Hamilton-based flow-lattices, logical limit-laws, and a measure on sign-matrices. Dissertation. TUM. 2014
[DG2016]  Zsuzsanna Dancso, Stavros Garoufalidis, A construction of the graphic matroid from the lattice of integer flows. Preprint. arXiv:1611.06282 [math.CO]


text:
Q: Proof of a closed-form of $\prod_{n=1}^{\infty} \frac{1}{e} \left(1+\frac{1}{3n}\right)^{3n+1/2}$ I'm looking for a proof of the following equality:

$$\prod_{n=1}^{\infty} \frac{1}{e} \left(1+\frac{1}{3n}\right)^{3n+1/2}=\sqrt{\frac{\Gamma\left(\frac{1}{3}\right)}{2\pi}}\frac{3^{13/24} \exp \left[1+\frac{2\pi^2-3\psi_1 \left(\frac{1}{3}\right)}{12\pi \sqrt{3}} \right]}{A^4}$$
Where $\psi_1$ is the trigamma function, and $A$ is the Glaisher-Kinkelin constant.

This product is the last entry of this Wolfram Mathworld page.
The product is stated to have been found by Gosper, however, his proof is not listed in the references. I have checked the OEIS entry of its decimal expansion also, however, the closed-form is not referenced there either. Assuming, Gosper refers to Bill Gosper, nothing about this product is stated on his Wikipedia page either.

A: The $\log$ of your product is $$
=\sum_{n\ge 1}  -1+(3n+1)\log(3n+1)-3n\log 3n-\frac12\log(3n+1)-
\frac12\log(3n)
$$
Up to a non-complicated constant coming from the regularization terms this is a mix of $\zeta(-1),\zeta'(-1),\zeta(0),\zeta'(0),\log\Gamma(1/3),L'(-1,\chi_3)$.

*

*$\chi$ is a an odd Dirichlet character so $L(-1,\chi_3)=0$ and the functional equation relates $L'(-1,\chi_3)$ with $L(2,\chi_3)$, it doesn't have a closed-form because $\chi_3$ is odd, which is where your $\psi_1(1/3)$ term comes from

*$\zeta'(0),\zeta'(-1)$ cause your $A$ term

redpajama_set_name: RedPajamaStackExchange


text:
Q: How is it possible to send multiple POST requests over a single TCP connection (Java)? I have a Spring Boot application running on Wildfly. A colleague is using curl to send a couple of files to my server.
When he sends the files, and we look at Wireshark, the two post requests are sent in the same frame.
My server processes them separately, reading the socket, saving the file, then closing the connection. Both requests get processed correctly.
How is this?
My guess is that when I close the connection in my code it's not closing the TCP connection, it's just finishing the HTTP request, but the actual socket remains open and the details are hidden from me. Is that correct?


text:
Q: Changing MySQL WHERE params I have these where params, but it's not returning what is desired:
WHERE `Profiles`.`Departure1` >= '2012-04-01'
OR `Profiles`.`Departure2` >= '2012-04-01'
OR `Profiles`.`Departure3` >= '2012-04-01'
AND `Profiles`.`Departure1` <= '2012-04-04'
OR `Profiles`.`Departure2` <= '2012-04-04'
OR `Profiles`.`Departure3` <= '2012-04-04'

There are three departure date fields and I'm trying to only return entries where the date lands between the two dates.  What I have here is returning everything.  Is there a better way to do this that might actually work?

A: Use mySQL's BETWEEN operator:
WHERE
    `Profiles`.`Departure1` BETWEEN CAST('2012-04-01' AS Date) AND CAST('2012-04-04' AS Date) OR
    `Profiles`.`Departure2` BETWEEN CAST('2012-04-01' AS Date) AND CAST('2012-04-04' AS Date) OR
    `Profiles`.`Departure3` BETWEEN CAST('2012-04-01' AS Date) AND CAST('2012-04-04' AS Date)

See the documentation:

*

*BETWEEN - http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between

*CAST/CONVERT - http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html#function_convert
A note: if this is the type of thing you're going to be doing a lot of, consider storing your dates as UNIX timestamps, using the BIGINT field type rather than a Date. That way you don't have to use CAST so much to do BETWEEN comparisons. You can use FROM_UNIXTIME (docs) to format on the way out of the db instead of monkeying around with converting every time you compare. See:

*

*PHP's strtotime - http://php.net/manual/en/function.strtotime.php

*PHP's date - http://php.net/manual/en/function.date.php

*mySQL's FROM_UNIXTIME - http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_from-unixtime

A: Use proper parenthesis:
WHERE ((`Profiles`.`Departure1` >= '2012-04-01'
OR `Profiles`.`Departure2` >= '2012-04-01'
OR `Profiles`.`Departure3` >= '2012-04-01' )
AND (`Profiles`.`Departure1` <= '2012-04-04'
OR `Profiles`.`Departure2` <= '2012-04-04'
OR `Profiles`.`Departure3` <= '2012-04-04'))

A: There are many ways to get this cleaner but I have kept it long hand to show the problem with the query above.
You need to make a link between the sets of departure dates, the one above is too broad.
WHERE (Profiles.Departure1 >= '2012-04-01' AND Profiles.Departure1 <= '2012-04-04')
OR
(Profiles.Departure2 >= '2012-04-01' AND Profiles.Departure2 <= '2012-04-04')
OR
(Profiles.Departure3 >= '2012-04-01' AND Profiles.Departure3 <= '2012-04-04')


text:
Q: When do I put - inside an  element? When do I put  headings inside a header element? I can't understand it, sometimes it seems to me that each heading has to be between header tags.
Let's take this sidebar as example :

How to code it?

How to format

or

How to format

A: See the specification of the header element:

A header element is intended to usually contain the section's heading
  (an h1–h6 element), but this is not required. The header element can
  also be used to wrap a section's table of contents, a search form, or
  any relevant logos.

So you can have many header elements in a page (it's not limited to the top of the page), and you can use it around headings, but it's optional. This means both of your examples are correct.

A: The header tag is for what displays at the top of the page of the page-what is sometimes called the banner. So put your h1-h6 tags in it when they are in the banner of your page.
Tags like header and footer are basically just div's renamed for organizational sanity. In the future search engines and browsers may look for header and footer tags to help them process and display information better. For now, it lets you avoid staring at a bunch of div tags.

     Web page Banner

Content

    Web page bottom

Instead of this...

 Web page Banner

Content

Web page bottom

A:  give us some great added semantic value in order to describe the head of a section.
You can use multiple headers in a web page, each of which will then become the  for that section of the document. So, using a  depends on the complexity of the section. The more complex it is, the more necessary the header element becomes.
a  typically contains at least (but not restricted to) one heading tag (
 –
).
hope it helps


text:
Q: Drupal 8 How to make a view that shows only taxonomy terms related to the current node In drupal 8 I have a content type "article" which has taxonomy terms. Now I would like to make a list of those terms in a block so I can put it somewhere else on the page than the bottom of the node content.
Edit: I tried to follow https://drupal.stackexchange.com/questions/69426/get-list-of-taxonomy-terms-for-current-node-through-views
but I can't select NID in step 4.

A: *

*Create a 'Taxonomy Terms' view, choose block attachment

*Add a relationship, something like 'Content using field_my_taxonomy_term' - in this case you want to use the entity ref field on your 'Article' content type.

*After adding the relationship, add a contextual filter, in this case it will simply be 'ID' for category 'Content':

*After adding, configure the relationship field and select 'Provide default value' in the first bullet point:

Then that should be it. You can use the 'preview' field to enter a node id and see results in the view itself.

Afterwards, you can add the block to the page you want and voila, the block should work correctly


text:
Q: Does Bluetooth App still work and collect data when phone is sleep I'm building an Android app for a smart watch that reads the smart watch data.
But the app relies on Bluetooth to connect with the watch.
I want to track heart rate for a day or two.
Is it possible for the the app to lose connection or stop collecting data over the course of 48 hours? When the phone "goes to sleep" or the display screen shuts down?


text:
Q: Atualizar um Switch de um Dialog Tenho um Dialog assim:
public void Dialogo_Iluminacao() {

    final Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.dialogo_iluminacao);

    dialog.setTitle("Iluminação");

    final Switch garagem = (Switch) dialog.findViewById(R.id.switchGaragem);
    final Switch jardim = (Switch) dialog.findViewById(R.id.switchJardim);
    final Switch sala = (Switch) dialog.findViewById(R.id.switchSala);

    garagem.setChecked(luzgaragem);
    jardim.setChecked(luzjardim);
    sala.setChecked(luzsala);
    holofote.setChecked(luzholofote);
    fundo.setChecked(luzfundo);
    lateral.setChecked(luzlateral);

    garagem.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        doCommand((garagem.isChecked() ? "acenda" : "apague") + " garagem", false);
                        garagem.setChecked(luzgaragem);
        }
    });

    jardim.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            doCommand((jardim.isChecked() ? "acenda" : "apague") + " jardim", false);
        }
    });

    sala.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            doCommand((sala.isChecked() ? "acenda" : "apague") + " sala", false);
        }
    });
 dialog.show();
}

quando eu click no Switch garagem, jardim ou sala ele chama uma função que se funcionar retornar uma boolean. Problema eu so posso mudar o estado do switch de on/off depois que tiver esse retorno como devo fazer isso?
Preciso alterar o estado do Switch quando tiver um retorno nessa função
public void OnStatusDaLuzRecebido(final Boolean b, final String setor) {

    new Thread() {
        public void run() {
            try {
                runOnUiThread(new Runnable() {

                    @Override
                    public void run() {

                        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
                        DateFormat horaformat = new SimpleDateFormat("HH:mm:ss");
                        Date date = new Date();
                        String dataagora = dateFormat.format(date);
                        switch (setor) {
                            case "garagem":
                                luzgaragem = b;
                                Toast.makeText(getApplicationContext(), (b ? " acesa " : "apagada"), Toast.LENGTH_LONG).show();
                                break;
                            case "jardim":
                                luzjardim = b;
                                Toast.makeText(getApplicationContext(), "Jardim " + (b ? "aceso" : "apagado"),
                                                Toast.LENGTH_LONG).show();
                                break;
                            case "sala":
                                luzsala = b;
                                Toast.makeText(getApplicationContext(), "Luz " + (b ? "acesa" : "apagada"), Toast.LENGTH_LONG).show();
                                break;
    });
                Thread.sleep(300);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }.start();

}


text:
Q: Dependency errors during OpenERP installation Im trying to install OpenERP v7 on ubuntu and when I try to install the dependencies I get this error:
E: Package 'python-pychart' has no installation candidate
E: Package 'python-pydot' has no installation candidate
E: Package 'python-vobject' has no installation candidate
E: Unable to locate package python-CherryPy3
E: Package 'python-pybabel' has no installation candidate
E: Package 'python-matplotlib' has no installation candidate
E: Unable to locate package python-hippocanvas
E: Package 'python-pydot' has no installation candidate
E: Package 'python-webdav' has no installation candidate

I have been searching on google on how to solve it but nothing has helped so far. Please help.

A: hi this is a command for all dependencies for openerp 7 in ubuntu 12.04 or later:
sudo apt-get install python-dateutil python-docutils python-feedparser python-gdata \
python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid \
python-psycopg2 python-psutil python-pybabel python-pychart python-pydot python-pyparsing \
python-reportlab python-simplejson python-tz python-unittest2 python-vatnumber python-vobject \
python-webdav python-werkzeug python-xlwt python-yaml python-zsi


text:
Q: pgsql: How to put Array_to_string inside the COALESCE In select statement i have column max(array_to_string(v_date,'||'::text)) filter (where type_key=1) .
Now i have to use COALESCE, to display default values for v_date nulls.
Tables/data is here dbfiddle
select obj_key, max(updated_on) as updated_on, max(att.status) as status,
      COALESCE(max(array_to_string(v_date,'||'::text)) filter (where att.type_key=1),max(default_value))  as "DOB",
      max(array_to_string(v_text,'||'::text)) filter (where att.type_key=2) as "First Name",
      max(array_to_string(v_text,'||'::text)) filter (where att.type_key=3) as "Last Name",
      max(array_to_string(v_number,'||'::text)) filter (where att.type_key=4) as "Contact"
from attributes att right join types ty on att.type_key=ty.type_key
group by obj_key

DOB for obj_key 3 must be '1/1/1950' but its giving sample1 ?
Is it possible to use array_to_string inside coalesce to get none null values (default values) ?

A: You need to join on the types table again to get the value as you have only the default_values for the type_key for the values 2 and 3 when you join on the attributes table grouped by obj_key.
Try this version:
select obj_key, max(updated_on) as updated_on, max(att.status) as status,
  COALESCE(max(array_to_string(v_date,'||'::text)) filter (where att.type_key=1),(select default_value from types where type_key=1))  as "DOB",
  COALESCE(max(array_to_string(v_text,'||'::text)) filter (where att.type_key=2),(select default_value from types where type_key=2)) as "First Name",
  COALESCE(max(array_to_string(v_text,'||'::text)) filter (where att.type_key=3),(select default_value from types where type_key=3))as "Last Name",
  COALESCE(max(array_to_string(v_number,'||'::text)) filter (where att.type_key=4),(select default_value from types where type_key=4)) as "Contact"
  from attributes att right join types ty on att.type_key=ty.type_key
  group by obj_key


text:
Q: How to avoid clear text password in JDBC data source in Tomcat 10 I am using Tomcat 10 and added a JDBC data source in server.xml with clear text password. I want to use an encrypted database password for security purposes.
How can I add a custom data source factory in server.xml file of Tomcat 10 to achieve data source password encryption/decryption?


text:
Q: Enable/disable swipe to dismiss at runtime I am working on a wear app and I am able to enable/disable swipe to dismiss functionality by setting
 android:windowSwipeToDismiss

to false/true in extended style. There are two states of the screen I am showing in my activity. For each of these exclusive states, the swipe to dismiss feature need to be either enabled or disabled. I have not been able to do this.
I have searched a lot but I am unable to find the right solution.
Thanks in advance

A: I would use SwipeDismissFrameLayout as your main layout and use that to control weather the activity can be dismissed or not. Having android:windowSwipeToDismiss set to false.


text:
Q: Efficient algorithm for finding intervals in a DAG Apologies if I don't use the right terminology, I'm an outsider to the field. Also I'm not sure whether to post this here or in programmers.stackexchange as my aim is primarily to find an efficient algorithm to solve the following problem. Please tell me off if I'm in the wrong place.
Problem:
I have a (transitive) DAG $G=(V,E)$ with $N=|V|$ vertices.
For any pair of vertices $u,v\in V$ such that $(u,v)\in E$ define the "interval" between $u$ and $v$ as the set $$I(u,v) = \{w \in G: (u,w)\in E \text{ and }(w,v)\in E\}.$$
I want to find an efficient algorithm that counts the number $N_k$ of intervals of cardinality $k$ for a given DAG $G$.
Notes:
The brute force approach - representing G with an adjacency matrix and scanning through the entries - takes $O(N^3)$. My graphs are typically sparse, $|E|<0.25N^2$. Making little adjustments to the brute force approach I've been able to make things a little quicker but I haven't been able to get my speed below $O(N^3)$. Perhaps there is an obvious reason that this task can't be performed faster than $O(N^3)$? Any comments welcome.

A: The Strassen-Algorithm can square the adjacency matrix in $O(|V|^{\log_2 7})$.


text:
Q: How do i hide the currency symbol when there is no input? So i am making a create product page. The items were product name, product price, product description. There are gonna be times where user doesnt want to input any price on their product just yet. In that case i dont want it to show currency with the value 0 on the page. Is there any way to hide the currency? thank you
const [price, setPrice] = useState();

  const formatter = new Intl.NumberFormat("id-ID", {
    style: "currency",
    currency: "IDR",
  });

{formatter.format(item.price)}

A: You can add a condition to check the empty value of item.price on your JSX like below

{Boolean(item.price) && formatter.format(item.price)}

If you want to reuse that formatter for other values, I'd suggest you introduce a function
const formatCurrency = (priceValue) => {
   if(!priceValue) {
     return '';
   }

   return new Intl.NumberFormat("id-ID", {
    style: "currency",
    currency: "IDR",
  });
}

{formatCurrency(item.price)}


text:
Q: Update manager works but shows I'm not updating I'm using 12.04 (I cannot upgrade due to hardware issues). When an update comes in, it comes up and I update; however, it still says I've not updated in awhile. this is more of a nuasian, then an interference. Why doesn't Update manager see the last time I've updated? Why do I have to see that alert saying I need to run it? Even the system alerts are shows urgent messages to update after just a few minutes after updating. I have no other issues by this. Now it says 45 days, but it was saying over 500 days. but as you can see in the image below there are no updates to install as I just installed them.

A: It's complaining because you haven't installed the Hardware Enablement Stack.  That's the line that says "New important security and hardware support update" and has its own button  More Info.
The importance of this is described at the link, but briefly:

Starting Aug 8, 2014 systems running 12.04.2 HWE, 12.04.3 HWE, or
  12.04.4 HWE will no longer receive software updates for the kernel and, if you're running it, the graphics stack.


text:
Q: Issue pushing file from linux to windows with smbclient I have a file located on my linux box that is generated by a python script, the file is dropped inside of the /root/ directory
My bash script looks like so:
#!/bin/bash
# Run the HR Data feed
cd /root/hr-feed
# the file created here will land one directory above the scripts in /root/
python main.py

# Transfer the file to the server
cd /root/
smbclient \\\\[SERVER]\\[SHARE] --workgroup=[WRKGRP] --user=[USR] [PASS] -c 'put HRDataFeed.txt'

Everything works as desired up to the last line.  It must be executing with an error (though I'm not quite sure how to figure out what that error might be).
This job is running from the crontab. Which as I understand runs in a slightly different environment than root (or at least it seems to with how it behaves).
If I execute the script directly (not from the crontab) it runs without a hitch and the file is transferred to the destination windows server box.  My guess is that maybe I need to supply the full path to the HRDataFeed.txt file as part of the put command; however, I cannot seem to figure that out.
smbclient .... -c "put /root/HRDataFeed.txt"

results in an error that the file /root/HRDataFeed.txt cannot be found.
Any input is greatly appreciated.
EDIT
I tried updating my crontab to read
(for the sake of testing i had it running every minute)

*

*
*

*
*

*
*

*
*

*/root/hrdatafeed > last_run.txt

However nothing ever seemed to land in the file.
I will try just adding a pipe directly to the SMBClient command.

A: Cron tries to send a mail (using /usr/bin/sendmail) when a command fails -- that's the only way I know of to get the actual output of the script (you could install sSMTP to get this working fairly easily). The main difference in the cron environment is usually $PATH, so try setting an appropriate PATH in the crontab which includes the directory where smbclient is.

A: I ended up slightly re-writing the script to read like so:
#!/bin/bash
# Run the HR Data feed
cd /root/hr-feed
python main.py

# Transfer the file to the server
cd /root/
/usr/bin/smbclient \\\\[SERVER]\\HRDataFeed --workgroup=[WRKGRP] --user=[USR] [PASS] -c 'put HRDataFeed.txt'

I changed my crontab to this:

*

*
*

*
*

*
*

*
*

*sh /root/hrdatafeed.sh > /root/last_run > 2>&1

Finally was able to get some meaningful messages in the last run file.  Though there were no errors, I assume it was because I made the change to setting the full path to the smbclient command.
Thanks for all of the help on getting this worked out.
Now of course i'll update the cron tab to run with a little less frequency ;)


text:
Q: Trouble importing hdf5 file using VScode with python 3.7 from anaconda3 distribution (Windows) I am trying to import two hdf5 files. dataFolder contains the file path.
I am using a conda venvvirtual environment in VScode. I have installed the same software via the exact same way on another computer and it works fine. The code I am trying to use is:
trainData = pd.read_hdf(dataFolder+"dftrain.h5").values
trainData = np.array(trainData)

validData = pd.read_hdf(dataFolder+"dfvalid.h5").values
validData = np.array(validData)

nTrain = trainData.shape[0]
nValid = validData.shape[0]

I have tried to conda install pytables and it shows it is already installed. (Checked also with conda list and its there: pytables                  3.6.1            py38ha5be198_0
PS D:\###\####\MLPM> conda install pytables
Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

I get the following traceback, stating that I have to install tables at the end:
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-421c5198a2e1> in <module>
      1 dataFolder = "D:/Master/ETH Spring2021/MLPM/"
      2 #C:/Users/gfrusque/Spyder_DataExploration/
----> 3 trainData = pd.read_hdf(dataFolder+"dftrain.h5").values
      4 trainData = np.array(trainData)
      5

~\anaconda3\envs\myenv\lib\site-packages\pandas\io\pytables.py in read_hdf(path_or_buf, key, mode, errors, where, start, stop, columns, iterator, chunksize, **kwargs)
    397             raise FileNotFoundError(f"File {path_or_buf} does not exist")
    398
--> 399         store = HDFStore(path_or_buf, mode=mode, errors=errors, **kwargs)
    400         # can't auto open/close if we are using an iterator
    401         # so delegate to the iterator

~\anaconda3\envs\myenv\lib\site-packages\pandas\io\pytables.py in __init__(self, path, mode, complevel, complib, fletcher32, **kwargs)
    540             raise ValueError("format is not a defined argument for HDFStore")
    541
--> 542         tables = import_optional_dependency("tables")
    543
    544         if complib is not None and complib not in tables.filters.all_complibs:

~\anaconda3\envs\myenv\lib\site-packages\pandas\compat\_optional.py in import_optional_dependency(name, extra, raise_on_missing, on_version)
    107     except ImportError:
    108         if raise_on_missing:
--> 109             raise ImportError(msg) from None
    110         else:
    111             return None

ImportError: Missing optional dependency 'tables'.  Use pip or conda to install tables.

I have tried these:
https://anaconda.org/ska/tables
Missing optional dependency 'tables'. In pandas to_hdf
ImportError HDFStore requires PyTables No module named tables
conda 4.9.2
Another weird thing is this:
PS D:\Master\ETH Spring2021\MLPM> python --version
Python 3.8.5

while the version indicated on the bottom right is Python 3.7.10 64-bit ('myenv':conda)


text:
Q: Django: How to change field name in nested serializer Currently, I have this serializer:
class TokenSerializer(serializers.ModelSerializer):
    """
    Serializer for Token model
    """
    user = UserDataSerializer(many=False, read_only=True)

    class Meta:
        model = TokenModel
        fields = ('key', 'user')

And this is the response I get:
{
    "key": "d1de7dd82f2b987a6d9f35f1d033876e164f7132",
    "user": {
        "username": "peter258",
        "first_name": "Peter",
        "last_name": "Jones",
        "email": "peter.jones@gmail.com"
    }
}

I would like to change the response so instead of saying "user" it says "data" but when I change the serializer to something like this, I only get the "key" in the response:
class TokenSerializer(serializers.ModelSerializer):
    """
    Serializer for Token model
    """
    data = UserDataSerializer(many=False, read_only=True)

    class Meta:
        model = TokenModel
        fields = ('key', 'data')

How do you properly change the name of the "user" field inside nested serializers?

A: You can achieve this by providing a source argument to your UserDataSerializer, which expects the name of the attribute that will be used to populate the field.
class TokenSerializer(serializers.ModelSerializer):
    """
    Serializer for Token model
    """
    data = UserDataSerializer(many=False, read_only=True, source="user")

    class Meta:
        model = TokenModel
        fields = ('key', 'data')


text:
Q: java.sql.SQLSyntaxErrorException: The number of values assigned is not the same as the number of specified or implied columns I'm calling a java function using a url from my front end to insert data to the data base
This is my url:
http://localhost:49779/BackEnd/mobile/rideshare/addride/1590105&toyota&4&Himalaya&10&good&12-04-2017

This is the Java method:
@Path("addride/{student_id}&{vehicle}&{seats}&{destination}&{price}&{description}&{datetime}")
@GET

public void addRide(@PathParam ("student_id") int S_id, @PathParam ("vehicle") String vehicle, @PathParam("seats") int seats,
        @PathParam("destination") String destination, @PathParam("price") int price, @PathParam("description") String description,@PathParam("datetime") String datetime) throws ClassNotFoundException,SQLException{
    Connection myCon = null;
    Class.forName("oracle.jdbc.OracleDriver");
     myCon=DriverManager.getConnection("jdbc:derby://localhost:1527/ride_share","yadhu","yadhu");
    Statement st=myCon.createStatement();

    st.executeUpdate("INSERT INTO RIDES (STUDENT_ID,VEHICLE,SEATS,DESTINATION,PRICE,DESCRIPTION,DATETIME) VALUES "
            + "("+S_id+",'"+vehicle+"',"+seats+",'"+destination+"',"+price+",'"+description+"','"+datetime+"')");

}

The table RIDES has a column RIDES_ID, which is made with auto increment property.
This is how I created the table:
CREATE TABLE RIDES (RIDE_ID INTEGER GENERATED ALWAYS AS IDENTITY (start with 1000), STUDENT_ID INTEGER, VEHICLE VARCHAR(200), SEATS INTEGER, DESTINATION VARCHAR(200), PRICE INTEGER, DESCRIPTION VARCHAR(200), DATETIME VARCHAR(50));

The insertion works when I do it implicitly, but when I call the method using the url it's showing the error. I couldn't find the mistake please help me.

A: The error means that the number of columns you are trying to add does not match the number of declared columns.
IE.  insert into table (col1, col2) values (val1, val2, val3).
This could be due to a code error when reading the parameters from the URL.
This can also be due if one of the values your are passing contains a coma "," .
first level of debug:
Do SYSTEM.OUT.PRINTLN to the statement before executing it and check its outcome in the console to spot possible errors.
Also, please do use PreparedStatement instead of Statement since this will prevent your code from having SQL Injections and avoid many errors.


text:
Q: How can we get the original event in ember controller action How can we get the original event in ember action while handling action inside controller?
Controller
import Ember from 'ember';
export default Controller.extend({
    showDetails:function(id)
    {
       // I want like $(this).position().top
    }
});

Template
{{#each item in list}}

{{/each}}

A: {{#each item in list}}

{{/each}}

In controller,
import Ember from 'ember';
export default Controller.extend({
    actions: {
        showDetails(id, event) {
            //i want like $(this).position().top
        }
    }
});


text:
Q: Adding existing XCode project to new project This is possibly an extension of

How can I add an existing project as a working copy in XCode 4?

I have an existing iOS XCode project 'Project A' with one target, which is the app it builds.
Now I have another project 'Project B' I am currently working on and would like to add the 1st project as is to this one as and include it as a feature.
When I drag the .xcodeproj file of A, I can see the project come in, however, it brings in the target as well. When I look at the 'Target Membership' of any file in A, it has A's target and I don't see B's target.
What I would like to do is only have B's target and link all files in A to B.
I tried creating a lib out of A but that process is far more tedious. I would really like to proceed down the copy+link path. Can someone suggest what can be done?

A: Sounds like you might be more interested in an Xcode Workspace, unless you are truly interested in merging these two projects for good.
If you want to bring in all of the source files of the other project, you can right click the project in Xcode and choose "Add files to 'MyProject' ..." and in the interface that is presented you can choose target membership. I would go this route to "merge" the projects together rather than dragging in the full Xcode project.
There very well may be a way to do it how you are hoping, but this is the route I know and would take.


text:
Q: How to open few different fragments on recyclerview different item click? I am using recycler view in a fragment. I have 4 items in my recycler view list. Now I want to open 4 new different fragments. Here I can open different activities but I want to open 4 different fragments instead of activities. Below is my RecyclerViewAdapeter code. Please help me.

public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.MyViewHolder> {

    Context mContext;
    List<HindiFragmentModel> mData;
    private MathFragment MathFragment;

    public RecyclerViewAdapter(Context mContext, List<HindiFragmentModel> mData) {
        this.mContext = mContext;
        this.mData = mData;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

        View v;
        v = LayoutInflater.from(mContext).inflate(R.layout.fragmentdesign,parent,false);
        MyViewHolder vHolder = new MyViewHolder(v);
        mContext = v.getContext();

        return vHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, final int position) {
        holder.tv_name.setText(mData.get(position).getName());
        holder.img.setImageResource(mData.get(position).getPhoto());

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

               // here i want to open 4 new fragments..
               if (position == 0) {
                    Intent intent = new Intent(v.getContext(), NewHindiActivity.class);
                    v.getContext().startActivity(intent);
                }
                if (position == 1) {
                    Intent intent = new Intent(v.getContext(), NewHindiActivity1.class);
                    v.getContext().startActivity(intent);
                }
            }
        });

    }

    @Override
    public int getItemCount() {
        return mData.size();
    }

    public static class MyViewHolder extends RecyclerView.ViewHolder {
        private TextView tv_name;
        private ImageView img;
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            tv_name = (TextView) itemView.findViewById(R.id.titleView);
            img = (ImageView) itemView.findViewById(R.id.imageView);
        }

    }

}

A: holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            if(position == 0){
                Bundle args = Bundle()
                args.putString("id", Id)
                NewFragment newFragment = NewFragment()
                newFragment.setArguments(args)
        FragmentManager  fragmentManager =currentfragment.getFragmentManager()
        FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction()
                fragmentTransaction.add(R.id.frame, newFragment)
                fragmentTransaction.hide(currentfragment)
                fragmentTransaction.addToBackStack(null)
                fragmentTransaction.commit()
               }if(position == 1){
               //as mentioned above only the change is Fragment Instance
               }

               //write similar code for other positions

          }
        });


text:
Q: Javascript Bokeh Plot not rendering in browser I am creating a Bokeh Plot, and passing the html code script, div = components(plot)
return render_template('results.html',the_div=div,the_script=script)

The script and div have been passed to the browser, but instead of seeing the plot it displays the html code.

{% extends "bootstrap/base.html" %}
{% import "bootstrap/wtf.html" as wtf %}

{% block html_attribs %} lang="en" charset="utf-8"{% endblock %}

{% block title %}  Results {% endblock %}
{% block metas %}
</mysite/static/favicon-96x96.png">
<link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">

<script src="https://cdn.bokeh.org/bokeh/release/bokeh-2.0.2.min.js"
        crossorigin="anonymous"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.0.2.min.js"
        crossorigin="anonymous"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.0.2.min.js"
        crossorigin="anonymous"></script>

{% endblock %}

{% block content %}

<div class="container">
        {{ the_script }}
        {{ the_div }}
</div>

Can someone point out where I'm going wrong?
-I've check that the bokeh version I'm using is 2.0.2
I am not familiar with javascript so I am assuming it could be a simple fix
The view from the browser console:

A: By default, all template parameters are escaped to prevent them from altering the DOM structure.
Since you do need to alter the DOM structure, you should just add |save to each variable:
{{ the_script|safe }}
{{ the_div|safe }}

More details: https://jinja.palletsprojects.com/en/2.11.x/templates/#working-with-automatic-escaping

A: Your console screenshot shows the problem. You are trying to load Bokeh JSON generated with Python Bokeh version 1.3.4 with BokehJS version 2.0.2 from CDN. This is not supported and will not work (the versions must match).


text:
Q: How to change API to Json API in Laravel 8.* I created API in Laravel. Friend that created Mobile app says that he can connect with my data but he requires it to be in JSON format. Here comes my question. Is there any way to change data to JSON format in Api??
Strange is that API gets result in JSON(at least that's what is says)
Example of data in API results
Should I change my API to JSON:API for this to work?
My database works on MySQL if that might be necessary.
My Api routes:
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

// Events

Route::get('/events', function(){
    $date = Carbon::now();
    return Event::where('date_of_event','>=',$date)->get();
});

Route::get('/events/{id}', function($id){

    return Event::findOrFail($id);
});

// Cities

Route::get('/cities', function(){

    return City::all();
});

Route::get('/cities/{id}', function($id){

    return City::findOrFail($id);
});

// Clubs

Route::get('/clubs', function(){

    return Club::all();
});

Route::get('/clubs/{id}', function($id){

    return Club::findOrFail($id);
});

A: I use ->json() on the response, there are sure other ways to do it globally.
return response()->json($message);


text:
Q: Folder contents are automatically deleted every time I deploy my Rails app I have a directory under /public folder with the use of CarrierWave I store all my PDF files under this dir. But the problem is all the time I deploy new version of my Rails app this directory gets cleaned up and the all files are missing. This directory is was set under my uploader.
I also have a directory named "private" which I created manually in order to not to serve sensitive files globally on WEB. Those files also gone after new deployment process.
How can I prevent files from deleting on deploy process?
Thanks.

A: I assume you are using some automation for deployment. Because if you are updating your code on server instance manually then you can preserve pre uploaded file, but using manually method to update code is not a good practice.
So in automation deployment we generally follow this kind of flow.
Whenever you deploy that create a new deploy version and set that as current version.
Simply that means it's creating a new directory and placing your rails project in it. Now the files you are storing inside the project directory are there in the previous version those are not gone if you are using any linux instance.(Only if you have setup that way to preserve last few versions to restore incase of new deploy is exploded)
Clear till now?
Not suppose you are not keeping any previous version, your files are gone forever.
So it's not a good idea to store any file under project repository.
Best practice is to use bucket system like AWS bucket or Google cloud bucket, where we store all the uploaded file. If having bucket is not in budget, you can choose a different directory on linux server instance outside of project directory. But you have to setup all those upload paths and directory system to be used as bucket.

A: This problem I am facing with is happening because of capistrano. Every time I run cap production deploy command on my server, the capistrano deployment tool syncs every file with git repo. And the files added by end-users are not stored under my git repos of course, so capistrano overwriting the empty public folder from my repo to the server. Adding the path to :linked_dirs variable under deploy.rb solved my problem.
Another approach could be using a directory which is somewhere else than your project root path (such as /home/files) to store all your files. By doing this you will be seperating your files from project and also prevent capistrano's overwriting problem.
Hope this information will be useful for someone or future me :) ..

A: When you deploy with capistrano, a new deploy(folder) is created from the repository.
Any files not in the repository are not carried over.
If you want to persist files in public, you need to create a directory in your server first and then create a symlink with capistrano inside public to that folder.
Then have your carrierwave uploads saved to that location.
During each deployment cap will symlink to that directory and your files will  be there


text:
Q: How to fix "The key _username must be a string" error with JWT I have a website with a standard connection, and I want to add a new way to connect thanks to the API part.
I have followed this doc :
1https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Resources/doc/index.md#getting-started
So I add JWT bundle to my Symfony 3 project, and I changed my security.yml :
# app/config/security.yml

security:
  encoders:
    Symfony\Component\Security\Core\User\User: sha512
    GS\UserBundle\Entity\User: sha512 #sha512

  role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

  providers:
    main:
      entity:
        class:    GS\UserBundle\Entity\User
        property: login

  firewalls:
    dev:
      pattern: ^/(_(profiler|wdt)|css|images|js)/
      security: false
    main:
      pattern:   ^/
      anonymous: true
      provider: main
      stateless: true
      form_login:
        login_path: login
        check_path: login_check
        default_target_path: preLogin
      logout:
        path:        logout
        target:      preLogin
      remember_me:
         secret:     '%secret%' # se souvenir de moi
         lifetime: 1000
         always_remember_me: true
    login:
        pattern:  ^/api/login
        stateless: true
        anonymous: true
        provider: main
        json_login:
            check_path:               /api/login_check
            success_handler:          lexik_jwt_authentication.handler.authentication_success
            failure_handler:          lexik_jwt_authentication.handler.authentication_failure
    api:
        pattern:   ^/api
        stateless: true
        guard:
            authenticators:
                - lexik_jwt_authentication.jwt_token_authenticator
  access_control:
    - { path: /admin, roles: ROLE_ADMIN }
    - { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/api,       roles: IS_AUTHENTICATED_FULLY }

I have configured my config.yml like this :
lexik_jwt_authentication:
    secret_key:       '%kernel.project_dir%/config/jwt/private.pem'
    public_key:       '%kernel.project_dir%/config/jwt/public.pem'
    user_identity_field: login
    pass_phrase:      'MY PASSWORD'
    token_ttl:        3600

And When I tried to obtain my token with postman like this :

I have this error :
The key "_username" must be a string, "NULL" given.

So, I tried to add "user_parameter" in the security.yml in order to give the parameters name of my user entity, like this :
 login:
        pattern:  ^/api/login
        stateless: true
        anonymous: true

        json_login:
            check_path:               /api/login_check
            username_parameter: login
            password_parameter: mdp
            success_handler:          lexik_jwt_authentication.handler.authentication_success
            failure_handler:          lexik_jwt_authentication.handler.authentication_failure

And now Postman answer me nothing.
EDIT:
I find a commande to check my config file and I have this answer :

And if I remove the username_parameter and the password_parameter, the commande check tell me that the config is ok, but I have the same error with postman :
The key "username" must be a string, "NULL" given.

Help me please I don't find any solution...

A: Lexik JWT authentication config needs the provider key in the security.yaml.
login:
        pattern:  ^/api/login
        stateless: true
        anonymous: true
        provider: YOUR_PRODIVER_NAME #in your case it's main
        json_login:
            check_path:               /api/login_check
            username_parameter: login
            password_parameter: mdp
            success_handler:          lexik_jwt_authentication.handler.authentication_success
            failure_handler:          lexik_jwt_authentication.handler.authentication_failure

Then to be able to verify the user informations, it needs to know what field is the identity field.
So in the lexik_jwt_authentication.yaml:
lexik_jwt_authentication:
    secret_key: '%env(resolve:JWT_SECRET_KEY)%'
    public_key: '%env(resolve:JWT_PUBLIC_KEY)%'
    pass_phrase: '%env(JWT_PASSPHRASE)%'
    user_identity_field: YOUR_USER_FIELD # example email
    token_ttl: 7200

About the request parameters, username and password have to be passed (No _)


text:
Q: Is there a way to know how many times a static file is served or it has been served or not at all in Node.js? I'm using express to serve static files.
app.use('/downloads', express.static('downloads'));

A: The code that runs behind the scenes to serve static files in Express is quite simple (in fact, it's a single file!) - it doesn't deal with anything like logging or analytics.
If you want to add stuff like that, you will have to add a middleware to the chain that provides that functionality, either by using a third-party library or by writing your own.


text:
Q: posts within custom post type all share the same content in the front-end I've created a new custom post type called doctors. I've been using ACF and pulling these fields to help create my banner. I was wondering what a post would look like if no fields were filled out, so I created a second test post, but I noticed it has all of the same content as my first post.
I feel like I'm writing my function incorrectly, obviously.
function doctor_banner_shortcode() {
    $args = array(
        'posts_per_page'    => 1,
        'post_type'     => 'doctors',
        'post_status'       => 'publish'
    );
    $doctors_query = new WP_Query( $args );
    if ( $doctors_query->have_posts() ) :
        while ( $doctors_query->have_posts() ) :
            $doctors_query->the_post();

            $dr_name = get_field( 'practitioner_name' );
            $dr_degree = get_field( 'practitioner_title' );
            $dr_bio = get_field( 'practitioner_short_bio' );
            $dr_cv = get_field( 'practitioner_cv' );

            $html_out = '
Dr. ' . $dr_name . '

' . $dr_degree . '

' . $dr_bio . '

                         ' . 'Read CV' . '';
        endwhile;
    else : // No results
        $html_out = "No Doctors Found.";
    endif;
    wp_reset_query();
    return $html_out;
}

add_shortcode( 'doctor_banner', 'doctor_banner_shortcode' );

Somehow, I think, it's not reading the proper ID of that post to output the correct data. I have two links for my two posts here and here.

A: You are querying the entire posts of doctors type, and setting the number of posts per page to one. This will obviously always return the same post.
You need to either set the id of the post, or navigate through the loop to find a match. If you are calling this function in single post page, to filter the results based on post id, you should use the function this way:
function doctor_banner_shortcode($doctor_id) {
$args = array(
    'posts_per_page'    => 1,
    'post_type'     => 'doctors',
    'post_status'       => 'publish',
    'p'        => $doctor_id
);
$doctors_query = new WP_Query( $args );
if ( $doctors_query->have_posts() ) :
    while ( $doctors_query->have_posts() ) :
        $doctors_query->the_post();

        $dr_name = get_field( 'practitioner_name' );
        $dr_degree = get_field( 'practitioner_title' );
        $dr_bio = get_field( 'practitioner_short_bio' );
        $dr_cv = get_field( 'practitioner_cv' );

        $html_out = '
Dr. ' . $dr_name . '

' . $dr_degree . '

' . $dr_bio . '

                     ' . 'Read CV' . '';
    endwhile;
else : // No results
    $html_out = "No Doctors Found.";
endif;
wp_reset_query();
return $html_out;
}

add_shortcode( 'doctor_banner', 'doctor_banner_shortcode' );

Then you can call your function in the single.php template in this way :
function doctor_banner_shortcode($post->ID)
If you want to call the function manually in some other page, you should set the ID while calling the function.

A: It looks like you are not supplying the ID into the loop, forcing it to get the first item chronologically (which is always going to be the latest, regardless of where you call the shortcode).
If your shorcode runs inside the_content you don't even have to run another loop, just use the get_field directly.
function doctor_banner_shortcode() {

    $dr_name = get_field( 'practitioner_name' );
    $dr_degree = get_field( 'practitioner_title' );
    $dr_bio = get_field( 'practitioner_short_bio' );
    $dr_cv = get_field( 'practitioner_cv' );

    $html_out = '
Dr. ' . $dr_name . '

' . $dr_degree . '

' . $dr_bio . '

                 ' . 'Read CV' . '';

    return $html_out;
}

Lemme know if it works!


text:
Q: Apple Pay on web Merchant validation I Managed to retrieve merchantSession object from Apple Pay server as below. I used Sandbox Test (Setup on itunesconnect and login the sandbox account on iphone and added tested visa card)
{
    "epochTimestamp":15065...20,
    "expiresAt":1506527672620,
    "merchantSessionIdentifier":"2EF498A9E...C24",
    "nonce":"f32....9",
    "merchantIdentifier":"7941CB932...DE2",
    "domainName":"mywebsite.com",
    "displayName":"My Test Shop",
    "signature":"30800609....0000"
}

However, in the Apple Pay pop-up sheet, it still stuck at "Processing", what do I need to do to able to process the next stage to show the "Touch Id"?
Also, below is my code snippet for onvalidatemerchant:
session.onvalidatemerchant = (event) => {
        console.log("Validate merchant");
        const validationURL = event.validationURL;
        getApplePaySession(event.validationURL).then(function(response) {
            console.log(response);
            session.completeMerchantValidation(response);
        });
    };

A: Now if all the below are met, the payment sheet should be displayed on the iPhone. You should verify several things:

*

*Your Mac and iPhone are connected to the same iCloud test account

*Both are on the same WiFi

*HandOff is on

*AirDrop is on

*Bluetooth is on

A simple check to see if they are connected is to open a browser on the iPhone/Mac and see it on the other device.


text:
Q: Error from simply initializing a variable? While putting together a Boggle solver, I ran into some strange behavior I was hoping someone could explain to me. I got the function to return a set of possible words, and all I seemed to be missing was a way to prevent the solver from including words which were created by visiting the same square twice in a play. I tried to create a list of already visited squares within the current play (a list of index numbers within the string representing the board) by iterating over the global variable seen (I know this would not be correct) which is used to memoize previously explored paths. However, simply initializing a variable with those values using:
previous_ind = [j for (pre, j) in seen]

within the recursive function find_bwords, somehow effects the index variable i and causes IndexErrors stemming from the last line in find_bwords.
seen = set() #(prefix, index) pairs

def boggle_words(board, minlength=3):
    "Find all the words on this Boggle board; return as a set of words."
    results = set()
    for i, sq in enumerate(board):
        if is_letter(sq):
            find_bwords(board, sq, i, results, minlength)
    return results

def find_bwords(board, pre, start, results, minlength): #adds to seen and results
    global seen
    #prev_ind = [j for (pre, j) in seen]  <---mystery culprit
    if (pre, start) not in seen:
        seen.add((pre, start))
        if len(pre) >= minlength and pre in WORDS:
            results.add(pre)
        if pre in PREFIXES:
            for i in neighbors(start, int(sqrt(len(board)))):
                #print 'index: ', i
                find_bwords(board, pre+board[i], i, results, minlength)

Here is a portion of the printout of indexes before introducing prev_ind:
index:  0
index:  1
index:  2
index:  6
index:  8
index:  12
index:  13
index:  14
index:  1
index:  2

and here is a portion after:
index:  0
index:  -7
index:  -14
index:  -21
index:  -28
index:  -35
index:  -42

Why is this happening?
To be clear, I am not looking for a solution to this assignment, I have solved it another way, I just want to understand what is happening in this instance.

A: The problem is on this line you are assigning to pre, overwriting the previous value it had:
prev_ind = [j for (pre, j) in seen]  # <---mystery culprit

Try changing it to this and it should work as you expect:
prev_ind = [j for (pre2, j) in seen]


text:
Q: Display flex acting differently in Chrome and Safari Background:
In a tool my team is working on, we are implementing a header that moves off the screen programmatically based on an event listener. After writing the first implementation it worked as expected but only in Chrome.
I am using display:flex on the #wrapper as well as on the #content elements.

  Header Content
   ...

            <svg id="svgTool" height="100%" width="100%" class="svgTool style-scope test-tool"></svg>

   ...

some of the css:
...
#wrapper {
  width:100%;
  height:100vh;
  position:relative;
  display:flex;
  flex-direction:column;
  margin-left:auto;
  margin-right:auto;
  min-height:100%;
}

#content {
  display: flex;
  flex-direction: column;
  height: 100%;
}
...

Using some simple JavaScript I am adjusting the margin-top of the header element when a button is clicked (for this example).
Problem: While Chrome works as expected, Safari does not. I suspect that this must be due to how Safari's version of webkit interprets elements using display: flex. edit: or perhaps it is due to how Safari works with vh units?
In Chrome the header will slide up and down without affecting the <svg> element. In Safari, adjusting the margin-top of the header will cause the svg element to create whitespace on the bottom of the screen equal to change in the header's margin-top.
JSBin:
This JSbin works identically to the current implementation of our tool.
Open it both in Chrome and Safari to see the discrepancy.
http://jsbin.com/kaxiqig/edit?html,css,output
sidenote: firefox also works as expected

A: In lieu of a real fix for what seems to be a bug, a simple workaround is to toggle the height of main while you are also toggling the header position. Basically, it seems that Safari is pulling main up with the header as it transitions upwards, so we'll just make it taller so it extends down to the bottom of the screen again.
The default height of main is calc(100vh - 80px), so we can just modify the second half of that calc expression to get our new value. Exactly how you modify it depends on how tall the header is in your application. Let's say that in this case the header is typically 100px tall. Since the header is transitioned to be margin-top: -75px, we can just change our calc expression to calc(100vh - 25px) for the new height.
While I initially suggested toggling a minimum-height on main, I noticed that we also get an ugly bug when doing that where the minimum height change doesn't quite transition right even if we add a matching transition property, leaving a white gap at the bottom of the screen for a split second. So we can just animate the actual height instead, which gives a nice smooth result.
In your CSS, I added this line:
main {
  transition: height .5s;
}

The new sliding function becomes:
function slide() {
  if (document.querySelector('header').style.marginTop !== "-75px") {
    document.querySelector('header').style.transition = ".5s";
    document.querySelector('header').style.marginTop = "-75px";
    document.querySelector('main').style.height = "calc(100vh - 25px)";
  } else {
    document.querySelector('header').style.marginTop = "0";
    document.querySelector('main').style.height = "";
  }
}

If your header is going to vary in height, you can either toggle a class on main instead, and revise the calc expression that class uses with different media queries, or you could enhance the function to first find the viewport height and then subtract the post-transition header height to find the new height to apply to main.


text:
Q: Static Methods or Not? Global variables? I want to know what way is more efficient.

*

*No global variables, passing variables through parameters, having all methods static

*No global variables, having only main method static and creating class object in main to access methods

*Use only global variables, having only main method static and creating class object in main to access methods
I am currently using method 3 but I want to know what is more efficient. This class will not be used by any other class outside of it, it pretty much stands alone.
Example of my code structure:
public class myClass {
   private int globalVariable;

   public static void main(String args[]) {
      myClass c;
      c.someMethod(); // Changes global variable from method
      System.out.println(someMethod); // Prints solution
   }

   public void someMethod() {...}
}

A: *

*No class is an island.

*There are no silver-bullets, at least its very true in programming.

*Premature optimisation is the root of all evil.

*In Java we don't have global variables. We only have class variables, instance variables, and method variables.

[Edit]
I am trying to explain here my last point. In fact, bringing the discussion, that is going-on in comments below, to the actual post.
First look at this, an SO thread of C#. There folks are also suggesting the same thing, which is,

*

*There are no global variables in C#". A variable is always locally-scoped. The fundamental unit of code is the class, and within a class you have fields, methods, and properties

*I would personally recommend erasing the phrase "global variable" from your vocabulary (this is in the comment section of the original question)

So, here we go.
retort: Classes are globally scoped, and thus all class variables are globally scoped. Hence should be called global.
counter-retort: Not all classes are globally scoped. A class can be package-private. Therefore, the static variables in there will not be visible outside the package. Hence, should not be called as global. Furthermore, classes can be nested, thus can be private as well and definitely can have some static variables but those wouldn't be called global.
retort: public classes are globally scoped, and thus all class variables are globally scoped.
counter-retort: Not exactly. I would like to move the previous argument here but on a variable level. No matter if the class itself is public. The variables in there can be protected, package-private and private. Hence, static variables will not be global in that case.
Now, if you like to call public static variable in public static class, as global then call it by any means. But consider this, when you create a new ClassLoader (as a child of the bootstrap ClassLoader) and load a class that you've already loaded. Then that results in a "very new copy of the class" -- complete with its own new set of statics. Very "un-global", indeed. However, we don't use the word global in Java because it tends to confuse the things and then we need to come with whole lot of explanations just to make everything clear. Folks rightly like to explain the feature of global variables in Java by static variables. There is no problem in that. If you have some problem/code in any other language and that is using global variables and you need to convert that code to Java, then you most likely make use of static variable as an alternative.
A couple of examples I like to render here

*

*When I started Java, instructors like to explain the difference of passing object type variable and primitive variables. And they constantly use the term objects are pass-by-reference, whereas primitives are pass-by-value. Students found this explanation quite confusing. So, we came up with the notion that everything in Java is pass-by-value. And we explain that for objects references are pass-by-value. It becomes much more clear and simple.

*Similarly, there are languages which support multiple-inheritance. But Java doesn't, again arguably speaking. But folks tend to explain that feature using interfaces. They explain it by class implementing many interfaces, and call it multiple-inheritance. That's perfectly fine. But what the class, actually, receives by inheriting a number of interfaces. Frankly speaking, nothing. Why?
. Because all the variables in interfaces are implicitly public, final and static, which apparently means those belongs to the class and anyone can access those. Now we can say that perhaps there would be some inner class in the interface, then the class implementing the interface will have it. But again that will be static implicitly and will belong to the interface. Therefore, all what the class will get are methods. And don't forget just the definition and the contract which says, "the class implementing this interface must provide the implementation of all methods or declare itself abstract". Hence, that class will only get responsibilities and nothing much. But that solves our problems in a brilliant way.
Bottom line
Therefore, we say

*

*There are no global variables in Java

*Java doesn't support multiple-inheritance, but something like that can be achieved by implementing multiple interfaces. And that really works

*There is nothing pass-by-reference in Java, but references are pass-by-value

Now I like to site few more places

*

*Java does not support global, universally accessible variables. You can get the same sorts of effects with classes that have static variables [Ref]

*However, extern in ObjectiveC is not an alternative to a class-scoped static variable in Java, in fact it is more like a global variable … so use with caution. [Ref]

*In place of global variables as in C/C++, Java allows variables in a class to be declared static [Ref]

*Furthermore, the overuse of static members can lead to problems similar to those experienced in languages like C and C++ that support global variables and global functions. [Ref]
All these are inferring one and the same idea. Which is Java doesn't support global variables.
Hell, I wrote that much. Sorry folks.

A: Performance doesn't matter. You want it as easy to read as possible.
I would do 2 as much as you can. When you really need constants and statics, make constants and statics.
For example, a null safe trim makes a good static method. New upping a StringTrimmer is silly. Putting if null then x else z in 1000 others is silly.

A: I think this was settled back in 1956 and 1958, when people invented Lisp and ALGOL58 and pondered about modularity, referential transparency, and sound code structure as means to tackle impenetrable spaghetti code that rely on global variables (and who tend to exhibit the software equivalent of the Heisenberg uncertainty principle.)
I mean seriously, this is 2011 and we still wonder about whether to use global variables over encapsulated fields or parameter passing for quote-n-quote efficiency. I mean, seriously.
I may sound arrogant (so be it), but I'll say this:
I can understand some spaces where you have to make some sort of global variable trade-offs (.ie. very resource constrained embedded platforms, for example). I can understand if a person that is just starting in CS (say a freshman) asks this.
But if someone beyond freshman level (let alone someone that does coding for a living and not coding in the most resource barren of environments) asks or even remotely thinks about this as an acceptable thing to do should seriously reconsider going back to the basics (or reconsider this profession - we have too much craptacular code already.)
Short and concise answer: No, it makes no sense. There are no noticeable games. It is not worth it. It leads to craptacular code. And all of these have been known for 50 years now.


text:
Q: How to prevent access to certain fields in Amplify graphql public API I have a graphql model in Amplify as follows:
type Blog @model @auth(rules: [
    { allow: owner },
    { allow: groups, groups: ["admins"] },
    { allow: public, provider: apiKey, operations: [read] }
    ]){
    id: ID!
    title: String!
    content: String!
    author: String
}

I would like all field to have read access via an API key except the 'author' field.It should only be readable by owner and the 'Admin' group.
I have tried all sorts of combinations of top level and field level @auth directives but it doesn't work.
Does anyone knows how to solve this.
Thank you

A: have you tried using the Field Level Authorization?
type User @model {
  id: ID!
  username: String
  ssn: String @auth(rules: [{ allow: owner, ownerField: "username" }])
}

Update: My mistake, in your question it does say you tried this out.


text:
Q: Wired Apex Method not getting called on Load I've a problem on a wired apex method not getting called from a Lightning Web Component on load.
This web component is inside a parent Lightning Aura Component which has a date picker where today's date is defaulted on initialization. Related to the date all events are shown through the child LWC.
First time , the date is coming correct but no records are coming up as no call is being made to the apex method. Now on changing the date (changing date to 5th Jan and then coming back to 4th Jan i.e. today) it does give the records properly.
I'm not able to understand why it does not give all records related to today's date on the 1st very time . As far I understand , wired methods always gets invoked the time the component is being created.
Aura Component Code (Parent Component) :
<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
<aura:attribute name="chosenDate" type="Date" />
<aura:handler name="init" action="{!c.doInit}" value="{!this}" />
<lightning:input type="date" name="inpDate" value="{!v.chosenDate}"/>
<c:evtCmpTst chosenDt="{!v.chosenDate}"/>

Aura JS Controller:
doInit : function(component, event, helper) {
    //old code . was in the original question
    /*var today = new Date();
    component.set('v.chosenDate', today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate());*/
    //this works fine. updated based on Mohith's answer
    var today = new Date().toISOString().slice(0,10);
    component.set('v.chosenDate', today);
}

LWC HTML
<template>
<lightning-input type="date" name="inpDate" value={chosenDate}></lightning-input>
<lightning:card>
    <template for:each={results} for:item="event">

                Subject : {event.Subject}

                Start Time : {event.StartDateTime}

                End Time : {event.EndDateTime}

    </template>

</lightning:card>

LWC JS
import { LightningElement,api,wire,track } from 'lwc';
import getEvents from '@salesforce/apex/RetrieveEvents.getEvents';

export default class EvtCmpTst extends LightningElement {

@api chosenDt;
@track results;

@wire(getEvents, {chosenDt : '$chosenDt'})
events({ error, data }) {
    console.log(this.chosenDt); //this is coming properly as today's date on load
    console.log(data); // this is coming undefined
    this.results = data;
    this.error = error;
    console.log(this.results);
}
}

APEX
public with sharing class RetrieveEvents {
@AuraEnabled(cacheable=true)
public static List<Event> getEvents(Date chosenDt) {

    Time startTime = Time.newInstance(0, 59, 59, 0);
    Time endTime = Time.newInstance(23, 59, 59, 0);
    DateTime dt1 = DateTime.newInstance(chosenDt, startTime);
    DateTime dt2 = DateTime.newInstance(chosenDt, endTime);
    List<Event> scheduledEvents = [SELECT Id,Subject, StartDateTime, EndDateTime, User_Choice__c FROM Event WHERE (StartDateTime >: dt1 AND EndDateTime <: dt2) ] ;
    return scheduledEvents;
}
}

Is this expected behavior (if not then how do I show the records on load from the child LWC) or am I doing something wrong?
EDIT - I tried calling the method imperatively as well but I still don't get any records on load.

A: The issue is happening because the parameter that is flowing from your lwc component to the apex controller is not in expected date format upon load.
The parameter value that aura enabled methods with date format expect should be of type "yyyy-MM-DD" strictly.
In your aura init method i did one line code change shown as below to match the format the aura component method needs.
({
    doInit : function(component, event, helper) {
     var today = new Date().toISOString().slice(0,10);
     component.set('v.chosenDate', today);
   }
})

The above change fixed the code.
The best way to debug these issues is use chrome dev console and enable pause on exceptions to see whats wrong. In this case the promise was rejected from server and it was swallowed.