text:
Q: Spring data JPA. Cascade update works for special cases only Most important structural description:
In my application is used Spring data JPA.
I have a model part in my application:
@Entity
public class Event implements Identifiable {
  // ...
  @OneToMany(cascade = CascadeType.ALL, mappedBy = "event", orphanRemoval = true)
  @OrderColumn(name = "order_index")
  private List<Attendee> attendees = new ArrayList<>();
  // ...
}

@Entity
public class Attendee implements Identifiable {
  // ...
  @ManyToOne
  @JoinColumn(columnDefinition = "event_id")
  private Event event;
  // ...
}

It should be clear for all who knows JPA.
I've implemented test to save an event, as result dependent attendees collection saves also (hibernate magic used because of correspond relation settings shown in very beginning.)
eventRepository.save(event);

provides save|update event and replace all old nested attendees with new ones.
Problem description:
Some times I need use additional handlers in same transaction with saving event. They use repositories also:
// transaction starts... some handlers are used
eventRepository.save(event);
// some additional handlers2 are used
// transaction ends

If handlers2 contains any repository operation with independent entity, for example:
profileRepository.findAll();
// or
profileRepository.findByEmail("anyEmail");

, it fails with exception org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.nextiva.calendar.entity.Attendee. It seems Attendee collection should be saved because it was not.
To fix the issue I've used workaround like:
// transaction starts... some handlers are used
attendeeRepository.save(event.getAttendees());
eventRepository.save(event);
// some additional handlers2 are used
// transaction ends

It works now, but I do not like this way.
Questions:

*

*Is it my architectural issue?

*Is it hibernate issue?

*How should it be configured without redundant calling attendeeRepository.save(event.getAttendees());?

A: Try to switch to JpaRepository and use
eventRepository.saveAndFlush(event);

instead of eventRepository.save(event).
Or
eventRepository.save(event);
eventRepository.flush();

It will force the repo to flush all pending changes to the database.

Also check whether you set @Transactional(readOnly = true) on your repo interface that turn the flush mode to NEVER (as described in the reference, or MANUAL as described here) also for save methods. Perhaps this is the issue...


text:
Q: Scipy error Inequality constraints incompatible (Exit mode 4) I'm solving an optimization problem to do a constrained nonlinear regression using experimental data. I use scipy minimize and it works with the original data, but it doesn't work when I do a simple data transformation. For the transformed data I use the excel solver solution for the same problem as the initial condition so it should work butcan't figure out why it doesn not. Please any help is appreciated. Thanks beforehand btw.
Here is the code with the original data (works) and the transformation (does not work)
import numpy as np
from scipy.optimize import Bounds, minimize

def yp(x, time, mode = 'fit'):
    y1 = x[0] + x[1]*time
    y2 = x[2] + (x[3] - x[2])*np.exp(-x[5]*(time - x[4])/(x[3] - x[2]))

    comparison = time < x[4]

    yp = y1*comparison + y2*(~comparison)
    if mode == 'fit':
        return yp
    elif mode == 'calc':
        return y1, y2
    else:
        print('Unsupported mode, returning default behavior for fitting data')
        return yp

def objective(x, time, y):
    ypred = yp(x, time)
    z = sum((ypred - y)**2)
    return z

#***********************
#Original data
#***********************
data_x = np.array([0,30,60,90,120,150,180,210,240,270,300,330,360,420,480,540,600,720,840])
data_y = np.array([11.06468023,10.03242418,9.771158736,8.873720137,8.618127786,
          8.397702515,7.581607582,7.131636821,6.537043245,6.358885017,
          5.898468977,5.25275811,4.983989976,4.141791045,2.602472349,
          2.07395813,1.078129376,0.551764193,0.480052971])

x0 = [11.5, -0.0211, 0.6, 3.26, 400, 0.01919]
lbound = [9, -0.1, 0.3, 1, 200, 0]
ubound = [14, -1e-5, 1, 4, 800, 0.1]
bounds = Bounds(lbound,ubound)

constraint = dict(type = 'ineq',
                 fun = lambda x: 0.1 - abs(x[0] + x[1]*x[4] - x[3]))

res = minimize(fun = objective,
             x0 = x0,
             args = (data_x, data_y),
             method = 'SLSQP',
             constraints = constraint,
             options = {'disp':True},
             bounds = bounds)

print(res)

Optimization terminated successfully    (Exit mode 0)
            Current function value: 0.6681037696841838
            Iterations: 20
            Function evaluations: 149
            Gradient evaluations: 20
     fun: 0.6681037696841838
     jac: array([ 1.19826198e-03,  5.93313336e-01,  9.38165262e-02,  6.77183270e-04,
        1.15633011e-05, -3.35602835e-02])
 message: 'Optimization terminated successfully'
    nfev: 149
     nit: 20
    njev: 20
  status: 0
 success: True
       x: array([ 1.06185481e+01, -1.59476490e-02,  3.00000000e-01,  3.86162000e+00,
        4.29964822e+02,  2.80661182e-02])

#***********************
#Transformed data
#***********************
data_y_rel = data_y/data_y[0]
x0_rel = [1, -0.00207571, 0.03, 0.359269446, 313.497571, 0.001970666]
lbound_rel = [1, -0.1, 0.03, 0.1, 200, 0]
ubound_rel = [1, -1e-5, 0.1, 0.4, 800, 0.1]
bounds_rel = Bounds(lbound_rel,ubound_rel)

constraint_rel = dict(type = 'ineq',
                 fun = lambda x: 0.01 - abs(x[0] + x[1]*x[4] - x[3]))

res_rel = minimize(fun = objective,
             x0 = x0_rel,
             args = (data_x, data_y_rel),
             method = 'SLSQP',
             constraints = constraint_rel,
             options = {'disp':True},
             bounds = bounds_rel)

print(res_rel)

Inequality constraints incompatible    (Exit mode 4)
            Current function value: 0.1593965203706159
            Iterations: 1
            Function evaluations: 7
            Gradient evaluations: 1
     fun: 0.1593965203706159
     jac: array([            nan, -2.88985475e+02, -1.53672213e-01, -1.13128023e+00,
       -1.58630125e-03,  5.45240970e+01])
 message: 'Inequality constraints incompatible'
    nfev: 7
     nit: 1
    njev: 1
  status: 4
 success: False
       x: array([ 1.00000000e+00, -2.07571000e-03,  3.00000000e-02,  3.59269446e-01,
        3.13497571e+02,  1.97066600e-03])
C:\Users\username\Anaconda3\lib\site-packages\scipy\optimize\_numdiff.py:519: RuntimeWarning: invalid value encountered in true_divide
  J_transposed[i] = df / dx

A: Changing the method from 'SLSQP' to 'trust-constr' worked for me. 'COBYLA' is also an option.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Show that $X \times Y$ is homeomorphic to $Y \times X$ This seems to be a trivial result, I just wish to check for correctness.
Show $X \times Y$ is homeomorphic to $Y \times X$
Let $\tau$ be the topology on $X$, $j$ be the topology on $Y$
Then a homeomorphism is given by $f: X \times Y \to Y \times X, (a,b) \to (b,a)$
We can show that $f$ is a homeomorphism by showing that it is continuous and open.
$f$ is continuous because given $B \times A$, $f^{-1}(B \times A) = A \times B$ is open in the product topology on $X \times Y$.
Similarly, we can show that $f$ is open in that $f(A \times B) = B \times A$ is open in the product topology on $Y \times X$
Therefore $f$ is a homeomorphism.
Is this correct?

A: I think that it the idea is correct. Maybe one should add that on $X\times Y$ and $Y\times X$ we choose the product topology. The basis of such product topology is the collection $A\times B$ with $A$ and $B$ open in the respective spaces (or in the respective bases). In order to have continuity it is enough to check the "open set property" for the basis elements.


text:
Q: Creating half normal probability distribution I have come across a problem where a half normal distribution is based on a single number, namely the sum of all costs. The exact definition of the number is not important. The important think is that it is a single number. I also know how many individual costs have been used to get to the total. Ex. there were 200 observations and the grand total is 25000.
This problem is in Bayesian context. A half normal distribution is used as weakly informative prior and the only input for the half normal distribution is the grand total. I cannot understand how this half-normal distribution is created solely with the grand total and the number of observations? Am I missing something?
Here the distribution is called. And here is explained that the grand total is to be used as input for the half normal distribution. I cannot recall the exact location, but somewhere in the docu I have read that the scale parameter is 2.
I feel like I am missing something with respect to the creation of the weakly informative prior. Is some sampling used or something? Here is the source code that is used for the half normal distribution.

A: Normal distribution is parametrized by two parameters - location $\mu$ and scale $\sigma$. Half-normal is parametrized by only one parameter - its scale $\sigma$, since the location is fixed to $\mu=0$ by the very definition of this distribution.

A: The half-Normal distribution has density
$$f_\sigma(x)=\sqrt{{2}/{\pi\sigma}}\,\exp\{-x^2/2\sigma\}\mathbb I_{x>0}\qquad\sigma>0$$
It is a possible prior for a standard deviation parameter, see e.g. Gelman et al. (2013). It thus requires one single input, $\sigma$, to be completely defined. However, Jeffreys' (1939) half-Cauchy
$$g_\sigma(x)=\frac{2}{\pi\sigma}\,\frac{1}{x^2+\sigma^2}\mathbb I_{x>0}\qquad\sigma>0$$
is also a potential prior distribution.


text:
Q: Passing a double pointer as argument to a function which expects a reference to a std::vector Is there any possible way to pass pointer to a double (double *) as argument to a function which expects a reference to a std::vector<double> argument in C++11

A: That will not be possible, you'll have to copy the data in a vector
vector<double> v(ptr, ptr + length);

Also, you cannot assign the data behind the pointer directly in the vector, copying is required, see here

A: Rather than copying the data into a vector, you could also change the function to take a span. You will still have to include the length along with the pointer.
e.g.
void takes_span(std::span<double>) {}

int main()
{
    std::vector<double> vec = { 1, 2, 3 };
    double arr[3] = { 4, 5, 6 };
    double * ptr = arr;

    takes_span(vec);
    takes_span(arr);
    takes_span({ptr, 3});
}


text:
Q: Error Exception Array to String Conversion in Curl Hi I'm trying to to Integrate Hubtel Payment Gateway but getting Array to string Conversion Error Exception .
if i do CURLOPT_POSTFIELDS =>http_build_query ($invoice), im getting blank response
please help
  $items = ["name" => "Harry Potter", "quantity" => 1, "unitPrice" => 50];
      $invoice = array("items" => $items, "totalAmount" => 1, "description" => "test", "callbackUrl" => "https://localhost:8000/status","returnUrl"=>"https://localhost:8000/return","cancellationUrl"=>"https://localhost:8000/cancel",
        "merchantBusinessLogoUrl"=>"https://localhost:8000/wallet","merchantAccountNumber"=>"HM0409180006","clientReference"=> '1');
      $curl = curl_init();

      curl_setopt_array($curl, array(
        CURLOPT_URL => "https://api.hubtel.com/v2/pos/onlinecheckout/items/initiate",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => $invoice,
        CURLOPT_HTTPHEADER => array(
          "Authorization: Basic bjJXS0o1Qjo0saMWU4NzA4ZS0wODVkLTQ0NDwUtOTQ3ZS1hZjBiODlkNzI1OWY=",
          "Content-Type: application/json",
          "Postman-Token: 2bd373c8-3669-4f5f-93e9-d3001af0a9cff",
          "cache-control: no-cache"
        ),
      ));


text:
Q: Second fundamental form of asymptotic line Why the second fundamental form at a point of a surface should vanish in the asymptotic direction?

A: Second fundamental form is
$$ ds^2= L du^2+2 M du dv + N dv^2 $$
$ds^2=0\;$ because normal lengths vanish and tangents run along asymptotic directions themselves.
For a particular direction, of the asymptotic line, its normal curvature vanishes.
Euler's relation is derived  from second fundamental form coefficients.
$$ \kappa_n=\dfrac{L}{E}\cos^2 \psi+\dfrac{N}{G}\sin^2 \psi$$
$$=\kappa_1\cos^2 \psi+\kappa_2\sin^2 \psi =0 $$
at particular
$$ \psi= \tan^{-1}\sqrt{\dfrac{k_1}{k_2}} $$
In one quadrant near a bisector of parametric lines  $k_n$ is positive and in the other quadrant it is negative and there is smooth transition of tangent bundle.
The fundamental form or formula itself does not vaniish.


text:
Q: Analytically solving a regular nonlinear 1st order quadratic ODE system I just sincerely hope somebody can help me to analytically solve the following ODE system. $x(t)$, $y(t)$, $z(t)$ are $3$ functions of $t$, and $C_1, C_2, C_3, C_4, C_5, C_6$ are just constants.
$$
\left\{
\begin{array}{l}
x'(t)=[1-x(t)][C_1 y(t)+C_2 z(t)]\\
y'(t)=[1-y(t)][C_3 x(t)+C_4 z(t)]\\
z'(t)=[1-z(t)][C_5 x(t)+C_6 y(t)]
\end{array}
\right.
$$
I appreciate a lot if you can offer me any closed-form solutions analytically, especially a general solution with $N$ functions. Or if you can point me to any related materials, I will also appreciate.    : )
Furthermore, if this is not solvable, is there any possible way to make approximation functions for them...?
Thanks a lot!

A: It appears your system is autonomous. It follows that the method of characteristics may help you solve it. Essentially, just solve for $dt$ then integrate. As $x'(t)=\frac{dx}{dt}$ and $y'(t) = \frac{dy}{dt}$ and $z'(t) = \frac{dz}{dt}$ you can see that
$$ dt = \frac{dx}{x'(t)} =  \frac{dy}{y'(t)} =  \frac{dy}{y'(t)} $$
You replace the expressions $x'(t),y'(t),z'(t)$ in the above with the expressions involving the unknown $x,y,z$ hence yielding the timeless system in $x,y,z$. Solutions should be level curves. These level curves give you the point-sets which the solutions to your give ODE will parametrize.
Since I'm not particularly interested in doing those integrations for your problem I'll illustrate this method with an easier problem:
$$ \frac{dx}{dt} = -y \qquad \frac{dy}{dt} =x $$
Hence,
$$ dt = \frac{dx}{-y} = \frac{dy}{x} \ \Rightarrow \ \ xdx = ydy \ \ \Rightarrow \boxed{x^2+y^2=R^2}$$
Of course this system is more easily solved by subsitution which reveals $x(t) = R\cos(t)$ and $y(t)=R\sin(t)$ which are clearly solutions to my given problem and parametrizations to the boxed level curve as I advertised.
I guess the integration for your problem might be a little trickier.


text:
Q: How do I remove the annoying Authenticator(Terminal)? I finally managed to reach to Ubuntu after many unfair-unsolved errors and boot errors as well..
Now another unfair issue detected. I made an user account with password, great, I downloaded steam, I double click it, authenicator shows up but when I type something, it doesnt show on authenticator!!!
It wants a password for the user name account I use to let steam download packages, but when I type anything, it does not show on authenticator!It does do nothing but to say error that I typed nothing. I even deleted password of my username account and it still shows up. What the h!!! is this problem? Its even annoying than Justin Bieber!!
Authenticator is my next nightmare...How do I solve it?

A: I'm not sure I understand your problem (authenticator ??? terminal ? graphical ?)  but in order to install anything the user must have administrator rights. To do so you must connect with your admin user (the first one you created) then go in user accounts application and give administrative rights to the new user.
Another problem I can think of is that you have enableb automatic login and you have an application that require administrative rights that starts right after login. You may check in the password wallet (just type key or password in the dash) you can then browse all the stored keys.


text:
Q: Table colspan and rowspan issues? I have a simple table, that was working fine but today I checked it out and its all messed up. None of the tables I have in my code with colspan or rowspan show correctly.

    BOP DRILLS
    DRILLING
    RAMS CLOSE
    WELL SECURE
    FINAL ACC.
    Sec
    Psi
    Recharge
    Sec
    Psi

      <input name="bopdrilling" id="boptext" type="text" />

      <input name="ramsclose" id="boptext" type="text" />

      <input name="wellsecure" id="boptext" type="text" />

      <input name="finalsec" id="boptext" type="text" />

      <input name="finalpsi" id="boptext" type="text" />

      <input name="rechargesec" id="boptext" type="text" />

      <input name="rechargepsi" id="boptext" type="text" />


text:
Q: Writing Parser for S Expressions I'm trying to write a Parser for S Expressions from Prof. Yorgey's 2013 homework.
newtype Parser a = Parser { runParser :: String -> Maybe (a, String) }
Given the following definitions, presented in the homework:
type Ident = String

-- An "atom" is either an integer value or an identifier.
data Atom = N Integer | I Ident
  deriving Show

-- An S-expression is either an atom, or a list of S-expressions.
data SExpr = A Atom
           | Comb [SExpr]
  deriving Show

I wrote a parser for Parser Atom and Parser SExpr for A Atom.
parseAtom :: Parser Atom
parseAtom = alt n i
   where n = (\_ z -> N z) <$> spaces <*> posInt
         i = (\ _ z -> I z) <$> spaces <*> ident

parseAAtom :: Parser SExpr
parseAAtom = fmap (\x -> A x) parseAtom

Then, I attempted to write a parser to handle a Parser SExpr for the Comb ... case:
parseComb :: Parser SExpr
parseComb = (\_ _ x _ _ _ -> x) <$> (zeroOrMore spaces) <*> (char '(') <*>
                                     (alt parseAAtom parseComb) <*> (zeroOrMore spaces)
                                        <*> (char ')') <*> (zeroOrMore spaces)

Assuming that parseComb was right, I could simply make usage of oneOrMore for Parser [SExpr].
parseCombElements :: Parser [SExpr]
parseCombElements = oneOrMore parseComb

So, my two last functions compile, but running runParser parseComb "( foo )" never terminates.
What's wrong with my parseComb definition? Please don't give me the whole answer, but rather a hint - for my own learning.

A: I am very suspicious of zeroOrMore spaces, because spaces is usually a parser which itself parses zero or more spaces.  Which means that it can parse the empty string if there aren't any spaces at that point. In particular, the spaces parser always succeeds.
But when you apply zeroOrMore to a parser that always succeeds, the combined parser will never stop - because zeroOrMore only stops trying again once its parser argument fails.
As an aside, Applicative expressions like (\_ _ x _ _ _ -> x) <$> ... <*> ... <*> ...... which only use a single of the subparsers can usually be written more succinctly with the *> and <* combinators:
... *> ... *> x_parser_here <* ... <* ...


text:
Q: VueJS - wait for updated() in parent before rendering child component I thought I had this cracked. I'm trying to grab an id from a URL query, e.g. http://localhost:8080/car?rec140ttKVWJCDr8v, assign it to a local variable and compare it against ids in a store object to pluck the matching node and send that to the Child component as a prop. It's simply never gets to the child unless I trigger a webpack re-render in the child itself. It needs to get there on page refresh.
I thought it might be a re-rendering issue so I tried random child component keys but that didn't work. I also tried using a computed prop, but had the same issue. I feel like I'm missing something simple.
Here's the rendering order in the console. The very last parent update is when the carsObject becomes available, but the child has already been created and mounted twice before then. I'm not sure why.
PARENT: created()= [__ob__: Observer]
CHILD: created()= {}
CHILD: mounted()= {}
PARENT: mounted()= [__ob__: Observer]
PARENT: updated()= [__ob__: Observer]
CHILD: created()= {}
CHILD: mounted()= {}
PARENT: updated()= [__ob__: Observer]
PARENT: updated()= (5) [{…}, {…}, {…}, {…}, {…}, __ob__: Observer] //here is when I want the child to render.

Here's the components:
// parent
<template>

    // wait for childData to be ready before rendering
    <Child v-bind:data="childData" :key="carId" /> // random keys doesn't work either

</template>

// child
<template>

    // do stuff with "data" prop

</template>

A: Your getCurrentChild method isn't returning anything; did you mean to use find instead of forEach (assuming carsObject is an array)?
getCurrentChild() {
  // get car id from URL
  let ref = location.href;
  let carId = ref.substring(ref.indexOf("?") + 1);
  if (this.carsObject) {
    return this.carsObject.find(car => car.car_id === carId);
  }
}

Also I'm not sure why you're doing that in the updated hook, it doesn't seem like the correct place. I almost never need to use the updated hook.


text:
Q: no matching unique or primary key for this column-list Hey guys im getting this error: "no matching unique or primary key for this column-list" In the tables Termine and Verbund. I really dont have any clue how i can solve the problem ;( It would be really awesome if someone could help me changing the code in order to get a working code! :)
Here is the code:

/* CREATE USER mydb IDENTIFIED BY mydb ;
ALTER SESSION SET CURRENT_SCHEMA = mydb ;*/
DROP TABLE VERBUND;
DROP TABLE TERMINE;
DROP TABLE KUNDE;
DROP TABLE ADRESSEN;
DROP TABLE PROTOKOLL;
DROP TABLE MITARBEITER;
DROP TABLE Abteilung;
DROP TABLE JobBeschreibung;

-- -----------------------------------------------------
-- Table `mydb`.`JobBeschreibung`
-- -----------------------------------------------------
CREATE  TABLE JobBeschreibung (
  idJobBeschreibung NUMBER(10) NOT NULL ,
  Beschreibung VARCHAR2(45) NULL ,
  PRIMARY KEY (idJobBeschreibung) )
;

-- -----------------------------------------------------
-- Table `mydb`.`Abteilung`
-- -----------------------------------------------------
CREATE  TABLE Abteilung (
  idAbteilung NUMBER(10) NOT NULL ,
  Beschreibung VARCHAR2(45) NULL ,
  PRIMARY KEY (idAbteilung) )
;

-- -----------------------------------------------------
-- Table `mydb`.`Mitarbeiter`
-- -----------------------------------------------------
CREATE  TABLE Mitarbeiter (
  idMitarbeiter NUMBER(10) NOT NULL ,
  Vorname VARCHAR2(45) NULL ,
  Nachname VARCHAR2(45) NULL ,
  Telefon NUMBER(19) NULL ,
  idAbteilung NUMBER(10) NOT NULL ,
  idJobBeschreibung NUMBER(10) NOT NULL ,
  PRIMARY KEY (idMitarbeiter, idAbteilung, idJobBeschreibung)
  ,
  CONSTRAINT fk_Mitarbeiter_Abteilung
    FOREIGN KEY (idAbteilung )
    REFERENCES Abteilung (idAbteilung )
   ,
  CONSTRAINT fk_Mitarbeiter_JobB
    FOREIGN KEY (idJobBeschreibung )
    REFERENCES JobBeschreibung (idJobBeschreibung )
   )
;

-- -----------------------------------------------------
-- Table `mydb`.`Protokoll`
-- -----------------------------------------------------
CREATE  TABLE Protokoll (
  idProtokoll NUMBER(10) NOT NULL ,
  Notizen VARCHAR2(45) NULL ,
  Abrechnungsbetrag BINARY_DOUBLE NULL ,
  idVerbund NUMBER(10) NOT NULL ,
  PRIMARY KEY (idProtokoll, idVerbund) )
;

-- -----------------------------------------------------
-- Table `mydb`.`Adressen`
-- -----------------------------------------------------
CREATE  TABLE Adressen (
  idAdressen NUMBER(10) NOT NULL ,
  Straße VARCHAR2(45) NULL ,
  Nummer VARCHAR2(5) NULL ,
  PLZ NUMBER(10) NULL ,
  Ort VARCHAR2(45) NULL ,
  Land VARCHAR2(45) NULL ,
  PRIMARY KEY (idAdressen) )
;

-- -----------------------------------------------------
-- Table `mydb`.`Kunde`
-- -----------------------------------------------------
CREATE  TABLE Kunde (
  idKunde NUMBER(10) NOT NULL ,
  Vorname VARCHAR2(45) NULL ,
  Nachname VARCHAR2(45) NULL ,
  Anrede VARCHAR2(45) NULL ,
  Firma VARCHAR2(45) NULL ,
  idAdressen NUMBER(10) NOT NULL ,
  PRIMARY KEY (idKunde, idAdressen)
  ,
  CONSTRAINT fk_Kunde_Adressen1
    FOREIGN KEY (idAdressen )
    REFERENCES  Adressen (idAdressen )
   )
;

-- -----------------------------------------------------
-- Table `mydb`.`Termine`
-- -----------------------------------------------------
CREATE  TABLE Termine (
  idTermine NUMBER(10) NOT NULL ,
  Anfangszeit TIMESTAMP(0) NULL ,
  Endzeit TIMESTAMP(0) NULL ,
  Thema VARCHAR2(45) NULL ,
  Beschreibung VARCHAR2(45) NULL ,
  idVerbund NUMBER(10) NOT NULL ,
  idKunde NUMBER(10) NOT NULL ,
  idMitarbeiter NUMBER(10) NOT NULL ,
  PRIMARY KEY (idTermine, idVerbund, idKunde, idMitarbeiter)
  ,
  CONSTRAINT fk_Termine_Protokoll1
    FOREIGN KEY (idVerbund )
    REFERENCES Protokoll (idVerbund )
   ,
  CONSTRAINT fk_Termine_Kunde1
    FOREIGN KEY (idKunde )
    REFERENCES Kunde (idKunde )
   ,
  CONSTRAINT fk_Termine_Termine1
    FOREIGN KEY (idTermine )
    REFERENCES Termine (idVerbund )
   ,
  CONSTRAINT fk_Termine_Mitarbeiter1
    FOREIGN KEY (idMitarbeiter )
    REFERENCES Mitarbeiter (idMitarbeiter )
   )
;

-- -----------------------------------------------------
-- Table `mydb`.`Verbund`
-- -----------------------------------------------------
CREATE  TABLE Verbund (
  idVerbund NUMBER(10) NOT NULL ,
  Document VARCHAR2(45) NULL ,
  idProtokoll NUMBER(10) NOT NULL ,
  PRIMARY KEY (idVerbund, idProtokoll)
  ,
  CONSTRAINT fk_Verbund_Protokoll1
    FOREIGN KEY (idProtokoll )
    REFERENCES  Protokoll (idProtokoll )
   )
;

/* SET SQL_MODE=@OLD_SQL_MODE; */
/* SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; */
/* SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; */

A: Try with this code. It is with respect to SQL Server 2012.
/* CREATE USER mydb IDENTIFIED BY mydb ;
ALTER SESSION SET CURRENT_SCHEMA = mydb ;*/
DROP TABLE VERBUND;

DROP TABLE TERMINE;

DROP TABLE KUNDE;

DROP TABLE ADRESSEN;

DROP TABLE PROTOKOLL;

DROP TABLE MITARBEITER;

DROP TABLE Abteilung;

DROP TABLE JobBeschreibung;

-- -----------------------------------------------------
-- Table `mydb`.`JobBeschreibung`
-- -----------------------------------------------------
CREATE TABLE JobBeschreibung
  (
     idJobBeschreibung NUMERIC(10) NOT NULL,
     Beschreibung      VARCHAR(45) NULL,
     PRIMARY KEY (idJobBeschreibung)
  );

-- -----------------------------------------------------
-- Table `mydb`.`Abteilung`
-- -----------------------------------------------------
CREATE TABLE Abteilung
  (
     idAbteilung  NUMERIC(10) NOT NULL,
     Beschreibung VARCHAR(45) NULL,
     PRIMARY KEY (idAbteilung)
  );

-- -----------------------------------------------------
-- Table `mydb`.`Mitarbeiter`
-- -----------------------------------------------------
CREATE TABLE Mitarbeiter
  (
     idMitarbeiter     NUMERIC(10) NOT NULL,
     Vorname           VARCHAR(45) NULL,
     Nachname          VARCHAR(45) NULL,
     Telefon           NUMERIC(19) NULL,
     idAbteilung       NUMERIC(10) NOT NULL,
     idJobBeschreibung NUMERIC(10) NOT NULL,
     PRIMARY KEY (idMitarbeiter, idAbteilung, idJobBeschreibung),
     CONSTRAINT fk_Mitarbeiter_Abteilung FOREIGN KEY (idAbteilung ) REFERENCES Abteilung (idAbteilung ),
     CONSTRAINT fk_Mitarbeiter_JobB FOREIGN KEY (idJobBeschreibung ) REFERENCES JobBeschreibung (idJobBeschreibung )
  );

-- -----------------------------------------------------
-- Table `mydb`.`Protokoll`
-- -----------------------------------------------------
CREATE TABLE Protokoll
  (
     idProtokoll       NUMERIC(10) NOT NULL,
     Notizen           VARCHAR(45) NULL,
     Abrechnungsbetrag FLOAT(53) NULL,
     idVerbund         NUMERIC(10) NOT NULL,
     PRIMARY KEY (idProtokoll, idVerbund)
  );

-- -----------------------------------------------------
-- Table `mydb`.`Adressen`
-- -----------------------------------------------------
CREATE TABLE Adressen
  (
     idAdressen NUMERIC(10) NOT NULL,
     Straaye    VARCHAR(45) NULL,
     Nummer     VARCHAR(5) NULL,
     PLZ        NUMERIC(10) NULL,
     Ort        VARCHAR(45) NULL,
     Land       VARCHAR(45) NULL,
     PRIMARY KEY (idAdressen)
  );

-- -----------------------------------------------------
-- Table `mydb`.`Kunde`
-- -----------------------------------------------------
CREATE TABLE Kunde
  (
     idKunde    NUMERIC(10) NOT NULL,
     Vorname    VARCHAR(45) NULL,
     Nachname   VARCHAR(45) NULL,
     Anrede     VARCHAR(45) NULL,
     Firma      VARCHAR(45) NULL,
     idAdressen NUMERIC(10) NOT NULL,
     PRIMARY KEY (idKunde, idAdressen),
     CONSTRAINT fk_Kunde_Adressen1 FOREIGN KEY (idAdressen ) REFERENCES Adressen (idAdressen )
  );

-- -----------------------------------------------------
-- Table `mydb`.`Termine`
-- -----------------------------------------------------
CREATE TABLE Termine
  (
     idTermine         NUMERIC(10) NOT NULL,
     Anfangszeit       DATETIME NULL,
     Endzeit           DATETIME NULL,
     Thema             VARCHAR(45) NULL,
     Beschreibung      VARCHAR(45) NULL,
     idProtokoll       NUMERIC(10) NULL,
     idVerbund         NUMERIC(10) NOT NULL,
     idAdressen        NUMERIC(10) NOT NULL,
     idKunde           NUMERIC(10) NOT NULL,
     idMitarbeiter     NUMERIC(10) NOT NULL,
     idAbteilung       NUMERIC(10) NOT NULL,
     idJobBeschreibung NUMERIC(10) NOT NULL,
     PRIMARY KEY (idTermine, idVerbund, idKunde, idMitarbeiter),
     CONSTRAINT fk_Termine_Protokoll1 FOREIGN KEY (idProtokoll, idVerbund ) REFERENCES Protokoll (idProtokoll, idVerbund ),
     CONSTRAINT fk_Termine_Kunde1 FOREIGN KEY (idKunde, idAdressen ) REFERENCES Kunde (idKunde, idAdressen ),
     --CONSTRAINT fk_Termine_Termine1 FOREIGN KEY (idTermine ) REFERENCES Termine (idVerbund ),--THIS IS WRONG you cannot refer the same column as references in the same table
     CONSTRAINT fk_Termine_Mitarbeiter1 FOREIGN KEY (idMitarbeiter, idAbteilung, idJobBeschreibung ) REFERENCES Mitarbeiter (idMitarbeiter, idAbteilung, idJobBeschreibung )
  );

-- -----------------------------------------------------
-- Table `mydb`.`Verbund`
-- -----------------------------------------------------
CREATE TABLE Verbund
  (
     idVerbund   NUMERIC(10) NOT NULL,
     Document    VARCHAR(45) NULL,
     idProtokoll NUMERIC(10) NOT NULL,
     PRIMARY KEY (idVerbund, idProtokoll),
     CONSTRAINT fk_Verbund_Protokoll1 FOREIGN KEY (idProtokoll, idVerbund ) REFERENCES Protokoll (idProtokoll, idVerbund )
  );


text:
Q: android Regex issue I had an issue with this regex:
(\{(([^\p{Space}][^\p{Punct}])+)\})

The problem is in number of chars. If I typing even number of chars it's works, when odd - not. I was trying to replace '+' with '?' or '*', but result still the same. How can I fix this?
I expect from this regex to block such strings: {%,$ #fd}. And allow this:
{F} or {F242fFSf23}.

A: Currently, it matches a {, then 1 or more repetitions of 2 chars, a non-space and then a non-punctuation, and then a }, hence you cannot use 1 char in between {...}.
To fix that, you need to use both the character classes inside bracket expression:
\{[^\p{Punct}\p{Space}]+\}

or
\{[^\p{P}\p{S}\s]+\}

Details

*

*\{ - a { char

*[^\p{Punct}\p{Space}]+ - 1 or more repetitons (+) of any char that does not belong to the \p{Punct} (punctuation) or \p{Space} (whitespace) class.

*\} - a }.

Note that if the contents between the braces can only include ASCII letters or digits (in regex, [A-Za-z0-9]+), you may even use a mere
\{[A-Za-z0-9]+\}

A: Disassembling your regex... the reason why it only accepts an even number in between is the following part:
([^\p{Space}][^\p{Punct}])+

This basically means: something which isn't a space, exactly 1 character and something which isn't a ~punct, exactly 1 character and this several times... so exactly 1 + exactly another 1 are exactly 2 characters... and this several times will always be even.
So what you probably rather want is the following:
[^\p{Space}\p{Punct}]+

for the part shown above... which will result in the following for your complete regex:
\{[^\p{Space}\p{Punct}]+}

that of course can be simplified even more. I leave that up to you.


text:
Q: Problem obtaining data from a MongoDB object and putting it in discord I am currently trying to convert data from a mongoDB object and paste it in discord, I can successfully obtain the data and log it in the console but when I try to paste it in discord my bot sends: "[object Object]" and I've tried converting it into a json file but im not getting any luck with that either, If anyone could help that would  be amazing!
Code:
  let name = args[0]

  MongoClient.connect(url, function(err, db) {
    if (err) throw err;
    var dbo = db.db("register");
    var query = { name: name };
    dbo.collection("registers").find(query).toArray(function(err, result) {
      if (err) throw err;
      console.log(result);
      message.channel.send(result)
      db.close();
    });
  });
}


text:
Q: Does using the downwards zigzag symbol imply the previous statement to be false? Here is the statement of the wikipedia page for mathematical symbols and i'm struggling to understand it in context;
Statement: Every finite, non-empty, ordered set has a largest element. Otherwise, let's assume that X is a finite, non-empty, ordered set with no largest element. Then, for some $x_1$ is a member of $X$, there exists an $x_2$ in $X$ with $x_1 < x_2$, but then there's also an $x_3$ in $X$ with $x_2 < x_3$, and so on. Thus, $x_1, x_2, x_3, ...$ are distinct elements in X. ↯ X is finite.
My thinking:
Every finite, non-empty, order set has a largest element. (True, a non-empty set has a element which has a quantity.)
Otherwise X is finite, non-empty, ordered with no largest element. (This can't happen, so it's unnecessary to make this statement?)
Then, for some $x_1$ in $X$ there exists an $x_2$ in $X$ with $x_1 < x_2$ (Well maybe not? if X is of length 1; Is this the contradictory statement?)
It then goes on to say this holds true for all $x_{n+1}$ (If what was stated before then this can't hold?)
My question is what does this ↯ mean in this statement, at what point is the contradiction? Isn't that kind of ambiguous in a mathematical proof?
Can someone shed some light, i'm getting all kinds of confused.

A: You should read this as "Contradiction, because $X$ is finite."
The assumption is that X is finite and has no largest element, and argument proceeds to show why that doesn't work. (Since it's finite, the chain $x_1 < x_2 < x_3 < ...$ must stop at some $x_n$)


text:
Q: Java calculation returning infinity it's been a while since I last asked anything around here!
I'm making an Android app, and so, having this problem when running this code.:
Button calc = (Button) findViewById(R.id.btnCalculate);
    calc.setOnClickListener(new View.OnClickListener()

    {
        public void onClick(View v) {

            EditText number1 = (EditText) findViewById(R.id.dnp);
            EditText number2 = (EditText) findViewById(R.id.ponte);
            EditText number3 = (EditText) findViewById(R.id.aro);
            EditText number4 = (EditText) findViewById(R.id.ed);
            EditText number5 = (EditText) findViewById(R.id.esf);
            EditText number6 = (EditText) findViewById(R.id.curvint);
            EditText number7 = (EditText) findViewById(R.id.curvb);
            EditText number8 = (EditText) findViewById(R.id.ind);
            EditText number9 = (EditText) findViewById(R.id.espmin);
            TextView display = (TextView) findViewById(R.id.display);

            double dnp = Double.parseDouble(number1.getText().toString());
            double ponte = Double.parseDouble(number2.getText().toString());
            double aro = Double.parseDouble(number3.getText().toString());
            double ed = Double.parseDouble(number4.getText().toString());
            double esf = Double.parseDouble(number5.getText().toString());
            double curvint = Double.parseDouble(number6.getText().toString());
            double curvb = Double.parseDouble(number7.getText().toString());
            double ind = Double.parseDouble(number8.getText().toString());
            double espmin = Double.parseDouble(number9.getText().toString());

            double R1;
            double R2;
            double DT; //Decentração total
            double DM; //Decentração monocular
            double diametro;
            double S1;
            double S2;
            double espessurafinal;

            if (esf < 0)
            {

                R1 = (ind - 1 / curvb) * 1000;
                R2 = (ind - 1 / curvint) * 1000;
                DT = (aro+ponte)-dnp;
                DM = (DT / 2);
                diametro = (ed + 2 * DM) / 2;
                S1 = R1 - (Math.sqrt(Math.exp(R1)-Math.exp(diametro)));
                S2 = R2 - (Math.sqrt(Math.exp(R2)-Math.exp(diametro)));
                espessurafinal = (S1 - S2) + espmin;
                display.setText(espessurafinal + "" + "\nMilímetros");
            }

            else {

                R1 = (ind - 1 / curvb) * 1000;
                R2 = (ind - 1 / curvint) * 1000;
                DT = (aro+ponte)-dnp;
                DM = (DT / 2);
                diametro = (ed + 2 * DM) / 2;
                S1 = R1 - (Math.sqrt(Math.exp(R1)-Math.exp(diametro)));
                S2 = R2 - (Math.sqrt(Math.exp(R2)-Math.exp(diametro)));
                espessurafinal = espmin - (S1 + S2);
                display.setText(espessurafinal + "\nMilímetros");
            }
        }
    });

I am probably missing something very trivial here, and my coding skills are
very limited, but this code snippet returns "Infinity", when I press the calculate button. Now, I was receiving NaN before and managed to get rid of it, but only to see it become infinity! I researched and found out that it's due to
some number being divided by 0, but I don't see that...
(Oh and yes, I'm making sure all the numbers being input are not 0)
May be just my coding that put things in their wrong places? (And yes, I know I could make the code a lot better by using functions and all that... but I'm learning people, be gentle to me lol ).
Or, my math is very wrong and returning something extremelly high?
Thanks in advance everyone!

A: It seems that some of input is not actually a number, or a number mixed with some Random string. Do a validation check on the edit text values by checking if the input is a instanceof Double. input instanceof Double
  if( input instanceof Double) {
    System.out.println("input is a Double");
  }

Before you can check instance of, make sure the input is clean, with only numerals.Run a java regular expression ^[0-9]*$ on the edit text , if true then only numbers were inputted, then use Double.valueOf(val)  or Double.parse() the only difference is the latter returns a object of type Double where as the other only returns a primitive type.


text:
Q: Generalize exception's handling Retrofit I have multiple API call in my Retrofit service and each methods are handling the same ugly Exceptions and checking the same attribute in the JSON response. I tried to make it more generic to reduce the size of each method but I don't know what's the best way to do it...   Here is two of many method that does pretty much the same things but with a different API call:
private void sendStopSecurityCheck() {
    Intent intent = new Intent(STOP_SECURITY_CHECK);
    intent.putExtra(RESULT, RESULT_FAILED);

    boolean isSuccess = connectAmazonApi();

    if(isSuccess){
        Call<ResponseBody> call = amazonServices.stopSecurityCheck(settings.getString("username", ""), settings.getString("orgid", ""));
        try {
            ResponseBody response = call.execute().body();
            JSONObject obj;
            if (response != null) {
                obj = new JSONObject(response.string());
                if(obj.getBoolean("success") == true){
                    intent.putExtra(RESULT, RESULT_OK);
                }
                Log.w(TAG, "Result " + obj.toString());
            }
        } catch (IOException e) {
            Log.w(TAG, "Request failed: " + e.getMessage());
        } catch (JSONException e) {
            Log.w(TAG, "Request failed: " + e.getMessage());
        }
    }else{
        Log.w(TAG, "Impossible to connect to Amazon API");
    }

    sendBroadcast(intent);
}

private void sendConfirmSecurityCheck() {
    Intent intent = new Intent(CONFIRM_SECURITY_CHECK);
    intent.putExtra(RESULT, RESULT_FAILED);

    boolean isSuccess = connectAmazonApi();

    if(isSuccess){
        Call<ResponseBody> call = amazonServices.confirmSecurityCheck(settings.getString("username", ""), settings.getString("orgid", ""));
        try {
            ResponseBody response = call.execute().body();
            JSONObject obj;
            if (response != null) {
                obj = new JSONObject(response.string());
                if(obj.getBoolean("success") == true){
                    intent.putExtra(RESULT, RESULT_OK);
                }
                Log.w(TAG, "Result " + obj.toString());
            }
        } catch (IOException e) {
            Log.w(TAG, "Request failed: " + e.getMessage());
        } catch (JSONException e) {
            Log.w(TAG, "Request failed: " + e.getMessage());
        }
    }else{
        Log.w(TAG, "Impossible to connect to Amazon API");
    }

    sendBroadcast(intent);
}

A: How about refactoring the code by extracting two methods?
One method to encapsulate the calling of synchronous requests and another to check if the synchronous request was successful or not.
private ResponseBody executeSynchronously(Call<ResponseBody> call) {
    try {
        return call.execute().body();
    } catch (IOException e) {
        Log.w(TAG, "Request failed: " + e.getMessage());
    }
    return null;
}

private boolean parseResponse(ResponseBody response) {
    if (response == null) return false;
    JSONObject obj = new JSONObject(response.string());
    try {
        Log.w(TAG, "Result " + obj.toString());
        return obj.getBoolean("success") == true;
    } catch (JSONException e) {
        Log.w(TAG, "Request failed: " + e.getMessage());
    }
    return false;
}

Now refactor the sendConfirmSecurityCheck method as follows:
private void sendConfirmSecurityCheck() {
    Intent intent = new Intent(CONFIRM_SECURITY_CHECK);
    intent.putExtra(RESULT, RESULT_FAILED);

    boolean isSuccess = connectAmazonApi();

    if(isSuccess){
        Call<ResponseBody> call = amazonServices.confirmSecurityCheck(settings.getString("username", ""), settings.getString("orgid", ""));
        ResponseBody response = executeSynchronously(call);
        if (parseResponse(response)) {
            intent.putExtra(RESULT, RESULT_OK);
        }
    } else {
        Log.w(TAG, "Impossible to connect to Amazon API");
    }

    sendBroadcast(intent);
}


text:
Q: How can i associate a library symbol with an existing class I am using Flash Develop for compilation ( Not Flash IDE )
Here is a sample code :
   [Embed(source = 'assets.swf', symbol = 'app.view.CustomButton')
    var customButton_Class:Class ;

    var customButton_Instance ;

    customButton_Instance = new customButton_Class();

The problem is that this "customButton_Instance" doesnot know anything about app.view.CustomButton ?? ( Actually this means there is no sense in setting the class as app.view.CustomButton in the assets.fla library )
The workaround i am following is :
 var customButton:CustomButton = new CustomButton();
customButton.setView( customButton_Instance )

But i wanted somehow, the customButton_Instance should automatically associate itself with the customButton class. Any ideas pls ?

A: When using Embed you lose the symbol's associated class. That's how it works.
Instead, if you're using Flash Pro, choose to Publish a SWC that you can then add to your FlashDevelop project (in FlashDevelop: right-click > Add to Library), and then all the symbols will be visible in code completion like any class and you can just write new app.view.CustomButton() or create a custom class extending it.


text:
Q: I can't understand the use of std::istream_iterator I can't understand the code below.
(from https://www.boost.org/doc/libs/1_74_0/more/getting_started/unix-variants.html)
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>

int main()
{
    using namespace boost::lambda;
    typedef std::istream_iterator<int> in;

    std::for_each(
        in(std::cin), in(), std::cout << (_1 * 3) << " " );
}

The web page doesn't explain anything for the code.
What I can't understand is the line with std::for_each function.
std::for_each is defined as below.
template <class InputIterator, class Function>
Function for_each(InputIterator first, InputIterator last, Function fn);

So first is in(std::cin), last is just in(), the function is the cout statement.
Could anyone explain to me the syntax of first and last syntax and meaning in the example code?
The first iterator seems to be constructed with initial value std::cin, but what's the use of in() for the last value?
I also can't understand the _1 part.
The program outputs 3 * any number of integer values I type in.

A: First a little explanation about the std::for_each function.
The function loops over a set of iterators, from the beginning to the end, calling a function for each element in the range.
If you have e.g. a vector of integers:
std::vector<int> v = { 1, 2, 3, 4 };

and want to print print them, then you could do:
std::for_each(v.begin(), v.end(), [](int val) { std::cout << val; });

The above call to std::for_each is equivalent to:
for (auto i = v.begin(); i != v.end(); ++i)
{
    std::cout << *i;
}

Now if we go the usage of the std::istream_iterator in the question, it is wrapping the input operator >> using iterators.
Rewriting the std::for_each call using standard C++ lambdas, it would look like this:
std::for_each(in(std::cin), in(), [](int value) { std::cout << (value * 3) << " " ); });

If we translate it to the "normal" for iterator loop then it becomes:
for (auto i = in(std::cin); i != in(); ++i)
{
    std::cout << (*i * 3) << " ";
}

What it does, is reading integer input (until end-of-file or an error) from std::cin, and then output the value multiplied by 3 and a space.

If you're wondering about in(std::cin) and in(), you have to remember that in is an alias for the type std::istream_iterator<int>.
That means in(std::cin) is the same as std::istream_iterator<int>(std::cin). I.e. it creates a std::istream_iterator<int> object, and passes std::cin to the constructor. And in() constructs an end-iterator object.
Making it even clearer, the code is equivalent to:
std::istream_iterator<int> the_beginning(std::cin);
std::istream_iterator<int> the_end;  // Default construct, becomes the "end" iterator

for (std::istream_iterator<int> i = the_beginning; i != the_end; ++i)
{
    int value = *i;  // Dereference iterator to get its value
                     // (effectively the same as std::cin >> value)

    std::cout << (value * 3) << " ";
}

A:

Could anyone explain to me the syntax of first and last syntax and meaning in the example code?

The first iterator seems to be constructed with initial value std::cin, but what's the use of in() for the last value?

If you look at the description of the constructor of std::istream_iterator you can see that in() constructs the end-of-stream iterator.

istream_iterator(); //  < C++11
constexpr istream_iterator(); // > C++11

Constructs the end-of-stream iterator, value-initializes the stored value. This constructor is constexpr if the initializer in the definition auto x = T(); is a constant initializer (since C++11).

As for in(std::cin):

istream_iterator( istream_type& stream );
istream_iterator( const istream_iterator& other );  //< C++11
istream_iterator( const istream_iterator& other ) = default; // > C++11

Initializes the iterator, stores the address of stream in a data member, and performs the first read from the input stream to initialize the cached value data member.

source

And I also can't understand the _1 part.

What this does is to replace the placeholder _1 with every element in the iteration sequence and multiply it by 3, using the result in the output stream, as it should, given the unary function argument.

for_each(a.begin(), a.end(), std::cout << _1 << ' ');

The expression std::cout << _1 << ' ' defines a unary function object. The variable _1 is the parameter of this function, a placeholder for the actual argument. Within each iteration of for_each, the function is called with an element of a as the actual argument. This actual argument is substituted for the placeholder, and the "body" of the function is evaluated.

source


text:
Q: Convert to decimal & format number to 2 digits after decimal mark The output from the code below produces a decimal number with 13 digits after decimal mark. I want to round off that number to only 2 digits after decimal mark. I've tried to use the Decimal.Round Method to no avail, apparently I'm not using it right.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TorrentPirate
{
    class Program
    {
        static void Main(string[] args)
        {

            TimeSpan time = TimeSpan.FromSeconds(1000);

            double downloadTime = time.TotalHours;

            double money = 50;

            double wifeSpending = money * downloadTime;

            Console.WriteLine(Convert.ToDecimal(wifeSpending));

        }
    }
}

A: As I understand from your comments, you are doing it like this:
Math.Round(wifeSpending, 2);

The Round method does not change the variable that you pass in. It even couldn't if it wanted to because the double value is passed by value (not by reference).
What the Round method does is that it returns a new double that is rounded. Here is what you need to do:
wifeSpending = Math.Round(wifeSpending, 2);


text:
Q: Fixed hight and width for a column table I have a table with multiple column, two of them are being displayed not the way they should be. In fact I want the content to fit the column.
this is my code

       <a style="display: block" href="../workitem/view.asp?item_id=<%=workItemId%>&hometoURL=<%=Server.URLEncode(navpath & "/de/ticket/liste_ticket_pl.asp")%>"><%=Workitem%>

        <%=WorkitemRecordset.fields("Workitem_Rel")%>

What i get is , when my href is  short , the Workitem_Rel is positioned at left , and when href is long it's positioned in the right.
EDIT : this what I get
col1    col2
----- |-------
text  | text
long text  |text
           |

A: It's probably from the  of the head. Fix there the width/height

A: Try this CSS
table td {
   width: 30px;
   overflow: hidden;
   display: inline-block;
   white-space: nowrap;
 }


text:
Q: Why does Janeway go on so many away missions? As I understand it, Starfleet captains were discouraged from going on away missions. In Star Trek Nemesis, Data cites a specific Starfleet regulation (Section 12, Paragraph 4) on the topic before being cut off by Picard.
With that in mind, why does Captain Janeway go on so many away missions and why does Chakotay never try to stop her?
I realize there are occasions where the captain overrides this regulation and goes anyway but one would think these instances would be few and far between like they are in TNG. Janeway seems to jump at the opportunity to get off Voyager every other episode.
Plus, the Delta Quadrant is completely unknown and therefore the potential for unforeseen danger is significantly higher than what Picard saw in TNG.

A: It's brought up multiple times, although not as often as in TNG. Tuvok seems to be the one typically reminding others of regulations but he's also one of those trusting Janeway's judgment the most, especially considering she doesn't throw away all regulations at a whim, even though it might look like that at first.
Overall I always considered the situation similar to ENT: They're understaffed with no way to call in specialists (both distance and partially lack of communication). Janeway might not be an ace pilot like Archer, but she's scientist and seems to be knowing more about different topics than any other member in the crew.
Overall it's just that typical Star Trek trope. The show wants action on the ship and on the ground, but they never want two full leads, so captains often join away teams, meet sexy aliens, etc. with no sane reason.


text:
Q: Why am Getting a "ValueError: Your API ID or Hash cannot be empty or None" when using Telethon inside a Docker Container I am getting a ValueError: Your API ID or Hash cannot be empty or None when i try to run a python script that send files to a chat using telethon inside a docker container. I scheduled it with cron.
This is part of my docker_compose file...
...
name_xyz:
  env_file: .env
  environment:
    PYTHONUNBUFFERED: 1
    TELEGRAM_POSTING_API_HASH: ${TELEGRAM_POSTING_API_HASH}
    TELEGRAM_POSTING_API_ID: ${TELEGRAM_POSTING_API_ID}
  build:
    context: ./xyz/
    dockerfile: Dockerfile
  volumes:
    - ./xyz:/app
  working_dir: /app/xyz/
  restart: always
  command: ./entrypoint.sh
...

So... in my python script i have:
import os
import asyncio
import requests
from telethon import TelegramClient

TELEGRAM_POSTING_API_HASH = os.getenv('TELEGRAM_POSTING_API_HASH')
TELEGRAM_POSTING_API_ID = os.getenv('TELEGRAM_POSTING_API_ID')

client = TelegramClient('session_name', TELEGRAM_POSTING_API_ID, TELEGRAM_POSTING_API_HASH)
...

and in my .env file i have:
TELEGRAM_POSTING_API_ID=11111111111
TELEGRAM_POSTING_API_HASH=11111111111

i actually dont know what am i doing wrong maybe i am missing something. Please help!
I tried hardcoding the api id and api hash in the python script and it works perfect.
But when i put the os.getenv() function it gives me a ValueError: Your API ID or Hash cannot be empty or None
When i change the docker compose file to this:
name_xyz:
  env_file: .env
  environment:
    PYTHONUNBUFFERED: 1
    TELEGRAM_POSTING_API_HASH: ${TELEGRAM_POSTING_API_HASH}
    TELEGRAM_POSTING_API_ID: ${TELEGRAM_POSTING_API_ID}
  build:
    context: ./xyz/
    dockerfile: Dockerfile
  volumes:
    - ./xyz:/app
  working_dir: /app/xyz/telegram
  restart: always
  command: python3 my_python_script.py

it also work... so i think maybe its cron.
here is my entrypoint.sh
#!/bin/bash

# Start the run once job.
echo "Docker container has been started"

# shellcheck disable=SC2046

# Setup a cron schedule
echo "SHELL=/bin/bash

*/2 * * * *  cd /app/xyz/telegram/ && python3 my_python_script.py  >> /var/log/cron.log 2>&1
# This extra line makes it a valid cron" > scheduler.txt

crontab scheduler.txt
cron -f


text:
Q: Structural type I have found for self is very interesting a fact. For example i've wrote:
type A = { val st: Set[Any]
           val start: Set[Any]
           val Sigma : Set[Char]
           def tr(f: (Tuple2[Any, Any])=>Boolean): Set[Any]
             }
class Fon {
          val st: Set[Any]
          val start: Set[Any]
          val Sigma : Set[Char]
          def tr(f: (Tuple2[Any, Any])=>Boolean): Set[Any] = Set(out)
          def out: String = "is just example"
}
val a: A = new Fon
a.tr(f(Tuple2('a',0)))

But if i will try do call a.out - i get an error, that the type A have not exist 'out'
What happening to  this, how this to work?
Thanks.

A: There is no such method as A.out, because of how you've defined the A type.  Thus, when you try to call a method called out on an object of type A, the compiler correctly tells you that no such method exists.
This is not related to structural typing, by the way - if you had made A a trait and had Fon extend it, you'd run into exactly the same problems.  Moreover, this is just how static typing systems work - the compiler can't guarantee that your code is typesafe so it won't compile it.
If you want to call the out method, then you'll need to refer to that object via a Fon variable:
val a: Fon = new Fon
println(a.out) // works fine, since a is guaranteed to be a Fon and thus have the method

A: Basically it allows you to use one object ( Fon )  as it was another  ( A )  granted they have the same features.
Since out  is not a feature of A the compiler doesn't let you proceed.

A: type A is an abstract class or trait. Its member variables and methods are abstract.
type A = {val st: Set[Any]
    val start: Set[Any]
    val Sigma: Set[Char]
    def tr(f: (Tuple2[Any, Any]) => Boolean): Set[Any]
  }

Fon is a concrete class, just implement type A all abstract member.
class Fon {
    val st: Set[Any] = null
    val start: Set[Any] = null
    val Sigma: Set[Char] = null

    def tr(f: (Tuple2[Any, Any]) => Boolean): Set[Any] = Set(out)

    def out: String = "is just example"
  }

So, you can define a variable, type is A ,and concrete instance is Fon
val a: A = new Fon
  println(a.tr(_ => false)) // Set(is just example)

extra:
    f: (Tuple2[Any, Any]) => Boolean is a abstract higher-order function as a parameter,
so, if you want to call method tr, the a.tr(f(Tuple2('a',0))) calling mode can not resolve symbol f.
f: (Tuple2[Any, Any]) => Boolean  just getting a parameter, and return boolean.
so (_ => false) is a concrete implement.


text:
Q: Unknown .exe file I downloaded a program called glasswire to see which programs are using the internet.
One program doesn't show in task manager and I can't find out what it does. Does someone know what it is or how I can find it out?
Info about the program:
name: gwinstst.exe
traffic type: HTTP
Host: 199.7.51.72
incoming: 3.4kb
outgoing: 0.447kb
location: c:\users\thijs\appdata\local\temp\nsx8a46.tmp\gwinstst.exe
Thanks in advance.

A: The fact that this file is in the Appdata\Temp area to me is a big red flag that it's suspect.  I'd try uploading it to VirusTotal - but also be prepared to do a full virus scan on your machine.

A: @GlassWireLabs Twitter account confirmed that gwinstst.exe is their own application. In their words:

"Yes it is ours.  It lets us know how many installs we get per day."

Source: https://twitter.com/GlassWireLabs/status/504363540074221568
(They also confirmed they will be rewriting their FAQ/Privacy Policy pages to reflect more detail in what they collect and why.)


text:
Q: firebase provide facility to upload json in other languages apart from english Does fire base support internationalization, like supporting other languages other than English. I need to upload a json which contains fonts in other languages like German ,France ,etc..

A: I couldn't find anything on Firebase's support page. I really think you should be able to use multiple languages since it just stores text.
I was able to find an article where someone did create an internationalization application using firebase. It stored the localized strings.
http://hwclass.in/developing-javascript-applications-supporting-simple-i18n/


text:
Q: Drawing Lines On a Canvas From Grid to Grid as Added Programmatically I have a Canvas that is bound to a List
  <ItemsControl x:Name="MyCanvasControl" ItemsSource="{Binding Nodes}" Grid.Column="2">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Canvas x:Name="NodeCanvas" >
                        <Canvas.Style>
                            <Style>
                                <Setter Property="Panel.Background" Value="Gray"/>
                            </Style>
                        </Canvas.Style>
                    </Canvas>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>

So I made multiple grids each with a rectangle inside of them. I add the grids to my Grid List which is bound to the Canvas. They appear fine.
I make a special grid with a special rectangle and I place it on the far end of the canvas.
This special grid will be my "TargetGrid". I want every grid I made previously in the collection to have a unique line drawn from them to my "target grid"
               Point p = TargetGrid.TransformToAncestor(MainWindowView.getInstance().MyCanvasControl).Transform(new Point(0, 0));
                Grid g = new Grid();
                g.Name = "line";
                Line RC = new Line();
                g.Children.Add(RC);
                foreach (Grid gr in Nodes)
                {
                        if(gr.Name != "line")
                       {
                         RC.X1 = Canvas.GetLeft(gr);
                         RC.Y1 = Canvas.GetTop(gr);
                         RC.Y2 = p.Y - RC.Y1;
                         RC.X2 = p.X - RC.X1;
                         Canvas.SetLeft(g, RC.X1);
                         Canvas.SetTop(g, RC.Y1);
                         RC.Stroke = System.Windows.Media.Brushes.Blue;
                         RC.StrokeThickness = 2;
                         Nodes.add(RC);
                       }
                }

What happens is peculiar. Every line hits TargetGrid fine. So the endpoints are correct (Y2 and X2). What isn't correct are the X1 and Y1 for some reason and I can't figure out why. They're correct for grid 1 and 3, but every grid after that gets lines that are all over the place. And the coordinates seem perfectly fine too! X1 and Y1 are exactly where I expect them to be.
If I get a picture later, I'll show it.
EDIT:
And if I do exactly what I do with p and my TargetGrid...
Point pp = gr.TransformToAncestor(MainWindowView.getInstance().MyCanvasControl).Transform(new Point(0, 0));

The pp.x and pp.y is ALWAYS 0,0 as if the grids aren't sitting in the canvas control. But curiously enough TargetGrid is always there and it gets a point just fine doing this.
Edit 2:
Image
http://imgur.com/GOnEmfp

A:       RC.X2 = p.X;
      RC.Y2 = p.Y;
      Canvas.SetLeft(g, Canvas.GetLeft(gr));
      Canvas.SetTop(g, Canvas.GetTop(gr));

The solution was to leave X1 and Y1 at 0. They origin point is the grid itself which will be positioned ~over~ the other grids. So instead of trying to align the lines with the other grids, I just needed to let the grids align the lines if you will through their origin.


text:
Q: installing nginx failed CentOS I got following error while installing nginx on CentOs 6.i googled but could not do anything.
   Error: Package: nginx-1.4.6-1.el6.ngx.x86_64 (nginx)
   Requires: libcrypto.so.10(OPENSSL_1.0.1_EC)(64bit)

A: How to find a library installed by which package.
# whereis libcrypto.so

libcrypto: /usr/lib64/libcrypto.so
# rpm -qf /usr/lib64/libcrypto.so

openssl-devel-xxxx.x86_64
Now run blow command:
# yum install openssl-devel

A: You need the cryptography library called: libcrypto.so.10
If you install openssl it will add the libcrypto library
yum install openssl

A: OPENSSL_1.0.1_EC is provided by the stock openssl libraries.
objdump -p /usr/lib64/libcrypto.so.10

Version definitions:
1 0x01 0x0af47420 libcrypto.so.10
2 0x00 0x0af47420 libcrypto.so.10
3 0x00 0x066a2b21 OPENSSL_1.0.1
4 0x00 0x02b21533 OPENSSL_1.0.1_EC

so that could mean you do not use the original libraries. Maybe ptudor's? https://www.ptudor.net/linux/openssl/
He drops openssl-1.0.1e/version.map.fips-ec entirely but do not want to include the version export. https://github.com/ptudor/centos6-openssl/issues/4
If so you can still fix it by rebuilding those ptudor library this way
--- openssl-1.0.1e-version.patch        2014-06-06 11:52:55.772046103 +0200
+++ new_openssl-1.0.1e-version.patch    2014-06-06 11:52:40.854045438 +0200
@@ -61,4 +61,12 @@
 +          _original*;
 +          _current*;
 +};
++OPENSSL_1.0.1_EC {
++    global:
++           EC*;
++};

Or else you can also rebuild the package that cannot be install now and link that to your custom openssl library.


text:
Q: How to pass price into my own div block In magento 2, I've created a recently viewed items using Magento Reports block. Now I need to show prices for only registered users.
I have 2 problems,

*

*price is rendered by following php code,
echo $block->getProductPriceHtml(
    $_item,
    \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE,
    \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST,
    [
        'price_id_suffix' => '-' . $type
    ]
);

When it renders, chrome inspector shows multiple div classes and spans, which makes my css obsolete. I need to just get the price value given from above block and put inside my own div block. How can I do that? From where this price comes from?
please help me

A: If your block extend "AbstractProduct"
(namespace Magento\Catalog\Block\Product)

Then you can use different Price Render or create your own, example found in the core code :
echo $block->getProductPriceHtml(
    $_product,
    \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE,
    \Magento\Framework\Pricing\Render::ZONE_ITEM_VIEW,
    [
        'price_id_suffix' => '_clone'
    ]
)

echo $block->getProductPriceHtml(
                            $_product,
                            \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE,
                            \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST,
                            [
                                'price_id_suffix' => '-widget-viewed-' . $suffix
                            ]


text:
Q: How to display 'png' image after clicking on a hyperlink (name of the file) using png? i have tried code as a result i can able to access the folder image and its filename but unable to display the respective image.As the beginner in php.kindly help!!
<?php
    $dir = '/var/www/info';
    $filearray = array('png');
        $dir_info = scandir($dir);
        foreach ($dir_info as $file)
        {
            $file_type = strtolower(end(explode('.', $file)));
            if ($file !== '.' && $file !== '..' && in_array($file_type, $filearray) == true)
            {
echo'
 'image/png'
    );
    $convert = strtolower(end(explode('.', $name)));
 $file = '/var/www/info/'.$name;
   header('content-type: '. $mimes[$convert]);
    header('content-disposition: inline; filename="'.$name.'";');
    readfile($file);
?>


text:
Q: How to redirect user to the playlist from the click of spotify button without the need to log in? I am using Spotify Widget and the embeded code is
<-iframe src="https://embed.spotify.com/?uri=spotify:user:erebore:playlist:788MOXyTfcUb1tdw4oC7KJ&view=coverart" width="292" height="80" frameborder="0" allowtransparency="true">

There is an option for embeded code where you can show the playlist like,
<-iframe src="https://embed.spotify.com/?uri=spotify:user:erebore:playlist:788MOXyTfcUb1tdw4oC7KJ" width="250" height="80" frameborder="0" allowtransparency="true">

But due to size limitation we cannot use this code.
I would like to have the ability for users on my site to click the Spotify button on my homepage and be directed straight to playlists I have chosen.  Right now, I can only see one song at a time and if I click the Spotify icon
it just take me to the home page of Spotify and invites me to register or log in.  Is there an easier way to direct my users straight to the music I've chosen for the theme of my website?
Thanks

A: I'm a bit unsure of how you exactly want it to look and work but you can always link to the open pages, here is an example (that will send the user to the open.spotify.com site tho):
http://open.spotify.com/user/spotify/playlist/1GQLlzxBxKTb6tJsD4RxHI
The playlist will start playing if you have the spotify desktop app open.
You can get an open link for any playlist in the Spotify client by pressing the (...) button in the header of a playlist and pick "copy http url".


text:
Q: Sorted for-each loop in XSLT can not reference nodes to XPath query outside of loop I am attempting to loop through a set of nodes to build a menu of distinct, sorted values.  All the possible values are known, but which and how many are included in the XML is not known at run time.  The known list changes from time to time, so including the full list would require maintenance control I would rather avoid.
The error text is Required item type of the context item for the parent axis is node(); supplied value has item type xs:anyAtomicType.
I am using XSLT 2.0 from Xerces embedded in Solr 7.6.
I think I understand why, because I am contextually at a text value and not at a node, but I do not know a way around it.
Here is an example XML...
<?xml version="1.0" encoding="UTF-8"?>
<response>

<result name="response" numFound="25" start="0">
  <doc>
    <str name="id">REF-50102</str>
    <str name="type-name">Reference</str>
    <str name="type-abbrv">REF</str>
  </doc>
  <doc>
    <str name="id">REF-50222</str>
    <str name="type-name">Reference</str>
    <str name="type-abbrv">REF</str>
  </doc>
  <doc>
    <str name="id">REF-50245</str>
    <str name="type-name">Reference</str>
    <str name="type-abbrv">REF</str>
  </doc>
  <doc>
    <str name="id">REF-50029</str>
    <str name="type-name">Reference</str>
    <str name="type-abbrv">REF</str>
  </doc>
  <doc>
    <str name="id">SUB-4</str>
    <str name="type-name">Subsystem</str>
    <str name="type-abbrv">SUB</str>
    <str name="system-name">AC-9</str>
  </doc>
  <doc>
    <str name="id">STK-80</str>
    <str name="type-name">Stack</str>
    <str name="type-abbrv">STK</str>
    <str name="system-name">AC-9</str>
  </doc>
  <doc>
    <str name="id">STK-61</str>
    <str name="type-name">Stack</str>
    <str name="type-abbrv">STK</str>
    <str name="system-name">AC-9</str>
  </doc>
  <doc>
    <str name="id">FLM-50025</str>
    <str name="type-name">Flavor</str>
    <str name="type-abbrv">FLM</str>
    <str name="system-name">AC-9</str>
  </doc>
  <doc>
    <str name="id">FLM-50108</str>
    <str name="type-name">Flavor</str>
    <str name="type-abbrv">FLM</str>
    <str name="system-name">AC-9</str>
  </doc>
  <doc>
    <str name="id">FLM-50109</str>
    <str name="type-name">Flavor</str>
    <str name="type-abbrv">FLM</str>
    <str name="system-name">AC-9</str>
  </doc>
  <doc>
    <str name="id">PFP-50101</str>
    <str name="type-name">Prefabricated</str>
    <str name="type-abbrv">PFP</str>
    <str name="system-name">AC-9</str>
  </doc>
  <doc>
    <str name="id">PFP-50103</str>
    <str name="type-name">Prefabricated</str>
    <str name="type-abbrv">PFP</str>
    <str name="system-name">AC-9</str>
  </doc>
  <doc>
    <str name="id">DSG-50163</str>
    <str name="type-name">Design Drawing</str>
    <str name="type-abbrv">DSG</str>
    <str name="system-name">AB-4</str>
  </doc>
  <doc>
    <str name="id">DSG-50164</str>
    <str name="type-name">Design Drawing</str>
    <str name="type-abbrv">DSG</str>
    <str name="system-name">AC-8</str>
  </doc>
  <doc>
    <str name="id">DSG-50162</str>
    <str name="type-name">Design Drawing</str>
    <str name="type-abbrv">DSG</str>
    <str name="system-name">AB-4</str>
  </doc>
  <doc>
    <str name="id">PXS-81</str>
    <str name="type-name">Production Assembly</str>
    <str name="type-abbrv">PXS</str>
    <str name="system-name">AC-9</str>
  </doc>
  <doc>
    <str name="id">PXS-83</str>
    <str name="type-name">Production Assembly</str>
    <str name="type-abbrv">PXS</str>
    <str name="system-name">AC-9</str>
  </doc>
  <doc>
    <str name="id">PXS-82</str>
    <str name="type-name">Production Assembly</str>
    <str name="type-abbrv">PXS</str>
    <str name="system-name">AC-9</str>
  </doc>
  <doc>
    <str name="id">DWG-42</str>
    <str name="type-name">Drawing</str>
    <str name="type-abbrv">DWG</str>
    <str name="system-name">AC-9</str>
  </doc>
</result>
</response>

And the XSL transform with the errors causing lines are commented out...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">

    <xsl:output method="html" indent="yes"/>

    <xsl:template match="/response">

            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

                <xsl:comment>Working if I know the list, but I do not.</xsl:comment>
                <xsl:apply-templates select="result" mode="countKnownList"/>

                <xsl:comment>Finds list dynamically, but can not get name or count.</xsl:comment>
                <xsl:apply-templates select="result" mode="countUnknownList"/>

    </xsl:template>

    <xsl:template name="listElementUnknownList">
        <xsl:param name="abbrv"/>
        <xsl:param name="name"/>

        <xsl:variable name="quantity">#</xsl:variable>

            <xsl:element name="input">
                <xsl:attribute name="id"><xsl:value-of select="$abbrv"/></xsl:attribute>
                <xsl:attribute name="type">checkbox</xsl:attribute>
                <xsl:attribute name="checked">true</xsl:attribute>
                <xsl:attribute name="onclick">toggleRows('<xsl:value-of select="$abbrv"/>');</xsl:attribute>
            </xsl:element><xsl:value-of select="$name"/>(<xsl:value-of select="$quantity" />)

    </xsl:template>

     <xsl:template match="result" mode="countUnknownList">

Type (<xsl:value-of select="count(doc)" />)

                    <xsl:for-each select="distinct-values(doc/str[@name='type-abbrv'])">
                        <xsl:sort select="."/>
                        <xsl:variable name="typeAbbrv"><xsl:value-of select="."/></xsl:variable>

                        <xsl:variable name="typeName"><xsl:value-of select="$typeAbbrv"/>-name</xsl:variable>
                        <xsl:call-template name="listElementUnknownList">
                            <xsl:with-param name="abbrv"><xsl:value-of select="$typeAbbrv"/></xsl:with-param>
                            <xsl:with-param name="name"><xsl:value-of select="$typeName"/></xsl:with-param>
                        </xsl:call-template>
                    </xsl:for-each>

System (<xsl:value-of select="count(doc)" />)

                    <xsl:for-each select="distinct-values(doc/str[@name='system-name']/text())">
                        <xsl:sort select="."/>
                        <xsl:variable name="sysName"><xsl:value-of select="."/></xsl:variable>
                        <xsl:call-template name="listElementUnknownList">
                            <xsl:with-param name="abbrv"><xsl:value-of select="$sysName"/></xsl:with-param>
                            <xsl:with-param name="name"><xsl:value-of select="$sysName"/></xsl:with-param>
                        </xsl:call-template>
                    </xsl:for-each>
                    <xsl:call-template name="listElementUnknownList">
                        <xsl:with-param name="abbrv">None</xsl:with-param>
                        <xsl:with-param name="name">None</xsl:with-param>
                    </xsl:call-template>

    </xsl:template>

    <xsl:template name="listElementKnownList">
        <xsl:param name="abbrv"/>
        <xsl:param name="name"/>
        <xsl:param name="quantity"/>

            <xsl:element name="input">
                <xsl:attribute name="id"><xsl:value-of select="$abbrv"/></xsl:attribute>
                <xsl:attribute name="type">checkbox</xsl:attribute>
                <xsl:attribute name="checked">true</xsl:attribute>
                <xsl:attribute name="onclick">toggleRows('<xsl:value-of select="$abbrv"/>');</xsl:attribute>
            </xsl:element><xsl:value-of select="$name"/>(<xsl:value-of select="$quantity" />)

    </xsl:template>

     <xsl:template match="result" mode="countKnownList">

Type (<xsl:value-of select="count(doc)" />)

                    <xsl:call-template name="listElementKnownList">
                        <xsl:with-param name="abbrv">DSG</xsl:with-param>
                        <xsl:with-param name="name">Design Drawing</xsl:with-param>
                        <xsl:with-param name="quantity"><xsl:value-of select="count(doc[str[@name='type-abbrv']/text()='DSG'])"/></xsl:with-param>
                    </xsl:call-template>
                    <xsl:call-template name="listElementKnownList">
                        <xsl:with-param name="abbrv">FLM</xsl:with-param>
                        <xsl:with-param name="name">Flavor</xsl:with-param>
                        <xsl:with-param name="quantity"><xsl:value-of select="count(doc[str[@name='type-abbrv']/text()='FLM'])"/></xsl:with-param>
                    </xsl:call-template>
                    <xsl:call-template name="listElementKnownList">
                        <xsl:with-param name="abbrv">STK</xsl:with-param>
                        <xsl:with-param name="name">Stack</xsl:with-param>
                        <xsl:with-param name="quantity"><xsl:value-of select="count(doc[str[@name='type-abbrv']/text()='STK'])"/></xsl:with-param>
                    </xsl:call-template>

    </xsl:template>

</xsl:stylesheet>

And finally, the result with the placeholders for unavailable data...

      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Type (19)

<input id="DSG" type="checkbox" checked="true" onclick="toggleRows('DSG');">Design Drawing(3)

<input id="FLM" type="checkbox" checked="true" onclick="toggleRows('FLM');">Flavor(3)

<input id="STK" type="checkbox" checked="true" onclick="toggleRows('STK');">Stack(2)

Type (19)

<input id="DSG" type="checkbox" checked="true" onclick="toggleRows('DSG');">DSG-name(#)

<input id="DWG" type="checkbox" checked="true" onclick="toggleRows('DWG');">DWG-name(#)

<input id="FLM" type="checkbox" checked="true" onclick="toggleRows('FLM');">FLM-name(#)

<input id="PFP" type="checkbox" checked="true" onclick="toggleRows('PFP');">PFP-name(#)

<input id="PXS" type="checkbox" checked="true" onclick="toggleRows('PXS');">PXS-name(#)

<input id="REF" type="checkbox" checked="true" onclick="toggleRows('REF');">REF-name(#)

<input id="STK" type="checkbox" checked="true" onclick="toggleRows('STK');">STK-name(#)

<input id="SUB" type="checkbox" checked="true" onclick="toggleRows('SUB');">SUB-name(#)

System (19)

<input id="AB-4" type="checkbox" checked="true" onclick="toggleRows('AB-4');">AB-4(#)

<input id="AC-8" type="checkbox" checked="true" onclick="toggleRows('AC-8');">AC-8(#)

<input id="AC-9" type="checkbox" checked="true" onclick="toggleRows('AC-9');">AC-9(#)

<input id="None" type="checkbox" checked="true" onclick="toggleRows('None');">None(#)

</html

A: One way to circumvent this is by defining a top-level variable containing the whole document like in this answer:
...
<xsl:output method="html" indent="yes"/>
<xsl:variable name="mainDoc" select="/" />
...

Then reference it in your commented-out variables (I also changed the predicate in the count to count the desired nodes):
The first
<xsl:variable name="quantity" select="count($mainDoc/response/result/doc/str[@name='type-abbrv' and text()=$abbrv])"/>

and the second
<xsl:variable name="typeName" select="($mainDoc//doc[str[@name='type-abbrv']/text()=$typeAbbrv]/str[@name='type-name'])[1]" />

A: The variable solves your problem but you wouldn't have it if you just used xsl:for-each-group e.g.
   <xsl:for-each-group select="doc" group-by="str[@name='type-abbrv']">
                    <xsl:sort select="current-grouping-key()"/>
                    <xsl:variable name="typeAbbrv" select="current-grouping-key()"/>

                    <xsl:variable name="typeName" select="str[@name='type-name']"/>

                    <xsl:variable name="typeName"><xsl:value-of select="$typeAbbrv"/>-name</xsl:variable>
                    <xsl:call-template name="listElementUnknownList">
                        <xsl:with-param name="abbrv"><xsl:value-of select="$typeAbbrv"/></xsl:with-param>
                        <xsl:with-param name="name"><xsl:value-of select="$typeName"/></xsl:with-param>
                    </xsl:call-template>
   </xsl:for-each-group>

which of course can be shortened to
   <xsl:for-each-group select="doc" group-by="str[@name='type-abbrv']">
                    <xsl:sort select="current-grouping-key()"/>
                    <xsl:call-template name="listElementUnknownList">
                        <xsl:with-param name="abbrv" select="current-grouping-key()"/>
                        <xsl:with-param name="name" select="concat(str[@name='type-name'], '-name')"/>
                    </xsl:call-template>
   </xsl:for-each-group>

So I think grouping is what you really want, I have tried to implement part of that as
 <xsl:template match="result" mode="countUnknownList">

Type (<xsl:value-of select="count(doc)" />)

               <xsl:for-each-group select="doc" group-by="str[@name='type-abbrv']">
                    <xsl:sort select="current-grouping-key()"/>

                           <input id="{current-grouping-key()}"
                                  type="checkbox"
                                  checked="checked"
                                  onclick="toggleRows('{current-grouping-key()}');"/>
                            <xsl:value-of select="concat(str[@name='type-name'], '(', count(current-group()), ')')"/>

               </xsl:for-each-group>

System (<xsl:value-of select="count(doc)" />)

               <xsl:for-each-group select="doc" group-by="str[@name='system-name']">
                    <xsl:sort select="current-grouping-key()"/>

                           <input id="{current-grouping-key()}"
                                  type="checkbox"
                                  checked="checked"
                                  onclick="toggleRows('{current-grouping-key()}');"/>
                            <xsl:value-of select="concat(current-grouping-key(), '(', count(current-group()), ')')"/>

               </xsl:for-each-group>

</xsl:template>

at https://xsltfiddle.liberty-development.net/gWvjQf4, result for your sample there is one list

<input id="DSG" type="checkbox" checked onclick="toggleRows('DSG');">Design Drawing(3)

<input id="DWG" type="checkbox" checked onclick="toggleRows('DWG');">Drawing(1)

<input id="FLM" type="checkbox" checked onclick="toggleRows('FLM');">Flavor(3)

<input id="PFP" type="checkbox" checked onclick="toggleRows('PFP');">Prefabricated(2)

<input id="PXS" type="checkbox" checked onclick="toggleRows('PXS');">Production Assembly(3)

<input id="REF" type="checkbox" checked onclick="toggleRows('REF');">Reference(4)

<input id="STK" type="checkbox" checked onclick="toggleRows('STK');">Stack(2)

<input id="SUB" type="checkbox" checked onclick="toggleRows('SUB');">Subsystem(1)

and the second as

<input id="AB-4" type="checkbox" checked onclick="toggleRows('AB-4');">AB-4(2)

<input id="AC-8" type="checkbox" checked onclick="toggleRows('AC-8');">AC-8(1)

<input id="AC-9" type="checkbox" checked onclick="toggleRows('AC-9');">AC-9(12)

hope I have grasped what the original code intended to do.


text:
Q: window.print issues with iFrame and IE7 I'm using window.print() from inside an iFrame. This works flawlessly in FF, but not so great in IE7. In IE7, it brings up the Print Dialog, however, the dialog itself is slow, choppy and unstable.
I'm having troubles understanding this problem, and any help would be greatly appreciated.

If I may add, the same thing happens when printing content of the same iFrame from outside of the iFrame in question. Further more, when clicking File->Print the Print Dialog appears to function normally.

A: Try using:
document.execCommand('print', false, null);

This appears to work in IE7, but you'll probably want to use a conditional and use window.print() for other browsers.


text:
Q: Is a Deligne-Mumford curve defined over Qbar if and only if its coarse moduli space is Let $\mathcal X$ be a smooth proper finite type Deligne-Mumford stack over $\mathbb C$ that is generically a scheme. Let $X$ be its coarse moduli space.
If $\mathcal X$ can be defined over $\overline{\mathbb Q}$, then $X$ can be defined over $\overline{\mathbb Q}$. This is because "the base-change of the coarse moduli space is the coarse moduli space of the base-change".
Does the converse hold?
What if we drop the properness condition?
My motivation is mere curiosity.

A: No.  Even if $X$ is "defined over $\overline{\mathbb{Q}}$" in the sense that $X$ is isomorphic to $X_0\otimes_{\overline{\mathbb{Q}}} \mathbb{C}$ for some variety $X_0$ over $\overline{\mathbb{Q}}$, nonetheless the stack $\mathcal{X}$ may not be defined over $\overline{\mathbb{Q}}$.
For instance, let $X_0$ be $\mathbb{P}^1_{\overline{\mathbb{Q}}}$ so that $X$ is $\mathbb{P}^1_{\mathbb{C}}$.  Now let $t_0,t_1,t_2\in \mathbb{P}^1_{\mathbb{C}}(\mathbb{C})\setminus\{0,1,\infty\}$ be three distinct points such that at least one is transcendental, e.g., $2$, $3$, $\pi$.  Denote by $$f:Y\to X,$$ the genus $2$, hyperelliptic curve branched over $$\{0,1,\infty,t_0,t_1,t_2\}.$$  There is an action of $\mathbb{Z}/2\mathbb{Z}$ on $Y$ via the hyperelliptic involution.  Let $\mathcal{X}$ be the quotient Deligne-Mumford stack, $$\mathcal{X} = [Y /(\mathbb{Z}/2\mathbb{Z})].$$  The coarse moduli space is $X$, via the unique morphism $\pi: \mathcal{X}\to X$ that factors $f$.  Of course $X$
is defined over $\overline{\mathbb{Q}}$.  However, the branch divisor of the morphism $\pi$ is not defined over $\overline{\mathbb{Q}}$ as a subscheme of $X$.  Thus, also $\mathcal{X}$ is not defined over $\overline{\mathbb{Q}}$.
Added by OP:
It might be useful to (slightly) generalize the above construction.
Let $X=\mathbb P^1_{\mathbb C}$ and let  $f:Y\to X$ be a hyperelliptic curve with branch locus $D$ (and $Y$ of positive genus). Write $U=X\backslash D$. Let $\mathcal X$ be the stack $[Y/G]$. Then the unique morphism $\pi:\mathcal X \to X$ that factors $f:Y\to X$ is the coarse moduli space of $\mathcal X$. Suppose that $U$ can't be defined over Qbar. Then $Y\to X$ (and $Y$) can't be defined over $\overline{\mathbb Q}$ (as the hyperelliptic  involution is unique). Therefore, $\mathcal X\to X$ and $\mathcal X$ can't be defined over Qbar.

A: Let $\mathcal{X}$ be an algebraic stack over $k$. A coarse moduli space for $\mathcal{X}$ over $k$ is a morphism $\pi:\mathcal{X}\rightarrow X$, where $X$ is a scheme such that:

*

*the morphism $\pi$ is universal for morphisms to schemes;

*$\pi$ induces a bijection between $|\mathcal{X}|$ and the closed points of $X$, where $|\mathcal{X}|$ denotes the set of isomorphism classes in $\mathcal{X}$.

If $\mathcal{X}$ admits a coarse moduli space $\pi:\mathcal{X}\rightarrow X$ then this is unique up to unique isomorphism. A separated algebraic stack has a coarse moduli space which is a separated algebraic space.
Let $\mathcal{X}$ be a separated stack admitting a scheme $X$ as coarse moduli space $\pi:\mathcal{X}\rightarrow X$. The map $\pi$ is universal for morphisms in schemes, that is for any morphism $f:\mathcal{X}\rightarrow Y$, with $Y$ scheme, there exists a unique morphisms of schemes $g:X\rightarrow Y$ such that $f = g\circ\pi$.
Now, if $\mathcal{X}$ is defined over $k$ we have a morphism $f:\mathcal{X}\rightarrow Spec(k)$. By universality there is a morphism of schemes $g:X\rightarrow Spec(k)$ such that $g\circ\pi = f$. In particular $X$ is defined over $k$.
Conversely, if $X$ is defined over $k$ then there is a morphism $g:X\rightarrow Spec(k)$. By composition we get a morphism $f:=g\circ\pi:\mathcal{X}\rightarrow X$. Therefore $\chi$ is defined over $k$.
For instance both the stack $\overline{\mathcal{M}}_{g,n}$ and its coarse moduli space $\overline{M}_{g,n}$ parametrizing Deligne-Mumford stable curves are defined over $\mathbb{Z}$. In particular over any commutative ring and hence over any field.


text:
Q: How to filter a Maybe value I am trying to create a function that validates an input String -> Maybe Int. I check to see if the input string is a number then check if that number is in a range. So far I have
validateNumber :: String -> Maybe Int
validateNumber n  = go $ (readMaybe::String -> Maybe Int) n
  where
    go (Just a) = inRange a
    go Nothing  = Nothing

inRange :: Int -> Maybe Int
inRange n
  | n > 0     = Just n
  | otherwise = Nothing

This feels like poor code. How should this be written?
Also, if I am trying to loop a function if it returns Nothing, what is the best way to do so:
So to loop the main function, I am doing :
case v of
  Nothing -> main
  Just x  -> {do something}

A: How about this?
validateNumber :: String -> Maybe Int
validateNumber n = (readMaybe n) >>= inRange

Or even this:
validateNumber :: String -> Maybe Int
validateNumber str = do
  n <- readMaybe str
  if n < 0 then Nothing else return n

(Avoids needing a separate inRange function.)

A: You can use mfilter to filter out-of-range values within a Maybe instead of explicitly matching:
import Control.Monad (mfilter)

validateNumber :: String -> Maybe Int
validateNumber = mfilter (> 0) . readMaybe

A: I would try something like this (not tested):
validateNumber :: String -> Maybe Int
validateNumber n = case (readMaybe::String -> Maybe Int) n of
    (Just a) -> case n > 0 of
        True  -> Just n
        False -> Nothing
    Nothing  -> Nothing

It's a bit shorter and more concise.


text:
Q: Blazor Server Component - How to two way bind input html tag and call function onchange I am trying to figure out how I can both two bind to an HTML input and call a function for the onchange event.
  <input id="nonce" type="hidden" @bind="@nonce" @onchange="Checkout" />

This gives the following error: The attribute 'onchange' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'onchange' is used by the '@bind' directive attribute.
One solution might be to not use the bind directive and instead use the onchange to update the value in the input.
Or can I override the onchange the @bind is using and add my own custom code?

A:
One solution might be to not use the bind directive and instead use
the onchange to update the value in the input.

This.
Depending on how you're using this, you might be able to do stuff in the get; set; for the property nonce as well, though technically trying to set a value doesn't guarantee that it's changing.

A: You should give the model value in OnInitialized method and then change it by @oninput event. Now, you can customize the @OnInputChange.
You can use the below code:
<input value="@Value" @oninput="@OnInputChange" />
<h4>@Value</h4>

@code {
BlazorRoom Room = new BlazorRoom
{
    Id = 1,
    Name = "Room 1",
    IsActive = true,
    Price = 499

};

public string Value { get; set; }

protected override void OnInitialized()
{
    base.OnInitialized();

    Value = Room.Name;
}

private void OnInputChange(ChangeEventArgs args )
{
    Value = (string)args.Value;

    //you can customized it
    Value = Value.ToUpper();
}
}

and the model is:
public class BlazorRoom
{
    public int Id { set; get; }

    public string Name { set; get; }

    public decimal Price { set; get; }

    public bool IsActive { set; get; }
}


text:
Q: Auto generating password generating up to n values and display into new line PHP I have a code from auto generating passwords and i want to produce up to 40 times of random passwords and displaying it into a new line.
$num = 0;
while($num != 40){
    $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
    $pass = array(); //remember to declare $pass as an array
    $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
        for ($i = 0; $i < 8; $i++) {
        $n = rand(0, $alphaLength);
        $pass[] = $alphabet[$n];
        }
print_r ($pass);
echo implode("
",$pass);
$num++;
}

the code separates the array per strings into new line. I need to display a strings with 8 characters up to 40 times per line.

A: Instead of echo implode("
",$pass);, you're looking for echo implode($pass) . "
";
$num = 0;
while($num != 40){
    $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
    $pass = array(); //remember to declare $pass as an array
    $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
        for ($i = 0; $i < 8; $i++) {
        $n = rand(0, $alphaLength);
        $pass[] = $alphabet[$n];
        }
    print_r ($pass);
    echo implode($pass) . "
";
    $num++;
}

This can be seen working here.
Note that rand() is not a cryptographically secure pseudorandom number generator, and should not be used for password generation. For such tasks, I would recommend checking out some of these answers. Keep in mind that length is far more important than complexity with regards to brute-forcing, so you may also wish to up your lengths from 8.


text:
Q: In a form with a tabbed control, a button click reduces panel-height in tab page in focus, which gets corrected if move to another tab and come back I have a fixed size form containing a tabcontrol component, which has two tab pages. The tab pages contain panels with tables which may contain a variable amount of data to be displayed. When I press a 'Refresh' button, in its event handler, I reinitialize the values in the table. So far, I do not recalculate the height of the panels. But the height of the panel on the tab page in focus somehow reduces by a small amount, i.e., when you scroll down to the bottom of the panel, some data gets cut off. But if I switch focus to another tab page, that tab page appears fine. Also, when I switch back to the original tab page, now that also appears fine. Can someone explain why this happens, and how can I fix it?

A: I think I used to have a similar problem and I solved it with
tabControl.TabPages[tabPage].Refresh();

after reinitializing the values... But I have no idea why it happens.


text:
Q: mysql left join with multiple tables based on user I Need to Join two tables car details and favorite cars.I used left join to join both tables.

|id| name |Model  |registration |Description  |Variant |status|User Detail Id

|1|  Etios    | Mini  | 123123     |AC Available |Petrol  |Active|51

|1|  Etios    | Mini  | 123123     |AC Available |Petrol  |Active|47

|1|  Etios    |  Mini | 123123     |AC Available |Petrol  |Active|52

|6| Indigo    |  Mini | 123        |AC Available |Gas     |Active|NULL

This is the output i got but exactly what i need is to display car based on userdetailid.For userdetailid='52' i need to get 3rd and 4th row
I used this query
SELECT `u`.`id`,`u`.`CarName`,`u`.`CarModel`,`u`.`RegistrationNumber`,`u`.`Description`,`u`.`Variant`,`u`.`Status`,`uf`.`CardetailsId`,`uf`.`UserDetailsId`
FROM `cardetails` AS `u`  LEFT JOIN `favoritecars` AS `uf` ON (`u`.`id` = `uf`.`CarDetailsId`)
where
u.status = 'Active' and u.CarModel = 'Mini'  and (uf.UserDetailsId='52' or uf.UserDetailsId is null)

Please help me.Thanks in advance

A: if i understand you question right, your on clause must be
ON (u.id = uf.userDetailsId)
SELECT `u`.`id`,`u`.`CarName`,`u`.`CarModel`,`u`.`RegistrationNumber`,`u`.`Description`,`u`.`Variant`,`u`.`Status`,`uf`.`CardetailsId`,`uf`.`UserDetailsId`
FROM `cardetails` AS `u`  LEFT JOIN `favoritecars` AS `uf` ON (`u`.`id` = `uf`.`userDetailsId`)
where
u.status = 'Active' and u.CarModel = 'Mini'  and (uf.UserDetailsId='52' or uf.UserDetailsId is


text:
Q: FilterBy from Start of String As it currently stands the filterBy filter looks for matching values throughout a string. For instance if I filter by "e", filtered results could entail:
"Entertainment",
"Internet",
"Services".
Is there a way for me to direct filterBy to start matching from the start of the string and ignore the rest so that the only result that comes back from that set is "Entertainment"?

A: You can write your own Filter and check the indexOf the field you're searching.
Let's say you have

  <input v-model="search">

    {{ item.name }}

Then your filter can look something like this:
Vue.filter('startsWith', function (array, search, field) {
  if (!search.length) return array;

  return array.filter(function(element) {
    return element[field].toLowerCase().indexOf(search.toLowerCase()) === 0;
  })
})

Here's a quick demo: https://jsfiddle.net/jb22wp1b/


text:
Q: Границы border CSS У меня текст выровнен по центру и у него обводка. Можно ли что бы эта обводка была в границах текста и дальше не лез

#headed{
  text-align: center;
  font-size: 34px;
  color: #70B8FF;
  font-family: Gabriola;
  border:5px blue dashed;

}
<!DOCTYPE html>

    <meta charset="utf-8">
    <link rel="stylesheet" href="D:\ВЛАД\AtomProject\FirstWeb\style.css">
    <title></title>

About Me

A:

#headed{
  text-align: center;
  font-size: 34px;
  color: #70B8FF;
  font-family: Gabriola;
  border:5px blue dashed;
  display: block;
  padding: .2rem;
  margin: 0 auto;
  width: 160px;
}

.flex-container {
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-flex-wrap: nowrap;
    -ms-flex-wrap: nowrap;
    flex-wrap: nowrap;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-align-content: center;
    -ms-flex-line-pack: center;
    align-content: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    }

.flex-item:nth-child(1) {
    -webkit-order: 0;
    -ms-flex-order: 0;
    order: 0;
    -webkit-flex: 0 1 auto;
    -ms-flex: 0 1 auto;
    flex: 0 1 auto;
    -webkit-align-self: center;
    -ms-flex-item-align: center;
    align-self: center;
    }

.flex-item h1 {
  padding: .2rem;
  border: 6px dotted red;
}
<!DOCTYPE html>

    <meta charset="utf-8">
    <link rel="stylesheet" href="D:\ВЛАД\AtomProject\FirstWeb\style.css">
    <title></title>

       About Me

About Me