text:
Q: Incorrect display of svg in the icon OpenLayers Please tell me how to use svg for icons in OpenLayers? What structure should svg have?
We have encountered several problems when using svg and have prepared an example:

*

*It is impossible to correctly change the color of the image using the "color" property (example with Green Smile and RedSmile)

*Images are not displayed if you remove the link to the standard "xmlns="http://www.w3.org/2000/svg "" (example with Yellow Smile). Why doesn't it work?
Thank you for the answers!

A: As mentioned in the ol/style/Icon docs, the color property adds a "tint" to the icon. This is done to add support for jpg and png icons.
What it means, is that the color is mixed into the icon color.
In your example, since all paths are black -> black + red = black, and the background is white -> white + red = red. If you want to color the lines only, remove the fill property from <rect> and fill all <path> white.
This is how the new icon would then look:
    let greenIcon =
  '<svg width="148" height="117" viewBox="0 0 148 117" fill="none" xmlns="http://www.w3.org/2000/svg">' +
  '<rect width="148" height="117"/>' +
  '<path d="M86.5833 55.833C90.0351 55.833 92.8333 53.0348 92.8333 49.583C92.8333 46.1312 90.0351 43.333 86.5833 43.333C83.1316 43.333 80.3333 46.1312 80.3333 49.583C80.3333 53.0348 83.1316 55.833 86.5833 55.833Z" fill="white"/>' +
  '<path d="M57.4167 55.833C60.8685 55.833 63.6667 53.0348 63.6667 49.583C63.6667 46.1312 60.8685 43.333 57.4167 43.333C53.9649 43.333 51.1667 46.1312 51.1667 49.583C51.1667 53.0348 53.9649 55.833 57.4167 55.833Z" fill="white"/>' +
  '<path d="M72 76.6663C65.8333 76.6663 60.5417 73.2913 57.625 68.333H50.6667C54 76.8747 62.2917 82.9163 72 82.9163C81.7083 82.9163 90 76.8747 93.3334 68.333H86.375C83.5 73.2913 78.1667 76.6663 72 76.6663ZM71.9583 18.333C48.9583 18.333 30.3333 36.9997 30.3333 59.9997C30.3333 82.9997 48.9583 101.666 71.9583 101.666C95 101.666 113.667 82.9997 113.667 59.9997C113.667 36.9997 95 18.333 71.9583 18.333ZM72 93.333C53.5833 93.333 38.6667 78.4163 38.6667 59.9997C38.6667 41.583 53.5833 26.6663 72 26.6663C90.4167 26.6663 105.333 41.583 105.333 59.9997C105.333 78.4163 90.4167 93.333 72 93.333Z" fill="white"/>' +
  "</svg>";


text:
Q: Nested dict loop I just wrote some code the should simulate parcel orders for a series of 90 day,
This part makes csv files for all order days:
Period = list(range(1,90))
for item in Preiod:
       "some code to simulate the days, which is irrelevant here"
       .to_csv(rf'file_location_Day{item}.csv)

I then use a solver to make routes for the vehicles that deliver the parcels. this solver opens the csv file, and gives an output like this(nested list):
[[36, 27, 11, 15, 41, 35, 20, 42, 24, 21, 37, 5, 25, 39, 12, 31], [3, 34, 32, 33, 47, 9, 16, 13, 28, 22, 17, 43, 7, 45, 38], [6, 30, 1, 40, 4, 8, 46, 23, 14, 18, 29, 44, 10, 26, 2, 19]]

In this case 3 lists: vehicle 1 delivers parcel 36 then 27 then 11, vehicle 2 delivers parcel 3 then 34, then 32 etc. This nested list is stored as results.routs
I would like to store this data in a nested dictionary, i think this is allready close:
Routes = {}
Routes[Day1] = result.routes

But i'd like an extra level:
Routes[Day1],[vehicle1] =
Routes[Day1],[vehicle1], [ParcelNumber, x-coordinate, y-coordinate] =

This is because i will later need to search the coordinates for all corresponding parcel locations. (bit like vlookup in excel)
e.g. in the csv file search the 36th parcel location, pick the x and y coordinate in the two  columns next to it, and then paste it in the corresponding lists in the dict.
My biggest challange: How do i make a loop for this in a neat way

redpajama_set_name: RedPajamaStackExchange


text:
Q: Obtain IP Direction using JAVA
Possible Duplicate:
Getting the 'external' IP address in Java

i'm using JAVA for a write a simple messenger, but i need know the IP address of the machine where is running my program
Thanks.

A: You can either parse a "what is my IP" website (like http://my-i-p.com/), which usually restrict the frequency you can get the IP.
Or, if you have your own web server, you can have the application contact a PHP page, for example, that prints the IP address on the page. Download that page to retrieve the IP address from the text.


text:
Q: Open Mapping Theorem and the Bounded Inverse Theorem to show $T^{-1}$ is not bounded Preface
This is a problem in my Functional Analysis course. I'm really struggling to dissect part (b) any help/alternative solutions would be greatly appreciated on both parts of the question :)

Question
Let X be the space of continuous functions $x : [1,\infty)\rightarrow \mathbb R$ which have compact support, that is there exists a compact interval $I_x$ of $[1,\infty)$ such that $x(t) = 0 \quad \forall t ∈ [1,\infty) \backslash \space I_x$. Consider X with
the norm $\left\lVert x \right\rVert = \max_{t\in[1,\infty)}
|x(t)|$ and define the mapping $T : X \rightarrow X$ as
$(Tx)(t) = \frac{1}{t^2}x(t)$,for every $t \in[1,\infty).\\$
(a) Show that T is linear, bounded, bijective and find $\left\lVert T \right\rVert$ and $T^{-1}$ and show that it is bijective.
\begin{aligned}
\forall x_{1}, x_{2} \in X \space \text{ and }\space \alpha, \beta \in \mathbb{R} \\
T\left(\alpha x_{1}+\beta x_{2}\right)(t) &=\frac{1}{t^{2}}\left(\alpha x_{1}+\beta x_{2}\right)=\alpha \frac{1}{t^{2}} x_{1}+\beta \frac{1}{t^{2}} x_{2} \\
& = \alpha\frac{1}{t^{2}} x_{1}(t)+\beta \frac{1}{t} x_{2}(t)\\
&=\alpha\left(T x_{1}\right)(t)+\beta\left(Tx_{2}\right)(t). \\ \text{Hence T is linear.}
\end{aligned}
\begin{array}{l}
\text { Note: } 0 \lt \frac{1}{t^{2}} \leqslant 1 \quad \forall t \in[1, \infty) \\
\Rightarrow \quad \frac{1}{t^{2}}|x(t)|=\left|\frac{1}{t^{2}} x(t)\right| \leqslant|x(t)| \quad\forall t \in[1, \infty) \\
\text { i.e }\|T x\|=\left\|\frac{1}{t^{2}} x(t)\right\|=\max _{t_{t}(1, \infty)}\left|\frac{1}{t^{2}} x(t)\right| \\
\leqslant \max _{t \in[1, \infty)}|x(t)|=\|x\| \\
\therefore T \text { is bounded }
\end{array}
as for finding $\left\lVert T \right\rVert$ and showing that $T^{-1}$ it is bijective I am unsure how to do this :/
(b) The next problem I have is showing that $T^{-1}$ is not bounded and to explain why this not in contradiction with the Open Mapping Theorem and the Bounded Inverse Theorem


text:
Q: BibTeX, IEEEtran and multiple citations I have encountered a problem when doing multiple citations using BibTeX and the document class IEEEtran in Mac OS X (Version 10.6.8). The desired effect is similar to this:

References [1, 2, 3].

with thin spaces in-between. Instead, I get

References [1], [2], [3].

For more details, see the attached example code. I tried the package cite and it didn't solve the problem. In fact, using cite (without options) produces this

References [1]-[3]

which is not what I want (I don't want compressed citations, which is a different thing, so this is not a duplicate of this question). The [nocompress] option of cite doesn't help either.
This is the example code:
\documentclass[12pt, draftclsnofoot, onecolumn]{IEEEtran}
\usepackage[T1]{fontenc}
%\usepackage{cite}
\begin{document}
\section{Introduction}
References~\cite{ref1, ref2, ref3}.
\bibliography{mybiblio}{}
\bibliographystyle{ieeetr}
\end{document}

And this is the mybiblio.bib file:
@article{ref1,
    Author = {Surname1, N. and Surname2, N. and Surname3, N.},
    Journal = {Test},
    Number = 0,
    Pages = {1-2},
    Title = {Reference title},
    Volume = 0,
    Year = 2016
    }

@article{ref2,
    Author = {Surname1, N. and Surname2, N.},
    Journal = {Test},
    Number = 0,
    Pages = {1-2},
    Title = {Reference2 title},
    Volume = 0,
    Year = 2016
    }

@article{ref3,
    Author = {Surname1, N.},
    Journal = {Test},
    Number = 0,
    Pages = {1-2},
    Title = {Reference3 title},
    Volume = 0,
    Year = 2016
    }

P.S. I can't use the natbib package.

A: IEEEtran explicitly defines citations to be separated into distinct [1],[2],[3] rather than the default [1,2,3] when the cite package is used by the \def\citepunct{], [} command which is used by cite.  To over-rule this you can just use \def\citepunct{,} to produce [1,2,3] or insert a manual space, i.e. for a small spacing \, after the comma \def\citepunt{,\,} produces the following.

Produced from
\documentclass[12pt, draftclsnofoot, onecolumn]{IEEEtran}
\usepackage{filecontents}
\begin{filecontents}{mybiblio.bib}
@article{ref1,
    Author = {Surname1, N. and Surname2, N. and Surname3, N.},
    Journal = {Test},
    Number = 0,
    Pages = {1-2},
    Title = {Reference title},
    Volume = 0,
    Year = 2016
    }

@article{ref2,
    Author = {Surname1, N. and Surname2, N.},
    Journal = {Test},
    Number = 0,
    Pages = {1-2},
    Title = {Reference2 title},
    Volume = 0,
    Year = 2016
    }

@article{ref3,
    Author = {Surname1, N.},
    Journal = {Test},
    Number = 0,
    Pages = {1-2},
    Title = {Reference3 title},
    Volume = 0,
    Year = 2016
    }
\end{filecontents}

\usepackage[nocompress]{cite}

\def\citepunct{,\,}

\begin{document}
\section{Introduction}
References~\cite{ref1, ref2, ref3}.
\bibliography{mybiblio}
\bibliographystyle{ieeetr}
\end{document}

It may be worth noting that IEEEtran does the same for the compressed citation by defaulting to \def\citedash{]--[} producing [1]--[3] rather than [1--3] which may be the expected result.


text:
Q: Azure Application Insights - search HTTP erros? Is there a way to use Application Insights as a substitute for Web Server Logging? My end goal here is to analyze 4xxs and 5xxs.
Details:
-Right now, i only have the requests info for controllers/action where I manually used TrackRequest
-Web App hosted on Azure.
-SDK added as documents instruct.
-Other parts (SQL Dependency Tracking for example) work out-of-the-box

A: For some reason the web.config was missing:
<httpModules>
  <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>


text:
Q: Property binding for `value1` in Filter Is it possible to bind a value from the model to a filter in SAPUI5?
My model:
{
  "MasterItems": [
    {
      "ID" : "1.1",
      "ParentID" :  "1",
      "Text" : "a"
    },
    {
      "ID" : "2.1",
      "ParentID" :  "2",
      "Text" : "b"
    }
  ]
}

My Control:
<List items="{
  path: 'MasterItems>/MasterItems',
  filters: [
    {
      path: 'ParentID',
      operator: 'EQ',
      value1: '1'
    }
  ]
}">

As expected, the list shows only the first Item with the text "1".
But the value1 is static. I want to know if I can do a property binding for value1?
Something like this:
value1: 'MasterItems>ParentID'

Now the filter SHOULD be dependent to the Model.
I already implemented the functionality within the controller but I think using aggregation binding would be better.

A: As Boghyon mentioned this is not possible. There is no way to bind filters directly to the model.
The only workaround for this is getting the binding of the aggregation you want to filter and set the filter in the controller:
Example snippet:
var oFilter = new sap.ui.model.Filter("SomeModelProperty", sap.ui.model.FilterOperator.EQ, "SomeValue");

var oControlBinding = this.getView().byId("idOfYourControl").getBinding("items");
oControlBinding.filter(oFilter);

You can also combine multiple filters by pushing them to an array an assign it then to the binding. See documentation https://sapui5.hana.ondemand.com/#/api/sap.ui.model.Filter


text:
Q: How can I train my LSTM model with multiple datasets? I have 1000 datasets that has the battery voltage of different devices. eg: device1.csv, device2.csv....etc.
Each dataset is sequential as it has a feature; the battery voltage measured at every age of the device. I want to train a single LSTM model with all those datasets without breaking my sequence.
The shape of every dataset is different therefore I cannot stack merge them into one dataframe.
Should I train the model in a for loop?


text:
Q: A p adic limit of a binomial coefficient Let $0 \leq a \leq p^n$ be a number coprime to p. Consider the following sequence of binomial coefficients:
$$B_k = \binom{p^{n+k}}{p^ka} $$
as $k\to \infty$. If I did the computation right, the p-adic valuation of $ B_k$ is finite and constant for $k$ large enough. This suggests that the limit exists p-adically, is this true? If so what is the limit and does it only depend on $a/p^n$?
Perhaps one can relate the limits with approximations obtained from the p-adic Gamma function?


text:
Q: Dynamic Mapping Disabled is not working in ElasticSearch I am running into errors when I try to disable dynamic mapping in ElasticSearch settings. I am using ElasticSearch 1.7 version for implementation.
StackTrace :
8151 [main] WARN org.apache.hadoop.mapred.YarnChild - Exception running child : org.elasticsearch.hadoop.rest.EsHadoopInvalidRequest: Found unrecoverable error [10.74.51.71:9200] returned Not Found(404) - [TypeMissingException[[test_2017051222] type[[vehicle, trying to auto create mapping, but dynamic mapping is disabled]] missing]]; Bailing out..
    at org.elasticsearch.hadoop.rest.RestClient.retryFailedEntries(RestClient.java:207)
    at org.elasticsearch.hadoop.rest.RestClient.bulk(RestClient.java:170)
    at org.elasticsearch.hadoop.rest.RestRepository.tryFlush(RestRepository.java:225)
    at org.elasticsearch.hadoop.rest.RestRepository.flush(RestRepository.java:248)
    at org.elasticsearch.hadoop.rest.RestRepository.doWriteToIndex(RestRepository.java:187)
    at org.elasticsearch.hadoop.rest.RestRepository.writeToIndex(RestRepository.java:163)
    at org.elasticsearch.hadoop.mr.EsOutputFormat$EsRecordWriter.write(EsOutputFormat.java:151)
    at org.apache.hadoop.mapred.ReduceTask$NewTrackingRecordWriter.write(ReduceTask.java:566)
    at org.apache.hadoop.mapreduce.task.TaskInputOutputContextImpl.write(TaskInputOutputContextImpl.java:89)
    at org.apache.hadoop.mapreduce.lib.reduce.WrappedReducer$Context.write(WrappedReducer.java:105)
    at org.apache.hadoop.mapreduce.Reducer.reduce(Reducer.java:150)
    at org.apache.hadoop.mapreduce.Reducer.run(Reducer.java:171)
    at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:635)
    at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:390)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:422)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1698)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

Settings snippet :
  "settings": {
    "number_of_shards": 5,
    "number_of_replicas": 1,
    "index.query.default_field":"test",
    "index.refresh_interval" : "5s",
    "index.mapper.dynamic": false ,
    "analysis": {
         "filter": {
            "ngram_filter": {
               "type": "ngram",
               "min_gram": 2,
               "max_gram": 18,
               "token_chars": [
                  "letter",
                  "digit"
               ]
            }
         },
         "analyzer": {
            "ngram_analyzer": {
               "type": "custom",
               "tokenizer": "standard",
               "filter": [
                  "lowercase",
                  "ngram_filter"
               ]
            }
         }
      }
  }

I am seeing that dynamic mapping is disabled in settings on ES endpoint but the job fails. I have a avro json mapping file and es json mapping file where avro json mapping file is the superset while es json mapping file is subset. I do not want all the fields in the superset mapping file to be reflected on ES index instead only dump fields which are in subset mapping file. Am I doing it wrong or is there any other way of doing it.
Thanks.

A: That's because you have set  "index.mapper.dynamic": false which means new types will not be created automatically without first declaring them.
What you would want to do is set "dynamic": "false" in the mapping of your type.

    PUT /test_index
    {
      "mappings": {
        "test_type": {
          "dynamic": "false"
        }
      }
    }

For more Info:
https://www.elastic.co/guide/en/elasticsearch/guide/1.x/dynamic-mapping.html
Example:

*

*Run Mapping

PUT /my_index
{
  "mappings": {
    "testing": {
      "dynamic": "false",
      "properties": {
        "field1": {
          "type": "string",
          "index": "analyzed"
        }
      }
    }
  }
}

*Index the document in testing type

POST /my_index/testing/1
{
  "field1":"demo",
  "field99":"anotherDemo"
}

*Response of GET /my_index/testing/_mapping

{
  "my_index": {
    "mappings": {
      "testing": {
        "dynamic": "false",
        "properties": {
          "field1": {
            "type": "string"
          }
        }
      }
    }
  }
}

As you will see that there is no mapping for the field99.


text:
Q: Is there an equivalent of f'{}' in c# I'm coming from a Python background and am dealing with code that creates many variables with the same name + an integer attached to the end, and need to replicate Python's f'something here {variable}' method in C#. How can I do this?
i.e.
int num1 = 1;
int num2 = 2;
int num3 = 3;
int num4 = 4;

etc...
is there a way to do something like
for (int i=1;i<5;i++)
{
    int f'num{i}' = i;
}

A: In an ideal world, you never number variables and just use an array (or some other collection). So you would have:
for (int i=0;i<5;i++)
{
    num[i] = i;
}

Which requires your list of variables to be instead one variable that is indexable (like an array)
int[] num = new int[5];

The only way to access a variable in C# from a string is with reflection (which is a fairly advanced concept, easy to get wrong, and not very efficient). That being said, you'd do something like:
Type thisClass = this.GetType(); //Even better, typeof(WhateverClassThisIs);
for (int i=1;i<5;i++)
{
    FieldInfo field = thisClass.GetField($"num{i}");
    field.SetValue(this, i);
}

Note that this only works if num1 etc. are existing class members (it does not create them) and not local to the function. If you have local variables, you are basically out of luck.


text:
Q: Rock, paper, lizard, spock. User has to input 100 games and it program should give the outcome of how many of each were choosen I got this code from youtube, but I don't know how to ask the user to input 100 games and show the outcome of how many of each were used.
import java.util.Scanner;

public class RockPaperSissors {

public static void main(String[] args) {
    Scanner console = new Scanner (System.in);

    String choice = console.nextLine();

    if (isValid(choice)){
        int aIChoice = (int)(Math.random()*3);
        int personChoice = getVal(choice);
        System.out.println("You picked " + choice);
        System.out.println("The computer picked " + getAIChoice(aIChoice));
        System.out.println("You " + didPersonWin(personChoice, aIChoice));
    }
    else {
        System.out.println("That is not a valid input!");
    }
}
public static String getAIChoice(int x){
    if (x == 0){
        return "Rock";
    }
    if (x ==1){
        return "Paper";
    }
    if (x == 2){
        return "Scissors";
    }
    return null;
}
public static String didPersonWin(int pChoice, int computerChoice){
    if (pChoice == 0){
        if (computerChoice != 1){
            if (computerChoice != 0){
                return "WIN" ;
            }
            return "Tie";
        }
        return "Lose";
    }
    if (pChoice == 1){
        if (computerChoice != 2){
            if (computerChoice != 1){
                return "WIN";
            }
            return "Tie";
        }
        return "Lose";
    }
    if (computerChoice != 0){
        if (computerChoice != 2){
            return "Win";
        }
        return "Tie";
    }
    return "Lose";
}
public static boolean isValid(String string){
    if (string.equalsIgnoreCase("rock")){
        return true;
    }
     if (string.equalsIgnoreCase("paper")){
        return true;
    }
     if (string.equalsIgnoreCase("scissors")){
         return true;
     }
        return false;
}
public static int getVal(String string){
    if (string.equalsIgnoreCase("rock")){
        return 0;
    }
    if (string.equalsIgnoreCase("paper")){
        return 1;
    }
    else {
        return 2;
    }

}

}

A: use the FOR loop for inputing 100 times?
    for (int i=0; i<100; i++){
          (USER INPUT HERE)
          (INCREMENT SOME VARIABLES TO KEEP TRACK OF SCORES SO FAR)
    }

this will ask user for input and then store the result in some variable for the program to keep track of results, and it will repeat 100 times

A: Use the do - while loop:
int i = -1;
do{
    i++;
    //get input from user
}while(i<100);

Beyond that your question is kind of hard to understand. It sounds like you want to store the users input into an array, then run the main game logic against that array. If that's the case, then the code in your main method will have to change to pull in the input and store it in an array and pass that array to the game logic to loop over and determine the outcome and print out the result.

A: import java.util.Random;

public class Test {
    public static void main(String[] args) {
        Random rand = new Random();
        int x = 0;
        int rock = 0;
        int paper = 0;
        int scissors = 0;

        for (int i = 0; i < 100; i++) {
            x = rand.nextInt(3);
            if (x == 1) {
                rock += 1;
            } else if (x == 2) {
                paper += 1;
            } else {
                scissors += 1;
            }

        }

        System.out.println("Rock = " + rock + "\nPaper = " + paper + "\nScissors = " + scissors);
    }
}

This code will simply run it 100 times of rock paper scissors and output the results of each outcome.


text:
Q: SSRS Report Builder 3.0: Conditional Formatting if value in multiple cells I'm asking this for a colleague who does not have an account. We both know little about Report Builder, so pardon any errors in terminology. He is using  SSRS Report Builder 3.0 on Windows 7.
Report Builder Screenshot
He is trying to add a formula to the HUB Name ID cell which says that if Design Status, Material Status, etc. (all of the fields except HUB Name ID) say 'Complete' then make the Hub Name ID cell green.
He tried...:
=IIf(First(Fields!Design_Status.Value,
"NodeAudit")First(Fields!Material_Status.Value,
"NodeAudit")First(Fields!RF_Balance_Status.Value,
"NodeAudit")First(Fields!FiberAudit_Status.Value,
"NodeAudit")First(Fields!CMTS_Wiring_Status.Value,
"NodeAudit")First(Fields!FieldAudit_Status.Value,
"NodeAudit")=Complete,"Green","Red")

...but it did not work.
I saw another posting using a Switch (I've never heard of it):
Ex:
=Switch(
  Fields!ID__to_Budget.Value < 0.30, "Red",
  Fields!ID__to_Budget.Value < 0.35, "Yellow",
  Fields!ID__to_Budget.Value >= 0.35, "Green"
)

Would something like this be helpful? The internet says that Switch "Specifies the value or expression that the item should be replaced with, if the condition is True." but I saw it in this forum's posting Similar Stackoverflow Posting where someone used Switch the above to make a background a certain color.
Question#1 If so, would you put this in the Hub Name ID cell?:
=Switch(
  Fields!ID__to_Design_Status.Value = "Complete", "Green",
  Fields!ID__to_Material_Status.Value = "Complete", "Green",
  Etc.....Etc...
)

Question# 2 Do you put it in the cell like you would Excel or as the other posting says, 'put in the background color properties of the cell the expression'?
Thank you in advance!

A: My colleague figured it out and he rewrote the formula below (he took out First and "NodeAudit" and added AND statements)
=IIf(Fields!Design_Status.Value AND Fields!Material_Status.Value AND
Fields!RF_Balance_Status.Value AND Fields!FiberAudit_Status.Value AND
Fields!CMTS_Wiring_Status.Value AND Fields!FieldAudit_Status.Value =
"complete", "Green", "No color")


text:
Q: ¿Como realizar un formulario con archivo adjunto multiple php? tengo una pequeña falla en mi sistema de formulario, quiero enviar varios archivo al correo, pero solo envia 1 archivo, mi formulario, me pueden ayudar a como ponerle adjunto multiple sin falla, se los agradecería.
    <?php

class Email {

    //nombre
    var $nombre;
    //email del emisor
    var $mail;
    //email del receptor
    var $mailr;
    var $asunto;
    //archivo adjunto
    var $adjunto;
        //archivo adjunto
        var $adjunt;
        //mensaje
        var $msn;
        //mensaje
        var $msn1;
        //mensaje
        var $msn2;
        //mensaje
        var $msn3;
        //mensaje
        var $msn4;
        //mensaje
        var $msn5;
        //mensaje
        var $msn6;
        //mensaje
        var $msn7;
        //mensaje
        var $msn8;
        //mensaje
        var $msn9;
        //mensaje
        var $msn10;
    //enviar el mensaje
    private $sender;}
    //url para redireccionar
    private $url;

    //función constructora
    public function __construct(){
        //cada uno de ellos es el parámetro que enviamos desde el formulario
        $this->nombre = $n;
        $this->mail = $m;
        $this->mailr = $mr;
        $this->asunto = $a;
        $this->msn = $msn;
        $this->msn = $msn1;
        $this->msn = $msn2;
        $this->msn = $msn3;
        $this->msn = $msn4;
        $this->msn = $msn5;
        $this->msn = $msn6;
        $this->msn = $msn7;
        $this->msn = $msn8;
        $this->msn = $msn9;
        $this->msn = $msn10;
        $this->adjunto = $ad;
        $this->adjunt = $adt;
    }

    //método enviar con los parámetros del formulario
    public function enviar($n,$m,$mr,$a,$ms,$msn1,$msn2,$msn3,$msn4,$msn5,$msn6,$msn7,$msn8,$msn9,$msn10,$ad,$adt){
        //si existe post
        if(isset($_POST)){

    //si existe adjunto
    if($ad) {
        //añadimos texto al nombre original del archivo
        $dir_subida = 'fichero_';
        //nombre del fichero creado -> fichero_nombreArchivo.pdf
        $fichero_ok = $dir_subida . basename($ad);
        //y lo subimos a la misma carpeta
        move_uploaded_file($_FILES['adjunto']['tmp_name'], $fichero_ok);
    }

            //creamos el mensaje
            $contenido = '

Appointments Ticket: '.$n.'

                Email: '.$m.'

                Problem:
'.$msn.'

                Solution: '.$msn1.'

                CPE model:
'.$msn2.'

                Antenna model:'.$msn3.'

                Tower options:
'.$msn4.'

                CPE gain set (Cambium and Mimosa radios only): '.$msn5.'

                CPE frequency all check (Cambium radios only): '.$msn6.'

                CPE surge suppressor: '.$msn7.'

                CPE bonded: '.$msn8.'

                CPE service loop / Drip loop: '.$msn9.'

                Vistabeam recommended firmware / radio - router: '.$msn10.'

            ';
            //archivo necesario para enviar los archivos adjuntos
            require_once 'AttachMailer.php';

            //enviamos el mensaje           (emisor,receptor,asunto,mensaje)
            $this->sender = new AttachMailer($m, $mr, $a, $contenido);
            $this->sender->attachFile($fichero_ok);

            //eliminamos el fichero de la carpeta con unlink()
            //si queremos que se guarde en nuestra carpeta, lo comentamos o borramos
            unlink($fichero_ok);
            //enviamos el email con el archivo adjunto
            $this->sender->send();
                        //enviamos el email con el archivo adjunto
                        $this->sender1->send();
            //url para redireccionar
            $this->url = 'http://getdiscoverit.com/demo/';
            //redireccionamos a la misma url conforme se ha enviado correctamente con la variable si
            header('Location:'.$this->url.'?s=si');
        }
        else{
            //redireccionamos a la misma url conforme NO se ha enviado correctamente con la variable no
            header('Location:'.$this->url.'?s=no');
        }
    }
}

//llamamos a la clase
$obj = new Email();
//ejecutamos el método enviar con los parámetros que recibimos del formulario
$obj->enviar($_POST['nombre'], $_POST['email'], $_POST['emailr'], $_POST['asunto'], $_POST['msn'], $_POST['msn1'], $_POST['msn2'], $_POST['msn3'], $_POST['msn4'], $_POST['msn5'], $_POST['msn6'], $_POST['msn7'], $_POST['msn8'], $_POST['msn9'], $_POST['msn10'], $_FILES['adjunto']['name'], $_FILES['adjunt']['name1']);

?>

html

                        Archivo adjunto

                        <input type="file" id="adjunto" name="adjunto">

....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................


text:
Q: multiple variation of a domain to one domain I was trying to write code for permanent redirect of multiple variations
For eg.
http://www.example.com
http://example.com

http://www.example.com/index.php

http://example.com/index.php

to https://example.comonly.
I have few lines of code
 RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example\.com$
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com/index.php$
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

Its working fine for me but Can these all lines of code be written in single or two lines??

A: I think you should only have RewriteCond %{HTTP_HOST} .*example.com$, without any ^.
This should cover both your first and second HTTP_HOST lines.
The HTTP_HOST third line that you have, with /index.php in it is a bad one, as /index.php is never part of the HTTP_HOST.
Also don't keep repeating RewriteEngine On and no need to set a condition on port 80. (If you have HTTPS on port 443, you still want this redirect, right?)
So in the end:
RewriteEngine On
RewriteCond %{HTTP_HOST} .*example\.com$
RewriteRule ^(.*)$ https://example.com/$1 [R,L]


text:
Q: Difficult sequence puzzle What is the 25$^{th}$ term of this infinite sequence?
$$1,1,1,1,1,691,2,3617,...$$
I have tried for an hour now and I can't find any meaningful relation between the terms.

A: This is the sequence of numerators of taylor series expansion of $\log(x/\sin(x))$ as can be seen in the online encyclopedia of integer sequences: OEIS.org
The next term is $43867$.


text:
Q: Is the saving time of record proportional to the number of item lines in NetSuite? I have a SO with 500 item lines.
Once I click the "Save" button, the following code will execute and it may spend about 90 to 120 seconds to finish saving:
var so_submit_id = so_record.save({
                    // enableSourcing: true,
                    // ignoreMandatoryFields: false
});

I found the more item lines, the longer time the record is saved.
Is the saving time is proportional to the number of item lines? Is there a linear relationship which the time complexity is O(n) between them?
How can we reduce the record saving time? Can we divide the record to update the values and finally merge the child records?

A: Under Customisation>Scripting>Scripted Records, how many scripts are running for your record type?
Based on that, you can get results for your "Performance Details" by double clicking on the Oracle | NetSuite logo on the top left of the UI. This will prompt a dialogue box depicting what, and how long things took. A few tests on the number of lines and you can plot a curve for your system.
Hope this added value for the testing!


text:
Q: Как ускорить поиск: vue3 + vuex Помогите разобраться, как ускорить вывод данных на странице (vue3, vuex4)
Есть массив товаров +10k
В каждом 40 полей
На странице выводятся только 5 полей (id, name, date, price, status)
Нужен быстрый поиск (@input) по списку (по всем 5 полям)
Для этого я загружаю все товары во vuex (+localStorage)
Но загрузка (+ отрисовка) всех +10k товаров занимает 10 секунд = долго
Как правильно решается эта задача?
Спасибо!


text:
Q: Mathematica & J/Link: Memory Constraints? I am doing a computing-intensive benchmark using Mathematica and its J/Link Java interface.
The benchmark grinds to a halt if a memory footprint of about 320 MB is reached, since this seems to be the limit and the garbage collector needs more and more time and will eventually fail.
The Mathematica function ReinstallJava takes the argument command line. I tried to do
ReinstallJava[CommandLine -> "java -Xmx2000m ..."]

but Mathematica seems to ignore the -Xmx option completely.
How can I set the -Xmx memory option for my java program? Where does the limit of 320 MB come from? Any help would be greatly appreciated.

A: ReinstallJava takes a JVMArguments option. You can use it to pass heap size like so:
In[1]:= Needs["JLink`"]

In[2]:= Options[ReinstallJava]

Out[2]= {ClassPath -> Automatic, CommandLine -> Automatic,
 JVMArguments -> None, ForceLaunch -> False, Default -> Automatic,
 CreateExtraLinks -> Automatic, "Asynchronous" -> Automatic}

In[3]:= ?JVMArguments

JVMArguments is an option to InstallJava that
allows you to specify additional command-line
arguments passed to the Java virtual machine at
startup. The string you specify is added to the
command line used to launch Java. You can use this
option to specify properties with the standard -D
syntax, such as "-Dsome.property=true". This
option is not supported on Mac OSX. >>

In[4]:= LoadJavaClass["java.lang.Runtime"];

In[5]:= java`lang`Runtime`getRuntime[]@maxMemory[]

Out[5]= 238616576

In[6]:= ReinstallJava[JVMArguments -> "-Xmx64g"];

In[7]:= LoadJavaClass["java.lang.Runtime"];

In[8]:= java`lang`Runtime`getRuntime[]@maxMemory[]

Out[8]= 61084008448

(I once figured this out in desperation by reading through the code in C:\Program Files\Wolfram Research\Mathematica\7.0\SystemFiles\Links\JLink\Kernel. After noticing it was listed in Options[ReinstallJava] it seemed kind of obvious…)

A: For Mac OS X users, replace
ReinstallJava[JVMArguments -> "-Xmx64g"];

by
ReinstallJava[CommandLine -> "java", JVMArguments -> "-Xmx64g"];


text:
Q: using python to count unique values and scale by frequency I've got myself a dataset that looks like this:
[
    {'A':'0'},
    {'B':'0'},
    {'C':'1'}
]

I'd like to transmogrify it into a dataset that looks like this:
[
    {'0':'2'},
    {'1':'1'}
]

Essentially the task is counting the values,
and for each unique value
creating a new entry in a data-structure
for each one of those unique entries (once again, based on the values)
to increment the corresponding entry,
Basically the task is tallying up all of the times we've seen unique values and magnifying that by the number of times the value has been expressed.
What's the most efficient, effective way to do that in python?
I've been experimenting with counter but thus far without much success, as my base data structure seems to be incompatible, the codebase looks like this:
dict_hash_gas = list()
for line in inpt:
    resource = json.loads(line)
    dict_hash_gas.append({resource['first']:resource['second']})

and the dataset like this:
{"first":"A","second":"0","third":"2"}
{"first":"B","second":"0","third":"2"}
{"first":"C","second":"1","third":"2"}

A: result = dict()

for name, value in input.items():
    result.update({value: result.get(value, 0) + 1})

A: You can use a Counter quite easily:
>>> data = [
...     {'A':'0'},
...     {'B':'0'},
...     {'C':'1'}
... ]
>>> import collections
>>> counts = collections.Counter(v for d in data for v in d.values())
>>> counts
Counter({'0': 2, '1': 1})

Now, to get the final list you want, simply:
>>> [{k:v} for k,v in counts.items()]
[{'0': 2}, {'1': 1}]

Although, I don't know why you would want such a list, I can only presume some REST-based API is expecting some JSON in that format...


text:
Q: Kendo UI & Codeigniter - DataSource - Read - Uncaught SyntaxError: Unexpected token I'm new in Kendo UI & Codeigniter. I have trouble with Kendo UI when i trying to read data from codeigniter controller.
I can see json data, which is return from controller, but it not display at Kendo UI grid. Below is some screen shoot when i'm debug.
Here is screen shot error
http://prntscr.com/5bmn3n
Here is screen shot data i recived
http://prntscr.com/5bmne5
Here is screen shot Kendo UI code:
prntscr.com/5bmnib
And here is screen shot my controller code:
prntscr.com/5bmnni
Hope you can help

A: Please, try to add
transport: {
   read: {
   ...
   dataType: "json"
   ...
         }
  },
Also, please have in mind that "jsonp" is required for cross-domain requests!


text:
Q: NodeJS Express running on AWS Lambda returns error: 'listen EADDRINUSE: address already in use' I've set up AWS lambda with some NodeJS code to learn creating an API. API is set up using Express. The runtime is v18. I also set up API Gateway HTTP API with the lambda integration to invoke it.
When I try to call GET method on the /collage route I get internal server error and the Lambda logs return the following:
ERROR   Uncaught Exception
{
    "errorType": "Error",
    "errorMessage": "listen EADDRINUSE: address already in use /tmp/server-undefined.sock",
    "code": "EADDRINUSE",
    "errno": -98,
    "syscall": "listen",
    "address": "/tmp/server-undefined.sock",
    "port": -1,
    "stack": [
        "Error: listen EADDRINUSE: address already in use /tmp/server-undefined.sock",
        "    at Server.setupListenHandle [as _listen2] (node:net:1468:21)",
        "    at listenInCluster (node:net:1533:12)",
        "    at Server.listen (node:net:1632:5)",
        "    at Function.listen (/var/task/node_modules/express/lib/application.js:635:24)",
        "    at startServer (/var/task/node_modules/@vendia/serverless-express/src/index.js:138:17)",
        "    at proxy (/var/task/node_modules/@vendia/serverless-express/src/index.js:191:14)",
        "    at Server.<anonymous> (/var/task/node_modules/@vendia/serverless-express/src/index.js:192:32)",
        "    at Server.emit (node:events:513:28)",
        "    at emitListeningNT (node:net:1519:10)",
        "    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)"
    ]
}

Here is my code:
const express = require('express');
const { proxy } = require('aws-serverless-express');
const app = express();

app.get('/collage', (req, res) => {
  const response = {
    statusCode: 200,
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ message: 'Hello, World!' })
  };
  return response;
});

exports.handler = (event, context) => {
  return proxy(app, event, context);
};

The code is as basic as it gets and I put it ogether using some example tutorials and GPT3. Not really sure what could be the issue or how to debug it. There should be no port conflicts since it runs in Lambda..
I did accidentaly include app.listen(3000, () =>{}); before when I deployed the initial version. But it has since been fixed and lambda re-deployed. To make sure I even created a new lambda and deployed latest version to it and got same error.
I tried searching this error on the web, but everyone recommends killing the process, but this is running in lambda so not really possible.
What can I do to debug this?

A: You are using a deprecated package aws-serverless-express.
You should use serverless-express

On 11/30, the AWS Serverless Express library is moving to Vendia and will be rebranded to serverless-express. Similarly, the aws-serverless-express NPM package will be deprecated in favor of a new serverless-express package.


text:
Q: Array Job on LSF: Setting Seed? I'm running a standard statistical simulation to split e.g. 10000 iterations (each with different random seed) among say 100 array nodes.
I've done this many times in the past and always received the desired results, however, this time all 100 nodes produced exactly the same results, as if they all had the same random seed. Is there something subtle in LSF that can set everything to the same seed?
I'm running R jobs and I'm not setting seeds in R. I realize one solution is to set the seed in R from the job index in the array, but I'm just trying to figure out what happened. BTW I know that the scheduler did not start all of the jobs simultaneously.
Here's a minimal example: (all 10 output files are identical)
array.test.sim.job
#BSUB-J test[1-10]
#BSUB-o Rout/sim%I.out
#BSUB-W 12:00
#BSUB-q short

module load stats/R/3.2.1

R CMD BATCH --no-save arraytest.R Rout/sim${LSB_JOBID}${LSB_JOBINDEX}.Rout

arraytest.R
write.csv(rnorm(100), file = paste('rnorms', Sys.Date(), ',', format(Sys.time(), "%H.%M.%S"), '.txt', sep = ''))

A: In my case this was caused by a stray .Rdata file that had appeared in the working directory. Deleting this file, or using the flag --no-restore solved the problem.


text:
Q: Adjust the start of a polar barplot in ggplot2 I think this is a quite common problem but I can't figure out how to adjust my polar barplot so that the bars are centered at zero and the rest of my manually drawn axes are also drawn properly.
I made this function to plot the way I want.
polar_chart_theme <- function(data, start = 0){

  #max_rate <- data %>% pull(rate) %>% max
  ggplot(data=data)+
  coord_polar(start = start)+
  theme(panel.background = element_rect(fill="white"),
        axis.text.y = element_blank(),
         axis.ticks.y = element_blank(),
        panel.grid = element_blank())+
  annotate("rect", xmin=12, xmax=24, ymin=-Inf, ymax=Inf, fill="gray70")+
  # annotate+
  geom_hline(yintercept = seq(0, 30, by = 10), colour = "grey50", size = 0.2) +
  geom_vline(xintercept = seq(0, 23, by = 6), colour = "grey50", size = 0.2) +
  scale_x_continuous(breaks=seq(0, 23, 6), expand = c(0, 0))+
  # add the y labels
  geom_text(
    data = data.frame(x=2, y=seq(10, 30, 10)),
    aes(
    x = x,
    y = y,
    label = as.character(y)))

}

It basically creates the scaffolding where things will go later.
polar_chart_theme(toy)

If I plot this with a line, I get the desired output
toy %>%
  polar_chart_theme(.) +
  facet_wrap(~date)+
  stat_summary(geom = "polygon",
               fun = mean,
               aes(x=hour_of_day, y=rate,
                   group=Treatment, color=Treatment, fill=Treatment), alpha=0.5) +
  labs(title = "Chronogram",
       y="",
       x="") +
  scale_color_manual(values=c("orange", "black"))+
  scale_fill_manual(values=c("orange", "black"))

If I try to get a barplot, because the bars have some width, things get weird:
toy %>%
polar_chart_theme(.) +
  facet_wrap(~date)+
stat_summary(geom = "bar",
             position = "stack",
             fun = mean,
             aes(x=hour_of_day, y=rate,
                 group=Treatment, color=Treatment, fill=Treatment), alpha=0.5) +
  labs(title = "Chronogram",
       y="",
       x="") +
  scale_color_manual(values=c("orange", "black"))+
  scale_fill_manual(values=c("orange", "black"))

How can I guesstimate/adjust for the plot to be plotted properly? Maybe using the start argument on the polar_chart_theme?. My final output will probably have two facets but using position="stack" was convenient to avoid scale problems due to position="dodge".
To make it more clear:

*

*0 and 24 are no longer at the same spot in the plot

*Neither 0 or 24 are aligned to 12

*6 and 18 are no longer aligned

Looks like the bars are positioned on the center of the tick mark, but, because each bar has a width there is some adjustment/alignment issue.

Data sample
structure(list(Treatment = c("B", "B", "B", "B", "B", "B", "B",
"B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "A", "A",
"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",
"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",
"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",
"A", "A", "A", "A", "A", "A", "A"), ID = c(1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), rate = c(9, 13, 8, 6, 6,
11, 3, 12, 0, 9, 2, 0, 0, 4, 0, 0, 5, 1, 0, 0, 7, 8, 12, 17,
14, 22, 27, 12, 19, 13, 7, 0, 8, 0, 0, 2, 0, 0, 0, 0, 0, 1, 0,
0, 0, 24, 19, 35, 3, 4, 0, 0, 0, 18, 2, 14, 2, 12, 3, 0, 0, 0,
2, 2, 0, 0, 0, 0, 6, 2, 11, 14, 23, 12, 13, 11, 16, 9, 11, 5,
12, 5, 3, 0, 0, 0, 0, 3, 4, 0, 4, 7, 0, 7, 15, 17, 3, 20, 14,
14, 17, 16, 17, 7, 6, 15, 8, 7, 4, 9, 6, 6, 0, 8, 0, 0, 5, 2,
11, 14, 23, 16, 5, 13, 15, 8, 13, 12, 1, 3, 7, 0, 0, 2, 0, 3,
6, 0, 5, 4, 6, 8, 17, 21), date = structure(c(18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606, 18606,
18606, 18606, 18606, 18606, 18606, 18606), class = "Date"), zt = structure(c(1607529600,
1607533200, 1607536800, 1607540400, 1607544000, 1607547600, 1607551200,
1607554800, 1607558400, 1607562000, 1607565600, 1607569200, 1607572800,
1607576400, 1607580000, 1607583600, 1607587200, 1607590800, 1607594400,
1607598000, 1607601600, 1607605200, 1607608800, 1607612400, 1607529600,
1607533200, 1607536800, 1607540400, 1607544000, 1607547600, 1607551200,
1607554800, 1607558400, 1607562000, 1607565600, 1607569200, 1607572800,
1607576400, 1607580000, 1607583600, 1607587200, 1607590800, 1607594400,
1607598000, 1607601600, 1607605200, 1607608800, 1607612400, 1607529600,
1607533200, 1607536800, 1607540400, 1607544000, 1607547600, 1607551200,
1607554800, 1607558400, 1607562000, 1607565600, 1607569200, 1607572800,
1607576400, 1607580000, 1607583600, 1607587200, 1607590800, 1607594400,
1607598000, 1607601600, 1607605200, 1607608800, 1607612400, 1607529600,
1607533200, 1607536800, 1607540400, 1607544000, 1607547600, 1607551200,
1607554800, 1607558400, 1607562000, 1607565600, 1607569200, 1607572800,
1607576400, 1607580000, 1607583600, 1607587200, 1607590800, 1607594400,
1607598000, 1607601600, 1607605200, 1607608800, 1607612400, 1607529600,
1607533200, 1607536800, 1607540400, 1607544000, 1607547600, 1607551200,
1607554800, 1607558400, 1607562000, 1607565600, 1607569200, 1607572800,
1607576400, 1607580000, 1607583600, 1607587200, 1607590800, 1607594400,
1607598000, 1607601600, 1607605200, 1607608800, 1607612400, 1607529600,
1607533200, 1607536800, 1607540400, 1607544000, 1607547600, 1607551200,
1607554800, 1607558400, 1607562000, 1607565600, 1607569200, 1607572800,
1607576400, 1607580000, 1607583600, 1607587200, 1607590800, 1607594400,
1607598000, 1607601600, 1607605200, 1607608800, 1607612400), tzone = "UTC", class = c("POSIXct",
"POSIXt")), hour_of_day = c(16, 17, 18, 19, 20, 21, 22, 23, 0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2,
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)), row.names = c(NA,
-144L), groups = structure(list(Treatment = c("A", "B"), ID = c(1,
1), .rows = structure(list(97:144, 1:96), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, -2L), class = c("tbl_df",
"tbl", "data.frame"), .drop = TRUE), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))

A: I often find it easier to debug polar problems in non-polar coords. Overriding the coord_polar with a coord_cartesian, we can see an offset introduced by the bars because the bars are centered:
toy %>% polar_chart_theme(.) +
  ## ...
  coord_cartesian()

We can address this by offsetting the data by half of a bar width (see the + 0.5 on the x coordinate)
toy %>%
  polar_chart_theme(.) +
  facet_wrap( ~ date) +
  stat_summary(
    geom = "bar",
    position = "stack",
    fun = mean,
    aes(
      x = hour_of_day + 0.5,
      y = rate,
      group = Treatment,
      color = Treatment,
      fill = Treatment
    ),
    alpha = 0.5
  ) +
  labs(title = "Chronogram",
       y = "",
       x = "") +
  scale_color_manual(values = c("orange", "black")) +
  scale_fill_manual(values = c("orange", "black")) +
  coord_cartesian()

Now that the bars are aligned with 0, we can go back to polar coordinates:
toy %>%
  polar_chart_theme(.) +
  facet_wrap( ~ date) +
  stat_summary(
    geom = "bar",
    position = "stack",
    fun = mean,
    aes(
      x = hour_of_day + 0.5,
      y = rate,
      group = Treatment,
      color = Treatment,
      fill = Treatment
    ),
    alpha = 0.5
  ) +
  labs(title = "Chronogram",
       y = "",
       x = "") +
  scale_color_manual(values = c("orange", "black")) +
  scale_fill_manual(values = c("orange", "black"))


text:
Q: How to compare the performance of ARIMA and LSTM for time series forecasting? I am facing some challenges in comparing LSTM and ARIMA for soma datasets.
I would like to know if there are some general expectations regarding the differences between ARIMA and LSTM regarding how they deal with outliers. In general, LSTM deal better with outliers tham ARIMA? Or is not possible to say that for the general case?
Besides that, I read some papers that state that differences in MAE and RMSE, in general, are due to outliers in forecasting. Is it possible to measure in some way the degree of such impact of outliers, by considering the MAE and the RMSE?
What can I conclude if model A is better than model B regarding MAE, but model B is better than model B regarding RMSE?

A:
What can I conclude if model A is better than model B regarding MAE, but model B is better than model B regarding RMSE?

It does not make sense to compare the same predictions from different models using different accuracy metrics, because different metrics elicit different functionals from the (frequently only implicit) predictive distribution:

*

*If you want to minimize the RMSE, you extract the predictive expectation.

*If you want to minimize the MAE, you extract the predictive median.
Now, if you assume a symmetric future density, like a normal, then of course the two functionals will coincide. But then, the two error measures should carry the same information. So if they tell you different stories, that is a strong indication that your density is not symmetric. So you are back to first deciding which functional you want and only then deciding on the appropriate error measure.
More information can be found in Kolassa (2020, International Journal of Forecasting). You may also be interested in What are the shortcomings of the Mean Absolute Percentage Error (MAPE)?

A: I'm not aware of any general framework for comparing the sensitivity to outliers as this usually depends on under/overfitting. I would say that ARIMA will typically not perform well at forecasting values outside of the previously observed range. See a blog post here for some comments on that topic.
The other part of your question relates to metrics that will capture sensitivity to outliers. Some comparable metrics which differ by sensitivity to outliers:

*

*Pearson vs Spearman correlation: Spearman only worries about getting the ordering of predictions correct (i.e. the biggest target value results in the biggest prediction) but doesn't consider the actual values. As such Pearson will be more affected by incorrectly predicted outliers.

*Mean vs Median Absolute Errors: Clearly the Mean absolute error will be impacted by an outlier as it contributes more to the mean than the other points. However a single outlier won't significantly affect the median error.


text:
Q: Why doesn't "correct" change to False in this if-else ladder of conditions for date-checking? I have correct = bool() declared outside any function or loop in the beginning of the script. I define a function and have the following conditions. Here is my code.
correct = bool()

...
def part1():
    global date, now, m, d, query

    #getting the date
    raw = input("Date: (MM/DD) ")
    #splitting the date by /
    m, d = raw.split("/")
    #checking for invalid date

    if int(m) > 12 or int(m) < 1:
        print("Something's wrong with your date.1")
        correct = False
    #February 29
    if int(m) == 2 and int(d) > 29:
        print("Something's wrong with your date.2")
        correct = False
    if int(m) in thirties and int(d) > 30:
        print("Something's wrong with your date.3")
        correct = False
    if int(m) in thirty_ones and int(d) > 31:
        print("Something's wrong with your date.4")
        correct = False
    if int(d) < 1:
        print("Something's wrong with your date.5")
        correct = False
    else:
        correct = True

    print(correct)
    #creating string of date from numbers
    if correct == True:
        date = months[m] + " " + d
        print("Date = ", date)
        #creating query
        query = months[m] + " " + d
        print("Query: " + query)

If I input 01/35 (January 35, obviously an invalid date), it goes through the conditions and prints "Something's wrong with your date.4", telling me it's faulty by the condition if int(m) in thirty_ones and int(d) > 31: (thirty_ones is a list of numbers representing months which have 31 days declared along with correct = bool()). Since it printed that statement, then it would've made correct = False. However, the query is generated, even if correct = False. Why is that?
(apologies for the indentation problems in the code)

A: You need to use elif.
if int(m) > 12 or int(m) < 1:
    print("Something's wrong with your date.1")
    correct = False
    #February 29
elif int(m) == 2 and int(d) > 29:
    print("Something's wrong with your date.2")
    correct = False
elif int(m) in thirties and int(d) > 30:
    print("Something's wrong with your date.3")
    correct = False
elif int(m) in thirty_ones and int(d) > 31:
    print("Something's wrong with your date.4")
    correct = False
elif int(d) < 1:
    print("Something's wrong with your date.5")
    correct = False
else:
    correct = True

A: It is because of the following condition.

if int(d) < 1:
    print("Something's wrong with your date.5")
    correct = False
else:
    correct = True

This code is getting executed after "if int(m) in thirty_ones and int(d) > 31" condition and it goes to else and set it to True.

A: You apparently didn't declare global correct, so the toplevel assignment correct = bool() gets masked by the assignment inside the function. Anyway, don't use globals, it's terrible practice.
Also, your code is quite convoluted, you can make the if-elif ladder shorter and clearer with the following.

*

*Python allows triple conditions with <, <=, so instead of int(m) > 12 or int(m) < 1, do not 1 <= m <= 12. Python gets that right and doesn't even need parens around the not ...

*all your your if...elif ladder's early-terminations give False, so just set that at the top, and override it if you get to the successful clause. Or else move check_date(m, d) into a separate predicate helper function, and call it.

Code like this:
m, d = [int(_) for _ in raw.split("/")]

# checking for invalid date
if not 1 <= m <= 12:
    return False
elif m == 2 and d > 29:
    print("Something's wrong with your date.2")
    return False
elif m > 30 and d > 30:
    print("Something's wrong with your date.3")
    return = False
elif m = 31 and d > 31:
    print("Something's wrong with your date.4")
    return False
else:
    return True

Notes:

*

*Python allows triple conditions with <, <=, >, >=, ==

*you only ever use the int() values of m and d, so convert them at the top, already. Doing that in a list comprehension saves an extra line.


text:
Q: omnipay package guzzle/common is abandon When I installed omnipay through composer I got the following errors. Are there any plans to use the latest version of Guzzle?
Package guzzle/common is abandoned, you should avoid using it. Use guzzle/guzzle instead.
Package guzzle/stream is abandoned, you should avoid using it. Use guzzle/guzzle instead.
Package guzzle/parser is abandoned, you should avoid using it. Use guzzle/guzzle instead.
Package guzzle/http is abandoned, you should avoid using it. Use guzzle/guzzle instead.
Package guzzle/plugin-mock is abandoned, you should avoid using it. Use guzzle/guzzle instead.

A: Yes, Omnipay V3 will use Guzzle 5.0, rather than Guzzle 3. It was discussed here: https://github.com/thephpleague/omnipay/issues/235


text:
Q: How to improve rendering performance with multiple equal and heavy movieclips? I have 25 kind of heavy movieclips on the screen. They show many bitmaps, each one of in one of their frames. The problem is that the application gets unusable when they are on screen. And even after removing them the app keeps slow.
Using Adobe Air 2.0, compiled by Flash CS5.

A: There literally thousands of optimization tricks for Flash, but one that usually helps when dealing with large (or complex) Sprites or MovieClips is the cacheAsBitmap property:
my_mc.cacheAsBitmap = true;

And since you are using Adobe Air, you can also have access to the cacheAsBitmapMatrix property, for further optimization (badly needed on mobile devices!):
my_mc.cacheAsBitmapMatrix= my_mc.transform.concatenatedMatrix;
my_mc.cacheAsBitmap = true; //also this!

Check out this Republic of Code tutorial about when/why better use them.
Hope this helps!


text:
Q: Quantum cohomology rings as invariants Let $X$ and $Y$ manifolds. What kind of relations between them (like homeomorphism, diffeomorphism, homotopy equivalence) gives an isomorphic quantum cohomology rings?

A: If $X$ and $Y$ are Calabi-Yau threefolds which are obtained from each other from a simple flop, then their quantum cohomologies are isomorphic (Li and Ruan proved this). Lee-Lin-Wang prove the analog of this in higher dimensions. One of the things that makes this interesting is that the classical cohomology rings are not (in general) isomorphic, but the quantum cohomology rings are.
More generally, if $X$ and $Y$ are birational and $K$-equivalent  (i.e. there is a resolution of the birational map $X\leftarrow W \to Y$ such that $K_X$ and $K_Y$ are isomorphic when pulled back to $W$), one expects their Gromov-Witten theories to be "equivalent". In some situations, "equivalent" will imply isomorphic quantum cohomologies, but not in general. To formulate the general equivalence properly requires Coates and Givental's Lagrangian cone formalism. Crepant resolutions are a special case of this and so the "crepant resolution conjecture" is part of this set of equivalences. Here are some papers on the subject (please forgive my laziness at only putting arXiv numbers and not journal references):
Li-Ruan  arXiv:math/9803036
Bryan-Graber arXiv:math/0610129
Iritani arXiv:0809.2749
Lee-Lin-Wang math.AG/0608370
Coates-Ruan arXiv:0710.5901

A: I am not an expert in the field, but I guess that there are examples of diffeomorphic symplectic manifolds with non-isomorphic quantum cohomologies (hence homotopy equivalence, homeomorphism, or even diffeomorphism alone is not enough to give an isomorphism on quantum cohomology).
Two simply connected smooth 4-manifolds having the same intersection form are homotopy equivalent by a theorem of Milnor. More than that, they are homeomorphic by a famous theorem of Freedman. However, very often these manifolds are not diffeomorphic. An example of homeomorphic but non-diffeomorphic pair is the Barlow surface and the blow-up of the complex plane in 8 points. Note that both manifolds admit a Kahler structure.
In the book of McDuff - Salamon J-holomorphic curves and quantum cohomology, they describe in Example 7.3.6 a construction due to Ruan of two diffeomorphic non-deformation equivalent 6-manifolds. The manifolds are the two 4-manifolds just described, both multiplied by $\mathbb{CP}^1$ (by a result of Wall, these two homeomorphic 4-manifolds become diffeomorphic after such a stabilization).
Ruan uses quantum cohmology to prove that these two diffeomorphic symplectic 6-manifolds are not deformation-equivalent, so my guess is that he uses that their quantum cohomologies are not isomorphic as a tool.

A: Quantum cohomology, and more generally Gromov Witten invariants, are invariants under deformation.
Given a family $X$ of compact symplectic manifolds over a base $B$, to a path in $B$ one can associate an isomorphism between the quantum cohomology of the fiber $X_0$ over the starting pooint of the path and the qc of the fiber $X_1$ over the end point of the path.
Homotopic paths (homotopic wrt end points) induce the same isomorphism. In particular $\pi_1(B,0)$ acts on the quantum cohomology of $X_0$.


text:
Q: How to get the Lenovo Y50-70 SUBWOOFER to work on Ubuntu 16.04.1 I know theres been quite some posts on this, but Im wondering, whether there still is no solution to this.
I tried making all kinds of changes to /etc/pulse A)default.pa and B)daemon.conf:
A)add "load-module module-combine channels=3 channel_map=front-left,front-right,lfe" at the end
B) ";enable-lfe-remixing = yes" (seems to be no by default for most people / previous versions) to "enable-lfe-remixing = yes"

"; default-sample-channels = 2" to either "; default-sample-channels = 3" and "default-sample-channels = 3"

"; default-channel-map = front-left,front-right" to either "; default-channel-map = front-left,front-right,lfe" and "default-channel-map = front-left,front-right,lfe"

I also followed miyalys instructions on Lenovo Y50 Subwoofer does no work with Ubuntu 14.04.2 LTS and tried all sorts of combinations of the above.
My first question is: How do I revert "sudo hda-verb /dev/snd/hwC1D0 0x17 SET_POWER 0x0" and "sudo hda-verb /dev/snd/hwC1D0 0x1a SET_POWER 0x0" in order to set my audio settings back to default.
Secondly and way more importantly:
Please, someone tell me how to get the Lenovo y50-70 subwoofer to work!

A: Here's a new type of solution I've attempted that works for me: https://github.com/dragosprju/y50-subwoofer-linux-enabler. Also, here's the question I posted with answers on which the solution is based on: https://superuser.com/questions/975219/how-to-disable-power-saving-on-my-lenovo-y50s-subwoofer-audio-pins.
Good luck!


text:
Q: Adjusting the width of column of table The following code of mine has a table with two columns. The total width of the table is 800px. I would like to have an equal number of width for both my columns. Therefore I set 400px for each. But it didn't work. I think I need to amend my codes to get it. How should this be done?

    <title>OCAAS</title>

I AM NEW TO THIS

A: use css for
 :table{width:100%}td{width:50%}

A: You image div width is a problem (it's wider that a column width you have specified):
#image div{
    width: 500px;

also,
margin-right: 500px;

Fix this values (use % if necessary, relative to td width as all these elements resides within the Table) to make you table td to align properly. Rgds,


text:
Q: Angular I can't get Image from Server Here for example is a link:
http://www.kalliany.at/SPG/getWassersport_withID.php?id=1
if you go onto it you can find this:
{"id":"1","sportart":"Paddeln","disziplin":"Kanu","kurzbez":"Einer-Kajak","bild":"large\/Kanu_01_large.jpg","beschreibung":"Die \u00d6sterreicherin (geborene Deutsche) Yvonne Schuring im \"Flachwasser\"-Kajak"}

This section:
"bild":"large/Kanu_01_large.jpg"
is a picture it is saying and I am trying to display that on my website
These are my model&interface for it
export class WassersportdetailRaw {
    id: string;
    sportart: string;
    disziplin: string;
    kurzbez: string;
    bild: string;
    beschreibung: string;
}

import { WassersportdetailRaw } from "./wassersportdetail.interface";

export class Wassersportdetail implements WassersportdetailRaw{

    constructor(
        public id: string,
        public sportart: string,
        public disziplin: string,
        public kurzbez: string,
        public bild: string,
        public beschreibung: string
      ) {}
}

This is my service to get it:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { WassersportdetailRaw } from './wassersportdetail.interface';
import { Wassersportdetail } from './wassersportdetail.model';

@Injectable({
  providedIn: 'root'
})
export class DataServiceService {
  api2 ='http://www.kalliany.at/SPG/getWassersport_withID.php?id=';

  constructor(private http: HttpClient) { }

 getWassersportDetail(id): Observable<Wassersportdetail> {
  return this.http
    .get<WassersportdetailRaw>(`${this.api2}`+id)
    .pipe(map(raws => this.provideWassersportDetailFrom(raws)));
 }

provideWassersportDetailFrom(raws: WassersportdetailRaw): Wassersportdetail {
  return new Wassersportdetail(
    raws.id,
    raws.sportart,
    raws.disziplin,
    raws.kurzbez,
    raws.bild,
    raws.beschreibung
  );
}
}

This is my html

Wassersportdetail

    <button routerLink="/form0" class="btn btn-primary" id = "oben" >Zurück zur  Startseite!</button>

          ID
          Sportart
          Disziplin
          Kurz Bezeichnung
          Bild
          beschreibung

          {{ sport.id }}
          {{ sport.sportart }}
          {{ sport.disziplin }}
          {{ sport.kurzbez }}
          {{ sport.bild }}
          {{ sport.beschreibung }}

but the  part is not functioning how can I get the image?
ANd it is just for a school project so I did not take everything very seriously dont mind the badly done things ^^

A: The relative path setted in bild field will concat with the active host in the browser.  So but the real images are in backend side I think. Get the absolute path from backend maybe static folders path or generated url from backend. Then concat the string the absolute lath and the bild field


text:
Q: Naudio BadDeviceId calling waveInOpen Error in C# I am trying to record system audio.
Why this code returns exception. error message is BadDeviceId calling waveInOpen...
Is there something wrong in code ? Or should I make something out of code? I enabled microphone device on computer (from recording devices) but there is no microphone plugged in. I just want to record system audio.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NAudio;
using NAudio.Wave;

namespace SeleniumDeneme.Classes
{
    class RecorderForVideo
    {

        public WaveIn waveSource = null;
        public WaveFileWriter waveFile = null;

        public RecorderForVideo() { }

        public void CreateObjectsForRecord()
        {
             waveSource = new WaveIn();
             waveSource.WaveFormat = new WaveFormat(44100, 1);
             waveSource.DataAvailable += new EventHandler<WaveInEventArgs>(waveSource_DataAvailable);
             waveSource.RecordingStopped += new EventHandler<StoppedEventArgs>(waveSource_RecordingStopped);

             waveFile = new WaveFileWriter(@"C:\Users\BerkayS\Desktop\Test0001.wav", waveSource.WaveFormat);

             waveSource.StartRecording();

        }

        void waveSource_DataAvailable(object sender, WaveInEventArgs e)
        {
            if (waveFile != null)
            {
                waveFile.Write(e.Buffer, 0, e.BytesRecorded);
                waveFile.Flush();
            }
        }

        void waveSource_RecordingStopped(object sender, StoppedEventArgs e)
        {
            if (waveSource != null)
            {
                waveSource.Dispose();
                waveSource = null;
            }

            if (waveFile != null)
            {
                waveFile.Dispose();
                waveFile = null;
            }

        }

    }
}

A: solved.
I plugged in a microphone to computer and problem is solved. So the code works completely.


text:
Q: How to center a tauri app on the osx tray icon I am trying to center a Tauri app on the osx tray icon, but cannot find a way to do it.
The idea is to make the app open and close on tray icon click, and to make it fixed at the top of the screen and centered on the icon (the y position may change depending on the number of items available from other apps). Something like this:
https://eshop.macsales.com/blog/wp-content/uploads/2019/05/Fantastical1280.jpg
(Sorry, i tried to add the image to the question, but always got a "Server error" when uploading)
I have searched the docs, but haven't found anything and also didn't find a solution on google

*

*On the tauri.conf.json there is a windows.x and windows.y options, but i don't think i can get this kind of logic there.

*I noticed that there is a window.set_position() function that i could call when the icon is clicked. But i am not sure how to get the correct position to enter the window on the icon


text:
Q: Problem when using SORT_VALUES in a MapReduce job using mrjob (key-values are not sorted in the reducer input) I want to create a MapReduce program whose reduce receives k-v pairs sorted by the value. I'm using mrjob, whose SORT_VALUES parameter seemed to be ideal for the task. After setting this parameter to True, the reducer input is not sorted, for instance, I get the following (considering A should come before X):
"ES"    ["X", 3]
"ES"    ["A", "Spain"]

I'm using Python 2.7.5, mrjob==0.6.1 and Hadoop. The local execution of the program gives me:
"ES"    ["A", "Spain"]
"ES"    ["X", 1]
"ES"    ["X", 2]

Which is correct. But the hadoop execution gives:
"ES"    ["X", 3]
"ES"    ["A", "Spain"]

My code is:

import sys, os, re
from mrjob.job import MRJob
from mrjob.step import MRStep

class MRJoin(MRJob):

    SORT_VALUES = True

    def mapper(self, _, line):
        splits = line.rstrip("\n").split(",")
        if len(splits) == 2: # countries
            symbol = 'A' # countries before clients
            country2digit = splits[1]
            yield country2digit, (symbol, splits[0])
        else: #  clients
            symbol = 'X'
            country2digit = splits[2]
            if splits[1]=='bueno':
                yield country2digit,(symbol, 1)

    def combiner(self,key, values):
        bueno=0
        for value in values:
            if value[0] == 'A':
                yield key, ('A', value[1])
            else:
                bueno=bueno + 1

        if bueno > 0:
            yield key, ('X', bueno)

    def reducerSimple(self, key, values):
        for value in values:
            yield key,value

    def steps(self):
        return [
            MRStep(mapper=self.mapper
                   ,combiner=self.combiner
                   ,reducer=self.reducerSimple)
        ]

if __name__ == '__main__':
    MRJoin.run()

I run the above code like this:
python mrjob-p2.py  /media/notebooks/clients.csv /media/notebooks/countries.csv   -r hadoop
Which gives:
"ES"    ["X", 3]
"ES"    ["A", "Spain"]
...
"GN"    ["A", "Guinea"]
"GN"    ["X", 1]
...

The values for the ES key (and few others) are not sorted, but for other keys they are sorted.
I expected (A should come before X if the values were sorted):
"ES"    ["A", "Spain"]
"ES"    ["X", 3]

If I run locally:
python mrjob-p2.py  /media/notebooks/clients.csv /media/notebooks/countries.csv   -r local
Then I get:
"ES"    ["A", "Spain"]
"ES"    ["X", 1]
"ES"    ["X", 2]
...
"GN"    ["A", "Guinea"]
"GN"    ["X", 1]
...

Which is correct.
Does anybody have an idea on how to get the values sorted?
Thanks :)


text:
Q: Django render multiple ModelForm in template and save I have a django Entry model which takes in several values related to an entity like height,weight etc. This value has to be entered every month. For each month, a new form along with the previous month's data has to be displayed on the template. My views look somewhat like this:
ntt=Entry.objects.get(pk=6)
lastmonth=EntryForm(instance=ntt)
thismonth=EntryForm()
return render(request, 'show.htm', {'thismonth':thismonth,'lastmonth':lastmonth})

I am not sure how to display the two values side by side, one line for each attribute like so:

<input type=text>thismonth.weight</input>	lastmonth.weight

<input type=text>thismonth.height</input>	lastmonth.height

Using the common way of rendering a form like {{thismonth.as_p}}{{lastmonth.as_p}}

{{thismonth.as_p}}
{{lastmonth.as_p}}

I was able to render them on the same rows but with labels on both of them.

*

*Is there a way to render the form where only the label will be displayed for thismonth, while lastmonth will only display the values and without manually specifying the field id and name?

*Also, since I don't want to change the value of lastmonth is there a way to get only the thismonth values from request.POST in order to save/update it?

A: *

*yes, you can render each form field seperately like so basically:

[...]

{{ thismonth.as_p }}
{{ lastmonth.form_field }}

[...]

that way you can control which form's label should be rendered and which shouldn't.

*yes, you can grab single values like so:

def your_view(request):
    if request.method == 'POST': # If the form has been submitted...
        form = EntryForm(request.POST) # A form bound to the POST data
        if form.is_valid():

            print form.cleaned_data['my_form_field_name']
            return [...]


text:
Q: time.sleep does not seem accurate with selenium so I use time.sleep to let my automation testing have a human like time and behaviour but the time.sleep looks like a bit faster or something (sometimes it does not even look it worked) is it build like this? and should I use the implicict wait ? and what's the diffrence between them?

A: you can use webdriver.implicitly_wait("time in s") instead if you prefer.
The difference is, that implicitly waits only in the browser, while time.sleep waits in the script itself.


text:
Q: Define a variable with a subvariable (or with a property) The target is to have a variable with a Unit property, which could be accessed by e.g.:
Params MyParams;

MyParams.Diae = 100.0;
MyParams.Diae.Unit = "kg";

Ideally, the variable Diae is a member of Class Params and should Inherit the Unit property from a class IParameter:
internal class IParameter
{
    string unit;
    internal string Unit { get; set; }

    internal IParameter()
    {
        unit = "";
    }

}

How to declare Diae variable? Here is a snippet of a quasi-code of the declaration expected:
namespace SomeCode
{
    internal class Params
    {
        double diae;

        internal class Diae:IParameter
        {
            get { return diae; }
            set { diae = value; }
        }
    }
}

A: You can't do exactly what you want -- you can't add extra properties to an existing type like double, so you'll have to make Diae return a separate class.  Something like this:
internal class ParamWithUnit
{
  public string Unit { get; set; }
  public double Value { get; set; }
}

internal class Params
{
  private ParamWithUnit diae = new ParamWithUnit();

  public ParamWithUnit Diae
  {
    get { return this.diae; }
  }
}

Then you can do:
Params MyParams = new Params();

MyParams.Diae.Value = 100.0;
MyParams.Diae.Unit = "kg";

A: You won't [want to] be able to assign a double to Diae while still allowing it to have a property Unit.  (You could hack around this through implicit conversions or something like that, but I would discourage you from doing so.)
The best option would be to create a class such as Measurement that will have both a Value and a Unit property:
public class Measurement
{
    public double Value {get;set;}
    public string Unit {get;set;}
}

Then Diae can be of that type:
internal class Params
{
    public Measurement Diae {get;private set}
    public Params()
    {
        Diae = new Measurement();
    }
}

Now you can do:
Params MyParams = new Params();

MyParams.Diae.Value = 100.0;
MyParams.Diae.Unit = "kg";


text:
Q: Connecting exoplayer with MediaSessionCompat I want to connect my implementation of exoplayer with the media session object. I set up a SimpleExoPlayerView to show a video. Every time a button is clicked, I want the media session callbacks to fire. I can only get the callbacks to fire when something like a pair of headphones is used. The code used in the app is written below
@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
public void setUp(LifecycleOwner lifecycleOwner){
    // Create a MediaSessionCompat
    Log.i("Hoe8", "lco setup called");
    mMediaSession = new MediaSessionCompat(activity, "this");

    // Enable callbacks from MediaButtons and TransportControls
    mMediaSession.setFlags(
            MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS |
                    MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);

    // Do not let MediaButtons restart the player when the app is not visible
    mMediaSession.setMediaButtonReceiver(null);

    // Set an initial PlaybackState with ACTION_PLAY, so media buttons can start the player
    mStateBuilder = new PlaybackStateCompat.Builder()
            .setActions(
                    PlaybackStateCompat.ACTION_PLAY |
                            PlaybackStateCompat.ACTION_PLAY_PAUSE);
    mMediaSession.setPlaybackState(mStateBuilder.build());

    // MySessionCallback has methods that handle callbacks from a media controller
    mMediaSession.setCallback(new MediaSessionCompat.Callback() {
        @Override
        public void onPlay() {
            super.onPlay();
            Log.i("Hoe8", "MediaSession callback play called");
            mMediaSession.setActive(true);
            ((JokesAdapter.VideoPostViewHolder) rv).setIsPlaying(true);
            ((JokesAdapter.VideoPostViewHolder) rv).setHasStarted(true);

        }

        @Override
        public void onPause() {
            super.onPause();
            ((JokesAdapter.VideoPostViewHolder) rv).setIsPlaying(false);
        }

        @Override
        public void onStop() {
            super.onStop();
            mMediaSession.setActive(false);
            ((JokesAdapter.VideoPostViewHolder) rv).setIsPlaying(false);
            ((JokesAdapter.VideoPostViewHolder) rv).setHasStarted(false);
        }
    });

    // Create a MediaControllerCompat
    MediaControllerCompat mediaController =
            new MediaControllerCompat(activity, mMediaSession);

    MediaControllerCompat.setMediaController(activity, mediaController);

    //Handler mainHandler = new Handler();
    BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
    TrackSelection.Factory videoTrackSelectionFactory =
            new AdaptiveTrackSelection.Factory(bandwidthMeter);
    TrackSelector trackSelector =
            new DefaultTrackSelector(videoTrackSelectionFactory);

// 2. Create the player
        player = ExoPlayerFactory.newSimpleInstance(activity, trackSelector);
        playerView.setPlayer(player);

    MediaSessionConnector mediaSessionConnector =
            new MediaSessionConnector(mMediaSession);
    mediaSessionConnector.setPlayer(player, null,null );

}

Made some changes to the code
public class VideoLifeCyclerObserver implements LifecycleObserver {

MediaSessionCompat mMediaSession;
PlaybackStateCompat.Builder mStateBuilder;
AppCompatActivity activity;
SimpleExoPlayerView playerView;
SimpleExoPlayer player;
ExoPlayer.ExoPlayerComponent rv;
MediaSessionConnector mediaSessionConnector;

public VideoLifeCyclerObserver(AppCompatActivity activity, SimpleExoPlayerView playerView, ExoPlayer.ExoPlayerComponent rv){
    this.activity = activity;
    this.playerView = playerView;
    this.activity.getLifecycle().addObserver(this);
    this.rv = rv;
    Log.i("Hoe8","video lco created");
}

@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
public void setUp(LifecycleOwner lifecycleOwner){
    // Create a MediaSessionCompat
    Log.i("Hoe8", "lco setup called");
    mMediaSession = new MediaSessionCompat(activity, "this");

    // Create a MediaControllerCompat
    MediaControllerCompat mediaController =
            new MediaControllerCompat(activity, mMediaSession);

    MediaControllerCompat.setMediaController(activity, mediaController);

    mediaSessionConnector =
            new MediaSessionConnector(mMediaSession, new PlayBackController());
}

@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void startPlayer(LifecycleOwner lifecycleOwner){
    BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
    TrackSelection.Factory videoTrackSelectionFactory =
            new AdaptiveTrackSelection.Factory(bandwidthMeter);
    TrackSelector trackSelector =
            new DefaultTrackSelector(videoTrackSelectionFactory);
    player = ExoPlayerFactory.newSimpleInstance(activity, trackSelector);
    playerView.setPlayer(player);
    mediaSessionConnector.setPlayer(player, null,null );
}

@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
public void tearDown(LifecycleOwner lifecycleOwner){
    player.stop();
    player.release();
    player.sendMessages(new ExoPlayer.ExoPlayerMessage(rv,1,player.getContentPosition()));
}

public class PlayBackController extends DefaultPlaybackController{
    @Override
    public void onPause(Player player) {
        Log.i("Hoe8", "onPause called");
        ((JokesAdapter.VideoPostViewHolder) rv).setIsPlaying(false);
        super.onPause(player);
    }

    @Override
    public void onPlay(Player player) {
        Log.i("Hoe8", "MediaSession callback play called 2");
        mMediaSession.setActive(true);
        ((JokesAdapter.VideoPostViewHolder) rv).setIsPlaying(true);
        ((JokesAdapter.VideoPostViewHolder) rv).setHasStarted(true);
        super.onPlay(player);
    }

    @Override
    public void onStop(Player player) {
        Log.i("Hoe8", "onStop called");
        mMediaSession.setActive(false);
        ((JokesAdapter.VideoPostViewHolder) rv).setIsPlaying(false);
        ((JokesAdapter.VideoPostViewHolder) rv).setHasStarted(false);
        super.onStop(player);
    }

}
}

How can I get the buttons that show in the SimpleExoPlayerView to fire the media session callbacks?

A: In short:
delete all code in your onCreate starting from (inclusive)
// Enable callbacks from MediaButtons and TransportControls
to (exclusive)
// Create a MediaControllerCompat
:)
More lengthy:
I recommend firing media session callbacks by listening to state transitions of the player instead of by click on buttons. This saves you from doing this for each UI element interacting with the player. That's actually what the MediaSessionConnector does for you.
With the MediaSessionConnector you do not need to manipulate the MediaSession yourself. The connector mediates between the player instance and the media session. This means the connector listens to state transitions of the player and maps the player state to the media session state. The connector also listens for media actions sent by transport controls and delegates them to the player or your app. Note: Your app does not need to provide a MediaSessionCompat.Callback, the connector registers its own (and overrides yours as there can be only one per session).
In general: your app does only interact with the SimpleExoPlayer instance while the connector maps the player state to the session.
Let's start with the basic approach which maps the state of the player to the session which triggers appropriate MediaControllerCompat.Callback methods:
// code running in a activity or service where (this instanceof Context)

mediaSession = new MediaSessionCompat(this, getPackageName());
mediaSessionConnector = new MediaSessionConnector(mediaSession)
mediaSessionConnector.setPlayer(player, null, null);
mediaSession.setActive(true);

You can now prepare and use the player like before, like call setPlayWhenReady(true|false), seekTo(t) and the connector maintains the PlaybackStateCompat which is broadcast to controllers of the session.
The connector does receive and implement a couple of media actions at this level (no need for your own MediaSession.Callback):
PlaybackStateCompat.ACTION_PLAY_PAUSE |
PlaybackStateCompat.ACTION_PLAY |
PlaybackStateCompat.ACTION_PAUSE |
PlaybackStateCompat.ACTION_STOP |
PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE |
PlaybackStateCompat.ACTION_SET_REPEAT_MODE;

PlayFromXYZ actions
You may want to support additional media actions like  ACTION_PLAY_FROM_MEDIA_ID. You can do so by providing your PlaybackPreparer:
playbackPreparer = new YourPlaybackPreparer();
mediaSessionConnector.setPlayer(player, playbackPreparer, null);

The connector now delegates actions like  ACTION_PLAY_FROM_MEDIA_ID or ACTION_PREPARE_FROM_MEDIA_ID to your playback preparer which creates a MediaSource for the given media ID to prepare the player.
Metadata and Queue management
Also interesting is the ability to map the Timeline of the player directly to queue and metadata of the media session. To do this you can provide a QueueNavigator. There is an abstract TimelineQueueNavigator provided by the extension:
QueueNavigator queueNavigator = new TimelineQueueNavigator(mediaSession) {
  @Override
  public MediaDescriptionCompat getMediaDescription(int windowIndex) {
    // implement this method and read from your backing data:
    getMediaDescriptionAtQueuePosition(windowIndex):
    return mediaDescription;
  }
}
mediaSessionConnector.setQueueNavigator(queueNavigator);

With this media controllers can now read metadata and queue of the session. The queue represents the current Timeline of the player and the metadata of the session describes the window in the Timeline which is currently playing. (more about playlists).
Provided a TimelineQueueNavigator, the connector listens for ACTION_SKIP_TO_NEXT, ACTION_SKIP_TO_PREVIOUS and ACTION_SKIP_TO_QUEUE_ITEM sent by transport controls and navigates along the timeline accordingly.
Lifecycle integration
Please note that you must create the player instance onStart/onResume and release it onPause/onStop. This makes sure codec resources you share with other apps are freed when you are in background. Your code sample does it only once onCreate which is not good citizenship :). See how the ExoPlayer demo app does it.
Please also consider the Medium blog about the MediaSessionConnector.


text:
Q: Upload npm dependencies to a server I need some help with the following situation:
At the moment I am working with Maven and Spring in order to do a web application. My team was working downloading the dependencies for different frameworks, but now I want to use npm to make the dependencies managment easier.
When I run npm install it downloads the dependencies locally, but the idea is not to upload the node_modules folder to git or the web, is to have the package.json file and download them manually in each computer.
I know that the app is compressed in a war file (I don't know when and how, when I started working here that was working like that), and when is compressed it downloads the maven dependencies (or that is what I understood). I want to make the same with the npm dependencies, the idea is to configure somewhere that it has to run npm install before compressing the whole application.
Does anyone know how to do that? I hope that you could get the idea.
Thank you!

A: Assuming that for war packaging Maven war plugin is used - you cannot invoke npm command from it.

Note: When using the war: goals it is assumed that the compile phase is already done. The WAR Plugin is not responsible for compiling the java sources or copying the resources.

https://maven.apache.org/plugins/maven-war-plugin/usage.html
As workaround for endpoint you can install required modules by npm install -g if your server have the access to npm repo. Otherwise you need to copy node-modules manually.
Don't forget about the permissions.